Class AbstractLabelConnectionFigure

All Implemented Interfaces:
ConnectableFigure, ConnectingFigure, Figure, FillableFigure, LabelConnectionFigure, PaddableFigure, PathIterableFigure, ShapeableFigure, StrokableFigure, TextFillableFigure, TextFontableFigure, TextLayoutableFigure, TransformableFigure, TransformCachingFigure, PropertyBean, StyleableBean, StyleablePropertyBean, TreeNode<Figure>
Direct Known Subclasses:
SimpleLabelConnectionFigure

public abstract class AbstractLabelConnectionFigure extends AbstractLabelFigure implements ConnectingFigure, TransformableFigure, LabelConnectionFigure
A label that can be attached to another figure by setting LabelConnectionFigure.LABEL_CONNECTOR and LabelConnectionFigure.LABEL_TARGET.

When the label is attached it computes the LABELED_LOCATION using the LabelConnectionFigure.LABEL_CONNECTOR on the target figure. Then it computes the AbstractLabelFigure.ORIGIN and rotation of the label using the properties LABEL_OFFSET and LABEL_AUTOROTATE.

 LABELED_LOCATION:    x,y (has a derivative that can be rotated)
                       |
                       | + LABEL_OFFSET (perpendicular to
                       |                 LABELED_LOCATION)
                       ↓
                   +--------------------+
 ORIGIN:           |  x,y               |
 LABEL_AUTOROTATE: |   ↺                |
                   |                    |
                   |    layout bounds   |
                   +--------------------+

 
