Class HistoDrawingUtils
This class holds the two static methods that were previously embedded in
HistoData but depend on the plot package — creating a
downward dependency from the data model into the view layer. Moving them here
removes that dependency from HistoData itself while keeping the
functionality in a single, discoverable place.
Usage
// Build the screen polygon for hit-testing or filled drawing
Polygon poly = HistoDrawingUtils.buildScreenPolygon(canvas, histoData);
// Get the mouse-position status string
String status = HistoDrawingUtils.statusString(canvas, histoData, mousePoint, worldPoint);
- Author:
- heddle (original), refactored for extraction
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic PolygonbuildScreenPolygon(PlotCanvas canvas, HistoData histo) Builds the screen-spacePolygonthat outlines the histogram bars.static StringstatusString(PlotCanvas canvas, HistoData histo, Point mousePoint, Point2D.Double wp) Builds the status string shown in the feedback pane when the mouse is over a histogram.
-
Method Details
-
buildScreenPolygon
Builds the screen-spacePolygonthat outlines the histogram bars.The polygon traces the top of every bar and the baseline, so it is suitable for both hit-testing (
Polygon.contains(java.awt.Point)) and filled rendering. Bins whose corners cannot be projected onto the screen (e.g. because transforms are not yet initialised) are silently skipped.- Parameters:
canvas- the plot canvas that owns the coordinate transforms (non-null)histo- the histogram data to outline (non-null)- Returns:
- a
Polygonin screen (component) coordinates; may be empty if the canvas has no valid transforms
-
statusString
public static String statusString(PlotCanvas canvas, HistoData histo, Point mousePoint, Point2D.Double wp) Builds the status string shown in the feedback pane when the mouse is over a histogram.Returns the bin range and count under the cursor, formatted using the canvas's current decimal and exponent settings. Returns an empty string when the mouse is outside the histogram polygon.
- Parameters:
canvas- the plot canvas (provides coordinate transforms and formatting parameters) (non-null)histo- the histogram data being queried (non-null)mousePoint- current mouse position in screen (component) coordinates (non-null)wp- current mouse position in data coordinates (non-null)- Returns:
- a formatted status string, or
""if the cursor is outside the histogram
-