Class AbstractLinkStrategy<T>

java.lang.Object
com.dlsc.gemsfx.treeview.link.AbstractLinkStrategy<T>
Type Parameters:
T - the type of the data value stored in each tree node
All Implemented Interfaces:
LinkStrategy<T>
Direct Known Subclasses:
ClockHandLinkStrategy, CurvedLineLink, LogarithmicLink, PolyLineLink, QuadCurveLink, SimpleCatmullRomLink, SineWaveDecayLink, StraightLineLink

public abstract class AbstractLinkStrategy<T> extends Object implements LinkStrategy<T>
Abstract base class for LinkStrategy implementations.

This class calculates the connection start and end points from the parent and child node positions and the active TreeNodeView.LayoutDirection, storing them in the protected fields startX, startY, endX, and endY. Subclasses implement drawLink(TreeNodeView.LayoutDirection, double, double, double, double, double, double, double) to produce the actual shape(s) using those pre-computed coordinates.

The class also provides helper methods for computing angles along Bézier curves and straight lines, which are used by subclasses to correctly orient arrow decorations.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected double
     
    protected double
     
    protected double
     
    protected double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected double
    Calculates the angle between the current start and end points.
    protected double
    calculateAngle(double p1X, double p1Y, double p2X, double p2Y)
    Calculates the angle of the line between two points.
    protected double
    calculateAngle(javafx.geometry.Point2D p1, javafx.geometry.Point2D p2)
    Calculates the angle of the line between two points.
    protected double
    calculateAngle(javafx.scene.shape.LineTo lineTo1, javafx.scene.shape.LineTo lineTo2)
    Calculates the angle of the line between two path segments.
    protected void
    calculateEndPoints(TreeNodeView.LayoutDirection direction, javafx.geometry.Point2D parentPoint, double parentW, double parentH, javafx.geometry.Point2D childPoint, double childW, double childH, double nodeLineGap)
    Calculates the link endpoints for the given parent and child nodes.
    protected javafx.scene.Node
    Creates a simple arrow node positioned at the link end point.
    protected abstract ArrayList<javafx.scene.Node>
    drawLink(TreeNodeView.LayoutDirection direction, double maxDimensionInLine, double startX, double startY, double endX, double endY, double vgap, double hgap)
    Draws the link for the given start and end coordinates.
    ArrayList<javafx.scene.Node>
    drawNodeLink(TreeNodeView.LayoutDirection direction, double maxDimensionInLine, TreeNode<T> parent, javafx.geometry.Point2D parentPoint, double parentW, double parentH, TreeNode<T> child, javafx.geometry.Point2D childPoint, double childW, double childH, double nodeLineGap, double vgap, double hgap)
    Draws the link between the given parent and child nodes.
    protected double
    getTangentAngle(javafx.scene.shape.CubicCurve curve, double t)
    Calculates the tangent angle of the given cubic curve.
    protected double
    getTangentAngle(javafx.scene.shape.CubicCurveTo curveTo, double t)
    Calculates the tangent angle of the given cubic curve segment.
    protected double
    getTangentAngle(javafx.scene.shape.QuadCurve curve, double t)
    Calculates the tangent angle of the given quadratic curve.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • startX

      protected double startX
    • startY

      protected double startY
    • endX

      protected double endX
    • endY

      protected double endY
  • Constructor Details

    • AbstractLinkStrategy

      public AbstractLinkStrategy()
  • Method Details

    • calculateEndPoints

      protected void calculateEndPoints(TreeNodeView.LayoutDirection direction, javafx.geometry.Point2D parentPoint, double parentW, double parentH, javafx.geometry.Point2D childPoint, double childW, double childH, double nodeLineGap)
      Calculates the link endpoints for the given parent and child nodes.
      Parameters:
      direction - the layout direction
      parentPoint - the parent node location
      parentW - the parent node width
      parentH - the parent node height
      childPoint - the child node location
      childW - the child node width
      childH - the child node height
      nodeLineGap - the gap between a node and its link
    • drawNodeLink

      public ArrayList<javafx.scene.Node> drawNodeLink(TreeNodeView.LayoutDirection direction, double maxDimensionInLine, TreeNode<T> parent, javafx.geometry.Point2D parentPoint, double parentW, double parentH, TreeNode<T> child, javafx.geometry.Point2D childPoint, double childW, double childH, double nodeLineGap, double vgap, double hgap)
      Draws the link between the given parent and child nodes.
      Specified by:
      drawNodeLink in interface LinkStrategy<T>
      Parameters:
      direction - the layout direction
      maxDimensionInLine - the maximum node dimension in the active line
      parent - the parent node
      parentPoint - the parent node location
      parentW - the parent node width
      parentH - the parent node height
      child - the child node
      childPoint - the child node location
      childW - the child node width
      childH - the child node height
      nodeLineGap - the gap between a node and its link
      vgap - the vertical gap between levels
      hgap - the horizontal gap between levels
      Returns:
      the nodes used to render the link
    • drawLink

      protected abstract ArrayList<javafx.scene.Node> drawLink(TreeNodeView.LayoutDirection direction, double maxDimensionInLine, double startX, double startY, double endX, double endY, double vgap, double hgap)
      Draws the link for the given start and end coordinates.
      Parameters:
      direction - the layout direction
      maxDimensionInLine - the maximum node dimension in the active line
      startX - the x-coordinate of the link start
      startY - the y-coordinate of the link start
      endX - the x-coordinate of the link end
      endY - the y-coordinate of the link end
      vgap - the vertical gap between levels
      hgap - the horizontal gap between levels
      Returns:
      the nodes used to render the link
    • createSimpleArrow

      protected javafx.scene.Node createSimpleArrow()
      Creates a simple arrow node positioned at the link end point.
      Returns:
      the arrow node
    • calculateAngle

      protected double calculateAngle()
      Calculates the angle between the current start and end points.
      Returns:
      the angle in degrees
    • calculateAngle

      protected double calculateAngle(double p1X, double p1Y, double p2X, double p2Y)
      Calculates the angle of the line between two points.
      Parameters:
      p1X - the x-coordinate of the first point
      p1Y - the y-coordinate of the first point
      p2X - the x-coordinate of the second point
      p2Y - the y-coordinate of the second point
      Returns:
      the angle in degrees
    • calculateAngle

      protected double calculateAngle(javafx.geometry.Point2D p1, javafx.geometry.Point2D p2)
      Calculates the angle of the line between two points.
      Parameters:
      p1 - the first point
      p2 - the second point
      Returns:
      the angle in degrees
    • calculateAngle

      protected double calculateAngle(javafx.scene.shape.LineTo lineTo1, javafx.scene.shape.LineTo lineTo2)
      Calculates the angle of the line between two path segments.
      Parameters:
      lineTo1 - the first path element
      lineTo2 - the second path element
      Returns:
      the angle in degrees
    • getTangentAngle

      protected double getTangentAngle(javafx.scene.shape.CubicCurve curve, double t)
      Calculates the tangent angle of the given cubic curve.
      Parameters:
      curve - the curve
      t - the relative position on the curve
      Returns:
      the tangent angle in degrees
    • getTangentAngle

      protected double getTangentAngle(javafx.scene.shape.CubicCurveTo curveTo, double t)
      Calculates the tangent angle of the given cubic curve segment.
      Parameters:
      curveTo - the curve segment
      t - the relative position on the curve
      Returns:
      the tangent angle in degrees
    • getTangentAngle

      protected double getTangentAngle(javafx.scene.shape.QuadCurve curve, double t)
      Calculates the tangent angle of the given quadratic curve.
      Parameters:
      curve - the curve
      t - the relative position on the curve
      Returns:
      the tangent angle in degrees