Class XYPlotBuilder

java.lang.Object
org.moeaframework.analysis.plot.PlotBuilder<XYPlotBuilder>
org.moeaframework.analysis.plot.XYPlotBuilder

public class XYPlotBuilder extends PlotBuilder<XYPlotBuilder>
Builds 2D plots with numeric X and Y axes, including line, scatter, area, stacked area, and deviation plots.
  • Constructor Details

    • XYPlotBuilder

      public XYPlotBuilder()
      Constructs a new, empty XY plot.
  • Method Details

    • getInstance

      protected XYPlotBuilder getInstance()
      Description copied from class: PlotBuilder
      Returns an instance of this builder cast to the concrete implementation type PlotBuilder. This is used by any intermediate classes to returns the concrete implementation.
      Specified by:
      getInstance in class PlotBuilder<XYPlotBuilder>
      Returns:
      a reference to this builder instance
    • build

      public org.jfree.chart.JFreeChart build()
      Description copied from class: PlotBuilder
      Builds and returns the configured plot.
      Specified by:
      build in class PlotBuilder<XYPlotBuilder>
      Returns:
      the resulting plot
    • xLabel

      public XYPlotBuilder xLabel(String label)
      Sets the X axis label.
      Parameters:
      label - the label for the X axis
      Returns:
      a reference to this builder
    • yLabel

      public XYPlotBuilder yLabel(String label)
      Sets the Y axis label.
      Parameters:
      label - the label for the Y axis
      Returns:
      a reference to this builder
    • xLim

      public XYPlotBuilder xLim(double min, double max)
      Sets the X axis limits.
      Parameters:
      min - the minimum bound
      max - the maximum bound
      Returns:
      a reference to this builder
    • xLim

      public XYPlotBuilder xLim(org.jfree.data.Range range)
      Sets the X axis limits.
      Parameters:
      range - the minimum and maximum bounds
      Returns:
      a reference to this builder
    • yLim

      public XYPlotBuilder yLim(double min, double max)
      Sets the Y axis limits.
      Parameters:
      min - the minimum bound
      max - the maximum bound
      Returns:
      a reference to this builder
    • yLim

      public XYPlotBuilder yLim(org.jfree.data.Range range)
      Sets the Y axis limits.
      Parameters:
      range - the minimum and maximum bounds
      Returns:
      a reference to this builder
    • gridPaint

      public XYPlotBuilder gridPaint(Paint paint)
      Sets the grid line paint for both axes.
      Parameters:
      paint - the paint
      Returns:
      a reference to this builder
    • scatter

      public XYPlotBuilder scatter(String label, double[] x, double[] y, PlotAttribute... attributes)
      Creates a new scatter plot series.
      Parameters:
      label - the label for the series
      x - the X values
      y - the Y values
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • scatter

      public XYPlotBuilder scatter(String label, Partition<? extends Number,? extends Number> partition, PlotAttribute... attributes)
      Creates a new scatter plot series.
      Parameters:
      label - the label for the series
      partition - the data stream partition
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • scatter

      public XYPlotBuilder scatter(String label, List<? extends Number> x, List<? extends Number> y, PlotAttribute... attributes)
      Creates a new scatter plot series.
      Parameters:
      label - the label for the series
      x - the X values
      y - the Y values
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • scatter

      public <D> XYPlotBuilder scatter(String label, List<D> data, Function<D,? extends Number> xAxis, Function<D,? extends Number> yAxis, PlotAttribute... attributes)
      Creates a new scatter plot series.
      Type Parameters:
      D - the type of each object
      Parameters:
      label - the label for the series
      data - the list of objects
      xAxis - a function converting each object into a numeric value for the X axis
      yAxis - a function converting each object into a numeric value for the Y axis
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • scatter

      public XYPlotBuilder scatter(String label, Population population, PlotAttribute... attributes)
      Creates a scatter plot representation of the feasible solutions in a population.
      Parameters:
      label - the label for the series
      population - the population
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • scatter

      public XYPlotBuilder scatter(String label, Population population, int x, int y, PlotAttribute... attributes)
      Creates a scatter plot representation of the feasible solutions in a population.
      Parameters:
      label - the label for the series
      population - the population
      x - the objective to plot on the X axis
      y - the objective to plot on the Y axis
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • line

      public XYPlotBuilder line(String label, double[] x, double[] y, PlotAttribute... attributes)
      Creates a new line plot series.
      Parameters:
      label - the label for the series
      x - the X values
      y - the Y values
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • line

      public XYPlotBuilder line(String label, Partition<? extends Number,? extends Number> partition, PlotAttribute... attributes)
      Creates a new line plot series.
      Parameters:
      label - the label for the series
      partition - the data stream partition
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • line

      public XYPlotBuilder line(String label, List<? extends Number> x, List<? extends Number> y, PlotAttribute... attributes)
      Creates a new line plot series.
      Parameters:
      label - the label for the series
      x - the X values
      y - the Y values
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • line

      public <D> XYPlotBuilder line(String label, List<D> data, Function<D,? extends Number> xAxis, Function<D,? extends Number> yAxis, PlotAttribute... attributes)
      Creates a new line plot series.
      Type Parameters:
      D - the type of each object
      Parameters:
      label - the label for the series
      data - the list of objects
      xAxis - a function converting each object into a numeric value for the X axis
      yAxis - a function converting each object into a numeric value for the Y axis
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • line

      public XYPlotBuilder line(String label, ResultSeries series, String property, PlotAttribute... attributes)
      Creates a new line plot series of NFE versus the property value.
      Parameters:
      label - the label for the series
      series - the result series
      property - the name of the property to plot
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • lines

      public XYPlotBuilder lines(ResultSeries series, PlotAttribute... attributes)
      Creates a new line plot series of NFE versus the property value. Each property is rendered as a separate line series.
      Parameters:
      series - the result series
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • histogram

      public XYPlotBuilder histogram(String label, List<? extends Number> values, PlotAttribute... attributes)
      Creates a new histogram showing the number of times each value occurs in the input.
      Parameters:
      label - the label for the series
      values - the values
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • histogram

      public <D> XYPlotBuilder histogram(String label, List<D> data, Function<D,? extends Number> getter, PlotAttribute... attributes)
      Creates a new histogram showing the number of times each value occurs in the input.
      Type Parameters:
      D - the type of each object
      Parameters:
      label - the label for the series
      data - the list of objects
      getter - a function converting each object into a numeric value
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • histogram

      public XYPlotBuilder histogram(String label, double[] values, PlotAttribute... attributes)
      Creates a new histogram showing the number of times each value occurs in the input.
      Parameters:
      label - the label for the series
      values - the values
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • area

      public XYPlotBuilder area(String label, double[] x, double[] y, PlotAttribute... attributes)
      Creates a new area plot series.
      Parameters:
      label - the label for the series
      x - the X values
      y - the Y values
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • area

      public XYPlotBuilder area(String label, Partition<? extends Number,? extends Number> partition, PlotAttribute... attributes)
      Creates a new area plot series.
      Parameters:
      label - the label for the series
      partition - the data stream partition
      attributes - the attributes configuring the plot
      Returns:
      a reference to this instance
    • area

      public XYPlotBuilder area(String label, List<? extends Number> x, List<? extends Number> y, PlotAttribute... attributes)
      Creates a new area plot series.
      Parameters:
      label - the label for the series
      x - the X values
      y - the Y values
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • area

      public <D> XYPlotBuilder area(String label, List<D> data, Function<D,? extends Number> xAxis, Function<D,? extends Number> yAxis, PlotAttribute... attributes)
      Creates a new area plot series.
      Type Parameters:
      D - the type of each object
      Parameters:
      label - the label for the series
      data - the list of objects
      xAxis - a function converting each object into a numeric value for the X axis
      yAxis - a function converting each object into a numeric value for the Y axis
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • stacked

      public XYPlotBuilder stacked(String label, double[] x, double[] y, PlotAttribute... attributes)
      Creates a new stacked area plot series.
      Parameters:
      label - the label for the series
      x - the X values
      y - the Y values
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • stacked

      public XYPlotBuilder stacked(String label, Partition<? extends Number,? extends Number> partition, PlotAttribute... attributes)
      Creates a new stacked area plot series.
      Parameters:
      label - the label for the series
      partition - the data stream partition
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • stacked

      public XYPlotBuilder stacked(String label, List<? extends Number> x, List<? extends Number> y, PlotAttribute... attributes)
      Creates a new stacked area plot series.
      Parameters:
      label - the label for the series
      x - the X values
      y - the Y values
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • stacked

      public <D> XYPlotBuilder stacked(String label, List<D> data, Function<D,? extends Number> xAxis, Function<D,? extends Number> yAxis, PlotAttribute... attributes)
      Creates a new stacked area plot series.
      Type Parameters:
      D - the type of each object
      Parameters:
      label - the label for the series
      data - the list of objects
      xAxis - a function converting each object into a numeric value for the X axis
      yAxis - a function converting each object into a numeric value for the Y axis
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • deviation

      public XYPlotBuilder deviation(String label, List<ResultSeries> data, String property, PlotAttribute... attributes)
      Creates a new deviation series, with a solid line indicating the median (50-th percentile) and a shaded area denoting the lower and upper percentiles.
      Parameters:
      label - the label for the series
      data - a collection of the ResultSeries to display
      property - the property to display
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • deviation

      public <D> XYPlotBuilder deviation(String label, List<D> data, Function<D,? extends Number> xAxis, Function<D,? extends Number> yAxis, PlotAttribute... attributes)
      Creates a new deviation series.
      Type Parameters:
      D - the type of each object
      Parameters:
      label - the label for the series
      data - the list of objects
      xAxis - a function converting each object into a numeric value for the X axis
      yAxis - a function converting each object into a numeric value for the Y axis
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • deviation

      public XYPlotBuilder deviation(String label, List<? extends Number> x, List<? extends Number> y, PlotAttribute... attributes)
      Creates a new deviation series. The data is aggregated using a given step size, with the median, low-percentile, and high-percentile values computed from the points lying within each step.
      Parameters:
      label - the label for the series
      x - the X values
      y - the Y values
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • deviation

      public XYPlotBuilder deviation(String label, double[] x, double[] y, PlotAttribute... attributes)
      Creates a new deviation series. The data is aggregated using a given step size, with the median, low-percentile, and high-percentile values computed from the points lying within each step.
      Parameters:
      label - the label for the series
      x - the X values
      y - the Y values
      attributes - the attributes configuring the plot
      Returns:
      a reference to this builder
    • text

      public XYPlotBuilder text(String text, double x, double y)
      Adds a label annotation to the plot.
      Parameters:
      text - the text to display
      x - the position of the label along the X axis
      y - the position of hte label along the Y axis
      Returns:
      a reference to this builder
    • pointer

      public XYPlotBuilder pointer(String text, double x, double y, double angle)
      Adds a pointer annotation, which includes a label and an arrow, to the plot.
      Parameters:
      text - the text to display
      x - the target position of the arrow along the X axis
      y - the target position of the arrow along the Y axis
      angle - the angle, in radians, of the arrow and label in relation to the target position
      Returns:
      a reference to this builder
    • getDefaultStroke

      protected Stroke getDefaultStroke()
      Returns the default stroke used when rendering lines.
      Returns:
      the default stroke
    • getDefaultShape

      protected RectangularShape getDefaultShape()
      Returns the default shape used when rendering points.
      Returns:
      the default shape