uchicago.src.sim.analysis
Class OpenSequenceGraph

java.lang.Object
  extended by uchicago.src.sim.analysis.plot.OpenGraph
      extended by uchicago.src.sim.analysis.OpenSequenceGraph
All Implemented Interfaces:
ZoomListener, MediaProducer
Direct Known Subclasses:
NetSequenceGraph

public class OpenSequenceGraph
extends OpenGraph

A graph that displays a connected series of points (a sequence). Encapsulates a sequence statistic class that manages the data. This statistic class can also be set. Typically, a time series updated every tick of the main schedule.

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

Field Summary
static uchicago.src.sim.analysis.OpenSequenceGraph.PolicyConstant SHOW_ALL
           
static uchicago.src.sim.analysis.OpenSequenceGraph.PolicyConstant SHOW_FIRST
           
static uchicago.src.sim.analysis.OpenSequenceGraph.PolicyConstant SHOW_LAST
           
 
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
OpenSequenceGraph(java.lang.String title, SimModel model)
          Creates an OpenSequenceGraph with the specified title for the specified model.
OpenSequenceGraph(java.lang.String title, SimModel model, java.lang.String fileName, int fileFormat)
          Creates an OpenSequenceGraph with the specified title, model, file name and file format.
 
Method Summary
 Sequence addSequence(java.lang.String name, Sequence sequence)
          Adds the specified sequence with the specified name.
 Sequence addSequence(java.lang.String name, Sequence sequence, java.awt.Color color)
          Adds the specified sequence with the specified name to be drawn in the specific color.
 Sequence addSequence(java.lang.String name, Sequence sequence, java.awt.Color color, int markStyle)
          Adds the specified sequence with the specified name to be drawn in the specific color, whose points will be drawn in the specified style.
 Sequence addSequence(java.lang.String name, Sequence sequence, int markStyle)
          Adds the specified sequence with specified name whose points will be drawn in the specified style.
 Sequence createSequence(java.lang.String name, java.awt.Color color, int markStyle, java.lang.Object feedFrom, java.lang.String methodName)
          Creates and adds a Sequence to this SequenceGraph.
 Sequence createSequence(java.lang.String name, java.awt.Color color, java.lang.Object feedFrom, java.lang.String methodName)
          Creates and adds a Sequence to this SequenceGraph.
 Sequence createSequence(java.lang.String name, int markStyle, java.lang.Object feedFrom, java.lang.String methodName)
          Creates and adds a Sequence to this SequenceGraph.
 Sequence createSequence(java.lang.String name, java.lang.Object feedFrom, java.lang.String methodName)
          Creates and adds a Sequence to this SequenceGraph.
 boolean getXAutoExpand()
          Returns whether the plot's x-axis scale will expand to include new points that will not fit in the current scale.
 uchicago.src.sim.analysis.OpenSequenceGraph.PolicyConstant getXViewPolicy()
          Returns the current view policy for the x-axis.
 boolean getYAutoExpand()
          Returns whether the plot's y-axis scale will expand to include new points that will not fit in the current scale.
 uchicago.src.sim.analysis.OpenSequenceGraph.PolicyConstant getYViewPolicy()
          Returns the current view policy for the y-axis.
 void record()
          Records the data for this graph without updating the display.
 void setXAutoExpand(boolean autoExpand)
          Sets whether the plot's x-axis scale will expand to include new points or not.
 void setXRange(double min, double max)
          Sets the initial range of the x-axis.
 void setXViewPolicy(uchicago.src.sim.analysis.OpenSequenceGraph.PolicyConstant policy)
          Sets the view policy for the x-axis.
 void setYAutoExpand(boolean autoExpand)
          Sets whether the plot's y-axis scale will expand to include new points or not.
 void setYRange(double min, double max)
          Sets the initial range of the y-axis.
 void setYViewPolicy(uchicago.src.sim.analysis.OpenSequenceGraph.PolicyConstant policy)
          Sets the view policy for the y-axis.
 void updateGraph()
          Updates the display to reflect any new data as captured by record.
 void writeToFile()
          Writes this graph to a file.
 
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, setXTick, setYIncrement, step, takeSnapshot, updateXTick, zoom
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHOW_ALL

public static final uchicago.src.sim.analysis.OpenSequenceGraph.PolicyConstant SHOW_ALL

SHOW_FIRST

public static final uchicago.src.sim.analysis.OpenSequenceGraph.PolicyConstant SHOW_FIRST

SHOW_LAST

