Class PresentationElementsManager


  • @OpenApiAll
    public class PresentationElementsManager
    extends java.lang.Object
    The utility class for ShapesElements and PathElement creating, moving and properties changing. Works together with SessionManager.

    This manager can be used only if some session was created with SessionManager. See code sample in SessionManager description for more details.

    See Also:
    SessionManager
    • Constructor Detail

      • PresentationElementsManager

        protected PresentationElementsManager()
        Private constructor. Do not allow to create instance outside this class.
    • Method Detail

      • getInstance

        public static PresentationElementsManager getInstance()
        Returns an instance of this manager.
        Returns:
        instance of this manager.
      • createShapeElement

        public ShapeElement createShapeElement​(Element element,
                                               PresentationElement parent)
                                        throws ReadOnlyElementException
        Creates a ShapeElement for given ModelElement in the given diagram. The created shape location is (0,0). The relationships to other symbols are not created.
        Parameters:
        element - the given ModelElement to create ShapeElement for.
        parent - presentation element in which symbol should be created. In case created symbol is illegal in such parent method can produce unpredictable results. Valid combination is such as package in package, class in package and etc.
        Returns:
        created shape element.
        Throws:
        ReadOnlyElementException - if diagram is read only.
      • createShapeElement

        public ShapeElement createShapeElement​(Element element,
                                               PresentationElement parent,
                                               boolean createRelationships,
                                               @CheckForNull
                                               java.awt.Point location)
                                        throws ReadOnlyElementException
        Creates a ShapeElement for given ModelElement in the given diagram. The created shape location is (0,0).
        Parameters:
        element - the given ModelElement to create ShapeElement for.
        createRelationships - create relationships to other symbols or not.
        parent - presentation element in which symbol should be created. In case created symbol is illegal in such parent method can produce unpredictable results. Valid combination is such as package in package, class in package and etc.
        location - the location where the new symbol is placed
        Returns:
        created shape element.
        Throws:
        ReadOnlyElementException - if diagram is read only.
      • createShapeElement

        public ShapeElement createShapeElement​(Element element,
                                               PresentationElement parent,
                                               boolean createRelationships)
                                        throws ReadOnlyElementException
        Creates a ShapeElement for given ModelElement in the given diagram. The created shape location is (0,0).
        Parameters:
        element - the given ModelElement to create ShapeElement for.
        createRelationships - create relationships to other symbols or not.
        parent - presentation element in which symbol should be created. In case created symbol is illegal in such parent method can produce unpredictable results. Valid combination is such as package in package, class in package and etc.
        Returns:
        created shape element.
        Throws:
        ReadOnlyElementException - if diagram is read only.
      • createPathElement

        public PathElement createPathElement​(Element relationship,
                                             PresentationElement client,
                                             PresentationElement supplier)
                                      throws ReadOnlyElementException
        Creates a PathElement for given relationship between given client and supplier PresentationElements. The PathElement will be created in the same diagram as client's and supplier's PresentationElements are.
        ModelElement of client must be equal to relationship's client.
        ModelElement of supplier must be equal to relationship's supplier.
        Parameters:
        relationship - the given relationship.
        client - a PresentationElement of relationship client.
        supplier - a PresentationElement of relationship supplier.
        Returns:
        created PathElement for given a relationship.
        Throws:
        ReadOnlyElementException - if diagram is read only.
      • isPresentationElementEditable

        protected boolean isPresentationElementEditable​(PresentationElement element)
      • movePresentationElement

        public void movePresentationElement​(PresentationElement view,
                                            PresentationElement parent,
                                            java.awt.Point location)
                                     throws ReadOnlyElementException
        Moves a presentation element to the given parent and the specified location. During this operation parent of the symbol can change both at the symbols and at the model level. If model is read-only, model element parent does not change, only symbol coordinates change.
        Parameters:
        view - presentation element to move.
        parent - parent to move into.
        location - location to move to.
        Throws:
        ReadOnlyElementException - if element permissions prohibited to perform this operation.
      • movePresentationElement

        public void movePresentationElement​(PresentationElement view,
                                            PresentationElement parent,
                                            java.awt.Point location,
                                            boolean canChangeElementOwner)
                                     throws ReadOnlyElementException
        Moves a presentation element to the given parent and the specified location. During this operation parent of the symbol can change both at the symbols and at the model level. If model is read-only, model element parent does not change, only symbol coordinates change.
        Parameters:
        view - presentation element to move.
        parent - parent to move into.
        location - location to move to.
        canChangeElementOwner - allow to change Element owner if needed by symbols structure
        Throws:
        ReadOnlyElementException - if element permissions prohibited to perform this operation.
      • movePresentationElement

        public void movePresentationElement​(PresentationElement view,
                                            java.awt.Point location)
                                     throws ReadOnlyElementException
        Moves a presentation element to the specified location. During this operation parent of the symbol does not change, only geometrical position changes.
        Parameters:
        view - symbol to move.
        location - location to move to.
        Throws:
        ReadOnlyElementException - if element permissions prohibited to perform this operation.
      • movePresentationElements

        public void movePresentationElements​(java.util.List<PresentationElement> views,
                                             PresentationElement parent,
                                             java.awt.Point location)
                                      throws ReadOnlyElementException
        Moves a list of presentation elements to the given parent and the specified location. During this operation parent of symbols can change both at the symbols and at the model level. If model is read-only, model element parent does not change, only symbol coordinates change.
        Parameters:
        views - presentation elements to move.
        parent - parent to move into.
        location - location to move to.
        Throws:
        ReadOnlyElementException - if element permissions prohibited to perform this operation.
      • movePresentationElements

        public void movePresentationElements​(java.util.List<PresentationElement> views,
                                             PresentationElement parent,
                                             java.awt.Point location,
                                             boolean canChangeElementOwner)
                                      throws ReadOnlyElementException
        Moves a list of presentation elements to the given parent and the specified location. During this operation parent of symbols can change both at the symbols and at the model level. If model is read-only, model element parent does not change, only symbol coordinates change.
        Parameters:
        views - presentation elements to move.
        parent - parent to move into.
        location - location to move to.
        canChangeElementOwner - allow to change Element owner if needed by symbols structure
        Throws:
        ReadOnlyElementException - if element permissions prohibited to perform this operation.
      • movePresentationElements

        public void movePresentationElements​(java.util.List<PresentationElement> views,
                                             java.awt.Point location)
                                      throws ReadOnlyElementException
        Moves a list of presentation elements to the specified location. During this operation parent of symbols does not change.
        Parameters:
        views - presentation elements to move.
        location - location to move to.
        Throws:
        ReadOnlyElementException - if element permissions prohibited to perform this operation.
      • reshapeShapeElement

        public void reshapeShapeElement​(ShapeElement element,
                                        java.awt.Rectangle newBounds)
                                 throws ReadOnlyElementException
        Reshapes given ShapeElement.
        Parameters:
        element - the ShapeElement to reshape.
        newBounds - a new bounds of the element.
        Throws:
        ReadOnlyElementException - if element is read only.
      • changePathBreakPoints

        public void changePathBreakPoints​(PathElement element,
                                          java.util.List newBreakPoints)
                                   throws ReadOnlyElementException
        Changes the break points of the given PathElement. The order of break points is from supplier to client.
        Parameters:
        element - the given PathElement.
        newBreakPoints - a list of new PathElement break points
        Throws:
        ReadOnlyElementException - if given element is read only and can't edit.
        java.lang.IllegalArgumentException - if given element is null or if given breakpoints are null
      • changePathPoints

        public void changePathPoints​(PathElement element,
                                     java.awt.Point supplierPoint,
                                     java.awt.Point clientPoint,
                                     java.util.List<java.awt.Point> newBreakPoints)
                              throws ReadOnlyElementException
        Changes the points of the given PathElement. The order of break points is from supplier to client.
        Parameters:
        element - the given PathElement.
        supplierPoint - new supplier
        clientPoint - new client point
        newBreakPoints - a list of new PathElement break points
        Throws:
        ReadOnlyElementException - if given element is read only and can't edit
        java.lang.IllegalArgumentException - if given element is null or if given breakpoints are null
      • resetLabelPositions

        public void resetLabelPositions​(PathElement element)
                                 throws ReadOnlyElementException
        Moves all given PathElement's labels to the default position(for example default position for name label is a middle of the path).
        Parameters:
        element - the given PathElement to reset labels for.
        Throws:
        ReadOnlyElementException - if given element is read only and can not be edited
        java.lang.IllegalArgumentException - if given element is null.
      • setPresentationElementProperties

        public void setPresentationElementProperties​(PresentationElement view,
                                                     PropertyManager propertyManager)
                                              throws ReadOnlyElementException
        Changes symbol properties of a given presentation element. Make sure to pass the newly created or cloned property manager, not the old one.

        Example:

         PresentationElement view =  // some view
         ChoiceProperty property = (ChoiceProperty) view.getProperty(PropertyID.TAGGED_VALUES_DISPLAY_MODE);
         // important to create a new property or clone the old one!
         Property clonedProperty = property.clone();
         clonedProperty.setValue(ClassifierView.IN_COMPARTMENT);
         // important to create a new property manager or clone the old one!
         PropertyManager properties = new PropertyManager();
         properties.addProperty(clonedProperty);
         PresentationElementsManager.getInstance().setPresentationElementProperties(view, properties);
         
        Parameters:
        view - symbol for which to change the property manager.
        propertyManager - a newly created or cloned manager with new properties, do not reuse the old property manager.
        Throws:
        ReadOnlyElementException - if given element is null and can not be edited.
        java.lang.IllegalArgumentException - if given element and properties is null and the element 's type can't have properties.
      • createNote

        public ShapeElement createNote​(PresentationElement parent)
                                throws ReadOnlyElementException
        Creates a note in the given parent. The created shape location is (0,0).
        Parameters:
        parent - the parent to create ShapeElement in
        Returns:
        created shape element
        Throws:
        ReadOnlyElementException - if diagram is read only and cannot edit
        java.lang.IllegalArgumentException - if given parent is null
      • createNote

        public ShapeElement createNote​(PresentationElement parent,
                                       @CheckForNull
                                       java.awt.Point location)
                                throws ReadOnlyElementException
        Creates a note in the given parent.
        Parameters:
        parent - the parent to create Note in
        location - location of created Note
        Returns:
        created Note
        Throws:
        ReadOnlyElementException - if diagram is read only and can not be edited
        java.lang.IllegalArgumentException - if parent is null
      • createTextBox

        public ShapeElement createTextBox​(PresentationElement parent)
                                   throws ReadOnlyElementException
        Creates a text box in the given parent. The created shape location is (0,0).
        Parameters:
        parent - the parent to create ShapeElement in.
        Returns:
        created shape element
        Throws:
        ReadOnlyElementException - if diagram is read only and cannot edit
        java.lang.IllegalArgumentException - if given parent is null
      • createImageShape

        public ShapeElement createImageShape​(PresentationElement parent,
                                             java.io.File imageFile,
                                             @CheckForNull
                                             java.awt.Point location)
                                      throws ReadOnlyElementException
        Creates an image shape in the given parent.
        Parameters:
        parent - the parent to create Image Shape in
        imageFile - image file
        location - location of created Image Shape
        Returns:
        created Image Shape
        Throws:
        ReadOnlyElementException - if diagram is read only and can not be edited
        java.lang.IllegalArgumentException - if parent is null
      • createImageShape

        public ShapeElement createImageShape​(PresentationElement parent,
                                             java.io.File imageFile)
                                      throws ReadOnlyElementException
        Creates an image shape in the given parent. The created shape location is (0,0).
        Parameters:
        parent - the parent to create Image Shape in
        imageFile - image file
        Returns:
        created shape element
        Throws:
        ReadOnlyElementException - if parent is read only and cannot edit
        java.lang.IllegalArgumentException - if given parent is null
      • createTextBox

        public ShapeElement createTextBox​(PresentationElement parent,
                                          @CheckForNull
                                          java.awt.Point location)
                                   throws ReadOnlyElementException
        Creates a text box in the given parent.
        Parameters:
        parent - the parent to create TextBox in
        location - location of TextBox
        Returns:
        created TextBox
        Throws:
        ReadOnlyElementException - if diagram is read only and can not be edited
        java.lang.IllegalArgumentException - if given parent is null
      • createContentShape

        public ContentShape createContentShape​(PresentationElement parent,
                                               @CheckForNull
                                               java.awt.Point location,
                                               Element pack)
                                        throws ReadOnlyElementException
        Creates a ContentShape in the given parent.
        Parameters:
        parent - the parent to create ContentShape in
        location - location of shape
        pack - content shape root content
        Returns:
        created TextBox
        Throws:
        ReadOnlyElementException - if diagram is read only and can not be edited
        java.lang.IllegalArgumentException - if given parent is null
      • createSeparator

        public ShapeElement createSeparator​(PresentationElement parent)
                                     throws ReadOnlyElementException
        Creates a separator shape in the given parent. The created shape location is (0,0).
        Parameters:
        parent - the parent to create ShapeElement in
        Returns:
        created shape element
        Throws:
        ReadOnlyElementException - if diagram is read only and cannot edit
        java.lang.IllegalArgumentException - if given parent is null
      • createSeparator

        public ShapeElement createSeparator​(PresentationElement parent,
                                            @CheckForNull
                                            java.awt.Point location)
                                     throws ReadOnlyElementException
        Creates a separator shape in the parent.
        Parameters:
        parent - the parent to create Separator in
        location - location of Separator
        Returns:
        created Separator
        Throws:
        ReadOnlyElementException - if diagram is read only and can not be edited
        java.lang.IllegalArgumentException - if given parent is null
      • createRectangularShape

        public ShapeElement createRectangularShape​(PresentationElement parent)
                                            throws ReadOnlyElementException
        Creates a rectangular shape in the given parent. The created shape location is (0,0).
        Parameters:
        parent - the parent to create ShapeElement in
        Returns:
        created shape element
        Throws:
        ReadOnlyElementException - if diagram is read only and cannot edit
        java.lang.IllegalArgumentException - if given parent is null
      • createRectangularShape

        public ShapeElement createRectangularShape​(PresentationElement parent,
                                                   @CheckForNull
                                                   java.awt.Point location)
                                            throws ReadOnlyElementException
        Creates a rectangular shape in the given parent.
        Parameters:
        parent - the parent to create Rectangular Shape in
        location - location of shape
        Returns:
        created shaped
        Throws:
        ReadOnlyElementException - if diagram is read only and can not be edited
        java.lang.IllegalArgumentException - if given parent is null
      • connectNote

        public PathElement connectNote​(ShapeElement noteOrComment,
                                       PresentationElement target)
                                throws ReadOnlyElementException
        Connects given note or comment shape with an anchor to the given presentation element.
        Parameters:
        noteOrComment - the given note or comment shape.
        target - the presentation element to connect note (or comment) to.
        Returns:
        created anchor.
        Throws:
        ReadOnlyElementException - if note (or comment) is read-only and cannot edit.
        java.lang.IllegalArgumentException - if given note is not instance of NoteView or comment is not instance of CommentView.
      • connectComment

        public PathElement connectComment​(ShapeElement comment,
                                          PresentationElement target)
                                   throws ReadOnlyElementException
        Connects given comment with note anchor to the given presentation element.
        Parameters:
        comment - comment to connect.
        target - the presentation element to connect comment to.
        Returns:
        created shape element.
        Throws:
        ReadOnlyElementException - if comment is read-only and not editable.
        java.lang.IllegalArgumentException - if given comment is not an instance of CommentView.
      • setText

        public void setText​(ShapeElement shape,
                            java.lang.String text)
                     throws ReadOnlyElementException
        Sets text for given symbol. Given symbol can be note, text box or separator.
        Parameters:
        shape - the given symbol.
        text - a new text for a given symbol.
        Throws:
        ReadOnlyElementException - if diagram is read only.
        java.lang.IllegalArgumentException - if given node is not instance of NoteView,TextBoxView,SeparatorView.
      • setConstraintForNote

        public void setConstraintForNote​(ShapeElement note,
                                         Constraint constraint)
                                  throws ReadOnlyElementException
        Shows given constraint in the given note. Constraint must be added into model already. Constraint must be assigned to ModelElement of symbol connected to the given note. If these conditions are not true, constraint may not be shown inside the note.
        Parameters:
        note - the given note.
        constraint - the given constraint.
        Throws:
        ReadOnlyElementException - if note is read only and cannot edit.
        java.lang.IllegalArgumentException - if given node is not instance of NoteView.
      • createSwimlane

        public SwimlaneView createSwimlane​(java.util.List<? extends ActivityPartition> horizontal,
                                           java.util.List<? extends ActivityPartition> vertical,
                                           DiagramPresentationElement diagram)
                                    throws ReadOnlyElementException
        Creates a swimlane in a given diagram. Adds horizontal and vertical partitions to the created swimlane.
        Parameters:
        horizontal - list of horizontal partitions
        vertical - list of vertical partitions
        diagram - parent for swimlane
        Returns:
        created swimlane
        Throws:
        ReadOnlyElementException - if given diagram is read only and cannot edit.
        java.lang.IllegalArgumentException - if given diagram is null.
      • createContainmentLink

        public PathElement createContainmentLink​(PresentationElement parentView,
                                                 PresentationElement childView)
                                          throws ReadOnlyElementException
        Connects given parent and child elements with containment link.
        Parameters:
        parentView - the presentation element of the parent element.
        childView - the presentation element of the child element.
        Returns:
        created link.
        Throws:
        ReadOnlyElementException - if diagram is read only.
        java.lang.IllegalArgumentException - if parent element does not contain child element.
      • createLostMessage

        public PathElement createLostMessage​(Message message,
                                             ShapeElement from,
                                             @CheckForNull
                                             Message insertAfter,
                                             int verticalGap)
                                      throws ReadOnlyElementException
        Creates a lost message symbol for given message from the given shape element. The given message is initialized (message ends are created and set, message sort is assigned) in this method.
        Parameters:
        message - the given message
        from - a ShapeElement of message client lifeline
        insertAfter - the new message is inserted after this message, or null to insert before all messages
        verticalGap - vertical gap before the new message
        Returns:
        created symbol for a given message
        Throws:
        ReadOnlyElementException - if diagram is read only
      • createFoundMessage

        public PathElement createFoundMessage​(Message message,
                                              ShapeElement from,
                                              @CheckForNull
                                              Message insertAfter,
                                              int verticalGap)
                                       throws ReadOnlyElementException
        Creates a found message symbol for given message from the given shape element. The given message is initialized (message ends are created and set, message sort is assigned) in this method.
        Parameters:
        message - the given message
        from - a ShapeElement of message client lifeline
        insertAfter - the new message is inserted after this message, or null to insert before all messages
        verticalGap - vertical gap before the new message
        Returns:
        created symbol for a given message
        Throws:
        ReadOnlyElementException - if diagram is read only
      • createSequenceMessage

        public PathElement createSequenceMessage​(Message message,
                                                 MessageSort sort,
                                                 ShapeElement from,
                                                 ShapeElement to,
                                                 boolean recursive,
                                                 int diagonal,
                                                 @CheckForNull
                                                 Message insertAfter,
                                                 int verticalGap)
                                          throws ReadOnlyElementException
        Creates a PathElement for given message between given client (from) and supplier (to) PresentationElements. The given message is initialized (message ends are created and set, message sort is assigned) in this method. The diagram should be opened to make the messages layout correctly.
        Parameters:
        message - the given message.
        sort - message sort.
        from - a ShapeElement of message client lifeline.
        to - a ShapeElement of message supplier lifeline.
        recursive - true if message is recursive (recursive message can be only when from == to).
        diagonal - vertical size of diagonal message, or 0 if the message is not diagonal.
        insertAfter - the new message is inserted after this message, or null to insert before all messages.
        verticalGap - vertical gap before the new message.
        Returns:
        created PathElement for given message.
        Throws:
        ReadOnlyElementException - if diagram is read only.
      • createDurationConstraint

        @CheckForNull
        public DurationConstraintView createDurationConstraint​(DurationConstraint durationConstraint,
                                                               PathElement firstConstrainedView,
                                                               PathElement secondConstrainedView)
                                                        throws ReadOnlyElementException
        Creates DurationConstraint presentation element between the given two end views, that can be either SeqMessageView or ActivationView
        Parameters:
        durationConstraint - model element for the DurationConstraintView
        firstConstrainedView - first end
        secondConstrainedView - second end
        Throws:
        ReadOnlyElementException - if diagram is not editable
      • createPartShape

        @CheckForNull
        public PartView createPartShape​(Property part,
                                        PresentationElement parent,
                                        java.util.List<Property> nestedPath,
                                        boolean createRelationships,
                                        @CheckForNull
                                        java.awt.Point location)
                                 throws ReadOnlyElementException
        Creates part shape on the diagram at a given coordinate. Parent symbol can be specified. If nested parts path is specified, nesting level is displayed in dot notation. It can be specified whether to create connected relationships.
        Parameters:
        part - part for which to create a shape.
        parent - parent symbol in which to add the part.
        nestedPath - a list of nested parts in which to nest the given part symbol.
        createRelationships - controls whether to display connected paths.
        location - location on the diagram where to move the part.
        Returns:
        created part symbol or null if it was not possible to create it.
        Throws:
        ReadOnlyElementException - if diagram is read only.
      • createVirtualRelation

        @CheckForNull
        public PathElement createVirtualRelation​(PresentationElement clientView,
                                                 PresentationElement supplierView,
                                                 java.lang.String ruleKey)
                                          throws ReadOnlyElementException
        Creates Virtual Relation view
        Parameters:
        clientView - relation client view
        supplierView - relation supplier view
        ruleKey - Virtual relation rule key
        Returns:
        created virtual relation symbol or null if it was not possible to create it.
        Throws:
        ReadOnlyElementException - if diagram is read only.
      • createGenericView

        public ShapeElement createGenericView​(Element element,
                                              PresentationElement parent,
                                              java.lang.String identifier)
                                       throws ReadOnlyElementException
        Creates Generic view
        Parameters:
        element - element for which the generic view is created
        parent - created view parent element
        identifier - Generic view unique identifier, you can have different Generic views for same element when the identifier is different
        Throws:
        ReadOnlyElementException - if diagram is read only.