Class DiagramComparatorImpl
java.lang.Object
com.nomagic.magicdraw.tests.common.comparators.DiagramComparatorImpl
- All Implemented Interfaces:
DiagramComparator
Implementation of diagram comparator.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDiagramComparatorImpl
(boolean compareSymbolProperties) DiagramComparatorImpl
(int boundsTolerance, boolean compareSymbolProperties) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addChange
(PresentationElement original, PresentationElement modified, String info) protected static void
addMarker
(Map<AbstractDiagramPresentationElement, List<com.nomagic.magicdraw.tests.common.comparators.DiffMarker>> map, AbstractDiagramPresentationElement diagram, com.nomagic.magicdraw.tests.common.comparators.DiffMarker marker) void
clear()
boolean
compareDiagrams
(AbstractDiagramPresentationElement diagrams1, AbstractDiagramPresentationElement diagrams2) Check if two diagrams are equals by comparing their graphical representations.boolean
compareDiagrams
(Collection<AbstractDiagramPresentationElement> diagrams1, Collection<AbstractDiagramPresentationElement> diagrams2) Compare diagrams in two parallel collections.boolean
protected boolean
Check if two presentation elements bounds are equals.protected com.nomagic.magicdraw.tests.common.comparators.DiffMarker
createMarker
(PresentationElement changed, PresentationElement original, Color color, boolean useNames) Forms shape which draw around element.getAdded()
Presentation elements which are added to second compared diagram and do not exist on the first compared diagram.Map<PresentationElement,
com.nomagic.magicdraw.tests.common.comparators.DiagramComparatorImpl.Diff> Changed presentation elements and their difference information found in compared diagrams.Formats textual information about differences found in compared diagrams.getPath
(PresentationElement element) Creates "kind of qualified name" for presentation element in diagram.getPointsOfShape
(PathElement element, int delta) Forms a points around the elements by making a poly line.Presentation elements which exist on first compared diagrams and do not exist on the second compared diagram.protected boolean
protected void
saveDiffToImage
(AbstractDiagramPresentationElement diagram, File file) void
saveDiffToImageFiles
(File file) Creates graphical differences on compared diagrams and save it to graphical file.protected String
-
Field Details
-
BOUNDS_TOLERANCE
protected int BOUNDS_TOLERANCE
-
-
Constructor Details
-
DiagramComparatorImpl
@OpenApi public DiagramComparatorImpl(int boundsTolerance, boolean compareSymbolProperties) Constructor.- Parameters:
boundsTolerance
- tolerance of bounds difference.compareSymbolProperties
- if compare symbol properties.
-
DiagramComparatorImpl
public DiagramComparatorImpl() -
DiagramComparatorImpl
public DiagramComparatorImpl(boolean compareSymbolProperties)
-
-
Method Details
-
clear
public void clear() -
compareRecursively
-
isNotCopyBoundsEquals
-
compareSymbols
Check if two presentation elements bounds are equals. Two presentations elements are equals if their bounds difference is not more than 1 pixel.- Parameters:
pe1
- first presentation element to compare.pe2
- second presentation element to compare.- Returns:
- true if compared presentation elements are equals, false otherwise
-
toString
-
compareDiagrams
public boolean compareDiagrams(Collection<AbstractDiagramPresentationElement> diagrams1, Collection<AbstractDiagramPresentationElement> diagrams2) Compare diagrams in two parallel collections.- Specified by:
compareDiagrams
in interfaceDiagramComparator
- Parameters:
diagrams1
- first diagram to compare.diagrams2
- second diagram to compare.- Returns:
- true if diagrams in both collections are equals, false otherwise.
-
compareDiagrams
public boolean compareDiagrams(AbstractDiagramPresentationElement diagrams1, AbstractDiagramPresentationElement diagrams2) Check if two diagrams are equals by comparing their graphical representations.- Parameters:
diagrams1
- first diagram to compare.diagrams2
- second diagram to compare.- Returns:
- true if compared diagrams graphical presentation is equals.
-
getDiffInfo
Formats textual information about differences found in compared diagrams. Formatted text contains information about new, removed, and changed symbols in compared diagrams.- Specified by:
getDiffInfo
in interfaceDiagramComparator
- Returns:
- String information about differences found in compared diagrams or empty String if no differences found.
-
saveDiffToImage
-
getPath
Creates "kind of qualified name" for presentation element in diagram. Such "qualified name" starts with diagram name and all nested presentation elements where given element is nested.- Parameters:
element
- presentation element to create "qualified name" for.- Returns:
- String formed from elements parent names separated by semicolon ':'.
-
addChange
-
getAdded
Presentation elements which are added to second compared diagram and do not exist on the first compared diagram.- Returns:
- Set of presentation elements which exist only on second compared diagram.
-
getRemoved
Presentation elements which exist on first compared diagrams and do not exist on the second compared diagram.- Returns:
- Set of presentation elements which exist only on first compared diagrams.
-
getChanged
public Map<PresentationElement,com.nomagic.magicdraw.tests.common.comparators.DiagramComparatorImpl.Diff> getChanged()Changed presentation elements and their difference information found in compared diagrams.- Returns:
- Map with changed presentation elements as keys and their differences specified as Diff values.
-
addMarker
protected static void addMarker(Map<AbstractDiagramPresentationElement, List<com.nomagic.magicdraw.tests.common.comparators.DiffMarker>> map, AbstractDiagramPresentationElement diagram, com.nomagic.magicdraw.tests.common.comparators.DiffMarker marker) -
saveDiffToImageFiles
Creates graphical differences on compared diagrams and save it to graphical file. Graphical differences are presented as rectangles on diagrams.- Specified by:
saveDiffToImageFiles
in interfaceDiagramComparator
- Parameters:
file
- graphical file to save compared diagram graphical differences to.
-
createMarker
protected com.nomagic.magicdraw.tests.common.comparators.DiffMarker createMarker(PresentationElement changed, @CheckForNull PresentationElement original, Color color, boolean useNames) Forms shape which draw around element.- Parameters:
changed
- changes elementoriginal
- original elementcolor
- of rectangle.useNames
- true if needed names for shape, false otherwise.- Returns:
- DiffMarker storing shape, text and color.
-
getPointsOfShape
Forms a points around the elements by making a poly line.- Parameters:
element
- PathElement.delta
- pixels from element till formed polyline around element.- Returns:
- List of points going around element.
-