Class DiagramCanvas

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, CaptureManager, DiagramCanvasExt, ElementCreator, ElementDeleter, ElementEditor, ElementRenderer, ExportManager, LinkLayoutManager, LiveEditor, NodeLayoutCache, NodeLayoutManager, VisibilityManager

Swing component that displays and edits one diagram panel.
See Also:
  • Field Details

    • PASTE_OFFSET

      public static final double PASTE_OFFSET
      See Also:
    • clipboardSnapshot

      public static ClipboardSnapshot clipboardSnapshot
    • TITLE_FONT

      public static final Font TITLE_FONT
    • BODY_FONT

      public static final Font BODY_FONT
    • COMMENT_MIN_WIDTH

      public static final int COMMENT_MIN_WIDTH
      See Also:
    • COMMENT_RESIZE_HANDLE_SIZE

      public static final int COMMENT_RESIZE_HANDLE_SIZE
      See Also:
    • COMMENT_MIN_HEIGHT

      public static final int COMMENT_MIN_HEIGHT
      See Also:
    • COMMENT_MIN_WIDTH_VALUE

      public static final int COMMENT_MIN_WIDTH_VALUE
      See Also:
    • CLASS_MIN_WIDTH

      public static final int CLASS_MIN_WIDTH
      See Also:
    • CLASS_HEADER_HEIGHT

      public static final int CLASS_HEADER_HEIGHT
      See Also:
    • CLASS_ROW_HEIGHT

      public static final int CLASS_ROW_HEIGHT
      See Also:
    • TEXT_PADDING

      public static final int TEXT_PADDING
      See Also:
    • CANVAS_BACKGROUND_COLOR

      public static final Color CANVAS_BACKGROUND_COLOR
    • GRID_COLOR

      public static final Color GRID_COLOR
    • SELECTION_COLOR

      public static final Color SELECTION_COLOR
    • SELECTION_FILL_COLOR

      public static final Color SELECTION_FILL_COLOR
    • COMMENT_CONNECTOR_COLOR

      public static final Color COMMENT_CONNECTOR_COLOR
    • DEFAULT_STROKE

      public static final BasicStroke DEFAULT_STROKE
    • FIELD_SELECTION_STROKE

      public static final BasicStroke FIELD_SELECTION_STROKE
    • SELECTION_STROKE

      public static final BasicStroke SELECTION_STROKE
    • COMMENT_CONNECTOR_SELECTION_STROKE

      public static final BasicStroke COMMENT_CONNECTOR_SELECTION_STROKE
    • ASSOCIATION_CONNECTOR_DEFAULT_STROKE

      public static final BasicStroke ASSOCIATION_CONNECTOR_DEFAULT_STROKE
    • ASSOCIATION_CONNECTOR_SELECTION_STROKE

      public static final BasicStroke ASSOCIATION_CONNECTOR_SELECTION_STROKE
    • CONCEPTUAL_ANCHOR_SPACING

      public static final double CONCEPTUAL_ANCHOR_SPACING
      See Also:
    • EXPORT_MARGIN

      public static final int EXPORT_MARGIN
      See Also:
    • DEFAULT_EXPORT_WIDTH

      public static final int DEFAULT_EXPORT_WIDTH
      See Also:
    • DEFAULT_EXPORT_HEIGHT

      public static final int DEFAULT_EXPORT_HEIGHT
      See Also:
  • Constructor Details

    • DiagramCanvas

      public DiagramCanvas(MainFrame mainFrame, ModelDocument modelDocument, PanelType panelType, DocumentChangeListener documentEventListener)
      Creates a diagram canvas instance.
      Parameters:
      mainFrame - main frame that owns the canvas or action
      modelDocument - document to read or modify
      panelType - diagram panel type whose model or layout should be used
      documentEventListener - listener notified when the document changes
  • Method Details

    • getCanvasAction

      public Action getCanvasAction(String actionKey)
      Returns the canvas action.
      Parameters:
      actionKey - key under which the action is registered
      Returns:
      the canvas action
    • getHeight

      public float getHeight(Font bodyFont)
      Returns the height on the active canvas.
      Parameters:
      bodyFont - font used for measurement or drawing
      Returns:
      the height
    • paintComponent

      public void paintComponent(Graphics g)
      Paints the component.
      Overrides:
      paintComponent in class JComponent
      Parameters:
      g - graphics context supplied by Swing
    • resetUiAfterDocumentRestore

      public void resetUiAfterDocumentRestore()
      Resets the UI after document restore on the active canvas.
    • findClassById

      default ClassModel findClassById(String id)
      Finds the class by ID that matches the supplied input.
      Parameters:
      id - stable id of the model element
      Returns:
      the matching class by ID, or null when no match exists
    • findCommentById

      default CommentModel findCommentById(String commentId)
      Finds the comment by ID that matches the supplied input.
      Parameters:
      commentId - id of the comment to look up or modify
      Returns:
      the matching comment by ID, or null when no match exists
    • findFieldById

      default FieldModel findFieldById(ClassModel classModel, String fieldId)
      Finds the field by ID that matches the supplied input.
      Parameters:
      classModel - class model affected by the operation
      fieldId - id of the field to look up or modify
      Returns:
      the matching field by ID, or null when no match exists
    • findFieldById

      default FieldModel findFieldById(String classId, String fieldId)
      Finds the field by ID that matches the supplied input.
      Parameters:
      classId - id of the class to look up or modify
      fieldId - id of the field to look up or modify
      Returns:
      the matching field by ID, or null when no match exists
    • findLinkByAssociationClassId

      default LinkModel findLinkByAssociationClassId(String classId)
      Finds the link by association class ID that matches the supplied input.
      Parameters:
      classId - id of the class to look up or modify
      Returns:
      the matching link by association class ID, or null when no match exists
    • findLinkById

      default LinkModel findLinkById(String id)
      Finds the link by ID that matches the supplied input.
      Parameters:
      id - stable id of the model element
      Returns:
      the matching link by ID, or null when no match exists
    • findOwnerClassOfField

      default ClassModel findOwnerClassOfField(String fieldId)
      Finds the owner class of field that matches the supplied input.
      Parameters:
      fieldId - id of the field to look up or modify
      Returns:
      the matching owner class of field, or null when no match exists
    • findPrimaryKeyField

      default FieldModel findPrimaryKeyField(String classId)
      Finds the primary key field that matches the supplied input.
      Parameters:
      classId - id of the class to look up or modify
      Returns:
      the matching primary key field, or null when no match exists
    • findType

      default Object findType(SelectedElement selectedElement)
      Finds the type that matches the supplied input.
      Parameters:
      selectedElement - selected element to read or update
      Returns:
      the matching type, or null when no match exists
    • linkEndpointExists

      default boolean linkEndpointExists(String classId, String fieldId)
      Checks whether the link endpoint exists.
      Parameters:
      classId - id of the class to look up or modify
      fieldId - id of the field to look up or modify
      Returns:
      true when the condition is met; otherwise false
    • addToSelection

      default void addToSelection(SelectedElement element)
      Adds the to selection.
      Parameters:
      element - element value used by the operation
    • clearSelection

      default void clearSelection()
      Clears the selection.
    • getSelectionInfo

      default SelectionInfo getSelectionInfo()
      Returns the selection info.
      Returns:
      the selection info
    • getStyleScope

      default StyleScope getStyleScope()
      Returns the style scope on the active canvas.
      Returns:
      the style scope
    • hasSelection

      default boolean hasSelection()
      Checks whether this object has a selection.
      Returns:
      true if selection exists; otherwise false
    • isClassSelected

      default boolean isClassSelected(String classId)
      Checks whether class selected is enabled or applies.
      Parameters:
      classId - id of the class to look up or modify
      Returns:
      true if class selected is enabled or applies; otherwise false
    • isCommentSelected

      default boolean isCommentSelected(String commentId)
      Checks whether comment selected is enabled or applies.
      Parameters:
      commentId - id of the comment to look up or modify
      Returns:
      true if comment selected is enabled or applies; otherwise false
    • isElementSelected

      default boolean isElementSelected(SelectedElement element)
      Checks whether element selected is enabled or applies on the active canvas.
      Parameters:
      element - element value used by the operation
      Returns:
      true if element selected is enabled or applies; otherwise false
    • isFieldSelected

      default boolean isFieldSelected(String classId, String fieldId)
      Checks whether field selected is enabled or applies.
      Parameters:
      classId - id of the class to look up or modify
      fieldId - id of the field to look up or modify
      Returns:
      true if field selected is enabled or applies; otherwise false
    • isLinkSelected

      default boolean isLinkSelected(String linkId)
      Checks whether link selected is enabled or applies.
      Parameters:
      linkId - id of the link to look up or modify
      Returns:
      true if link selected is enabled or applies; otherwise false
    • removeFromSelection

      default void removeFromSelection(SelectedElement element)
      Removes the from selection.
      Parameters:
      element - element value used by the operation
    • select

      default void select(SelectedElement element)
      Selects an element and updates dependent UI state.
      Parameters:
      element - element value used by the operation
    • selectAll

      default void selectAll()
      Selects the all on the active canvas.
    • updateSelectionFromMouse

      default void updateSelectionFromMouse(SelectedElement element, MouseEvent event)
      Updates the selection from mouse.
      Parameters:
      element - element value used by the operation
      event - event object supplied by Swing
    • blankToFallback

      default String blankToFallback(String primary, String secondary, String fallback)
      Returns the fallback text when the preferred value is blank.
      Parameters:
      primary - text value for primary
      secondary - text value for secondary
      fallback - text value for fallback
      Returns:
      the blank to fallback result
    • getEditableClassName

      default String getEditableClassName(ClassModel classModel)
      Returns the editable class name.
      Parameters:
      classModel - class model affected by the operation
      Returns:
      the editable class name
    • getEditableCommentText

      default String getEditableCommentText(String commentId)
      Returns the editable comment text.
      Parameters:
      commentId - id of the comment to look up or modify
      Returns:
      the editable comment text
    • getEditableFieldName

      default String getEditableFieldName(FieldModel fieldModel)
      Returns the editable field name.
      Parameters:
      fieldModel - field model affected by the operation
      Returns:
      the editable field name
    • resolveClassTitle

      default String resolveClassTitle(ClassModel classModel)
      Resolves the class title from the current model and layout state.
      Parameters:
      classModel - class model affected by the operation
      Returns:
      the resolved class title
    • resolveFieldName

      default String resolveFieldName(FieldModel fieldModel)
      Resolves the field name from the current model and layout state.
      Parameters:
      fieldModel - field model affected by the operation
      Returns:
      the resolved field name
    • setEditableClassName

      default void setEditableClassName(ClassModel classModel, String value)
      Sets the editable class name.
      Parameters:
      classModel - class model affected by the operation
      value - value to process
    • setEditableCommentText

      default void setEditableCommentText(String commentId, String value)
      Sets the editable comment text.
      Parameters:
      commentId - id of the comment to look up or modify
      value - value to process
    • setEditableFieldName

      default void setEditableFieldName(FieldModel fieldModel, String value)
      Sets the editable field name.
      Parameters:
      fieldModel - field model affected by the operation
      value - value to process
    • applyDefaultPaletteToClass

      default void applyDefaultPaletteToClass(ClassModel classModel)
      Applies the default palette to class.
      Parameters:
      classModel - class model affected by the operation
    • applyDefaultPaletteToClass

      @Deprecated default void applyDefaultPaletteToClass(ClassModel classModel, boolean deep, boolean visibleOnly)
      Deprecated.
      Applies the default palette to class.
      Parameters:
      classModel - class model affected by the operation
      deep - whether deep is enabled
      visibleOnly - whether visible only is enabled
    • applyDefaultPaletteToComment

      default void applyDefaultPaletteToComment(CommentModel commentModel)
      Applies the default palette to comment.
      Parameters:
      commentModel - comment model affected by the operation
    • applyDefaultPaletteToField

      default void applyDefaultPaletteToField(FieldModel fieldModel)
      Applies the default palette to field.
      Parameters:
      fieldModel - field model affected by the operation
    • applyDefaultPaletteToLink

      default void applyDefaultPaletteToLink(LinkModel linkModel)
      Applies the default palette to link.
      Parameters:
      linkModel - link model affected by the operation
    • applyPaletteToClass

      default void applyPaletteToClass(StylePalette palette, ClassModel classModel)
      Applies the palette to class.
      Parameters:
      palette - palette value used by the operation
      classModel - class model affected by the operation
    • applyPaletteToClass

      default void applyPaletteToClass(StylePalette palette, ClassModel classModel, boolean deep, boolean visibleOnly)
      Applies the palette to class.
      Parameters:
      palette - palette value used by the operation
      classModel - class model affected by the operation
      deep - whether deep is enabled
      visibleOnly - whether visible only is enabled
    • applyPaletteToComment

      default void applyPaletteToComment(StylePalette palette, CommentModel commentModel)
      Applies the palette to comment.
      Parameters:
      palette - palette value used by the operation
      commentModel - comment model affected by the operation
    • applyPaletteToField

      default void applyPaletteToField(StylePalette palette, FieldModel fieldModel)
      Applies the palette to field.
      Parameters:
      palette - palette value used by the operation
      fieldModel - field model affected by the operation
    • applyPaletteToLink

      default void applyPaletteToLink(StylePalette palette, LinkModel linkModel)
      Applies the palette to link.
      Parameters:
      palette - palette value used by the operation
      linkModel - link model affected by the operation
    • applyDefaultPaletteToSelection

      default void applyDefaultPaletteToSelection(StylePalette palette)
      Applies the default palette to selection.
      Parameters:
      palette - palette value used by the operation
    • applyPaletteToSelection

      default void applyPaletteToSelection(StylePalette palette)
      Applies the palette to selection.
      Parameters:
      palette - palette value used by the operation
    • setDefaultPalette

      default void setDefaultPalette(StylePalette defaultPalette)
      Sets the default palette on the active canvas.
      Parameters:
      defaultPalette - default palette value used by the operation
    • copySelection

      default void copySelection()
      Copies the selection.
    • cutSelection

      default void cutSelection()
      Cuts the selection and places it on the clipboard.
    • duplicateSelection

      default void duplicateSelection()
      Duplicates the selection.
    • pasteSelection

      default void pasteSelection()
      Pastes the selection from the clipboard.
    • buildSelfLinkPoints

      default List<Point2D> buildSelfLinkPoints(LinkModel linkModel, Point2D fromPoint, Point2D toPoint)
      Builds a self link points.
      Parameters:
      linkModel - link model affected by the operation
      fromPoint - point in canvas coordinates
      toPoint - point in canvas coordinates
      Returns:
      the built self link points
    • computePolylineMiddlePoint

      default Point2D computePolylineMiddlePoint(List<Point2D> points)
      Computes the polyline middle point on the active canvas.
      Parameters:
      points - points in canvas coordinates
      Returns:
      the compute polyline middle point result
    • computeUprightAngleAtMiddle

      default double computeUprightAngleAtMiddle(List<Point2D> points)
      Computes the upright angle at middle on the active canvas.
      Parameters:
      points - points in canvas coordinates
      Returns:
      the compute upright angle at middle result
    • resolveClassCenterAnchor

      default Point2D resolveClassCenterAnchor(String classId)
      Resolves the class center anchor from the current model and layout state.
      Parameters:
      classId - id of the class to look up or modify
      Returns:
      the resolved class center anchor
    • resolveCommentCenterAnchor

      default Point2D resolveCommentCenterAnchor(String commentId)
      Resolves the comment center anchor from the current model and layout state.
      Parameters:
      commentId - id of the comment to look up or modify
      Returns:
      the resolved comment center anchor
    • resolveLinkGeometry

      default LinkGeometry resolveLinkGeometry(LinkModel linkModel)
      Resolves the link geometry from the current model and layout state.
      Parameters:
      linkModel - link model affected by the operation
      Returns:
      the resolved link geometry
    • resolveLinkMiddleAnchor

      default Point2D resolveLinkMiddleAnchor(String linkId)
      Resolves the link middle anchor from the current model and layout state.
      Parameters:
      linkId - id of the link to look up or modify
      Returns:
      the resolved link middle anchor
    • resolvePreviewSourceAnchor

      default Point2D resolvePreviewSourceAnchor(Graphics2D g2)
      Resolves the preview source anchor from the current model and layout state.
      Parameters:
      g2 - graphics context used for drawing
      Returns:
      the resolved preview source anchor
    • resolvePreviewTargetAnchor

      default Point2D resolvePreviewTargetAnchor(SelectedElement target)
      Resolves the preview target anchor from the current model and layout state.
      Parameters:
      target - target value used by the operation
      Returns:
      the resolved preview target anchor
    • computeConceptualAnchorPoint

      default Point2D computeConceptualAnchorPoint(Rectangle2D bounds, AnchorSide side, int index, boolean big, int totalCount)
      Computes the conceptual anchor point on the active canvas.
      Parameters:
      bounds - bounds used for layout or hit testing
      side - node side to inspect
      index - zero-based index to read or update
      big - whether big is enabled
      totalCount - count value to use
      Returns:
      the compute conceptual anchor point result
    • computeConceptualSideCenter

      default Point2D computeConceptualSideCenter(Rectangle2D bounds, AnchorSide side, boolean big)
      Computes the conceptual side center on the active canvas.
      Parameters:
      bounds - bounds used for layout or hit testing
      side - node side to inspect
      big - whether big is enabled
      Returns:
      the compute conceptual side center result
    • ensureConceptualAnchorCache

      default void ensureConceptualAnchorCache()
      Ensures that the conceptual anchor cache exists or is up to date on the active canvas.
    • getConceptualSideLinkCount

      default int getConceptualSideLinkCount(String classId, AnchorSide side)
      Returns the conceptual side link count.
      Parameters:
      classId - id of the class to look up or modify
      side - node side to inspect
      Returns:
      the conceptual side link count
    • invalidateConceptualAnchorCache

      default void invalidateConceptualAnchorCache()
      Invalidates the conceptual anchor cache so it will be recalculated on the active canvas.
    • rebuildConceptualAnchorCache

      default void rebuildConceptualAnchorCache()
      Rebuilds the conceptual anchor cache on the active canvas.
    • findFieldHit

      default FieldHitResult findFieldHit(ClassModel classModel, Rectangle2D classBounds, Point2D.Double worldPoint)
      Finds the field hit that matches the supplied input.
      Parameters:
      classModel - class model affected by the operation
      classBounds - bounds used for layout or hit testing
      worldPoint - point in canvas coordinates
      Returns:
      the matching field hit, or null when no match exists
    • findTopmostHit

      default HitResult findTopmostHit(Point2D.Double worldPoint)
      Finds the topmost hit that matches the supplied input.
      Parameters:
      worldPoint - point in canvas coordinates
      Returns:
      the matching topmost hit, or null when no match exists
    • isInCommentResizeHandle

      default boolean isInCommentResizeHandle(Rectangle2D bounds, Point2D.Double worldPoint)
      Checks whether in comment resize handle is enabled or applies.
      Parameters:
      bounds - bounds used for layout or hit testing
      worldPoint - point in canvas coordinates
      Returns:
      true if in comment resize handle is enabled or applies; otherwise false
    • isPointNearGeometry

      default boolean isPointNearGeometry(Point2D.Double worldPoint, LinkGeometry geometry)
      Checks whether point near geometry is enabled or applies on the active canvas.
      Parameters:
      worldPoint - point in canvas coordinates
      geometry - resolved link geometry to draw or inspect
      Returns:
      true if point near geometry is enabled or applies; otherwise false
    • createExportImage

      default BufferedImage createExportImage(ViewExportScope scope)
      Creates an export image on the active canvas.
      Parameters:
      scope - export scope to use
      Returns:
      the created export image
    • createExportPreviewImage

      default BufferedImage createExportPreviewImage(ViewExportScope scope, int maxWidth, int maxHeight)
      Creates an export preview image on the active canvas.
      Parameters:
      scope - export scope to use
      maxWidth - width value
      maxHeight - height value
      Returns:
      the created export preview image
    • getExportSize

      default Dimension getExportSize(ViewExportScope scope)
      Returns the export size on the active canvas.
      Parameters:
      scope - export scope to use
      Returns:
      the export size
    • paintExport

      default void paintExport(Graphics2D graphics, ViewExportScope rawScope)
      Paints the export.
      Parameters:
      graphics - graphics context used for drawing
      rawScope - raw scope value used by the operation
    • editSelected

      default void editSelected()
      Opens or applies editing for the selected on the active canvas.
    • addComment

      default void addComment()
      Adds the comment.
    • addField

      default void addField()
      Adds the field.
    • addLink

      default void addLink()
      Adds the link.
    • addTable

      default void addTable()
      Adds the table on the active canvas.
    • deleteSelection

      default void deleteSelection()
      Deletes the selection.
    • moveFieldSelection

      default void moveFieldSelection(int delta)
      Moves the field selection.
      Parameters:
      delta - numeric delta value
    • moveSelectedFieldInList

      default void moveSelectedFieldInList(int delta)
      Moves the selected field in list.
      Parameters:
      delta - numeric delta value
    • addDraggedLayout

      default void addDraggedLayout(List<DraggedLayout> layouts, Set<String> seen, SelectedElement element, NodeLayout fallbackLayout)
      Adds the dragged layout.
      Parameters:
      layouts - layout objects to read or modify
      seen - seen value used by the operation
      element - element value used by the operation
      fallbackLayout - layout object to read or modify
    • buildDragRenderLayers

      default void buildDragRenderLayers(DraggedSelection selection)
      Builds a drag render layers.
      Parameters:
      selection - selection state to read or update
    • createDraggedSelection

      default DraggedSelection createDraggedSelection(SelectedElement hitSelection, NodeLayout hitLayout, Point2D.Double worldPoint, Rectangle2D hitBounds)
      Creates a dragged selection.
      Parameters:
      hitSelection - hit selection value used by the operation
      hitLayout - layout object to read or modify
      worldPoint - point in canvas coordinates
      hitBounds - bounds used for layout or hit testing
      Returns:
      the created dragged selection
    • isDragRenderingActive

      default boolean isDragRenderingActive()
      Checks whether drag rendering active is enabled or applies.
      Returns:
      true if drag rendering active is enabled or applies; otherwise false
    • resolveNodeLayoutForSelection

      default NodeLayout resolveNodeLayoutForSelection(SelectedElement element, NodeLayout fallbackLayout)
      Resolves the node layout for selection from the current model and layout state.
      Parameters:
      element - element value used by the operation
      fallbackLayout - layout object to read or modify
      Returns:
      the resolved node layout for selection
    • buildForeignKeyFieldName

      default String buildForeignKeyFieldName(ClassModel targetClass, FieldModel targetField)
      Builds a foreign key field name.
      Parameters:
      targetClass - target class value used by the operation
      targetField - target field value used by the operation
      Returns:
      the built foreign key field name
    • buildForeignKeyFieldTechnicalName

      default String buildForeignKeyFieldTechnicalName(ClassModel targetClass, FieldModel targetField)
      Builds a foreign key field technical name.
      Parameters:
      targetClass - target class value used by the operation
      targetField - target field value used by the operation
      Returns:
      the built foreign key field technical name
    • buildLinkPath

      default String buildLinkPath(LinkModel linkModel)
      Builds a link path.
      Parameters:
      linkModel - link model affected by the operation
      Returns:
      the built link path
    • buildSelectionPath

      default String buildSelectionPath()
      Builds a selection path.
      Returns:
      the built selection path
    • createMouseAdapter

      default MouseAdapter createMouseAdapter()
      Creates a mouse adapter on the active canvas.
      Returns:
      the created mouse adapter
    • handleMouseDragged

      default void handleMouseDragged(MouseEvent event)
      Handles the mouse dragged on the active canvas.
      Parameters:
      event - event object supplied by Swing
    • getSelectedDragAnchor

      default SelectedElement getSelectedDragAnchor(SelectedElement element)
      Returns the selected drag anchor on the active canvas.
      Parameters:
      element - element value used by the operation
      Returns:
      the selected drag anchor
    • handleMousePressed

      default void handleMousePressed(MouseEvent event)
      Handles the mouse pressed on the active canvas.
      Parameters:
      event - event object supplied by Swing
    • handleMouseReleased

      default void handleMouseReleased(MouseEvent event)
      Handles the mouse released on the active canvas.
      Parameters:
      event - event object supplied by Swing
    • handleMouseWheelMoved

      default void handleMouseWheelMoved(MouseWheelEvent event)
      Handles the mouse wheel moved on the active canvas.
      Parameters:
      event - event object supplied by Swing
    • focusSelection

      default void focusSelection()
    • focusAll

      default void focusAll()
    • focusBounds

      default void focusBounds(Rectangle2D bounds)
      Moves and zooms the current canvas view so the supplied world-space bounds fit inside the viewport.
      Parameters:
      bounds - bounds to focus
    • appendSuffix

      default String appendSuffix(String value, String suffix)
      Appends the suffix on the active canvas.
      Parameters:
      value - value to process
      suffix - suffix to append when needed
      Returns:
      the append suffix result
    • clamp

      default double clamp(double value, double min, double max)
      Constrains a numeric value to the supplied range.
      Parameters:
      value - value to process
      min - numeric min value
      max - numeric max value
      Returns:
      the clamp result
    • configureGraphics

      default void configureGraphics(Graphics2D g2)
      Configures the graphics on the active canvas.
      Parameters:
      g2 - graphics context used for drawing
    • createGraphicsContext

      default Graphics2D createGraphicsContext()
      Creates a graphics context on the active canvas.
      Returns:
      the created graphics context
    • ensureLayouts

      default void ensureLayouts()
      Ensures that the layouts exists or is up to date.
    • ensureTechnicalSourceField

      default FieldModel ensureTechnicalSourceField(ClassModel sourceClass, ClassModel targetClass, FieldModel targetField)
      Ensures that the technical source field exists or is up to date.
      Parameters:
      sourceClass - source class value used by the operation
      targetClass - target class value used by the operation
      targetField - target field value used by the operation
      Returns:
      the ensure technical source field result
    • findBoundTargetAnchor

      default Point2D findBoundTargetAnchor(Graphics2D g2, CommentModel commentModel)
      Finds the bound target anchor that matches the supplied input.
      Parameters:
      g2 - graphics context used for drawing
      commentModel - comment model affected by the operation
      Returns:
      the matching bound target anchor, or null when no match exists
    • getActiveLinks

      default List<LinkModel> getActiveLinks()
      Returns the active links.
      Returns:
      the active links
    • getLinkCreationSource

      default SelectedElement getLinkCreationSource()
      Returns the link creation source.
      Returns:
      the link creation source
    • getTechnicalSideLinkCount

      default int getTechnicalSideLinkCount(String classId, AnchorSide side, String ignoredLinkId)
      Returns the technical side link count.
      Parameters:
      classId - id of the class to look up or modify
      side - node side to inspect
      ignoredLinkId - id of the element to read or modify
      Returns:
      the technical side link count
    • getVisibleFields

      @Deprecated default List<FieldModel> getVisibleFields(ClassModel classModel)
      Deprecated.
      Returns the visible fields.
      Parameters:
      classModel - class model affected by the operation
      Returns:
      the visible fields
    • hasAssociationClass

      default boolean hasAssociationClass(LinkModel linkModel)
      Checks whether this object has an association class.
      Parameters:
      linkModel - link model affected by the operation
      Returns:
      true if association class exists; otherwise false
    • hasOutgoingTechnicalLink

      default boolean hasOutgoingTechnicalLink(String classId, String fieldId)
      Checks whether this object has an outgoing technical link.
      Parameters:
      classId - id of the class to look up or modify
      fieldId - id of the field to look up or modify
      Returns:
      true if outgoing technical link exists; otherwise false
    • installKeyBindings

      default void installKeyBindings()
      Installs the key bindings on the active canvas.
    • isLinkConnectedTo

      default boolean isLinkConnectedTo(LinkModel linkModel, String classId)
      Checks whether link connected to is enabled or applies.
      Parameters:
      linkModel - link model affected by the operation
      classId - id of the class to look up or modify
      Returns:
      true if link connected to is enabled or applies; otherwise false
    • isValidPreviewTarget

      default boolean isValidPreviewTarget(SelectedElement target)
      Checks whether valid preview target is enabled or applies on the active canvas.
      Parameters:
      target - target value used by the operation
      Returns:
      true if valid preview target is enabled or applies; otherwise false
    • mapId

      default String mapId(Map<String,String> idMap, String oldId)
      Maps the ID on the active canvas.
      Parameters:
      idMap - map to read or update
      oldId - id of the element to read or modify
      Returns:
      the map ID result
    • getMouseWorldPos

      default Point2D.Double getMouseWorldPos()
      Returns the mouse world pos on the active canvas.
      Returns:
      the mouse world pos
    • getMouseViewportPos

      default Point2D.Double getMouseViewportPos()
      Returns the mouse viewport pos on the active canvas.
      Returns:
      the mouse viewport pos
    • normalizeConnectionSourceSelection

      default SelectedElement normalizeConnectionSourceSelection(SelectedElement selection)
      Normalizes the connection source selection.
      Parameters:
      selection - selection state to read or update
      Returns:
      the normalize connection source selection result
    • normalizeConnectionTargetSelection

      default SelectedElement normalizeConnectionTargetSelection(SelectedElement selection)
      Normalizes the connection target selection.
      Parameters:
      selection - selection state to read or update
      Returns:
      the normalize connection target selection result
    • notifyDocumentChanged

      default void notifyDocumentChanged()
      Notifies the frame that the document content changed.
    • notifySelectionChanged

      default void notifySelectionChanged()
      Notifies listeners that the selection changed changed.
    • openEditDialogForSelection

      default void openEditDialogForSelection()
      Opens the edit dialog for selection.
    • resolveConceptualPreviewAnchor

      default Point2D resolveConceptualPreviewAnchor(String classId, Point2D reference)
      Resolves the conceptual preview anchor from the current model and layout state.
      Parameters:
      classId - id of the class to look up or modify
      reference - reference value used by the operation
      Returns:
      the resolved conceptual preview anchor
    • resolveOppositeReferencePoint

      default Point2D resolveOppositeReferencePoint(String classId, String fieldId)
      Resolves the opposite reference point from the current model and layout state.
      Parameters:
      classId - id of the class to look up or modify
      fieldId - id of the field to look up or modify
      Returns:
      the resolved opposite reference point
    • resolvePreviewSourceAnchorReference

      default Point2D resolvePreviewSourceAnchorReference()
      Resolves the preview source anchor reference from the current model and layout state.
      Returns:
      the resolved preview source anchor reference
    • resolveTechnicalEndpointSide

      default AnchorSide resolveTechnicalEndpointSide(String classId, String fieldId, String oppositeClassId, String oppositeFieldId, boolean selfLink)
      Resolves the technical endpoint side from the current model and layout state.
      Parameters:
      classId - id of the class to look up or modify
      fieldId - id of the field to look up or modify
      oppositeClassId - id of the element to read or modify
      oppositeFieldId - id of the element to read or modify
      selfLink - whether self link is enabled
      Returns:
      the resolved technical endpoint side
    • resolveTechnicalFieldAnchor

      default Point2D resolveTechnicalFieldAnchor(String classId, String fieldId, Point2D oppositeReference)
      Resolves the technical field anchor from the current model and layout state.
      Parameters:
      classId - id of the class to look up or modify
      fieldId - id of the field to look up or modify
      oppositeReference - opposite reference value used by the operation
      Returns:
      the resolved technical field anchor
    • resolveTechnicalFieldAnchor

      default FieldAnchor resolveTechnicalFieldAnchor(String classId, String fieldId, String oppositeClassId, String oppositeFieldId)
      Resolves the technical field anchor from the current model and layout state.
      Parameters:
      classId - id of the class to look up or modify
      fieldId - id of the field to look up or modify
      oppositeClassId - id of the element to read or modify
      oppositeFieldId - id of the element to read or modify
      Returns:
      the resolved technical field anchor
    • resolveTechnicalSelfLinkAnchor

      default Point2D resolveTechnicalSelfLinkAnchor(String classId, String fieldId, AnchorSide side)
      Resolves the technical self link anchor from the current model and layout state.
      Parameters:
      classId - id of the class to look up or modify
      fieldId - id of the field to look up or modify
      side - node side to inspect
      Returns:
      the resolved technical self link anchor
    • resolveTechnicalSourceEndpoint

      default SelectedElement resolveTechnicalSourceEndpoint(SelectedElement source, SelectedElement target)
      Resolves the technical source endpoint from the current model and layout state.
      Parameters:
      source - source object used by the operation
      target - target value used by the operation
      Returns:
      the resolved technical source endpoint
    • resolveTechnicalTargetEndpoint

      default SelectedElement resolveTechnicalTargetEndpoint(SelectedElement target)
      Resolves the technical target endpoint from the current model and layout state.
      Parameters:
      target - target value used by the operation
      Returns:
      the resolved technical target endpoint
    • screenToWorld

      default Point2D.Double screenToWorld(Point point)
      Converts screen coordinates into world coordinates.
      Parameters:
      point - point in canvas coordinates
      Returns:
      the screen to world result
    • setAssociationClassForLink

      default void setAssociationClassForLink(String classId, String linkId)
      Sets the association class for link.
      Parameters:
      classId - id of the class to look up or modify
      linkId - id of the link to look up or modify
    • shouldExportClass

      default boolean shouldExportClass(ClassModel classModel)
      Decides whether the canvas should export class.
      Parameters:
      classModel - class model affected by the operation
      Returns:
      true if the operation should happen; otherwise false
    • shouldExportComment

      default boolean shouldExportComment(CommentModel commentModel)
      Decides whether the canvas should export comment.
      Parameters:
      commentModel - comment model affected by the operation
      Returns:
      true if the operation should happen; otherwise false
    • shouldExportLink

      default boolean shouldExportLink(LinkModel linkModel)
      Decides whether the canvas should export link.
      Parameters:
      linkModel - link model affected by the operation
      Returns:
      true if the operation should happen; otherwise false
    • getViewportCenterWorld

      default Point2D.Double getViewportCenterWorld()
      Returns the viewport center world on the active canvas.
      Returns:
      the viewport center world
    • getViewportCenter

      default Point2D.Double getViewportCenter()
      Returns the viewport center on the active canvas.
      Returns:
      the viewport center
    • worldToViewport

      default Point2D.Double worldToViewport(Point2D world)
      Converts world coordinates into viewport coordinates.
      Parameters:
      world - world value used by the operation
      Returns:
      the world to viewport result
    • worldToviewportZoom

      default Point2D.Double worldToviewportZoom(Point2D world)
      Converts a world-space size into a zoomed viewport size.
      Parameters:
      world - world value used by the operation
      Returns:
      the world toviewport zoom result
    • worldToViewportZoom

      default Point2D.Double worldToViewportZoom(Dimension world)
      Converts a world-space size into a zoomed viewport size.
      Parameters:
      world - world value used by the operation
      Returns:
      the world to viewport zoom result
    • wrapText

      @Deprecated default List<String> wrapText(String text, Font font, int maxWidth)
      Deprecated.
      Wraps text into lines that fit within the requested width.
      Parameters:
      text - text to display or edit
      font - font used for measurement or drawing
      maxWidth - width value
      Returns:
      the matching values
    • stringWidth

      default double stringWidth(Font titleFont, String classTitle)
      Measures the width of text with the supplied font.
      Parameters:
      titleFont - font used for measurement or drawing
      classTitle - text value for class title
      Returns:
      the string width result
    • installDefaultKeyBindings

      default void installDefaultKeyBindings(DiagramCanvasActions actions)
      Installs the default key bindings on the active canvas.
      Parameters:
      actions - actions value used by the operation
    • installKeyBind

      default void installKeyBind(InputMap inputMap, ActionMap actionMap, KeyStroke keyStroke, String actionKey, Runnable action)
      Installs the key bind on the active canvas.
      Parameters:
      inputMap - Swing input map to update
      actionMap - Swing action map to update
      keyStroke - keyboard shortcut to register
      actionKey - key under which the action is registered
      action - action to register or execute