package nl.tudelft.simulation.dsol.swing.charts.boxAndWhisker; import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.Font; import java.awt.GradientPaint; import java.io.Serializable; import java.rmi.RemoteException; import javax.naming.NamingException; import javax.swing.BorderFactory; import javax.swing.border.EtchedBorder; import org.djutils.stats.summarizers.event.EventBasedTally; import org.djutils.stats.summarizers.event.EventBasedTimestampWeightedTally; import org.djutils.stats.summarizers.event.EventBasedWeightedTally; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.Plot; import nl.tudelft.simulation.dsol.simulators.SimulatorInterface; import nl.tudelft.simulation.dsol.swing.Swingable; import nl.tudelft.simulation.naming.context.ContextInterface; import nl.tudelft.simulation.naming.context.util.ContextUtil; /** * The BoxAndWhiskerChart specifies a Box-and-Whisker chart. *
* Copyright (c) 2002-2022 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 Peter Jacobs * @author Alexander Verbraeck */ public class BoxAndWhiskerChart implements Swingable, Serializable { /** */ private static final long serialVersionUID = 20200108L; /** TITLE_FONT refers to the font to be used for the title of the plot. */ public static final Font TITLE_FONT = new Font("SansSerif", Font.BOLD, 18); /** chart refers to the actual chart. */ private JFreeChart chart = null; /** * constructs a new BoxAndWhiskerChart. * @param title String; the title of the chart */ public BoxAndWhiskerChart(final String title) { Plot plot = new BoxAndWhiskerPlot(); this.chart = new JFreeChart(title, TITLE_FONT, plot, true); this.chart.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.white, 1000F, 0.0F, Color.blue)); } /** * constructs a new BoxAndWhiskerChart, linked to the simulator-provided context. * @param simulator SimulatorInterface<?, ?, ?>; the simulator * @param title String; the title */ public BoxAndWhiskerChart(final SimulatorInterface, ?, ?> simulator, final String title) { this(title); try { ContextInterface context = ContextUtil.lookupOrCreateSubContext(simulator.getReplication().getContext(), "charts"); context.bindObject(this); } catch (NamingException | RemoteException exception) { simulator.getLogger().always().warn(exception, "