Class PathObjectScatterChart

All Implemented Interfaces:
Styleable, EventTarget

public class PathObjectScatterChart extends ScatterChart<Number,Number>
An interactive ScatterChart implementation for showing large(ish) numbers of PathObject, optionally linked to a QuPathViewer.

A goal of this class is to reduce expensive chart manipulations, such as adding and removing data points. Instead, data points are reused and updated where possible.

Additionally, the maximum number of data points can be specified, so that the chart can automatically randomly subsample points to show only some.

Since:
v0.6.0
  • Property Details

  • Field Details

    • NO_SHUFFLE_SEED

      public static final int NO_SHUFFLE_SEED
      Seed value to use to specify that no shuffling should be applied before displaying the objects.
      See Also:
  • Constructor Details

    • PathObjectScatterChart

      public PathObjectScatterChart(QuPathViewer viewer)
      Create an interactive scatter plot using the current viewer
      Parameters:
      viewer - The QuPath viewer.
  • Method Details

    • setAutorangeToFullData

      public void setAutorangeToFullData(boolean useFullData)
      Parameters:
      useFullData - whether to use the full data when setting the axis autorange
    • autorangeToFullDataProperty

      public BooleanProperty autorangeToFullDataProperty()
      Get a property representing whether to use the entire dataset when calculating axis limits automatically. This is useful whenever we are subsampling data points.
      Returns:
      whether to use the full data when setting the axis autorange
      See Also:
    • getAutorangeToFullData

      public boolean getAutorangeToFullData()
      Returns:
      whether to use the full data when setting the axis autorange
    • setMaxPoints

      public void setMaxPoints(int maxPoints)
      Set the value of maxPointsProperty().
      Parameters:
      maxPoints - the maximum number of elements
    • maxPointsProperty

      public IntegerProperty maxPointsProperty()
      Get a property representing the maximum number of points that the plot will display. Subsampling will be used to ensure only this number of points or fewer are displayed.
      Returns:
      the maximum number of points to show
      See Also:
    • getMaxPoints

      public int getMaxPoints()
      Get the value of maxPointsProperty()
      Returns:
      the maximum number of points to show
    • setRngSeed

      public void setRngSeed(int rngSeed)
      Set the value of rngSeedProperty().
      Parameters:
      rngSeed - the random number generator seed to use
    • rngSeedProperty

      public IntegerProperty rngSeedProperty()
      Get a property representing the random number generator's seed for subsampling. The default value is #NO_SHUFFLE_SEED which indicates no shuffling should be performed.
      Returns:
      the rng seed property
      See Also:
    • getRngSeed

      public int getRngSeed()
      Get the value of rngSeedProperty().
      Returns:
      the random number generator
    • setPointOpacity

      public void setPointOpacity(double pointOpacity)
      Set the value of pointOpacityProperty().
      Parameters:
      pointOpacity - the new point opacity
    • pointOpacityProperty

      public DoubleProperty pointOpacityProperty()
      Get a property representing the opacity of all data points. Making points translucent can be helpful when there are a lot of them.
      Returns:
      the point opacity property
      See Also:
    • getPointOpacity

      public double getPointOpacity()
      Get the value o pointOpacityProperty()
      Returns:
      the point opacity property
    • setPointRadius

      public void setPointRadius(double radius)
      Set the value of pointOpacityProperty()
      Parameters:
      radius - the point radius
    • pointRadiusProperty

      public DoubleProperty pointRadiusProperty()
      Get a property representing the radius of all data points.
      Returns:
      the point radius property
      See Also:
    • getPointRadius

      public double getPointRadius()
      Get the value of pointOpacityProperty()
      Returns:
      the point radius
    • updateLegend

      protected void updateLegend()
      Overrides:
      updateLegend in class XYChart<Number,Number>
    • refreshData

      public void refreshData()
      Recalculate the values of all data points. This may be useful when measurements or classifications may have changed.
    • setData

      public void setData(Collection<? extends qupath.lib.objects.PathObject> pathObjects, Function<qupath.lib.objects.PathObject,Number> xFun, Function<qupath.lib.objects.PathObject,Number> yFun)
      Set the data to display in the plot.
      Parameters:
      pathObjects - the objects to display
      xFun - a function to extract the x value to plot
      yFun - a function to extract the y value to plot
    • setDataFromTable

      public void setDataFromTable(Collection<? extends qupath.lib.objects.PathObject> pathObjects, PathTableData<qupath.lib.objects.PathObject> model, String xMeasurement, String yMeasurement)
      Set the data to display in the plot from a table model.

      This calls setData(Collection, Function, Function) in addition to setting the x and y labels.

      Parameters:
      pathObjects - the objects to display
      model - the table model containing the measurements
      xMeasurement - the column to use for x values
      yMeasurement - the column to use for y values
    • dataItemAdded

      protected void dataItemAdded(XYChart.Series<Number,Number> series, int itemIndex, XYChart.Data<Number,Number> item)
      Overrides:
      dataItemAdded in class ScatterChart<Number,Number>
    • dataItemRemoved

      protected void dataItemRemoved(XYChart.Data<Number,Number> item, XYChart.Series<Number,Number> series)
      Overrides:
      dataItemRemoved in class ScatterChart<Number,Number>
    • updateAxisRange

      protected void updateAxisRange()
      Overrides:
      updateAxisRange in class XYChart<Number,Number>