Class ChartTools

java.lang.Object
qupath.lib.gui.charts.ChartTools

public class ChartTools extends Object
Collection of static methods to help when working with JavaFX charts, and adapting these for QuPath's purposes.
Author:
Pete Bankhead
  • Constructor Details

    • ChartTools

      public ChartTools()
  • Method Details

    • getChartDataAsString

      public 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.
      Parameters:
      chart -
      Returns:
    • makeChartInteractive

      public 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. Also double-click to stop zooming.
      Parameters:
      chart -
      xAxis -
      yAxis -
    • addChartExportMenu

      public static void addChartExportMenu(XYChart<Number,Number> chart, ContextMenu menu)
      Add a menu item to a context menu for displaying a chart for export.
      Parameters:
      chart -
      menu -
    • setLineChartLegendLines

      public static void setLineChartLegendLines(Chart chart, double length)
      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

      public static void expandChartClip(Chart chart, double pad)
      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 update
      counts - mapping between items and their counts
      stringFun - function to extract a string from each item (may be null to use default toString() 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 values
      includeTooltips - if true, install tooltips for each 'slice' to display the numeric information