package nl.tudelft.simulation.jstats.charts.histogram; import java.awt.Color; import java.awt.Container; import java.awt.GradientPaint; import java.rmi.RemoteException; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.PlotOrientation; import nl.tudelft.simulation.event.EventProducerInterface; import nl.tudelft.simulation.event.EventType; import nl.tudelft.simulation.jstats.Swingable; import nl.tudelft.simulation.jstats.statistics.Counter; /** * The histogram specifies a histogram chart for the DSOL framework. *
* copyright (c) 2002-2018 Delft University of Technology , the Netherlands.
*
* See for project information www.simulation.tudelft.nl .
*
* Copyright (c) 2002-2018 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights * reserved. See for project information * https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can * be found at * https://simulation.tudelft.nl/dsol/3.0/license.html. *
* @author Alexander VerbraeckCounter.COUNT_EVENT
.
* @param counter the counter to add.
*/
public synchronized void add(final Counter counter)
{
HistogramSeries set = this.getDataset().addSeries(counter.getDescription());
counter.addListener(set, Counter.COUNT_EVENT, false);
}
/**
* adds an eventProducer to the histogram dataset. The histogram subscribes its dataset subsequentially to the
* specified event.
* @param description the description of the eventProducer
* @param source the eventproducer which functions as source for this histogram.
* @param eventType the eventType.
* @throws RemoteException on network error for the (possibly remote) event listener
*/
public synchronized void add(final String description, final EventProducerInterface source,
final EventType eventType) throws RemoteException
{
HistogramSeries set = this.getDataset().addSeries(description);
source.addListener(set, eventType, false);
}
/**
* returns the chart
* @return JFreeChart
*/
public JFreeChart getChart()
{
return this.chart;
}
/**
* returns the chartPanel of this histogram.
* @return ChartPanel
*/
public Container getSwingPanel()
{
ChartPanel result = new ChartPanel(this.chart);
result.setMouseZoomable(true, false);
return result;
}
/**
* returns the dataset of a histogram.
* @return the HistogramDataset containing all series.
*/
public HistogramDataset getDataset()
{
return this.dataset;
}
}