public static final uchicago.src.sim.analysis.OpenSequenceGraph.PolicyConstant SHOW_LAST
Constructor Detail

OpenSequenceGraph

public OpenSequenceGraph(java.lang.String title,
                         SimModel model)
Creates an OpenSequenceGraph with the specified title for the specified model.

Parameters:
title - the title for this graph.
model - the model associated with this graph

OpenSequenceGraph

public OpenSequenceGraph(java.lang.String title,
                         SimModel model,
                         java.lang.String fileName,
                         int fileFormat)
Creates an OpenSequenceGraph with the specified title, model, file name and file format. File name and file format provide are necessary if the data displayed by this graph is to be outputed to a file.

Parameters:
title - the title of the graph.
model - the model associated with this graph
fileName - the file name to be used when this graph is dumped to a file
fileFormat - the format to be used for dumping data to the file. At the moment only OpenSeqStatistic.CSV is supported.
Method Detail

addSequence

public Sequence addSequence(java.lang.String name,
                            Sequence sequence)
Adds the specified sequence with the specified name.

Parameters:
name - the name of the sequence
sequence - the sequence to add

createSequence

public Sequence createSequence(java.lang.String name,
                               java.lang.Object feedFrom,
                               java.lang.String methodName)
Creates and adds a Sequence to this SequenceGraph. The Sequence will have the specified name and wraps a call to the specified methodName on the specified Object. The value returned from this method call will be plotted. The value must be numeric.

Parameters:
name - the name of the sequence
feedFrom - the object on which to call the method
methodName - the name of the method to call

addSequence

public Sequence addSequence(java.lang.String name,
                            Sequence sequence,
                            java.awt.Color color)
Adds the specified sequence with the specified name to be drawn in the specific color.

Parameters:
name - the name of the sequence
sequence - the sequence to add
color - the color of the sequence

createSequence

public Sequence createSequence(java.lang.String name,
                               java.awt.Color color,
                               java.lang.Object feedFrom,
                               java.lang.String methodName)
Creates and adds a Sequence to this SequenceGraph. The Sequence will have the specified name and color. The Sequence itself wraps a call to the specified methodName on the specified Object. The value returned from this method call will be plotted. This return value must be numeric.

Parameters:
name - the name of the sequence
color - the color of the sequence
feedFrom - the object on which to call the method
methodName - the name of the method to call

addSequence

public Sequence addSequence(java.lang.String name,
                            Sequence sequence,
                            int markStyle)
Adds the specified sequence with specified name whose points will be drawn in the specified style. The markStyle is one of the following constants: FILLED_CIRCLE, CROSS, SQUARE, FILLED_TRIANGLE, DIAMOND, CIRCLE, PLUS_SIGN, FILLED_SQUARE, TRIANGLE, FILLED_DIAMOND.

Parameters:
name - the name of the sequence
sequence - the sequence to add
markStyle - the shape of the plotted points

createSequence

public Sequence createSequence(java.lang.String name,
                               int markStyle,
                               java.lang.Object feedFrom,
                               java.lang.String methodName)
Creates and adds a Sequence to this SequenceGraph. The Sequence will have the specified name and its points will be drawn in the specified style. The sequence itself wraps a call to the specified methodName on the specified Object. The value returned from this method call will be plotted. This value must be numeric. The markStyle is one of the following constants: FILLED_CIRCLE, CROSS, SQUARE, FILLED_TRIANGLE, DIAMOND, CIRCLE, PLUS_SIGN, FILLED_SQUARE, TRIANGLE, FILLED_DIAMOND.

Parameters:
name - the name of the sequence
markStyle - the shape of the plotted points
feedFrom - the object on which to call the method
methodName - the name of the method to call

addSequence

public Sequence addSequence(java.lang.String name,
                            Sequence sequence,
                            java.awt.Color color,
                            int markStyle)
Adds the specified sequence with the specified name to be drawn in the specific color, whose points will be drawn in the specified style. The markStyle is one of the following constants: FILLED_CIRCLE, CROSS, SQUARE, FILLED_TRIANGLE, DIAMOND, CIRCLE, PLUS_SIGN, FILLED_SQUARE, TRIANGLE, FILLED_DIAMOND.

Parameters:
name - the name of the sequence
sequence - the sequence to add
color - the color of the sequence
markStyle - the shape of the plotted points

createSequence

public Sequence createSequence(java.lang.String name,
                               java.awt.Color color,
                               int markStyle,
                               java.lang.Object feedFrom,
                               java.lang.String methodName)
