uchicago.src.sim.analysis
Class Plot

java.lang.Object
  extended by uchicago.src.sim.analysis.plot.OpenGraph
      extended by uchicago.src.sim.analysis.Plot
All Implemented Interfaces:
ZoomListener, MediaProducer

public class Plot
extends OpenGraph

A generic point plotting class. This can be used to plot multiple points, plotting a function whose input is some simulation data. Use the plotPoint method to plot the points, updateGraph to display those points, and clear to clear the graph of all the points.

Version:
$Revision: 1.6 $ $Date: 2004/11/03 19:51:00 $
Author:
Nick Collier

Field Summary
 
Fields inherited from class uchicago.src.sim.analysis.plot.OpenGraph
CIRCLE, CROSS, DIAMOND, fileName, FILLED_CIRCLE, FILLED_DIAMOND, FILLED_SQUARE, FILLED_TRIANGLE, frame, HISTOGRAM, inNormalState, location, model, movieMaker, plot, PLUS_SIGN, SEQUENCE, SQUARE, title, TRIANGLE, xIncr, xMax, xMin, yIncr, yMax, yMin
 
Fields inherited from interface uchicago.src.sim.gui.MediaProducer
MPEG, QUICK_TIME
 
Constructor Summary
Plot(java.lang.String title)
          Creates a Plot with the specified title.
Plot(java.lang.String title, SimModel model)
          Creates a Plot with the specified title and associated with the specified SimModel.
 
Method Summary
 void addLegend(int dataset, java.lang.String legend)
          Adds a legend for the specified dataset.
 void addLegend(int dataset, java.lang.String legend, java.awt.Color color)
          Adds a legend for the specified dataset.
 void addLegend(int dataset, java.lang.String legend, java.awt.Color color, int markStyle)
          Adds a legend for the specified dataset.
 void addLegend(int dataset, java.lang.String legend, int markStyle)
          Adds a legend for the specified dataset.
 void addString(java.lang.String string)
          Adds a String to the plot.
 void clear(int dataset)
          Clears all the points from the specified dataset from the graph.
 void clearStrings()
          Clears any added strings from the plot.
 void fillPlot()
          Shrinks or enlarges the scale so that the plotted points all fit.
static void main(java.lang.String[] args)
          Tests Plot
 void plotPoint(double x, double y, int dataset)
          Plots a point on the graph.
 void record()
          Empty method that does nothing.
 void setConnected(boolean connected)
          Whether or not all the points should be connected.
 void setConnected(boolean connected, int dataset)
          Whether or not the points specific to some dataset should be connected.
 void updateGraph()
          Updates the graph by redrawing the points.
 
Methods inherited from class uchicago.src.sim.analysis.plot.OpenGraph
addMovieFrame, closeMovie, createBinDataSource, createListBinDataSource, createSequence, display, dispose, getAxisTitles, getSize, getTitle, getXIncrement, getXRange, getYIncrement, getYRange, setAxisTitles, setBars, setLocation, setMovieName, setSize, setSnapshotFileName, setXIncrement, setXRange, setXTick, setYIncrement, setYRange, step, takeSnapshot, updateXTick, zoom
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Plot

public Plot(java.lang.String title)
Creates a Plot with the specified title.

Parameters:
title - the title of the plot

Plot

public Plot(java.lang.String title,
            SimModel model)
Creates a Plot with the specified title and associated with the specified SimModel. If you want take a snapshot of this Plot you need to use this constructor.

Parameters:
title - the title of this Plot
model - the associated model.
Method Detail

setConnected

public void setConnected(boolean connected)
Whether or not all the points should be connected.

Parameters:
connected - if true the points are connected

setConnected

public void setConnected(boolean connected,
                         int dataset)
Whether or not the points specific to some dataset should be connected.

Parameters:
connected - if true the points will be connected
dataset - the dataset whose points should be connected

plotPoint

public void plotPoint(double x,
                      double y,
                      int dataset)
Plots a point on the graph. This point will not appear on the graph untill updateGraph is called. Points are specific to datasets. Multiple datasets allow you to plot multiple functions etc. on a single chart.

Parameters:
x - the x coordinate for the point to be plotted
y - the y coordinate for the point to be plotted
dataset - the dataset for the point to be plotted

record

public void record()
Empty method that does nothing.

Specified by:
record in class OpenGraph

updateGraph

public void updateGraph()
Updates the graph by redrawing the points.

Specified by:
updateGraph in class OpenGraph

clear

public void clear(int dataset)
Clears all the points from the specified dataset from the graph. This will update the graph.

Parameters:
dataset - the number of the dataset to clear.

addLegend

public void addLegend(int dataset,
                      java.lang.String legend)
Adds a legend for the specified dataset.

Parameters:
dataset - the number of the dataset to add a legend for.
legend - the legend to add.

addLegend

public void addLegend(int dataset,
                      java.lang.String legend,
                      java.awt.Color color)
Adds a legend for the specified dataset. The legend and the plot for this dataset will be drawn in the specified color.

Parameters:
dataset - the number of the dataset to add a legend for.
legend - the legend to add.
color - the color of the legend / plot

addLegend

public void addLegend(int dataset,
                      java.lang.String legend,
                      int markStyle)
Adds a legend for the specified dataset. The plotted points for this dataset will be drawn in the specified style. markStyle is one of the following constants: FILLED_CIRCLE, CROSS, SQUARE, FILLED_TRIANGLE, DIAMOND, CIRCLE, PLUS_SIGN, FILLED_SQUARE, TRIANGLE, FILLED_DIAMOND.

Parameters:
dataset - the number of the dataset to add a legend for.
legend - the legend to add.
markStyle - the style of the plotted points

addLegend

public void addLegend(int dataset,
                      java.lang.String legend,
                      java.awt.Color color,
                      int markStyle)
Adds a legend for the specified dataset. The legend and the plot for this dataset will be drawn in the specified color. The plotted points for this dataset will be drawn in the specified style. markStyle is one of the following constants: FILLED_CIRCLE, CROSS, SQUARE, FILLED_TRIANGLE, DIAMOND, CIRCLE, PLUS_SIGN, FILLED_SQUARE, TRIANGLE, FILLED_DIAMOND.

Parameters:
dataset - the number of the dataset to add a legend for.
legend - the legend to add.
color - the color of the legend / plot
markStyle - the style of the plotted points

fillPlot

public void fillPlot()
Shrinks or enlarges the scale so that the plotted points all fit. This will update the graph.


addString

public void addString(java.lang.String string)
Adds a String to the plot. The string will be displayed to the right of the box. Additional statistics or more information about the graph can be displayed here.


clearStrings

public void clearStrings()
Clears any added strings from the plot.


main

public static void main(java.lang.String[] args)
Tests Plot