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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intDashed path stroke.static final intDotted path stroke.static final intSolid path stroke. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddProperty(Property prop) Add property to presentation element.final voidCollects all visible and manipulated elements in this hierarchy.final voidStarts online diagram editing for a symbolvoidStarts online diagram editing for a symbolMethod returns bounds of this element.final ShapegetBoundsShape(ConverterToShape converterToShape) Provides a bounding shape of the symbolReturns diagram of this presentation element.Returns diagram surface for this presentation element.Returns model element of this presentation element.final PresentationElementfinal List<PresentationElement>Returns a list of children of this element those have manipulator.Returns middle point of this element.Returns the presentation element parent.final PresentationElementReturns parent of this element.Returns preferable dimension of the element.final DimensionDeprecated.Returns all children of this elementfinal BasicStrokeReturn a stroke used to paint symbol's main partfinal BasicStrokegetPresentationElementStroke(int width) Return a stroke used to paint symbol's main partgetProperty(String id) Returns element's property with given id.final PropertyManagerReturns the propertyManager of this element.Returns a list of selected elements in the diagram.static BasicStrokegetStroke(float width, int cap, int join, float miterLimit, float[] dash, float dash_phase) Get cached stroke.static BasicStrokegetStroke(int lineStyle) Get cached stroke of given style and default width.static BasicStrokegetStroke(int lineStyle, int width) Get cached stroke of given style and width.static BasicStrokegetStroke(int lineStyle, int width, int join) Get cached stroke of given style, width and join.static BasicStrokegetStroke(int lineStyle, int width, int join, int cap) Get cached stroke of given style, width and join.static BasicStrokegetStroke(BasicStroke stroke, int width) Get cached stroke of given width.final booleanbooleanReturns true, if this element is selected in the diagram.final voidonFind()Scrolls diagram canvas to this symbol and selects this symbolfinal voidonFind(boolean center) Scrolls diagram canvas to this symbol and selects this symbolvoidsetAllSelected(boolean select) Selects(or deselects) all presentation elements in the diagram.voidsetSelected(boolean select) Selects or deselects this presentation element in the diagram.voidsetSelected(List<PresentationElement> elements) Selects given elements in the diagram.booleanDoes this element uses parent properties or has it own?Methods inherited from class com.nomagic.magicdraw.uml.MDElementImpl
accept, accept, addPropertyChangeListener, canAdd, canAddChild, canBeDeleted, canDeleteChild, compareTo, createSortKeys, getClassType, getCommandForAppending, getID, getName, getProject, getProjectProvider, getResourceID, getSortKeys, hasListeners, isEditable, removeAllParents, removeAllPropertyChangeListeners, removePropertyChangeListener, setID, setProjectProvider, sGetID, toStringMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.nomagic.magicdraw.uml.BaseElement
canAdd
-
Field Details
-
SOLID_STROKE
@OpenApi public static final int SOLID_STROKESolid path stroke.- See Also:
-
DASHED_STROKE
@OpenApi public static final int DASHED_STROKEDashed path stroke.- See Also:
-
DOTTED_STROKE
@OpenApi public static final int DOTTED_STROKEDotted path stroke.- See Also:
-
-
Method Details
-
getElement
Returns model element of this presentation element. Some presentation elements (for example TextBoxes) do not have model elements.- Specified by:
getElementin interfaceModelElementProvider- Returns:
- model element of this presentation element.
-
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
Returns parent of this element.- Returns:
- parent of this element.
-
getPreferredSize
Deprecated.Returns preferable dimension of the element.- Returns:
- preferred dimension
-
getPreferredDimension
Returns preferable dimension of the element.- Returns:
- preferred dimension
-
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
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
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
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
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
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
Collects all visible and manipulated elements in this hierarchy. -
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
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
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
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 usePresentationElementsManager.setPresentationElementProperties(com.nomagic.magicdraw.uml.symbols.PresentationElement, com.nomagic.magicdraw.properties.PropertyManager)- Parameters:
prop- property
-
editName
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 nulltextEditorOptions- boolean options for text editor. Passed when creating text editor withTextEditorFactory
-
getManipulatedParent
- Returns:
- first parent with manipulator or null if such does not exist.
-
getObjectParent
Returns the presentation element parent. Implementation of super method.- Specified by:
getObjectParentin interfaceBaseElement- Overrides:
getObjectParentin classcom.nomagic.magicdraw.uml.MDElementImpl- Returns:
- the parent of the element.
- See Also:
-
getBoundsShape
Provides a bounding shape of the symbol- Parameters:
converterToShape- transform bounding shape according this converter- Returns:
- bounding shape of the symbol
-
getPresentationElementStroke
Return a stroke used to paint symbol's main part- Returns:
- a stroke used to paint symbol's main part
-
getPresentationElementStroke
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
Get cached stroke of given width.- Parameters:
stroke- base stroke.width- of the stroke.- Returns:
- stroke
-
getStroke
Get cached stroke of given style and default width.- Parameters:
lineStyle- style of line.- Returns:
- stroke
- See Also:
-
getStroke
Get cached stroke of given style and width.- Parameters:
lineStyle- style of linewidth- width- Returns:
- stroke
- See Also:
-
getStroke
Get cached stroke of given style, width and join.- Parameters:
lineStyle- style of linewidth- width- Returns:
- stroke
- See Also:
-
getStroke
Get cached stroke of given style, width and join.- Parameters:
lineStyle- style of linewidth- 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.
-
getPreferredDimension()