Class Charts.BarChartBuilder

java.lang.Object
qupath.lib.gui.charts.Charts.BarChartBuilder
Enclosing class:
Charts

public static class Charts.BarChartBuilder extends Object
Builder for creating scatter charts.
  • Field Details

    • xLabel

      protected String xLabel
    • yLabel

      protected String yLabel
    • viewer

      protected QuPathViewer viewer
    • imageData

      protected ImageData<?> imageData
    • title

      protected String title
    • legendVisible

      protected boolean legendVisible
    • legendSide

      protected Side legendSide
    • markerOpacity

      protected double markerOpacity
    • width

      protected double width
    • height

      protected double height
  • Method Details

    • getDefaultWindowTitle

      protected String getDefaultWindowTitle()
      Get a window title to use for charts of this kind, assuming the user has not specified one.
      Returns:
      a suitable title to use
    • series

      public <T> Charts.BarChartBuilder series(String name, Collection<? extends T> collection, Function<T,PathClass> xFun)
      Plot values extracted from objects within a specified collection.
      Type Parameters:
      T -
      Parameters:
      name -
      collection - the objects to plot
      xFun - function capable of extracting a numeric value for the x location from each object in the collection
      Returns:
      this builder
    • series

      public <T extends Number> Charts.BarChartBuilder series(String name, Collection<? extends String> x, Collection<T> y)
      Create a bar chart using collections of numeric values.
      Parameters:
      name -
      x -
      y -
      Returns:
      this builder
    • series

      public <T extends Number> Charts.BarChartBuilder series(String name, Map<String,T> data)
      Create a bar chart using a map of String values and associated numeric values.
      Parameters:
      name -
      data - a map of String values to associated numeric values
      Returns:
      this builder
    • series

      public Charts.BarChartBuilder series(String name, String[] x, double[] y)
      Create a bar chart using arrays of String values and associated numeric values.
      Parameters:
      name -
      x - x-values
      y - y-values
      Returns:
      this builder
    • series

      public <T> Charts.BarChartBuilder series(String name, String[] x, double[] y, T[] extra)
      Create a bar chart using collections String values and associated numeric values, with an associated custom object.
      Type Parameters:
      T -
      Parameters:
      name -
      x - x-values
      y - y-values
      extra - array of values to associate with each data point; should be the same length as x and y
      Returns:
      this builder
    • series

      public <T> Charts.BarChartBuilder series(String name, String[] x, double[] y, List<T> extra)
      Create a bar chart using collections of String values and associated numeric values, with an associated custom object.
      Type Parameters:
      T -
      Parameters:
      name -
      x - x-values
      y - y-values
      extra - list of values to associate with each data point; should be the same length as x and y
      Returns:
      this builder
    • series

      Create a bar chart from existing data plots.
      Parameters:
      name -
      data - the data points to plot
      Returns:
      this builder
    • updateChart

      protected void updateChart(BarChart<String,Number> chart)
      Method that applies properties of this builder to the chart. Each subclass should call the method in the parent class to ensure its properties have been applied.
      Parameters:
      chart -
    • classifications

      public Charts.BarChartBuilder classifications(Collection<? extends PathObject> pathObjects)
      Plot two measurements against one another for the specified objects.
      Parameters:
      pathObjects - the objects to plot
      Returns:
      this builder
    • createNewChart

      protected BarChart<String,Number> createNewChart(Axis<String> xAxis, Axis<Number> yAxis)
    • getThis

      protected Charts.BarChartBuilder getThis()
    • yAxisMin

      public Charts.BarChartBuilder yAxisMin(double lowerBound)
      Set the lower bound for the y-axis.
      Parameters:
      lowerBound -
      Returns:
      this builder
    • yAxisMax

      public Charts.BarChartBuilder yAxisMax(double upperBound)
      Set the upper bound for the y-axis.
      Parameters:
      upperBound -
      Returns:
      this builder
    • yAxisRange

      public Charts.BarChartBuilder yAxisRange(double lowerBound, double upperBound)
      Set the lower and upper bounds for the y-axis.
      Parameters:
      lowerBound -
      upperBound -
      Returns:
      this builder
    • createNewChart

      protected BarChart<String,Number> createNewChart()
    • xLabel

      public Charts.BarChartBuilder xLabel(String label)
      Specify the x-axis label.
      Parameters:
      label - the label to display
      Returns:
      this builder
    • yLabel

      public Charts.BarChartBuilder yLabel(String label)
      Specify the y-axis label.
      Parameters:
      label - the label to display
      Returns:
      this builder
    • title

      public Charts.BarChartBuilder title(String title)
      Specify the chart title.
      Parameters:
      title - the title to display
      Returns:
      this builder
    • legend

      public Charts.BarChartBuilder legend(boolean show)
      Specify whether the legend should be shown or not.
      Parameters:
      show - if true, show the legend; otherwise hide the legend
      Returns:
      this builder
    • legend

      public Charts.BarChartBuilder legend(String side)
      Specify the side of the chart where the legend should be shown. Valid values are "top", "bottom", "left", "right".

      Any other value (including null) will result in the legend being hidden.

      Parameters:
      side - the side where the legend should be shown
      Returns:
      this builder
    • legend

      public Charts.BarChartBuilder legend(Side side)
      Specify the side of the chart where the legend should be shown. If null, the legend will be hidden.
      Parameters:
      side - the side where the legend should be shown
      Returns:
      this builder
    • markerOpacity

      public Charts.BarChartBuilder markerOpacity(double opacity)
      Specify the marker opacity.
      Parameters:
      opacity - value between 0 (transparent) and 1 (opaque).
      Returns:
      this builder
    • imageData

      public Charts.BarChartBuilder imageData(ImageData<?> imageData)
      Specify an ImageData object. This can be used to make some charts 'live', e.g. if they relate to objects within the hierarchy of this data.
      Parameters:
      imageData - the imageData to associated with this chart
      Returns:
      this builder
    • viewer

      public Charts.BarChartBuilder viewer(QuPathViewer viewer)
      Specify a viewer. This can be used to make some charts 'live', e.g. if they relate to objects within the viewer.
      Parameters:
      viewer - the viewer to associated with this chart
      Returns:
      this builder
    • width

      public Charts.BarChartBuilder width(double width)
      Set the preferred width of the chart.
      Parameters:
      width - preferred width
      Returns:
      this builder
    • height

      public Charts.BarChartBuilder height(double height)
      Set the preferred height of the chart.
      Parameters:
      height - preferred height
      Returns:
      this builder
    • size

      public Charts.BarChartBuilder size(double width, double height)
      Set the preferred size of the chart.
      Parameters:
      width - preferred width
      height - preferred height
      Returns:
      this builder
    • parent

      public Charts.BarChartBuilder parent(Window parent)
      Set the parent window. If not set, QuPath will try to choose a sensible default. This is useful to avoid the chart falling 'behind' other windows when not in focus.

      This is relevant only if show() or toStage() will be called.

      Parameters:
      parent - the requested parent window
      Returns:
      this builder
    • windowTitle

      public Charts.BarChartBuilder windowTitle(String title)
      Title to use for the window, if the chart is shown.

      This is relevant only if show() or toStage() will be called.

      Parameters:
      title - window title
      Returns:
      this builder
    • build

      public BarChart<String,Number> build()
      Build a chart according to the specified parameters.
      Returns:
      the chart
    • toStage

      public Stage toStage()
      Add the chart to a stage, but do not show it.
      Returns:
      the stage containing this Chart.
      See Also:
    • show

      public Stage show()
      Add the chart to a stage, and show it in the Application thread.
      Returns:
      the stage containing this Chart.
      See Also: