Class ClusterComponent

java.lang.Object
ffx.numerics.clustering.visualization.ClusterComponent
All Implemented Interfaces:
Paintable

public class ClusterComponent extends Object implements 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

    Constructors
    Constructor
    Description
    ClusterComponent(Cluster cluster, boolean printName, VCoord initPoint)
    Constructs a visual node component for a Cluster.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns 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
    Sets the list of child visual components.
    void
    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.

    Methods inherited from class java.lang.Object

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

    • ClusterComponent

      public ClusterComponent(Cluster cluster, boolean printName, VCoord initPoint)
      Constructs a visual node component for a Cluster.
      Parameters:
      cluster - the cluster represented by this component
      printName - whether to render the cluster name
      initPoint - the initial virtual coordinate of this node
  • Method Details

    • getChildren

      public List<ClusterComponent> 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

      public void setChildren(List<ClusterComponent> children)
      Sets the list of child visual components.
      Parameters:
      children - list of child components
    • getLinkPoint

      public VCoord getLinkPoint()
      Gets the virtual coordinate where this node connects to its parent.
      Returns:
      link point coordinate
    • setLinkPoint

      public void setLinkPoint(VCoord linkPoint)
      Sets the virtual coordinate where this node connects to its parent.
      Parameters:
      linkPoint - link point coordinate
    • getInitPoint

      public VCoord getInitPoint()
      Gets the virtual coordinate at which this node is drawn.
      Returns:
      initial coordinate for this node
    • setInitPoint

      public void setInitPoint(VCoord initPoint)
      Sets the virtual coordinate at which this node is drawn.
      Parameters:
      initPoint - initial coordinate for this node
    • getCluster

      public Cluster getCluster()
      Gets the Cluster model represented by this component.
      Returns:
      the associated Cluster
    • setCluster

      public void setCluster(Cluster cluster)
      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 interface Paintable
      Parameters:
      g - the Graphics2D to draw into
      xDisplayOffset - x-axis pixel offset applied to model coordinates
      yDisplayOffset - y-axis pixel offset applied to model coordinates
      xDisplayFactor - scale factor to convert model X to pixels
      yDisplayFactor - scale factor to convert model Y to pixels
      decorated - 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

      public int getNameWidth(Graphics2D g, boolean includeNonLeafs)
      Computes the width in pixels of this node's name label.
      Parameters:
      g - graphics context used for font metrics
      includeNonLeafs - if true, include internal nodes; otherwise only leaf names
      Returns:
      width in pixels of the label (0 if not drawn)
    • getMaxNameWidth

      public int getMaxNameWidth(Graphics2D g, boolean includeNonLeafs)
      Recursively computes the maximal name width across this node and its children.
      Parameters:
      g - graphics context used for font metrics
      includeNonLeafs - if true, include internal nodes; otherwise only leaf names
      Returns:
      maximum label width in pixels across the subtree