Class PresentationElement
- java.lang.Object
-
- com.nomagic.magicdraw.uml.MDElementImpl
-
- com.nomagic.magicdraw.uml.ElementImpl
-
- com.nomagic.magicdraw.uml.symbols.PresentationElement
-
- All Implemented Interfaces:
BaseElement
,MDElement
,ModelElementProvider
,NameOwner
,java.beans.PropertyChangeListener
,java.lang.Cloneable
,java.lang.Comparable
,java.util.EventListener
- Direct Known Subclasses:
DiagramPresentationElement
,PathConnector
@OpenApi public abstract class PresentationElement extends ElementImpl implements java.beans.PropertyChangeListener, ModelElementProvider, NameOwner
Base class for all visual elements used in the UML diagrams.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DASHED_STROKE
Dashed path stroke.static int
DOTTED_STROKE
Dotted path stroke.static int
SOLID_STROKE
Solid path stroke.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addProperty(Property prop)
Add property to presentation element.void
collectSubManipulatedElements(java.util.List<PresentationElement> col)
Collects all visible and manipulated elements in this hierarchy.void
editName(java.awt.event.KeyEvent evt)
Starts online diagram editing for a symbolvoid
editName(java.awt.event.KeyEvent evt, java.util.Map<java.lang.String,java.lang.Boolean> textEditorOptions)
Starts online diagram editing for a symboljava.awt.Rectangle
getBounds()
Method returns bounds of this element.java.awt.Shape
getBoundsShape(ConverterToShape converterToShape)
Provides a bounding shape of the symbolDiagramPresentationElement
getDiagramPresentationElement()
Returns diagram of this presentation element.DiagramSurface
getDiagramSurface()
Returns diagram surface for this presentation element.Element
getElement()
Returns model element of this presentation element.PresentationElement
getManipulatedParent()
java.util.List<PresentationElement>
getManipulatedPresentationElements()
Returns a list of children of this element those have manipulator.java.awt.Point
getMiddlePoint()
Returns middle point of this element.BaseElement
getObjectParent()
Returns the presentation element parent.PresentationElement
getParent()
Returns parent of this element.UnmodifiableDimension
getPreferredDimension()
Returns preferable dimension of the element.java.awt.Dimension
getPreferredSize()
Deprecated.java.util.List<PresentationElement>
getPresentationElements()
Returns all children of this elementjava.awt.BasicStroke
getPresentationElementStroke()
Return a stroke used to paint symbol's main partjava.awt.BasicStroke
getPresentationElementStroke(int width)
Return a stroke used to paint symbol's main partProperty
getProperty(java.lang.String id)
Returns element's property with given id.PropertyManager
getPropertyManager()
Returns the propertyManager of this element.java.util.List<PresentationElement>
getSelected()
Returns a list of selected elements in the diagram.static java.awt.BasicStroke
getStroke(float width, int cap, int join, float miterLimit, float[] dash, float dash_phase)
Get cached stroke.static java.awt.BasicStroke
getStroke(int lineStyle)
Get cached stroke of given style and default width.static java.awt.BasicStroke
getStroke(int lineStyle, int width)
Get cached stroke of given style and width.static java.awt.BasicStroke
getStroke(int lineStyle, int width, int join)
Get cached stroke of given style, width and join.static java.awt.BasicStroke
getStroke(int lineStyle, int width, int join, int cap)
Get cached stroke of given style, width and join.static java.awt.BasicStroke
getStroke(java.awt.BasicStroke stroke, int width)
Get cached stroke of given width.boolean
hasManipulatedPresentationElements()
boolean
isSelected()
Returns true, if this element is selected in the diagram.void
onFind()
Scrolls diagram canvas to this symbol and selects this symbolvoid
onFind(boolean center)
Scrolls diagram canvas to this symbol and selects this symbolvoid
setAllSelected(boolean select)
Selects(or deselects) all presentation elements in the diagram.void
setSelected(boolean select)
Selects or deselects this presentation element in the diagram.void
setSelected(java.util.List<PresentationElement> elements)
Selects given elements in the diagram.boolean
useParentProperties()
Does this element uses parent properties or has it own?-
Methods inherited from class com.nomagic.magicdraw.uml.MDElementImpl
accept, accept, addPropertyChangeListener, canAdd, canAdd, canAddChild, canBeDeleted, canDeleteChild, compareTo, createSortKeys, getClassType, getCommandForAppending, getID, getName, getProject, getProjectProvider, getResourceID, getSortKeys, hasListeners, isEditable, removeAllChildren, removeAllParents, removeAllPropertyChangeListeners, removePropertyChangeListener, setID, setProjectProvider, sGetID, toString
-
-
-
-
Field Detail
-
SOLID_STROKE
@OpenApi public static final int SOLID_STROKE
Solid path stroke.- See Also:
- Constant Field Values
-
DASHED_STROKE
@OpenApi public static final int DASHED_STROKE
Dashed path stroke.- See Also:
- Constant Field Values
-
DOTTED_STROKE
@OpenApi public static final int DOTTED_STROKE
Dotted path stroke.- See Also:
- Constant Field Values
-
-
Method Detail
-
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 interfaceModelElementProvider
- 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 PresentationElement getParent()
Returns parent of this element.- Returns:
- parent of this element.
-
getPreferredSize
@Deprecated @OpenApi public final java.awt.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 java.awt.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 java.awt.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:
PresentationElementsManager.reshapeShapeElement(com.nomagic.magicdraw.uml.symbols.shapes.ShapeElement, java.awt.Rectangle)
-
getPresentationElements
@OpenApi public java.util.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.- See Also:
getDiagramPresentationElement()
-
setSelected
@OpenApi public void setSelected(java.util.List<PresentationElement> elements)
Selects given elements in the diagram.- Parameters:
elements
- elements to select.- See Also:
getDiagramPresentationElement()
-
setSelected
@OpenApi public void setSelected(boolean select)
Selects or deselects this presentation element in the diagram.- Parameters:
select
- select or deselect this presentation element.- See Also:
getDiagramPresentationElement()
-
getSelected
@OpenApi public java.util.List<PresentationElement> getSelected()
Returns a list of selected elements in the diagram.- Returns:
- a list of selected elements. List is unmodifiable.
- See Also:
getDiagramPresentationElement()
-
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 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(java.util.List<PresentationElement> col)
Collects all visible and manipulated elements in this hierarchy.
-
getManipulatedPresentationElements
@OpenApi public final java.util.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:
useParentProperties()
,PresentationElementsManager.setPresentationElementProperties(com.nomagic.magicdraw.uml.symbols.PresentationElement, com.nomagic.magicdraw.properties.PropertyManager)
-
getProperty
@CheckForNull @OpenApi public Property getProperty(java.lang.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:
useParentProperties()
-
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 usePresentationElementsManager.setPresentationElementProperties(com.nomagic.magicdraw.uml.symbols.PresentationElement, com.nomagic.magicdraw.properties.PropertyManager)
- Parameters:
prop
- property
-
editName
@OpenApi public final void editName(@CheckForNull java.awt.event.KeyEvent evt)
Starts online diagram editing for a symbol- Parameters:
evt
- first key event or null
-
editName
@OpenApi public void editName(@CheckForNull java.awt.event.KeyEvent evt, @CheckForNull java.util.Map<java.lang.String,java.lang.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
@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 interfaceBaseElement
- Overrides:
getObjectParent
in classcom.nomagic.magicdraw.uml.MDElementImpl
- Returns:
- the parent of the element.
- See Also:
getParent()
-
getBoundsShape
@OpenApi @CheckForNull public final java.awt.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 java.awt.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 java.awt.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 java.awt.BasicStroke getStroke(java.awt.BasicStroke stroke, int width)
Get cached stroke of given width.- Parameters:
stroke
- base stroke.width
- of the stroke.- Returns:
- stroke
-
getStroke
@OpenApi public static java.awt.BasicStroke getStroke(int lineStyle)
Get cached stroke of given style and default width.- Parameters:
lineStyle
- style of line.- Returns:
- stroke
- See Also:
SOLID_STROKE
,DASHED_STROKE
,DOTTED_STROKE
-
getStroke
@OpenApi public static java.awt.BasicStroke getStroke(int lineStyle, int width)
Get cached stroke of given style and width.- Parameters:
lineStyle
- style of linewidth
- width- Returns:
- stroke
- See Also:
SOLID_STROKE
,DASHED_STROKE
,DOTTED_STROKE
-
getStroke
@OpenApi public static java.awt.BasicStroke getStroke(int lineStyle, int width, int join)
Get cached stroke of given style, width and join.- Parameters:
lineStyle
- style of linewidth
- width- Returns:
- stroke
- See Also:
SOLID_STROKE
,DASHED_STROKE
,DOTTED_STROKE
,BasicStroke.JOIN_BEVEL
,BasicStroke.JOIN_MITER
,BasicStroke.JOIN_ROUND
-
getStroke
@OpenApi public static java.awt.BasicStroke getStroke(int lineStyle, int width, int join, int cap)
Get cached stroke of given style, width and join.- Parameters:
lineStyle
- style of linewidth
- width- Returns:
- stroke
- See Also:
SOLID_STROKE
,DASHED_STROKE
,DOTTED_STROKE
,BasicStroke.JOIN_BEVEL
,BasicStroke.JOIN_MITER
,BasicStroke.JOIN_ROUND
-
getStroke
@OpenApi public static java.awt.BasicStroke getStroke(float width, int cap, int join, float miterLimit, @CheckForNull float[] dash, float dash_phase)
Get cached stroke.- See Also:
BasicStroke(float, int, int, float, float[], float)
-
-