Class TreeView

  • All Implemented Interfaces:
    BaseElement, MDElement, ModelElementProvider, com.nomagic.magicdraw.uml.symbols.filter.FilteredSymbols.FilteredSymbolsChangeListener, com.nomagic.magicdraw.uml.symbols.LabelOwner, com.nomagic.magicdraw.uml.symbols.LineJumpDrawer, com.nomagic.magicdraw.uml.symbols.manipulators.centerlines.CenterlineableShape, com.nomagic.magicdraw.uml.symbols.SuspendShapeAutoResizeModeProvider, NameOwner, java.beans.PropertyChangeListener, java.lang.Cloneable, java.lang.Comparable, java.util.EventListener

    @OpenApi
    public class TreeView
    extends com.nomagic.magicdraw.uml.symbols.shapes.ContainerShapeView
    implements com.nomagic.magicdraw.uml.symbols.LabelOwner, com.nomagic.magicdraw.uml.symbols.LineJumpDrawer, com.nomagic.magicdraw.uml.symbols.filter.FilteredSymbols.FilteredSymbolsChangeListener
    This class represents tree header (part of generalization tree symbol).
    • Field Detail

      • arrowToDashDistance

        private static final int arrowToDashDistance
        Minimal distance between connect link arrow(anchor) and horizontal bar of the tree.
        See Also:
        Constant Field Values
      • baseClass

        private ShapeElement baseClass
        Base class of tree
      • verticalBarX

        private int verticalBarX
        The x coordinate of the tree vertical bar to the base class
      • verticalBarRelativeX

        private int verticalBarRelativeX
        distance between shape left corner and vertical bar.
      • verticalBarY

        private int verticalBarY
        The y coordinate of the tree vertical bar at the base class
      • horizontalBarY

        private int horizontalBarY
        The y coordinate of the tree view horizontal bar
      • implicitlySetY

        private boolean implicitlySetY
        Implicitly set y coordinate
      • horizontalBarLeft

        private int horizontalBarLeft
        x coordinates of the tree view horizontal bar edges
      • horizontalBarRight

        private int horizontalBarRight
      • showArrow

        private boolean showArrow
      • labelHandler

        private com.nomagic.magicdraw.uml.symbols.shapes.LabelHandler labelHandler
      • resetLabels

        private boolean resetLabels
      • lineJumpPlace

        @CheckForNull
        private com.nomagic.magicdraw.uml.symbols.LineJumpPlace lineJumpPlace
      • verticalLineJumps

        @CheckForNull
        private java.util.List<com.nomagic.magicdraw.uml.symbols.LineJumpInfo> verticalLineJumps
      • horizontalLineJumps

        @CheckForNull
        private java.util.List<com.nomagic.magicdraw.uml.symbols.LineJumpInfo> horizontalLineJumps
      • verticalLineJumpStartAngle

        private double verticalLineJumpStartAngle
      • horizontalLineJumpStartAngle

        private double horizontalLineJumpStartAngle
    • Constructor Detail

      • TreeView

        public TreeView()
    • Method Detail

      • getTreeConnectors

        public java.util.List<com.nomagic.magicdraw.uml.symbols.paths.TreeViewConnector> getTreeConnectors()
        Returns all connected tree connectors.
      • hasSharedData

        public boolean hasSharedData()
        Description copied from class: PresentationElement
        Returns true if data of this object can be shared. If data is not shared data can be deleted with del key. Or it must be deleted with CRL+D
        Returns:
        true if data of this object can be shared.
      • paintSelf

        public void paintSelf​(com.nomagic.magicdraw.uml.symbols.DiagramPaintContext context)
      • createBoundsShape

        public ContainerShape createBoundsShape​(@CheckForNull
                                                PathElement path,
                                                BoundsTransformation transformation)
        Description copied from class: ShapeElement
        Creates bounding shape for intersection calculation.
        Parameters:
        path - path
        transformation - transformation
        Returns:
        shape
      • setVerticalBarRelativeX

        public void setVerticalBarRelativeX​(int x)
      • getVerticalBarRelativeX

        public int getVerticalBarRelativeX()
      • getRealBounds

        private java.awt.Rectangle getRealBounds()
        Because getBounds return just horizontal bar bounds, we need method to calculate real bounds
      • setHorizontalBarY

        public void setHorizontalBarY​(int yPosition)
        Implicitly specify the y coordinate of the tree view horizontal bar.
        Parameters:
        yPosition - new y coordinate of the tree view horizontal bar
      • movePathElements

        public void movePathElements()
      • sSetHorizontalBarY

        public void sSetHorizontalBarY​(int yPosition)
        Implicitly specify the y coordinate of the tree view horizontal bar.
        Parameters:
        yPosition - new y coordinate of the tree view horizontal bar
      • setHorizontalBarYExplicitly

        public void setHorizontalBarYExplicitly​(int yPosition)
        Explicitly specify the y coordinate of the tree view horizontal bar.
        Parameters:
        yPosition - new y coordinate of the tree view horizontal bar.
      • simpleSetBounds

        public void simpleSetBounds​(java.awt.Rectangle bnd,
                                    boolean moveChildren,
                                    boolean calculatePrefSize)
        Overrides:
        simpleSetBounds in class com.nomagic.magicdraw.uml.symbols.shapes.ContainerShapeView
      • resetHorizontalBarY

        public void resetHorizontalBarY()
        Explicitly specify that the y coordinate of the tree view horizontal bar is not implicitly defined.
      • getHorizontalBarY

        public int getHorizontalBarY()
        Returns y coordinate of the horizontal bar of the tree view.
      • setHorizontalBarLeft

        public void setHorizontalBarLeft​(int xPosition)
        Specify x coordinate of the tree view horizontal bar left edge.
        Parameters:
        xPosition - new x coordinate of the tree view horizontal bar left edge.
      • sSetHorizontalBarLeft

        public void sSetHorizontalBarLeft​(int xPosition)
      • getHorizontalBarLeft

        public int getHorizontalBarLeft()
        Returns x coordinate of the tree view horizontal bar left edge.
      • setHorizontalBarRight

        public void setHorizontalBarRight​(int xPosition)
        Specify x coordinate of the tree view horizontal bar right edge.
        Parameters:
        xPosition - new x coordinate of the tree view horizontal bar right edge.
      • sSetHorizontalBarRight

        public void sSetHorizontalBarRight​(int xPosition)
      • getHorizontalBarRight

        public int getHorizontalBarRight()
        Returns x coordinate of the tree view horizontal bar right edge.
      • setVerticalBarX

        public void setVerticalBarX​(int xPosition)
        Explicitly specify the x coordinate of the vertical bar to the base class for the tree view.
      • sSetVerticalBarX

        public void sSetVerticalBarX​(int pos)
      • getVerticalBarX

        public int getVerticalBarX()
        Returns x coordinate of the vertical bar to the base class for the tree view.
      • setVerticalBarY

        public void setVerticalBarY​(int yPosition)
        Specify the y coordinate of the vertical bar end at the base class for the tree view.
      • sSetVerticalBarY

        public void sSetVerticalBarY​(int yPosition)
      • getVerticalBarY

        public int getVerticalBarY()
        Returns y coordinate of the tree view vertical bar end at the base class.
      • calculateHorizontalBar

        public void calculateHorizontalBar()
        Calculates the y coordinate of the middle bar for the view according to the positions of the child classes, connected by the tree view
      • sCalculateHorizontalBar

        public void sCalculateHorizontalBar()
        Calculates the y coordinate of the middle bar for the view according to the positions of the child classes, connected by the tree view
      • calculateMostLeftAndRightHorizontalXPointsByContext

        public com.nomagic.magicdraw.uml.symbols.shapes.TreeView.TreeData calculateMostLeftAndRightHorizontalXPointsByContext​(com.nomagic.magicdraw.uml.symbols.DiagramPaintContext context)
      • calculateMostLeftAndRightHorizontalXPoints

        private com.nomagic.magicdraw.uml.symbols.shapes.TreeView.TreeData calculateMostLeftAndRightHorizontalXPoints​(java.util.function.Predicate<PresentationElement> pathElementPredicate)
      • clone

        public TreeView clone()
        Description copied from class: ElementImpl
        Returns a copy of the Element.
        Specified by:
        clone in interface BaseElement
        Overrides:
        clone in class com.nomagic.magicdraw.uml.symbols.shapes.ContainerShapeView
        Returns:
        the cloned object
      • movePathElement

        public void movePathElement​(PathElement linkView,
                                    @CheckForNull
                                    PathConnector requestor)
        Description copied from class: PathConnector
        Calculates position of path element.
        Parameters:
        linkView - element which position will be calculated.
        requestor - the requestor of this path moving. Implementations may check in order to avoid endless loops.
      • setBaseClass

        public void setBaseClass​(ShapeElement classView)
        Sets base class
        Parameters:
        classView - new base class
      • sSetBaseClass

        public void sSetBaseClass​(@CheckForNull
                                  ShapeElement classView)
        Sets base class
        Parameters:
        classView - new base class
      • calculateVerticalBarX

        public void calculateVerticalBarX()
        If horizontal bar is outside shape moves it to shape.
      • coversPoint

        public boolean coversPoint​(int x,
                                   int y)
        Description copied from class: PresentationElement
        checks if object covers provided point
        Returns:
        true if object covers this point
      • intersects

        public boolean intersects​(int x,
                                  int y,
                                  int width,
                                  int height)
        Description copied from class: PresentationElement
        checks whether object intersects with given rectangle
        Returns:
        true if object and rectangle intersects
      • removeConnectedPathElement

        public boolean removeConnectedPathElement​(PathElement link)
        Description copied from class: PathConnector
        Removes path element.
        Parameters:
        link - element to remove.
        Returns:
        true if element was removed
      • updateLinksCoordinates

        private void updateLinksCoordinates()
      • accept

        public void accept​(Visitor visitor)
                    throws java.lang.Exception
        Description copied from interface: MDElement
        Method accepts visitor, and calls method visit<class name>(this) of visitor . See Visitor pattern for more details.
        Specified by:
        accept in interface MDElement
        Overrides:
        accept in class com.nomagic.magicdraw.uml.symbols.shapes.ContainerShapeView
        Parameters:
        visitor - which visits this element.
        Throws:
        java.lang.Exception
      • getImplicitlySetY

        public boolean getImplicitlySetY()
      • sSetImplicitlySetY

        public void sSetImplicitlySetY​(boolean v)
      • getRealCoords

        public int[] getRealCoords()
        Used for saving
      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent e)
        Description copied from class: PresentationElement
        Listens for property change it can be: data was edited text box was edited
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener
      • recalculatePoints

        private void recalculatePoints()
        Recalculates points of the tree.
      • getMiddlePointX

        public int getMiddlePointX()
      • getMiddlePointY

        public int getMiddlePointY()
      • constructCommandForUnGroup

        public void constructCommandForUnGroup​(com.nomagic.magicdraw.commands.MacroCommand macro)
      • canChangeParent

        public boolean canChangeParent​(java.util.Collection<? extends PresentationElement> movedTogether,
                                       @CheckForNull
                                       BaseElement newParent,
                                       boolean changeElementParent)
        Description copied from class: PresentationElement
        Returns true, if element can change parent.
        Parameters:
        movedTogether - collection of the elements, whose will change the parent together with this.
        newParent - new symbol parent
        changeElementParent - change element parent
        Returns:
        true if parent of symbol can be changed
      • recalculateTreeBounds

        public void recalculateTreeBounds()
        Recalculates and sets new bounds of the tree according to the position of the horizontal bar
      • isConnectorOfTheSameType

        public boolean isConnectorOfTheSameType​(com.nomagic.magicdraw.uml.symbols.paths.TreeViewConnector con)
        Returns true if all connected connectors are of the same type as given connector
      • isTreeOfType

        public boolean isTreeOfType​(java.lang.Class clazz)
      • getFirstTreeConnector

        @CheckForNull
        public com.nomagic.magicdraw.uml.symbols.paths.TreeViewConnector getFirstTreeConnector()
        First connector of the tree
      • canBeAutosized

        public boolean canBeAutosized()
      • getNotCopyBounds

        public java.awt.Rectangle getNotCopyBounds()
        Description copied from class: PresentationElement
        get not copy bounds of object throws NoRectangleDefinedException
        Returns:
        rectangle of bounds
      • sSetBounds

        public void sSetBounds​(java.awt.Rectangle r)
        Description copied from class: PresentationElement
        Sets bounds of this object view only.
        Parameters:
        r - rectangle of bounds.
      • excludedSymbolsChanged

        public void excludedSymbolsChanged​(java.util.Collection<PresentationElement> symbols,
                                           boolean isExcluded)
        Specified by:
        excludedSymbolsChanged in interface com.nomagic.magicdraw.uml.symbols.filter.FilteredSymbols.FilteredSymbolsChangeListener
      • filteredSymbolsChanged

        public void filteredSymbolsChanged​(java.util.Collection<PresentationElement> symbols,
                                           boolean isFiltered)
        Specified by:
        filteredSymbolsChanged in interface com.nomagic.magicdraw.uml.symbols.filter.FilteredSymbols.FilteredSymbolsChangeListener
      • recalculateHorizontalBar

        private void recalculateHorizontalBar​(java.util.Collection<PresentationElement> symbols)
      • setShowArrow

        public void setShowArrow​(boolean showArrow)
      • internalGetElementToConnectLink

        public Element internalGetElementToConnectLink​(@CheckForNull
                                                       Element path,
                                                       boolean asClient)
        Description copied from class: PresentationElement
        Returns element that should be used for given link connecting. All possible elements are return by method getElementsForLinkConnecting. Usually this method should be overridden together with getElementsForLinkConnecting().
        Returns:
        all possible elements
        See Also:
        PresentationElement.getElementsForLinkConnecting()
      • getGeneralizationSetLabelWrapper

        public com.nomagic.magicdraw.uml.symbols.shapes.GeneralizationSetLabelWrapper getGeneralizationSetLabelWrapper()
      • setResetLabels

        public void setResetLabels​(boolean resetLabels)
      • internalUpdatePresentationElement

        protected void internalUpdatePresentationElement()
        Description copied from class: PresentationElement
        Internal symbol update method for subclassing. It is called from update as part of full update action.
        Overrides:
        internalUpdatePresentationElement in class com.nomagic.magicdraw.uml.symbols.shapes.ContainerShapeView
        See Also:
        PresentationElement.update()
      • sSetElement

        public void sSetElement​(@CheckForNull
                                Element element)
      • canAddInstance

        public boolean canAddInstance​(PresentationElement o)
        Description copied from class: PresentationElement
        Object view has no children.
        Overrides:
        canAddInstance in class com.nomagic.magicdraw.uml.symbols.shapes.ContainerShapeView
      • getChildrenInsets

        public com.nomagic.ui.UnmodifiableInsets getChildrenInsets​(com.nomagic.magicdraw.uml.symbols.shapes.InsetsLevel insetsLevel)
        Overrides:
        getChildrenInsets in class com.nomagic.magicdraw.uml.symbols.shapes.ContainerShapeView
        Parameters:
        insetsLevel - describes the level of insets
        Returns:
        shape insets for children
      • getRemovableChildren

        public java.util.List<PresentationElement> getRemovableChildren()
        Overrides:
        getRemovableChildren in class com.nomagic.magicdraw.uml.symbols.shapes.ContainerShapeView
      • internalSilentApply

        public void internalSilentApply()
        Description copied from class: PresentationElement
        Silently applies all properties after initialization
      • internalApplyProperties

        public void internalApplyProperties​(PropertyManager man)
        Description copied from class: PresentationElement
        Applies properties from given property manager
        Parameters:
        man - new properties
      • getStroke

        public java.awt.BasicStroke getStroke​(boolean line,
                                              int width)
        This method must be overridden, if you need to use DASHED_STROKE or another one.
        Returns:
        the stroke for line drawing ( by default SOLID_STROKE).
      • internalGetPresentationElementStroke

        public java.awt.BasicStroke internalGetPresentationElementStroke​(int width)
        Description copied from class: PresentationElement
        Return a stroke used to paint symbol's main part
        Parameters:
        width - a custom stroke width. Other stroke parameters will be specific to symbol
        Returns:
        a stroke used to paint symbol's main part
      • prepareForLineDrawing

        protected boolean prepareForLineDrawing​(java.awt.Graphics2D g,
                                                boolean line)
        Prepares graphics for line drawing. Calls super prepareForLineDrawing and sets stroke.
      • isShowGeneralizationSet

        public boolean isShowGeneralizationSet()
        Indicates if generalization set should be displayed.
        Returns:
        show generalization property value.
      • sSetShowGeneralizationSet

        public void sSetShowGeneralizationSet​(boolean show)
        Simple sets (no updates) show generalization set property value.
        Parameters:
        show - - show generalization set property value.
      • setShowGeneralizationSet

        public void setShowGeneralizationSet​(boolean show)
        Sets show generalization set property value.
        Parameters:
        show - - show generalization set property value.
      • getPaths

        public java.util.List<java.util.List<java.awt.Point>> getPaths()
        Specified by:
        getPaths in interface com.nomagic.magicdraw.uml.symbols.LineJumpDrawer
      • isDrawLineJumps

        public boolean isDrawLineJumps()
        Specified by:
        isDrawLineJumps in interface com.nomagic.magicdraw.uml.symbols.LineJumpDrawer
      • registerLineJumpInfos

        public void registerLineJumpInfos​(int pathIndex,
                                          java.awt.Point segmentStartPoint,
                                          @CheckForNull
                                          java.util.List<com.nomagic.magicdraw.uml.symbols.LineJumpInfo> lineJumps)
        Specified by:
        registerLineJumpInfos in interface com.nomagic.magicdraw.uml.symbols.LineJumpDrawer
      • registerLineJumpStartAngle

        public void registerLineJumpStartAngle​(int pathIndex,
                                               java.awt.Point point,
                                               double lineJumpStartAngle)
        Specified by:
        registerLineJumpStartAngle in interface com.nomagic.magicdraw.uml.symbols.LineJumpDrawer
      • clearRegisteredLineJumpInfos

        public void clearRegisteredLineJumpInfos()
        Specified by:
        clearRegisteredLineJumpInfos in interface com.nomagic.magicdraw.uml.symbols.LineJumpDrawer
      • setLineJumpPlace

        public void setLineJumpPlace​(@CheckForNull
                                     com.nomagic.magicdraw.uml.symbols.LineJumpPlace lineJumpPlace)
        Specified by:
        setLineJumpPlace in interface com.nomagic.magicdraw.uml.symbols.LineJumpDrawer
      • addLineJumps

        public void addLineJumps​(java.awt.geom.GeneralPath path,
                                 java.awt.Point segmentStartPoint,
                                 java.awt.Point startPoint,
                                 java.awt.Point endPoint)
        Specified by:
        addLineJumps in interface com.nomagic.magicdraw.uml.symbols.LineJumpDrawer
      • drawHorizontalPart

        public void drawHorizontalPart​(java.awt.Graphics2D g2,
                                       int horizontalBarLeft,
                                       int horizontalBarRight)
        Paints horizontal part of the tree.
        Parameters:
        g2 - Graphics2D object.
      • drawVerticalPart

        public void drawVerticalPart​(java.awt.Graphics2D g2,
                                     java.awt.Point pt)
        Paints vertical part of the tree.
        Parameters:
        g2 - Graphics2D object.
        pt - point
      • drawDecorations

        private java.awt.Point drawDecorations​(java.awt.Graphics2D g2,
                                               com.nomagic.magicdraw.uml.symbols.paths.TreeViewConnector con)
        Parameters:
        g2 - Graphics object.
        con - connector
        Returns:
        actual supplier and client points of the link.
      • addLabel

        public void addLabel​(ShapeElement label)
        Specified by:
        addLabel in interface com.nomagic.magicdraw.uml.symbols.LabelOwner
      • removeLabel

        public void removeLabel​(ShapeElement label)
        Specified by:
        removeLabel in interface com.nomagic.magicdraw.uml.symbols.LabelOwner
      • isLabelWrapText

        public boolean isLabelWrapText()
        Specified by:
        isLabelWrapText in interface com.nomagic.magicdraw.uml.symbols.LabelOwner
      • getLabelHandler

        public com.nomagic.magicdraw.uml.symbols.shapes.LabelHandler getLabelHandler()
        Specified by:
        getLabelHandler in interface com.nomagic.magicdraw.uml.symbols.LabelOwner
      • isNameWrapped

        public boolean isNameWrapped()
      • sSetNameWrapped

        public void sSetNameWrapped​(boolean wrapped)
      • setNameWrapped

        public void setNameWrapped​(boolean wrapped)
      • sSetSuspendLabelAutoDisplayMode

        public void sSetSuspendLabelAutoDisplayMode​(java.lang.String mode)
      • setSuspendLabelAutoDisplayMode

        public void setSuspendLabelAutoDisplayMode​(java.lang.String mode)
      • setSuspendShapeAutoResizeMode

        public void setSuspendShapeAutoResizeMode​(java.lang.String mode)
      • registerToFilteredSymbols

        private void registerToFilteredSymbols()