Package qupath.lib.gui.charts
Class ChartTools
java.lang.Object
qupath.lib.gui.charts.ChartTools
Collection of static methods to help when working with JavaFX charts,
and adapting these for QuPath's purposes.
- Author:
- Pete Bankhead
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addChartExportMenu
(XYChart<Number, Number> chart, ContextMenu menu) Add a menu item to a context menu for displaying a chart for export.static void
expandChartClip
(Chart chart, double pad) Expand the clip region for a chart.static String
getChartDataAsString
(XYChart<Number, Number> chart) Get a string representation of chart data, in such a way that it could be pasted into a spreadsheet.static void
makeChartInteractive
(Chart chart, NumberAxis xAxis, NumberAxis yAxis) Make it possible to select chart regions to zoom in, and scroll to navigate around it.static void
setLineChartLegendLines
(Chart chart, double length) Charts tend to show their legends with circular/square markers...static <T> void
setPieChartData
(PieChart chart, Map<T, ? extends Number> counts, Function<T, String> stringFun, Function<T, Color> colorFun, boolean convertToPercentages, boolean includeTooltips) Set pie chart data from a count map.
-
Constructor Details
-
ChartTools
public ChartTools()
-
-
Method Details
-
getChartDataAsString
Get a string representation of chart data, in such a way that it could be pasted into a spreadsheet.- Parameters:
chart
-- Returns:
-
makeChartInteractive
Make it possible to select chart regions to zoom in, and scroll to navigate around it. Also double-click to stop zooming.- Parameters:
chart
-xAxis
-yAxis
-
-
addChartExportMenu
Add a menu item to a context menu for displaying a chart for export.- Parameters:
chart
-menu
-
-
setLineChartLegendLines
Charts tend to show their legends with circular/square markers... which isn't much use when line strokes distinguish between different Series. This method addresses this by setting the graphics for legend labels to be lines with the appropriate strokes.- Parameters:
chart
-length
-
-
expandChartClip
Expand the clip region for a chart. This helps to avoid clipping off markers at the chart boundaries.- Parameters:
chart
-pad
- The amount by which to expand the clip rectangle in each direction; if < 0, the clip will be completely removed
-
setPieChartData
public static <T> void setPieChartData(PieChart chart, Map<T, ? extends Number> counts, Function<T, String> stringFun, Function<T, Color> colorFun, boolean convertToPercentages, boolean includeTooltips) Set pie chart data from a count map.- Type Parameters:
T
- the type of the data being counted- Parameters:
chart
- the pie chart to updatecounts
- mapping between items and their countsstringFun
- function to extract a string from each item (may be null to use defaulttoString()
method)colorFun
- function to extract a color from each item (may be null to use default colors)convertToPercentages
- if true, convert counts to percentages; if false, use original valuesincludeTooltips
- if true, install tooltips for each 'slice' to display the numeric information
-