Class DiagramPresentationElement

java.lang.Object
com.nomagic.magicdraw.uml.MDElementImpl
All Implemented Interfaces:
com.nomagic.magicdraw.core.diagram.DiagramPresentationImplementer, BaseElement, MDElement, ModelElementProvider, com.nomagic.magicdraw.uml.symbols.PropertyBasedPresentationElement, com.nomagic.magicdraw.uml.symbols.shapes.DiagramFrameHeaderOwner, StereotypesDisplayModeOwner, NameOwner, PropertyChangeListener, Cloneable, Comparable, EventListener

@OpenApi public class DiagramPresentationElement extends AbstractDiagramPresentationElement implements com.nomagic.magicdraw.uml.symbols.shapes.DiagramFrameHeaderOwner, StereotypesDisplayModeOwner, com.nomagic.magicdraw.core.diagram.DiagramPresentationImplementer, com.nomagic.magicdraw.uml.symbols.PropertyBasedPresentationElement
Class for representing UML diagram. Diagram purpose is to contain set of presentation elements.
For diagram creation use ModelElementsManager class.
For working with diagram presentation elements use PresentationElementsManager class.
See Also:
  • Field Details

    • DIAGRAM_USE_STEREOTYPE_MODES

      public static final List<String> DIAGRAM_USE_STEREOTYPE_MODES
      Diagram use stereotype modes.
  • Constructor Details

    • DiagramPresentationElement

      @OpenApi public DiagramPresentationElement()
      Constructs new empty diagram. Do not use this constructor to create a diagram explicitly. Open API provides method for diagrams creation.
      See Also:
    • DiagramPresentationElement

      public DiagramPresentationElement(@CheckForNull Diagram diagram)
    • DiagramPresentationElement

      public DiagramPresentationElement(@CheckForNull Diagram diagram, @CheckForNull DiagramType type)
    • DiagramPresentationElement

      public DiagramPresentationElement(@CheckForNull Diagram diagram, @CheckForNull com.nomagic.magicdraw.core.diagram.DiagramRepresentationObject repObject)
  • Method Details

    • internalAddToCache

      protected void internalAddToCache(AbstractDiagramPresentationElement diagram, @CheckForNull String oldType, @CheckForNull String newType)
      Overrides:
      internalAddToCache in class AbstractDiagramPresentationElement
    • internalRemoveFromCache

      protected void internalRemoveFromCache(AbstractDiagramPresentationElement diagram)
      Overrides:
      internalRemoveFromCache in class AbstractDiagramPresentationElement
    • hasNoRegisteredRealTypeDescriptor

      public boolean hasNoRegisteredRealTypeDescriptor()
      Overrides:
      hasNoRegisteredRealTypeDescriptor in class AbstractDiagramPresentationElement
    • sSetDiagramType

      @OpenApi public void sSetDiagramType(@CheckForNull DiagramType type)
      Sets the type of the diagram.
      Parameters:
      type - the type of the diagram
    • setDiagramType

      @OpenApi public void setDiagramType(DiagramType type)
      Sets the type of the diagram and fires the property change event with name ExtendedPropertyNames.EDIT_DIAGRAM_TYPE .
      Parameters:
      type - the type of the diagram
      See Also:
    • internalSetDiagramType

      protected void internalSetDiagramType(String diagramType, String diagramUmlType)
      Specified by:
      internalSetDiagramType in class AbstractDiagramPresentationElement
    • getDiagramType

      @OpenApi public DiagramType getDiagramType()
      Returns the type of the diagram.
      Specified by:
      getDiagramType in class AbstractDiagramPresentationElement
      Returns:
      the type of the diagram
      See Also:
    • getHumanType

      public String getHumanType()
      Returns human representation of the data type
      Specified by:
      getHumanType in interface BaseElement
      Overrides:
      getHumanType in class PresentationElement
      Returns:
      the name of the data
    • clone

      Specified by:
      clone in interface BaseElement
      Overrides:
      clone in class AbstractDiagramPresentationElement
    • getDiagram

      @OpenApi public Diagram getDiagram()
      Returns Diagram model element of this presentation element.
      Returns:
      Diagram object of this element.
      See Also:
    • getElement

      public Diagram getElement()
      Description copied from class: PresentationElement
      Returns model element of this presentation element. Some presentation elements (for example TextBoxes) do not have model elements.
      Specified by:
      getElement in interface ModelElementProvider
      Overrides:
      getElement in class PresentationElement
      Returns:
      model element of this presentation element.
    • propertyChange

      public void propertyChange(PropertyChangeEvent evt)
      Description copied from class: PresentationElement
      Listens for property change it can be: data was edited text box was edited
      Specified by:
      propertyChange in interface PropertyChangeListener
      Overrides:
      propertyChange in class AbstractDiagramPresentationElement
    • accept

      @OpenApi public void accept(Visitor visitor) throws Exception
      Description copied from interface: MDElement
      Method accepts a visitor, and calls method "visit<class name>(this)" of a visitor. See "Visitor" pattern for more details.
      Specified by:
      accept in interface MDElement
      Overrides:
      accept in class AbstractDiagramPresentationElement
      Parameters:
      visitor - which visits this element.
      Throws:
      Exception
    • getDiagramTypeAsString

      public String getDiagramTypeAsString()
      Specified by:
      getDiagramTypeAsString in class AbstractDiagramPresentationElement
    • getName

      public String getName()
      Gets the name of this DiagramPresentationElement object.
      Specified by:
      getName in interface MDElement
      Specified by:
      getName in interface NameOwner
      Overrides:
      getName in class com.nomagic.magicdraw.uml.MDElementImpl
      Returns:
      name of this object
    • sSetShowDiagramOwner

      public void sSetShowDiagramOwner(boolean show)
    • sSetShowAbbreviatedDiagramType

      public void sSetShowAbbreviatedDiagramType(boolean show)
    • sSetShowDiagramName

      public void sSetShowDiagramName(boolean show)
    • sSetShowParameters

      public void sSetShowParameters(boolean show)
    • sSetShowContextName

      public void sSetShowContextName(boolean show)
    • sSetShowContextType

      public void sSetShowContextType(boolean show)
    • sSetShowDiagramType

      public void sSetShowDiagramType(boolean show)
    • sSetShowContextKind

      public void sSetShowContextKind(boolean show)
    • setShowAbbreviatedDiagramType

      public void setShowAbbreviatedDiagramType(boolean show)
    • setShowDiagramName

      public void setShowDiagramName(boolean show)
    • setShowParameters

      public void setShowParameters(boolean show)
    • setShowContextName

      public void setShowContextName(boolean show)
    • setShowContextType

      public void setShowContextType(boolean show)
    • setShowDiagramType

      public void setShowDiagramType(boolean show)
    • setShowContextKind

      public void setShowContextKind(boolean show)
    • isShowAbbreviatedDiagramType

      public boolean isShowAbbreviatedDiagramType()
      Specified by:
      isShowAbbreviatedDiagramType in interface com.nomagic.magicdraw.uml.symbols.shapes.DiagramFrameHeaderOwner
    • isShowDiagramName

      public boolean isShowDiagramName()
      Specified by:
      isShowDiagramName in interface com.nomagic.magicdraw.uml.symbols.shapes.DiagramFrameHeaderOwner
    • isShowParameters

      public boolean isShowParameters()
      Specified by:
      isShowParameters in interface com.nomagic.magicdraw.uml.symbols.shapes.DiagramFrameHeaderOwner
    • isShowContextName

      public boolean isShowContextName()
      Specified by:
      isShowContextName in interface com.nomagic.magicdraw.uml.symbols.shapes.DiagramFrameHeaderOwner
    • isShowContextType

      public boolean isShowContextType()
      Specified by:
      isShowContextType in interface com.nomagic.magicdraw.uml.symbols.shapes.DiagramFrameHeaderOwner
    • isShowDiagramType

      public boolean isShowDiagramType()
      Specified by:
      isShowDiagramType in interface com.nomagic.magicdraw.uml.symbols.shapes.DiagramFrameHeaderOwner
    • isShowContextKind

      public boolean isShowContextKind()
      Specified by:
      isShowContextKind in interface com.nomagic.magicdraw.uml.symbols.shapes.DiagramFrameHeaderOwner
    • sSetShowDiagramFrame

      public void sSetShowDiagramFrame(boolean show)
    • isShowDiagramOwner

      public boolean isShowDiagramOwner()
    • isShowDiagramFrame

      public boolean isShowDiagramFrame()
      Overrides:
      isShowDiagramFrame in class AbstractDiagramPresentationElement
    • setShowDiagramOwner

      public void setShowDiagramOwner(boolean show)
    • setShowDiagramFrame

      public void setShowDiagramFrame(boolean show)
    • sSetElement

      public void sSetElement(@CheckForNull Element element)
      Sets diagram element for this object.
      Overrides:
      sSetElement in class PresentationElement
    • canAddInstance

      public boolean canAddInstance(PresentationElement symbol)
      Description copied from class: PresentationElement
      Object view has no children.
      Overrides:
      canAddInstance in class AbstractDiagramPresentationElement
    • hasManipulationSortManager

      protected boolean hasManipulationSortManager()
      Overrides:
      hasManipulationSortManager in class AbstractDiagramPresentationElement
    • onFontChange

      public void onFontChange()
      Overrides:
      onFontChange in class PresentationElement
    • setShowMessageNumbers

      public void setShowMessageNumbers(boolean b)
    • setUseAdvancedNumbering

      public void setUseAdvancedNumbering(boolean b)
    • isShowMessageNumbers

      public boolean isShowMessageNumbers()
    • isUseAdvancedNumbering

      public boolean isUseAdvancedNumbering()
    • isShowDiagramInfo

      public boolean isShowDiagramInfo()
    • sSetShowDiagramInfo

      public void sSetShowDiagramInfo(boolean b)
    • resetLastModificationUpdateTime

      public void resetLastModificationUpdateTime()
      Reset cached last diagram modification time.
    • getDiagramPropertiesShape

      @CheckForNull public DiagramPropertiesShape getDiagramPropertiesShape()
    • setShowDiagramInfo

      public void setShowDiagramInfo(boolean showDiagramInfo)
    • createDiagramInfoShape

      public void createDiagramInfoShape(boolean simple)
    • positionDiagramInfoShapeOnFrame

      public void positionDiagramInfoShapeOnFrame(DiagramPropertiesShape shape)
    • addDiagramCreationInfo

      public static void addDiagramCreationInfo(Diagram diagram)
    • addDiagramCreationInfo

      public static void addDiagramCreationInfo(Diagram diagram, boolean overwrite)
    • sSetShowActivations

      public void sSetShowActivations(boolean b)
    • setShowActivations

      public void setShowActivations(boolean b)
    • isShowActivations

      public boolean isShowActivations()
    • sSetDiagramOrientationMode

      public void sSetDiagramOrientationMode(String mode)
      Simple set for diagram orientation mode property
      Parameters:
      mode - - diagram orientation mode.
    • setDiagramOrientationMode

      public void setDiagramOrientationMode(String mode)
      Sets diagram orientation mode.
      Parameters:
      mode - - diagram orientation mode.
    • sSetUseStereotypeMode

      public void sSetUseStereotypeMode(String mode)
      Simple set for diagram use stereotype mode property
      Parameters:
      mode - - diagram orientation mode.
    • setUseStereotypeMode

      public void setUseStereotypeMode(String mode)
      Sets diagram use stereotype mode.
      Parameters:
      mode - - diagram orientation mode.
    • getUseStereotypeMode

      public String getUseStereotypeMode()
      Gets diagram use stereotype mode.
      Specified by:
      getUseStereotypeMode in interface com.nomagic.magicdraw.uml.symbols.shapes.DiagramFrameHeaderOwner
      Returns:
      diagram orientation mode.
    • getAspectRatioMode

      public String getAspectRatioMode()
    • setAspectRatioMode

      public void setAspectRatioMode(String mode)
    • sSetAspectRatioMode

      public void sSetAspectRatioMode(String mode)
    • internalSilentApply

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

      public void internalApplyProperties(com.dassault_systemes.modeler.magic.diagram.styledelegates.PresentationElementStyleChanger changer)
      Description copied from class: PresentationElement
      Applies properties from given property manager
      Overrides:
      internalApplyProperties in class AbstractDiagramPresentationElement
      Parameters:
      changer - new properties
    • preferredSize

      public void preferredSize(Dimension dim)
      Overrides:
      preferredSize in class AbstractDiagramPresentationElement
    • isModificationTimeUpdateDisabled

      public boolean isModificationTimeUpdateDisabled()
      Indicates if automatic diagram modification time update is disabled
      Returns:
      true when diagram modification time update is disabled
    • setModificationTimeUpdateDisabled

      public void setModificationTimeUpdateDisabled(boolean modificationTimeUpdateDisabled)
      Disables automatic diagram modification time update.
      Parameters:
      modificationTimeUpdateDisabled - true to disable automatic diagram modification time update.
    • updateDiagramPropertiesShapeModificationTime

      public void updateDiagramPropertiesShapeModificationTime()
    • applyForcedProperties

      public void applyForcedProperties()
      Applies properties stored in default style for diagram and marked as forced. They can be marked as forced using "apply" from styles dialog.
      Specified by:
      applyForcedProperties in class AbstractDiagramPresentationElement
    • getUsedModelElements

      @OpenApi @Deprecated public Collection<Element> getUsedModelElements(boolean checkOnlyPersistent)
      Deprecated.
      checkOnlyPersistent parameter is ignored. Use getUsedModelElements()
      Returns collection of model elements that are drawn in this diagram.
      Parameters:
      checkOnlyPersistent - if true, result includes elements for symbols which are saved to XMI and not created at run-time. If false, includes all elements.
      Returns:
      collection of model elements.
    • getUsedModelElements

      @Deprecated public Collection<Element> getUsedModelElements(boolean checkOnlyPersistent, boolean checkOnlyFriendly)
      Deprecated.
      checkOnlyPersistent and checkOnlyFriendly parameters are ignored. Use getUsedModelElements()
      Returns collection of model elements that are drawn in this diagram.
      Parameters:
      checkOnlyPersistent - if true, result includes elements for symbols which are saved to XMI and not created at run-time. If false, includes all elements.
      checkOnlyFriendly - check only "friendly" symbols
      Returns:
      collection of model elements.
    • getUsedModelElements

      @OpenApi public Collection<Element> getUsedModelElements()
      Returns collection of model elements that have views in this diagram.
      Returns:
      collection of model elements.
    • getUsedModelElements

      @OpenApi public Set<Element> getUsedModelElements(UsedElementPolicy usedElementPolicy)
      Returns collection of model elements that are used in this diagram.
      Parameters:
      usedElementPolicy - used element policy
      Returns:
      collection of model elements.
    • isElementInDiagram

      @OpenApi public boolean isElementInDiagram(Element element)
      Checks if given element exist in any diagram.
      Parameters:
      element - element
      Returns:
      true if element exist in any diagram otherwise false
    • isElementInDiagram

      @OpenApi public boolean isElementInDiagram(Element element, UsedElementPolicy usedElementPolicy)
      Checks if given element exist in any diagram.
      Parameters:
      element - element
      Returns:
      true if element exist in any diagram otherwise false
    • isElementInDiagram

      public boolean isElementInDiagram(Element element, boolean skipProxyCheck, UsedElementPolicy usedElementPolicy)
      Checks if given element exist in any diagram.
      Parameters:
      element - element
      skipProxyCheck - enables to skip if diagram's actual element is proxy
      Returns:
      true if element exist in any diagram otherwise false
    • setDefaultStyleID

      public void setDefaultStyleID(@CheckForNull String id)
      Sets new diagram style id to representation object
      Parameters:
      id - new id
    • getDefaultStyleID

      @CheckForNull public String getDefaultStyleID()
      Returns:
      Returns the defaultStyleForDiagramID, can be null if default style is equal to diagram style, or diagram is loaded.
    • getDefaultStyleForDiagram

      @CheckForNull public Style getDefaultStyleForDiagram(StyleManager styleManager)
      Finds style for this diagram
      Parameters:
      styleManager - manager to find in.
      Returns:
      found style, null if no style is created.
    • getRealType

      @CheckForNull public String getRealType()
      Returns real diagram type. Real diagram type is diagram type which is not registered but loaded from project file.
      Overrides:
      getRealType in class AbstractDiagramPresentationElement
      Returns:
      real type. Can be null.
    • setRealType

      public void setRealType(@CheckForNull String realType)
      If diagram type is not registered then known type is set. Real type is preserved for saving.
      Parameters:
      realType - real diagram type.
    • getCurrentDate

      public static String getCurrentDate()
    • sSetDiagramFrame

      public void sSetDiagramFrame(@CheckForNull com.nomagic.magicdraw.uml.symbols.shapes.BaseHeaderShapeView diagramFrame)
      Overrides:
      sSetDiagramFrame in class AbstractDiagramPresentationElement
    • getDiagramFrame

      @OpenApi @CheckForNull public DiagramFrameView getDiagramFrame()
      Get the frame of the diagram.
      Specified by:
      getDiagramFrame in class AbstractDiagramPresentationElement
      Returns:
      frame of the diagram.
    • getContainer

      public com.nomagic.magicdraw.uml.symbols.DiagramObjectViewContainer getContainer()
      Overrides:
      getContainer in class AbstractDiagramPresentationElement
      Returns:
      diagram container
    • setInitialDiagramFrameBounds

      public void setInitialDiagramFrameBounds()
      Sets initial diagram frame bounds for this diagram's frame.
      Overrides:
      setInitialDiagramFrameBounds in class AbstractDiagramPresentationElement
    • getStereotypesDisplayMode

      public String getStereotypesDisplayMode()
      Description copied from interface: com.nomagic.magicdraw.uml.symbols.shapes.DiagramFrameHeaderOwner
      Gets setereotypes display mode.
      Specified by:
      getStereotypesDisplayMode in interface com.nomagic.magicdraw.uml.symbols.shapes.DiagramFrameHeaderOwner
      Specified by:
      getStereotypesDisplayMode in interface StereotypesDisplayModeOwner
      Returns:
      stereotypes display mode.
    • sSetStereotypesDisplayMode

      public void sSetStereotypesDisplayMode(String mode)
      Description copied from interface: StereotypesDisplayModeOwner
      Simple sets (no updates) stereotypes display mode.
      Specified by:
      sSetStereotypesDisplayMode in interface StereotypesDisplayModeOwner
      Parameters:
      mode - stereotypes display mode value.
    • setStereotypesDisplayMode

      public void setStereotypesDisplayMode(String mode)
      Description copied from interface: StereotypesDisplayModeOwner
      Sets stereotype display mode value.
      Specified by:
      setStereotypesDisplayMode in interface StereotypesDisplayModeOwner
      Parameters:
      mode - stereotype display mode.
    • getDSLStereotypesDisplayMode

      public String getDSLStereotypesDisplayMode()
      Description copied from interface: StereotypesDisplayModeOwner
      Gets DSL stereotype display mode.
      Specified by:
      getDSLStereotypesDisplayMode in interface StereotypesDisplayModeOwner
      Returns:
      stereotype display mode.
    • sSetDSLStereotypesDisplayMode

      public void sSetDSLStereotypesDisplayMode(String mode)
      Description copied from interface: StereotypesDisplayModeOwner
      Simple sets (no updates) DSL stereotypes display mode.
      Specified by:
      sSetDSLStereotypesDisplayMode in interface StereotypesDisplayModeOwner
      Parameters:
      mode - stereotypes display mode value.
    • setDSLStereotypesDisplayMode

      public void setDSLStereotypesDisplayMode(String mode)
      Description copied from interface: StereotypesDisplayModeOwner
      Sets DSL stereotype display mode value.
      Specified by:
      setDSLStereotypesDisplayMode in interface StereotypesDisplayModeOwner
      Parameters:
      mode - stereotype display mode.
    • isAutosized

      public boolean isAutosized()
    • sSetAutosize

      public void sSetAutosize(boolean val)
    • setAutosize

      public void setAutosize(boolean val)
    • updateFrameSize

      public void updateFrameSize(PresentationElement element)
      Overrides:
      updateFrameSize in class AbstractDiagramPresentationElement
    • isUseFlowLayoutLogic

      public boolean isUseFlowLayoutLogic()
      Indicates if smart path/shape edit should be used in this diagram.
      Overrides:
      isUseFlowLayoutLogic in class AbstractDiagramPresentationElement
      Returns:
      true if smart symbol editing should be used, false otherwise.
    • clearCaches

      protected void clearCaches()
      Overrides:
      clearCaches in class AbstractDiagramPresentationElement
    • isInitialFrameSizeSet

      @OpenApi public boolean isInitialFrameSizeSet()
      Returns:
      false if diagram frame size should not be recalculated on opening.
    • setInitialFrameSizeSet

      @OpenApi public void setInitialFrameSizeSet(boolean value)
      Set a flag that diagram frame size should not be recalculated on opening.
      Parameters:
      value - new value
    • hasHeavyWeightSymbols

      public boolean hasHeavyWeightSymbols()
      Check is diagram has heavyweight symbols - symbols those can be painted correctly only if diagram is displayed in some JComponent
      Returns:
      true if heavyweight symbols exists in the diagram
    • registerHeavyWeightSymbolsChecker

      public static void registerHeavyWeightSymbolsChecker(com.nomagic.magicdraw.uml.symbols.DiagramPresentationElement.HeavyWeightSymbolsChecker checker)
    • unRegisterHeavyWeightSymbolsChecker

      public static void unRegisterHeavyWeightSymbolsChecker(com.nomagic.magicdraw.uml.symbols.DiagramPresentationElement.HeavyWeightSymbolsChecker checker)
    • sSetSuspendShapeAutoResizeMode

      public void sSetSuspendShapeAutoResizeMode(String mode)
      Overrides:
      sSetSuspendShapeAutoResizeMode in class AbstractDiagramPresentationElement
    • setSuspendShapeAutoResizeMode

      public void setSuspendShapeAutoResizeMode(String mode)
      Overrides:
      setSuspendShapeAutoResizeMode in class AbstractDiagramPresentationElement
    • internalClearOnUnload

      protected void internalClearOnUnload()
      Overrides:
      internalClearOnUnload in class AbstractDiagramPresentationElement
    • getRepresentationFromModelElement

      public com.nomagic.magicdraw.core.diagram.DiagramRepresentationObject getRepresentationFromModelElement()
      Specified by:
      getRepresentationFromModelElement in class AbstractDiagramPresentationElement
    • postOpenFromCommand

      public void postOpenFromCommand()
      Overrides:
      postOpenFromCommand in class AbstractDiagramPresentationElement
    • sSetForceStoreContentOnSave

      protected void sSetForceStoreContentOnSave(boolean forceStoreContentOnSave)
      Overrides:
      sSetForceStoreContentOnSave in class AbstractDiagramPresentationElement
    • get

      @OpenApi public static DiagramPresentationElement get(PresentationElement symbol)
      Returns diagram of given presentation element.
      Returns:
      diagram of given presentation element.
    • layout

      @OpenApi @Deprecated(since="2024x Refresh3", forRemoval=true) public boolean layout(boolean useCommands, DiagramLayouter layouter)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from class: AbstractDiagramPresentationElement
      Layouts the diagram with the specified layouter. Only selected symbols in the diagram are layouted. All symbols are layouted if selection is empty. Use PresentationElement.setSelected(java.util.List)} to select symbols in the diagram.
      Specified by:
      layout in class AbstractDiagramPresentationElement
      Parameters:
      useCommands - true to create commands. If true, this command will be available in the project's command history
      layouter - layouter to be used for layouting
      Returns:
      true if layout was performed.
    • getDefaultDiagramLayouter

      public DiagramLayouter getDefaultDiagramLayouter()
      Specified by:
      getDefaultDiagramLayouter in class AbstractDiagramPresentationElement