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
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected doubleCalculates the angle between the current start and end points.protected doublecalculateAngle(double p1X, double p1Y, double p2X, double p2Y) Calculates the angle of the line between two points.protected doublecalculateAngle(javafx.geometry.Point2D p1, javafx.geometry.Point2D p2) Calculates the angle of the line between two points.protected doublecalculateAngle(javafx.scene.shape.LineTo lineTo1, javafx.scene.shape.LineTo lineTo2) Calculates the angle of the line between two path segments.protected voidcalculateEndPoints(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.NodeCreates 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 doublegetTangentAngle(javafx.scene.shape.CubicCurve curve, double t) Calculates the tangent angle of the given cubic curve.protected doublegetTangentAngle(javafx.scene.shape.CubicCurveTo curveTo, double t) Calculates the tangent angle of the given cubic curve segment.protected doublegetTangentAngle(javafx.scene.shape.QuadCurve curve, double t) Calculates the tangent angle of the given quadratic curve.
-
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 directionparentPoint- the parent node locationparentW- the parent node widthparentH- the parent node heightchildPoint- the child node locationchildW- the child node widthchildH- the child node heightnodeLineGap- 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:
drawNodeLinkin interfaceLinkStrategy<T>- Parameters:
direction- the layout directionmaxDimensionInLine- the maximum node dimension in the active lineparent- the parent nodeparentPoint- the parent node locationparentW- the parent node widthparentH- the parent node heightchild- the child nodechildPoint- the child node locationchildW- the child node widthchildH- the child node heightnodeLineGap- the gap between a node and its linkvgap- the vertical gap between levelshgap- 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 directionmaxDimensionInLine- the maximum node dimension in the active linestartX- the x-coordinate of the link startstartY- the y-coordinate of the link startendX- the x-coordinate of the link endendY- the y-coordinate of the link endvgap- the vertical gap between levelshgap- 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 pointp1Y- the y-coordinate of the first pointp2X- the x-coordinate of the second pointp2Y- 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 pointp2- 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 elementlineTo2- 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 curvet- 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 segmentt- 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 curvet- the relative position on the curve- Returns:
- the tangent angle in degrees
-