Class ClusterComponent
java.lang.Object
ffx.numerics.clustering.visualization.ClusterComponent
- All Implemented Interfaces:
Paintable
Visual component representing a single cluster node within a dendrogram.
Responsible for rendering the node, its label, and the connector lines to
its parent/children based on virtual coordinates.
Used by DendrogramPanel to draw hierarchical clustering results.
- Since:
- 1.0
- Author:
- Lars Behnke, 2013, Michael J. Schnieders
-
Constructor Summary
ConstructorsConstructorDescriptionClusterComponent
(Cluster cluster, boolean printName, VCoord initPoint) Constructs a visual node component for a Cluster. -
Method Summary
Modifier and TypeMethodDescriptionReturns the child visual components corresponding to child clusters.Gets the Cluster model represented by this component.int
Gets the radius of node dots in pixels.Gets the virtual coordinate at which this node is drawn.Gets the virtual coordinate where this node connects to its parent.int
getMaxNameWidth
(Graphics2D g, boolean includeNonLeafs) Recursively computes the maximal name width across this node and its children.int
Gets the pixel padding between a leaf node and its name text.int
getNameWidth
(Graphics2D g, boolean includeNonLeafs) Computes the width in pixels of this node's name label.double
Computes the maximal X value of this component and its children in model space.double
Computes the maximal Y value of this component and its children in model space.double
Computes the minimal X value of this component and its children in model space.double
Computes the minimal Y value of this component and its children in model space.boolean
Returns whether the node name should be drawn.void
paint
(Graphics2D g, int xDisplayOffset, int yDisplayOffset, double xDisplayFactor, double yDisplayFactor, boolean decorated) Paints this visual component onto the provided Graphics2D context.void
setChildren
(List<ClusterComponent> children) Sets the list of child visual components.void
setCluster
(Cluster cluster) Sets the Cluster model represented by this component.void
setDotRadius
(int dotRadius) Sets the radius of node dots in pixels.void
setInitPoint
(VCoord initPoint) Sets the virtual coordinate at which this node is drawn.void
setLinkPoint
(VCoord linkPoint) Sets the virtual coordinate where this node connects to its parent.void
setNamePadding
(int namePadding) Sets the pixel padding between a leaf node and its name text.void
setPrintName
(boolean printName) Sets whether the node name should be drawn.
-
Constructor Details
-
ClusterComponent
Constructs a visual node component for a Cluster.- Parameters:
cluster
- the cluster represented by this componentprintName
- whether to render the cluster nameinitPoint
- the initial virtual coordinate of this node
-
-
Method Details
-
getChildren
Returns the child visual components corresponding to child clusters.- Returns:
- list of child ClusterComponents (lazy-initialized)
-
getNamePadding
public int getNamePadding()Gets the pixel padding between a leaf node and its name text.- Returns:
- name padding in pixels
-
setNamePadding
public void setNamePadding(int namePadding) Sets the pixel padding between a leaf node and its name text.- Parameters:
namePadding
- name padding in pixels
-
getDotRadius
public int getDotRadius()Gets the radius of node dots in pixels.- Returns:
- dot radius in pixels
-
setDotRadius
public void setDotRadius(int dotRadius) Sets the radius of node dots in pixels.- Parameters:
dotRadius
- dot radius in pixels
-
setChildren
Sets the list of child visual components.- Parameters:
children
- list of child components
-
getLinkPoint
Gets the virtual coordinate where this node connects to its parent.- Returns:
- link point coordinate
-
setLinkPoint
Sets the virtual coordinate where this node connects to its parent.- Parameters:
linkPoint
- link point coordinate
-
getInitPoint
Gets the virtual coordinate at which this node is drawn.- Returns:
- initial coordinate for this node
-
setInitPoint
Sets the virtual coordinate at which this node is drawn.- Parameters:
initPoint
- initial coordinate for this node
-
getCluster
Gets the Cluster model represented by this component.- Returns:
- the associated Cluster
-
setCluster
Sets the Cluster model represented by this component.- Parameters:
cluster
- the Cluster to associate with this component
-
isPrintName
public boolean isPrintName()Returns whether the node name should be drawn.- Returns:
- true if the name should be drawn
-
setPrintName
public void setPrintName(boolean printName) Sets whether the node name should be drawn.- Parameters:
printName
- true to draw the node name
-
paint
public void paint(Graphics2D g, int xDisplayOffset, int yDisplayOffset, double xDisplayFactor, double yDisplayFactor, boolean decorated) Paints this visual component onto the provided Graphics2D context. Draws the node dot, horizontal and vertical connectors, and optionally labels.- Specified by:
paint
in interfacePaintable
- Parameters:
g
- the Graphics2D to draw intoxDisplayOffset
- x-axis pixel offset applied to model coordinatesyDisplayOffset
- y-axis pixel offset applied to model coordinatesxDisplayFactor
- scale factor to convert model X to pixelsyDisplayFactor
- scale factor to convert model Y to pixelsdecorated
- if true, draw additional decorations (e.g., distance labels)
-
getRectMinX
public double getRectMinX()Computes the minimal X value of this component and its children in model space.- Returns:
- minimal X coordinate across subtree
-
getRectMinY
public double getRectMinY()Computes the minimal Y value of this component and its children in model space.- Returns:
- minimal Y coordinate across subtree
-
getRectMaxX
public double getRectMaxX()Computes the maximal X value of this component and its children in model space.- Returns:
- maximal X coordinate across subtree
-
getRectMaxY
public double getRectMaxY()Computes the maximal Y value of this component and its children in model space.- Returns:
- maximal Y coordinate across subtree
-
getNameWidth
Computes the width in pixels of this node's name label.- Parameters:
g
- graphics context used for font metricsincludeNonLeafs
- if true, include internal nodes; otherwise only leaf names- Returns:
- width in pixels of the label (0 if not drawn)
-
getMaxNameWidth
Recursively computes the maximal name width across this node and its children.- Parameters:
g
- graphics context used for font metricsincludeNonLeafs
- if true, include internal nodes; otherwise only leaf names- Returns:
- maximum label width in pixels across the subtree
-