Class PresentationElement

java.lang.Object
com.nomagic.magicdraw.uml.MDElementImpl
com.nomagic.magicdraw.uml.symbols.PresentationElement
All Implemented Interfaces:
BaseElement, MDElement, ModelElementProvider, NameOwner, PropertyChangeListener, Cloneable, Comparable, EventListener
Direct Known Subclasses:
AbstractDiagramPresentationElement, PathConnector

@OpenApi public abstract class PresentationElement extends com.nomagic.magicdraw.uml.MDElementImpl implements PropertyChangeListener, ModelElementProvider, NameOwner
Base class for all visual elements used in the UML diagrams.
  • Field Details

    • SOLID_STROKE

      @OpenApi public static final int SOLID_STROKE
      Solid path stroke.
      See Also:
    • DASHED_STROKE

      @OpenApi public static final int DASHED_STROKE
      Dashed path stroke.
      See Also:
    • DOTTED_STROKE

      @OpenApi public static final int DOTTED_STROKE
      Dotted path stroke.
      See Also:
  • Method Details

    • getElement

      @OpenApi @CheckForNull public Element getElement()
      Returns model element of this presentation element. Some presentation elements (for example TextBoxes) do not have model elements.
      Specified by:
      getElement in interface ModelElementProvider
      Returns:
      model element of this presentation element.
    • getDiagramSurface

      @CheckForNull @OpenApi public DiagramSurface getDiagramSurface()
      Returns diagram surface for this presentation element. DiagramSurface is null if diagram of this element is not opened in some window.
      Returns:
      diagram surface or null if diagram is not opened.
    • getParent

      @OpenApi public final PresentationElement getParent()
      Returns parent of this element.
      Returns:
      parent of this element.
    • getPreferredSize

      @Deprecated @OpenApi public final Dimension getPreferredSize()
      Deprecated.
      Returns preferable dimension of the element.
      Returns:
      preferred dimension
    • getPreferredDimension

      @OpenApi public UnmodifiableDimension getPreferredDimension()
      Returns preferable dimension of the element.
      Returns:
      preferred dimension
    • getMiddlePoint

      @CheckForNull @OpenApi public Point getMiddlePoint()
      Returns middle point of this element. Middle point for shapes usually will be center point of bounds, middle point for paths will be center of path curve.
      Returns:
      point that is considered as middle for this element.
    • getBounds

      @OpenApi public Rectangle getBounds() throws NoRectangleDefinedException
      Method returns bounds of this element. Use PresentationElementsManager to change a bounds of the element.
      Returns:
      bounds of the element.
      Throws:
      NoRectangleDefinedException - when bounds can not be calculated (some presentation elements are abstract and can not have bounds).
      See Also:
    • getPresentationElements

      @OpenApi public List<PresentationElement> getPresentationElements()
      Returns all children of this element
      Returns:
      all children of this element. The collection is unmodifiable.
    • setAllSelected

      @OpenApi public void setAllSelected(boolean select)
      Selects(or deselects) all presentation elements in the diagram.
      Parameters:
      select - select or deselect all elements.
    • setSelected

      @OpenApi public void setSelected(List<PresentationElement> elements)
      Selects given elements in the diagram.
      Parameters:
      elements - elements to select.
    • setSelected

      @OpenApi public void setSelected(boolean select)
      Selects or deselects this presentation element in the diagram.
      Parameters:
      select - select or deselect this presentation element.
    • getSelected

      @OpenApi public List<PresentationElement> getSelected()
      Returns a list of selected elements in the diagram.
      Returns:
      a list of selected elements. List is unmodifiable.
    • isSelected

      @OpenApi public boolean isSelected()
      Returns true, if this element is selected in the diagram.
      Returns:
      true, if this element is selected in the diagram.
    • getDiagramPresentationElement

      @OpenApi public final DiagramPresentationElement getDiagramPresentationElement()
      Returns diagram of this presentation element.
      Returns:
      diagram of this presentation element.
    • onFind

      @OpenApi public final void onFind()
      Scrolls diagram canvas to this symbol and selects this symbol
    • onFind

      @OpenApi public final void onFind(boolean center)
      Scrolls diagram canvas to this symbol and selects this symbol
      Parameters:
      center - if true, centers current view in the center of the window.
    • collectSubManipulatedElements

      @OpenApi public final void collectSubManipulatedElements(List<PresentationElement> col)
      Collects all visible and manipulated elements in this hierarchy.
    • getManipulatedPresentationElements

      @OpenApi public final List<PresentationElement> getManipulatedPresentationElements()
      Returns a list of children of this element those have manipulator.
      Returns:
      a list of manipulated elements. Collection is unmodifiable.
    • hasManipulatedPresentationElements

      @OpenApi public final boolean hasManipulatedPresentationElements()
      Returns:
      true if at least one child is manipulated and visible
    • useParentProperties

      @OpenApi public boolean useParentProperties()
      Does this element uses parent properties or has it own?
      Returns:
      true, if element does not have properties and uses parent's.
    • getPropertyManager

      @OpenApi public final PropertyManager getPropertyManager()
      Returns the propertyManager of this element. If element does not have properties, empty manager will be created.
      Use method useParentProperties() to check if properties exist.
      Use PresentationElementsManager to change the properties.
      Returns:
      propertyManager of this element.
      See Also:
    • getProperty

      @CheckForNull @OpenApi public Property getProperty(String id)
      Returns element's property with given id.
      Parameters:
      id - ID of property.
      Returns:
      property with given id or null if element does not have such property.
      See Also:
    • addProperty

      @OpenApi public final void addProperty(Property prop)
      Add property to presentation element. This method should be called only on a new instance of presentation element while it is not added into the diagram. In order to change some property use PresentationElementsManager.setPresentationElementProperties(com.nomagic.magicdraw.uml.symbols.PresentationElement, com.nomagic.magicdraw.properties.PropertyManager)
      Parameters:
      prop - property
    • editName

      @OpenApi public final void editName(@CheckForNull KeyEvent evt)
      Starts online diagram editing for a symbol
      Parameters:
      evt - first key event or null
    • editName

      @OpenApi public void editName(@CheckForNull KeyEvent evt, @CheckForNull Map<String,Boolean> textEditorOptions)
      Starts online diagram editing for a symbol
      Parameters:
      evt - first key event or null
      textEditorOptions - boolean options for text editor. Passed when creating text editor with TextEditorFactory
    • getManipulatedParent

      @CheckForNull @OpenApi public final PresentationElement getManipulatedParent()
      Returns:
      first parent with manipulator or null if such does not exist.
    • getObjectParent

      @OpenApi public BaseElement getObjectParent()
      Returns the presentation element parent. Implementation of super method.
      Specified by:
      getObjectParent in interface BaseElement
      Overrides:
      getObjectParent in class com.nomagic.magicdraw.uml.MDElementImpl
      Returns:
      the parent of the element.
      See Also:
    • getBoundsShape

      @OpenApi @CheckForNull public final Shape getBoundsShape(ConverterToShape converterToShape)
      Provides a bounding shape of the symbol
      Parameters:
      converterToShape - transform bounding shape according this converter
      Returns:
      bounding shape of the symbol
    • getPresentationElementStroke

      @OpenApi public final BasicStroke getPresentationElementStroke()
      Return a stroke used to paint symbol's main part
      Returns:
      a stroke used to paint symbol's main part
    • getPresentationElementStroke

      @OpenApi public final BasicStroke getPresentationElementStroke(int width)
      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
    • getStroke

      @OpenApi public static BasicStroke getStroke(BasicStroke stroke, int width)
      Get cached stroke of given width.
      Parameters:
      stroke - base stroke.
      width - of the stroke.
      Returns:
      stroke
    • getStroke

      @OpenApi public static BasicStroke getStroke(int lineStyle)
      Get cached stroke of given style and default width.
      Parameters:
      lineStyle - style of line.
      Returns:
      stroke
      See Also:
    • getStroke

      @OpenApi public static BasicStroke getStroke(int lineStyle, int width)
      Get cached stroke of given style and width.
      Parameters:
      lineStyle - style of line
      width - width
      Returns:
      stroke
      See Also:
    • getStroke

      @OpenApi public static BasicStroke getStroke(int lineStyle, int width, int join)
      Get cached stroke of given style, width and join.
      Parameters:
      lineStyle - style of line
      width - width
      Returns:
      stroke
      See Also:
    • getStroke

      @OpenApi public static BasicStroke getStroke(int lineStyle, int width, int join, int cap)
      Get cached stroke of given style, width and join.
      Parameters:
      lineStyle - style of line
      width - width
      Returns:
      stroke
      See Also:
    • getStroke

      @OpenApi public static BasicStroke getStroke(float width, int cap, int join, float miterLimit, @CheckForNull float[] dash, float dash_phase)
      Get cached stroke.
      See Also: