Class AbstractPlot

    • Field Detail

      • GRAPH_ADD_EVENT

        public static final EventType GRAPH_ADD_EVENT
        The (regular, not timed) event type for pub/sub indicating the addition of a graph. Not used internally.
        Payload: String graph caption (not an array, just a String)
      • GRAPH_REMOVE_EVENT

        public static final EventType GRAPH_REMOVE_EVENT
        The (regular, not timed) event type for pub/sub indicating the removal of a graph. Not used internally.
        Payload: String Graph caption (not an array, just a String)
      • DEFAULT_INITIAL_UPPER_TIME_BOUND

        public static final Time DEFAULT_INITIAL_UPPER_TIME_BOUND
        Initial upper bound for the time scale.
    • Constructor Detail

      • AbstractPlot

        public AbstractPlot​(OTSSimulatorInterface simulator,
                            String caption,
                            Duration updateInterval,
                            Duration delay)
        Constructor.
        Parameters:
        simulator - OTSSimulatorInterface; simulator
        caption - String; caption
        updateInterval - Duration; regular update interval (simulation time)
        delay - Duration; amount of time that chart runs behind simulation to prevent gaps in the charted data
    • Method Detail

      • setChart

        protected void setChart​(JFreeChart chart)
        Sets the chart and adds menus and listeners.
        Parameters:
        chart - JFreeChart; chart
      • encodeAsPng

        public byte[] encodeAsPng​(int width,
                                  int height,
                                  double fontSize)
                           throws IOException
        Returns the chart as a byte array representing a png image.
        Parameters:
        width - int; width
        height - int; height
        fontSize - double; font size (16 is the original on screen size)
        Returns:
        byte[]; the chart as a byte array representing a png image
        Throws:
        IOException - on IO exception
      • setAutoBoundDomain

        public void setAutoBoundDomain​(XYPlot plot)
        Overridable; activates auto bounds on domain axis from user input. This class does not force the use of XYPlots, but the auto bounds command comes from the ChartPanel that this class creates. In case the used plot is a XYPlot, this method is then invoked. Sub classes with auto domain bounds that work with an XYPlot should implement this. The method is not abstract as the use of XYPlot is not obligated.
        Parameters:
        plot - XYPlot; plot
      • setAutoBoundRange

        public void setAutoBoundRange​(XYPlot plot)
        Overridable; activates auto bounds on range axis from user input. This class does not force the use of XYPlots, but the auto bounds command comes from the ChartPanel that this class creates. In case the used plot is a XYPlot, this method is then invoked. Sub classes with auto range bounds that work with an XYPlot should implement this. The method is not abstract as the use of XYPlot is not obligated.
        Parameters:
        plot - XYPlot; plot
      • getGraphType

        public abstract GraphType getGraphType()
        Return the graph type for transceiver.
        Returns:
        GraphType; the graph type.
      • getStatusLabel

        public abstract String getStatusLabel​(double domainValue,
                                              double rangeValue)
        Returns the status label when the mouse is over the given location.
        Parameters:
        domainValue - double; domain value (x-axis)
        rangeValue - double; range value (y-axis)
        Returns:
        String; status label when the mouse is over the given location
      • increaseTime

        protected abstract void increaseTime​(Time time)
        Increase the simulated time span.
        Parameters:
        time - Time; time to increase to
      • notifyPlotChange

        public final void notifyPlotChange()
        Notify all change listeners.
      • getChart

        public final JFreeChart getChart()
        Returns the chart.
        Returns:
        JFreeChart; chart
      • getSimulator

        public OTSSimulatorInterface getSimulator()
        Retrieve the simulator.
        Returns:
        OTSSimulatorInterface; the simulator
      • setUpdateInterval

        public final void setUpdateInterval​(Duration interval)
        Sets a new update interval.
        Parameters:
        interval - Duration; update interval
      • getUpdateTime

        public final Time getUpdateTime()
        Returns time until which data should be plotted.
        Returns:
        Time; time until which data should be plotted
      • update

        protected void update()
        Redraws the plot and schedules the next update.
      • getCaption

        public String getCaption()
        Retrieve the caption.
        Returns:
        String; the caption of the plot