Author:
Werner Randelshofer
  • Property Details

    • connected

      public javafx.beans.property.ReadOnlyBooleanProperty connectedProperty
      This property is true when the figure is connected.
      See Also:
  • Field Details

  • Constructor Details

    • AbstractLabelConnectionFigure

      public AbstractLabelConnectionFigure()
  • Method Details

    • onPropertyChanged

      protected <T> void onPropertyChanged(Key<T> key, @Nullable T oldValue, @Nullable T newValue, boolean wasAdded, boolean wasRemoved)
      Description copied from class: AbstractFigure
      Overrides of this method must call super!
      Overrides:
      onPropertyChanged in class AbstractFigure
      Type Parameters:
      T - the value type of the property
      Parameters:
      key - the changed key
      oldValue - the old value
      newValue - the new value
      wasAdded - whether the value was added (hence oldValue does not matter)
      wasRemoved - whether the value was removed (hence newValue does not matter)
    • doAddedToDrawing

      public void doAddedToDrawing(Drawing drawing)
      Description copied from class: AbstractFigure
      This method is called by Figure.addedToDrawing(org.jhotdraw8.draw.figure.Drawing). The implementation of this class is empty.
      Overrides:
      doAddedToDrawing in class AbstractFigure
      Parameters:
      drawing - the drawing
    • doRemovedFromDrawing

      protected void doRemovedFromDrawing(Drawing drawing)
      Description copied from class: AbstractFigure
      This method is called by AbstractFigure.removedFromDrawing(org.jhotdraw8.draw.figure.Drawing). The implementation of this class is empty.
      Overrides:
      doRemovedFromDrawing in class AbstractFigure
      Parameters:
      drawing - the drawing
    • connectedProperty

      public javafx.beans.property.ReadOnlyBooleanProperty connectedProperty()
      This property is true when the figure is connected.
      Returns:
      the connected property
      See Also:
    • createHandles

      public void createHandles(HandleType handleType, List<Handle> list)
      Description copied from interface: Figure
      Creates handles of the specified level and adds them to the provided list.
      Specified by:
      createHandles in interface Figure
      Parameters:
      handleType - The desired handle type
      list - The handles.
    • getLayoutSubjects

      public ReadOnlySet<Figure> getLayoutSubjects()
      Returns all figures which are connected by this figure - they provide to the layout of this figure.
      Specified by:
      getLayoutSubjects in interface Figure
      Returns:
      a list of connected figures
    • isConnected

      public boolean isConnected()
      Gets the value of the connected property.
      Property description:
      This property is true when the figure is connected.
      Returns:
      the value of the connected property
      See Also:
    • isGroupReshapeableWith

      public boolean isGroupReshapeableWith(Set<Figure> others)
      Description copied from interface: Figure
      Whether the figure can be reshaped as a group together with other figures.

      If this figure uses one of the other figures for computing its position or its layout, then it will return false.

      The default implementation always returns true.

      Specified by:
      isGroupReshapeableWith in interface Figure
      Parameters:
      others - A set of figures.
      Returns:
      true if the user may svgStringReshapeToBuilder this figure together with those in the set.
    • isLayoutable

      public boolean isLayoutable()
      Description copied from interface: Figure
      Whether the layout method of this figure does anything.

      The default implementation returns false.

      Specified by:
      isLayoutable in interface Figure
      Returns:
      true if the layout method is not empty.
    • layout

      public void layout(RenderContext ctx)
      Description copied from class: AbstractLabelFigure
      Computes the layout bounds of this figure.
      Specified by:
      layout in interface Figure
      Overrides:
      layout in class AbstractLabelFigure
      Parameters:
      ctx - the render context
    • layoutOrigin

      protected void layoutOrigin(RenderContext ctx)
      Parameters:
      ctx -
    • removeAllLayoutSubjects

      public void removeAllLayoutSubjects()
      Description copied from class: AbstractFigure
      This implementation is empty.
      Specified by:
      removeAllLayoutSubjects in interface Figure
      Overrides:
      removeAllLayoutSubjects in class AbstractFigure
    • removeLayoutSubject

      public void removeLayoutSubject(Figure subject)
      Description copied from class: AbstractFigure
      This implementation is empty.
      Specified by:
      removeLayoutSubject in interface Figure
      Overrides:
      removeLayoutSubject in class AbstractFigure
      Parameters:
      subject - the connected figure
    • updateGroupNode

      public void updateGroupNode(RenderContext ctx, javafx.scene.Group node)
      Description copied from class: AbstractLabelFigure
      Updates the group node that holds all other nodes of the label.

      This method is empty. Subclasses may apply properties to the group node.

      Overrides:
      updateGroupNode in class AbstractLabelFigure
      Parameters:
      ctx - the render context
      node - the group node
    • reshapeInLocal

      public void reshapeInLocal(CssSize x, CssSize y, CssSize width, CssSize height)
      Description copied from interface: Figure
      Attempts to change the local bounds of the figure.

      See {#link #reshapeInLocal(Transform)} for a description of this method.

      This method takes parameters as CssSizes. This can be used to avoid rounding errors when the figure is reshaped in non-pixel units.

      This method can forward a call to Figure.reshapeInLocal(Transform) using the following code:

      
       void reshapeInLocal(CssSize x, CssSize y, CssSize width, CssSize height) {
         Transform tx = Transforms.createReshapeTransform(getCssBoundsInLocal(), x, y, width, height);
         reshapeInLocal(tx);
       }
       
      Specified by:
      reshapeInLocal in interface Figure
      Overrides:
      reshapeInLocal in class AbstractLabelFigure
      Parameters:
      x - desired x-position in parent coordinates
      y - desired y-position in parent coordinates
      width - desired width in parent coordinates, may be negative
      height - desired height in parent coordinates, may be negative
    • translateInLocal

      public void translateInLocal(CssPoint2D delta)
      Description copied from interface: Figure
      Attempts to translate the local bounds of the figure.
      Specified by:
      translateInLocal in interface Figure
      Overrides:
      translateInLocal in class AbstractLabelFigure
      Parameters:
      delta - the translation in x and in y direction
    • setLabelConnection

      public void setLabelConnection(@Nullable Figure target, @Nullable Connector connector)