Creates and adds a Sequence to this SequenceGraph. The Sequence will have the specified name and color. Its points will be drawn in the specified style. The sequence itself wraps a call to the specified methodName on the specified Object. The value returned from this method call will be plotted. This return value mustbe numeric. The markStyle is one of the following constants: FILLED_CIRCLE, CROSS, SQUARE, FILLED_TRIANGLE, DIAMOND, CIRCLE, PLUS_SIGN, FILLED_SQUARE, TRIANGLE, FILLED_DIAMOND.

Parameters:
name - the name of the sequence
color - the color of the sequence
markStyle - the shape of the plotted points
feedFrom - the object on which to call the method
methodName - the name of the method to call

setXRange

public void setXRange(double min,
                      double max)
Sets the initial range of the x-axis. Depending on the view policy for the x-axis this range may change as new points are added to the graph.

Under the SHOW_FIRST and SHOW_LAST view policies, this range is the viewable range. For example, given a range of 5, 100, SHOW_FIRST will only show the points that fall into the range from 5 to 100; SHOW_LAST will show all the points that fall into the range of lastPoint - 95 (i.e the "range" of 5 to 100) to the lastPoint.

Overrides:
setXRange in class OpenGraph
Parameters:
min - the minimum value of the range
max - the maximum value of the range
See Also:
setXViewPolicy

setYRange

public void setYRange(double min,
                      double max)
Sets the initial range of the y-axis. Depending on the view policy for the y-axis this range may change as new points are added to the graph.

Under the SHOW_FIRST and SHOW_LAST view policies, this range is the viewable range. For example, given a range of 5, 100, SHOW_FIRST will only show the points that fall into the range from 5 to 100; SHOW_LAST will show all the points that fall into the range of lastPoint - 95 (i.e the "range" of 5 to 100) to the lastPoint.

Overrides:
setYRange in class OpenGraph
Parameters:
min - the minimum value of the range
max - the maximum value of the range
See Also:
setYViewPolicy

setXViewPolicy

public void setXViewPolicy(uchicago.src.sim.analysis.OpenSequenceGraph.PolicyConstant policy)
Sets the view policy for the x-axis. The view policy controls which the visibility of points w/r to the x-axis and thus whether graph expands along the x-axis in order for new points to be visible. The appropriate arguments are: NoteUsing SHOW_LAST is much slower than the other two as the graph will have to entirely repaint itself whenver a point is added.

Parameters:
policy - determines what points are visible w/r to the x-axis

getXViewPolicy

public uchicago.src.sim.analysis.OpenSequenceGraph.PolicyConstant getXViewPolicy()
Returns the current view policy for the x-axis.


setYViewPolicy

public void setYViewPolicy(uchicago.src.sim.analysis.OpenSequenceGraph.PolicyConstant policy)
Sets the view policy for the y-axis. The view policy controls which the visibility of points w/r to the y-axis and thus whether graph expands along the y-axis in order for new points to be visible. The appropriate arguments are: NoteUsing SHOW_LAST is much slower than the other two as the graph will have to entirely repaint itself whenver a point is added. Also, this sets the view policy for all the sequences added to this graph. Given that the y-values of sequences can vary by large amounts, setting the y-axis view policy to anything other than SHOW_ALL (the default) can hide some sequences and show others.

Parameters:
policy - determines what points are visible w/r to the y-axis

getYViewPolicy

public uchicago.src.sim.analysis.OpenSequenceGraph.PolicyConstant getYViewPolicy()
Returns the current view policy for the y-axis.


setXAutoExpand

public void setXAutoExpand(boolean autoExpand)
Sets whether the plot's x-axis scale will expand to include new points or not. Default value is true.

Parameters:
autoExpand - if true, plot scale will expand, if false then it will not

getXAutoExpand

public boolean getXAutoExpand()
Returns whether the plot's x-axis scale will expand to include new points that will not fit in the current scale.


setYAutoExpand

public void setYAutoExpand(boolean autoExpand)
Sets whether the plot's y-axis scale will expand to include new points or not. Default value is true.

Parameters:
autoExpand - if true, plot scale will expand, if false then it will not

getYAutoExpand

public boolean getYAutoExpand()
Returns whether the plot's y-axis scale will expand to include new points that will not fit in the current scale.


record

public void record()
Records the data for this graph without updating the display.

Specified by:
record in class OpenGraph

updateGraph

public void updateGraph()
Updates the display to reflect any new data as captured by record.

Specified by:
updateGraph in class OpenGraph

writeToFile

public void writeToFile()
Writes this graph to a file.