Package sim.display

Class ChartUtilities

java.lang.Object
sim.display.ChartUtilities

public class ChartUtilities extends Object
ChartUtilities.java A collection of static methods designed to make it easy for you to set up charts as displays.

In your init() method, you will create a chart by calling one of the build...Generator(...) methods. Then you will create one or more series by calling one of the add...Series(...) methods.

Store the series you created in instance variables.

Finally, in your start() and load() methods (perhaps in setupPortrayals() if both of them call that method), you will schedule each of the series by calling the schedule...Series(...) methods.

The ChartUtilities schedule...Series(...) methods expect a "value provider" object which implements one of the ChartUtilities.Provides... interfaces. This object is called each timestep to add new data (for ProvidesDoubles) or replace all the data (for the other Provides interfaces) in the chart before the chart is redrawn. You can pass in null for this object, which prevents the data from ever being updated; in this case it's up to you to update the data on your own.

  • Constructor Details

    • ChartUtilities

      public ChartUtilities()
  • Method Details

    • buildTimeSeriesChartGenerator

      public static TimeSeriesChartGenerator buildTimeSeriesChartGenerator(String title, String domainAxisLabel)
      Builds a TimeSeriesChartGenerator not attached to any MASON simulation.
    • buildTimeSeriesChartGenerator

      public static TimeSeriesChartGenerator buildTimeSeriesChartGenerator(GUIState state, String title, String domainAxisLabel)
      Builds a TimeSeriesChartGenerator and attaches it as a display in a MASON simulation.
    • addSeries

      public static TimeSeriesAttributes addSeries(TimeSeriesChartGenerator chart, String seriesName)
      Adds a series to the TimeSeriesChartGenerator
    • scheduleSeries

      public static Stoppable scheduleSeries(GUIState state, TimeSeriesAttributes attributes, Valuable valueProvider)
      Schedules a series with the MASON simulation. You specify a value provider to give series data each timestep. This value provider can be null, in which case no data will ever be updated -- you'd have to update it on your own as you saw fit.
    • buildHistogramGenerator

      public static HistogramGenerator buildHistogramGenerator(String title, String rangeAxisLabel)
      Builds a HistogramGenerator not attached to any MASON simulation.
    • buildHistogramGenerator

      public static HistogramGenerator buildHistogramGenerator(GUIState state, String title, String rangeAxisLabel)
      Builds a HistogramGenerator and attaches it as a display in a MASON simulation.
    • addSeries

      public static HistogramSeriesAttributes addSeries(HistogramGenerator chart, String seriesName, int bins)
      Adds a series to the HistogramGenerator. You also provide the default number of histogram bins.
    • scheduleSeries

      public static Stoppable scheduleSeries(GUIState state, HistogramSeriesAttributes attributes, ChartUtilities.ProvidesDoubles valueProvider)
      Schedules a series with the MASON simulation. You specify a value provider to give series data each timestep. This value provider can be null, in which case no data will ever be updated -- you'd have to update it on your own as you saw fit.
    • buildBoxPlotGenerator

      public static BoxPlotGenerator buildBoxPlotGenerator(String title, String rangeAxisLabel)
      Builds a BoxPlotGenerator not attached to any MASON simulation.
    • buildBoxPlotGenerator

      public static BoxPlotGenerator buildBoxPlotGenerator(GUIState state, String title, String rangeAxisLabel)
      Builds a BoxPlotGenerator and attaches it as a display in a MASON simulation.
    • addSeries

      public static BoxPlotSeriesAttributes addSeries(BoxPlotGenerator chart, String seriesName)
      Adds a series to the BoxPlotGenerator.
    • scheduleSeries

      public static Stoppable scheduleSeries(GUIState state, BoxPlotSeriesAttributes attributes, ChartUtilities.ProvidesDoubles valueProvider)
      Schedules a series with the MASON simulation. You specify a value provider to give series data each timestep. This value provider can be null, in which case no data will ever be updated -- you'd have to update it on your own as you saw fit.
    • scheduleSeries

      public static Stoppable scheduleSeries(GUIState state, BoxPlotSeriesAttributes attributes, ChartUtilities.ProvidesDoubleDoublesAndLabels valueProvider)
      Schedules a series with the MASON simulation. You specify a value provider to give series data each timestep. This value provider can be null, in which case no data will ever be updated -- you'd have to update it on your own as you saw fit.
    • buildScatterPlotGenerator

      public static ScatterPlotGenerator buildScatterPlotGenerator(String title, String rangeAxisLabel, String domainAxisLabel)
      Builds a ScatterPlotGenerator not attached to any MASON simulation.
    • buildScatterPlotGenerator

      public static ScatterPlotGenerator buildScatterPlotGenerator(GUIState state, String title, String rangeAxisLabel, String domainAxisLabel)
      Builds a ScatterPlotGenerator and attaches it as a display in a MASON simulation.
    • addSeries

      public static ScatterPlotSeriesAttributes addSeries(ScatterPlotGenerator chart, String seriesName)
      Adds a series to the ScatterPlotGenerator.
    • scheduleSeries

      public static Stoppable scheduleSeries(GUIState state, ScatterPlotSeriesAttributes attributes, ChartUtilities.ProvidesDoubleDoubles valueProvider)
      Schedules a series with the MASON simulation. You specify a value provider to give series data each timestep. This value provider can be null, in which case no data will ever be updated -- you'd have to update it on your own as you saw fit.
    • buildBubbleChartGenerator

      public static BubbleChartGenerator buildBubbleChartGenerator(String title, String rangeAxisLabel, String domainAxisLabel)
      Builds a BubbleChartGenerator not attached to any MASON simulation.
    • buildBubbleChartGenerator

      public static BubbleChartGenerator buildBubbleChartGenerator(GUIState state, String title, String rangeAxisLabel, String domainAxisLabel)
      Builds a BubbleChartGenerator and attaches it as a display in a MASON simulation.
    • addSeries

      public static BubbleChartSeriesAttributes addSeries(BubbleChartGenerator chart, String seriesName)
      Adds a series to the BubbleChartGenerator.
    • scheduleSeries

      public static Stoppable scheduleSeries(GUIState state, BubbleChartSeriesAttributes attributes, ChartUtilities.ProvidesTripleDoubles valueProvider)
      Schedules a series with the MASON simulation. You specify a value provider to give series data each timestep. This value provider can be null, in which case no data will ever be updated -- you'd have to update it on your own as you saw fit.
    • buildPieChartGenerator

      public static PieChartGenerator buildPieChartGenerator(String title)
      Builds a PieChartGenerator not attached to any MASON simulation.
    • buildPieChartGenerator

      public static PieChartGenerator buildPieChartGenerator(GUIState state, String title)
      Builds a PieChartGenerator and attaches it as a display in a MASON simulation.
    • addSeries

      public static PieChartSeriesAttributes addSeries(PieChartGenerator chart, String seriesName)
      Adds a series to the PieChartGenerator.
    • scheduleSeries

      public static Stoppable scheduleSeries(GUIState state, PieChartSeriesAttributes attributes, ChartUtilities.ProvidesDoublesAndLabels valueProvider)
      Schedules a series with the MASON simulation. You specify a value provider to give series data each timestep. This value provider can be null, in which case no data will ever be updated -- you'd have to update it on your own as you saw fit.
    • scheduleSeries

      public static Stoppable scheduleSeries(GUIState state, PieChartSeriesAttributes attributes, ChartUtilities.ProvidesObjects valueProvider)
      Schedules a series with the MASON simulation. You specify a value provider to give series data each timestep. This value provider can be null, in which case no data will ever be updated -- you'd have to update it on your own as you saw fit.
    • scheduleSeries

      public static Stoppable scheduleSeries(GUIState state, PieChartSeriesAttributes attributes, ChartUtilities.ProvidesCollection valueProvider)
      Schedules a series with the MASON simulation. You specify a value provider to give series data each timestep. This value provider can be null, in which case no data will ever be updated -- you'd have to update it on your own as you saw fit.
    • buildBarChartGenerator

      public static BarChartGenerator buildBarChartGenerator(String title)
      Builds a BarChartGenerator not attached to any MASON simulation.
    • buildBarChartGenerator

      public static BarChartGenerator buildBarChartGenerator(GUIState state, String title)
      Builds a BarChartGenerator and attaches it as a display in a MASON simulation.
    • addSeries

      public static BarChartSeriesAttributes addSeries(BarChartGenerator chart, String seriesName)
      Adds a series to the BarChartGenerator.
    • scheduleSeries

      public static Stoppable scheduleSeries(GUIState state, BarChartSeriesAttributes attributes, ChartUtilities.ProvidesDoublesAndLabels valueProvider)
      Schedules a series with the MASON simulation. You specify a value provider to give series data each timestep. This value provider can be null, in which case no data will ever be updated -- you'd have to update it on your own as you saw fit.
    • scheduleSeries

      public static Stoppable scheduleSeries(GUIState state, BarChartSeriesAttributes attributes, ChartUtilities.ProvidesObjects valueProvider)
      Schedules a series with the MASON simulation. You specify a value provider to give series data each timestep. This value provider can be null, in which case no data will ever be updated -- you'd have to update it on your own as you saw fit.
    • scheduleSeries

      public static Stoppable scheduleSeries(GUIState state, BarChartSeriesAttributes attributes, ChartUtilities.ProvidesCollection valueProvider)
      Schedules a series with the MASON simulation. You specify a value provider to give series data each timestep. This value provider can be null, in which case no data will ever be updated -- you'd have to update it on your own as you saw fit.