uchicago.src.sim.analysis
Class OpenHistogram

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

public class OpenHistogram
extends OpenGraph

A dynamic bar chart. The OpenHistogram class allows the user to histogram data generated by a collection of objects. The histogram range, as displayed, is [lowerBound, maxValue] where the maxValue is calculated each time the graph is stepped. The individual bin ranges except for the final bin are [Math.floor(value), Math.ceil(value + interval)) where interval is calculated by (maxValue - lowerBound) / numBins. The final bin is inclusive.

Version:
$Revision: 1.8 $ $Date: 2004/11/03 19:51:00 $
Author:
Nick Collier
See Also:
HistogramStatistic, HistogramItem

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
OpenHistogram(java.lang.String title, int numBins, long lowerBound)
          Constructs an OpenHistogram with the specified title, the specified number of bins, and the specified lowerBound.
OpenHistogram(java.lang.String title, int numBins, long lowerBound, SimModel model)
          Constructs an OpenHistogram with the specified title, the specified number of bins, and the specified lowerBound.
 
Method Summary
 void createHistogramItem(java.lang.String name, java.util.List list, BinDataSource source)
          Creates a HistogramItem with specified name, list and BinDataSource to be displayed by this Histogram.
 void createHistogramItem(java.lang.String name, java.util.List list, BinDataSource source, int maxIntegerDigits, int maxFractionDigits)
          Creates a HistogramItem with specified name, list and BinDataSource to be displayed by this Histogram.
 void createHistogramItem(java.lang.String name, java.util.List list, java.lang.Object target, java.lang.String methodName)
          Creates a HistogramItem with specified name to be displayed by this OpenHistogram.
 void createHistogramItem(java.lang.String name, java.util.List list, java.lang.Object target, java.lang.String methodName, int maxIntegerDigits, int maxFractionDigits)
          Creates a HistogramItem with specified name to be displayed by this OpenHistogram.
 void createHistogramItem(java.lang.String name, java.util.List list, java.lang.String listObjMethodName)
          Creates a HistogramItem to be displayed by this OpenHistogram.
 void createHistogramItem(java.lang.String name, java.util.List list, java.lang.String listObjMethodName, int maxIntegerDigits, int maxFractionDigits)
          Creates a HistogramItem to be displayed by this OpenHistogram.
 void record()
          Records data from the HistogramItems without updating the display
 void step()
          Records any new data and updates the displayed graph.
 void updateGraph()
          Updates the graph.
 
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, takeSnapshot, updateXTick, zoom
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OpenHistogram

public OpenHistogram(java.lang.String title,
                     int numBins,
                     long lowerBound)
Constructs an OpenHistogram with the specified title, the specified number of bins, and the specified lowerBound. A lowerBound higher than any expected data values will cause that data not to be included in the histogram.

Parameters:
title - the title of the histogram
numBins - the number of bins
lowerBound - the lower bound of the histogram

OpenHistogram

public OpenHistogram(java.lang.String title,
                     int numBins,
                     long lowerBound,
                     SimModel model)
Constructs an OpenHistogram with the specified title, the specified number of bins, and the specified lowerBound. A lowerBound higher than any expected data values will cause that data not to be included in the histogram. Model parameter necessary if you want to take snapshots or movies of this graph.

Parameters:
title - the title of the histogram
numBins - the number of bins
lowerBound - the lower bound of the histogram
model - the model associated with this graph
Method Detail

createHistogramItem

public void createHistogramItem(java.lang.String name,
                                java.util.List list,
                                BinDataSource source)
Creates a HistogramItem with specified name, list and BinDataSource to be displayed by this Histogram. The HistogramItem iterates over the specified list passing each Object in the list as argument to the getBinValue method of the BinDataSource. This getBinValue method returns a double. All these doubles are then distributed across the bins according to the number of bins, the lower bound, and the maximum value. For example, given 2 bins, a lower bound of 0 and a maximum value of 4. The first bin will contain all the values from 0 up to but not including 2, and the final bin will contain all the values from 2 up to and including 4. The displayed bin value (i.e. the height of the bar in the chart) is the number of values that fall within this bin.

Note: This creates a Histogram that updates faster than those created with createHistogramItem(String name, List list, String methodName). Consequently, it should be preferred over the other method.

Parameters:
name - the name of the item
list - the list of objects that provided the data for the item
source - the BinDataSource used to get the data from the objects in the list.

createHistogramItem

public void createHistogramItem(java.lang.String name,
                                java.util.List list,
                                java.lang.Object target,
                                java.lang.String methodName)
Creates a HistogramItem with specified name to be displayed by this OpenHistogram. The HistogramItem iterates over the specified list passing each Object in the list as argument to the method with the specified name. This method is a method of the specified object and returns a double. All these doubles are then distributed across the bins according to the number of bins, the lower bound, and the maximum value. For example, given 2 bins, a lower bound of 0 and a maximum value of 4. The first bin will contain all the values from 0 up to but not including 2, and the final bin will contain all the values from 2 up to and including 4. The displayed bin value (i.e. the height of the bar in the chart) is the number of values that fall within this bin.

Parameters:
name - the name of the item
list - the list of objects that provided the data for the item
target - the target of the name method
methodName - the name of the method to call and pass each object in the list to

createHistogramItem

public void createHistogramItem(java.lang.String name,
                                java.util.List list,
                                java.lang.Object target,
                                java.lang.String methodName,
                                int maxIntegerDigits,
                                int maxFractionDigits)
Creates a HistogramItem with specified name to be displayed by this OpenHistogram. The HistogramItem iterates over the specified list passing each Object in the list as argument to the method with the specified name. This method is a method of the specified object and returns a double. All these doubles are then distributed across the bins according to the number of bins, the lower bound, and the maximum value. For example, given 2 bins, a lower bound of 0 and a maximum value of 4. The first bin will contain all the values from 0 up to but not including 2, and the final bin will contain all the values from 2 up to and including 4. The displayed bin value (i.e. the height of the bar in the chart) is the number of values that fall within this bin.

Parameters:
name - the name of the item
list - the list of objects that provided the data for the item
target - the target of the name method
methodName - the name of the method to call and pass each object in the list to
maxIntegerDigits - the maximum number of digits before the decimal point in the bin labels. A value of -1 will record all the digits.
maxFractionDigits - the maximum number of digits after the decimal point in the bin labels. A value of -1 will record all the digits.

createHistogramItem

public void createHistogramItem(java.lang.String name,
                                java.util.List list,
                                BinDataSource source,
                                int maxIntegerDigits,
                                int maxFractionDigits)
Creates a HistogramItem with specified name, list and BinDataSource to be displayed by this Histogram. The HistogramItem iterates over the specified list passing each Object in the list as argument to the getBinValue method of the BinDataSource. This getBinValue method returns a double. All these doubles are then distributed across the bins according to the number of bins, the lower bound, and the maximum value. For example, given 2 bins, a lower bound of 0 and a maximum value of 4. The first bin will contain all the values from 0 up to but not including 2, and the final bin will contain all the values from 2 up to and including 4. The displayed bin value (i.e. the height of the bar in the chart) is the number of values that fall within this bin.

Parameters:
name - the name of the item
list - the list of objects that provided the data for the item
source - the BinDataSource used to get the data from the objects in the list.
maxIntegerDigits - the maximum number of digits before the decimal point in the bin labels. A value of -1 will record all the digits.
maxFractionDigits - the maximum number of digits after the decimal point in the bin labels. A value of -1 will record all the digits.

createHistogramItem

public void createHistogramItem(java.lang.String name,
                                java.util.List list,
                                java.lang.String listObjMethodName)
Creates a HistogramItem to be displayed by this OpenHistogram. The HistogramItem iterates over the specified list calling the specified method on each object in the list. This method must return a value that can be cast into a double (i.e. float, int, double, short, etc.). These values are then distributed across the bins according to the number of bins, the lower bound, and the maximum value. For example, given 2 bins, a lower bound of 0 and a maximum value of 4. The first bin will contain all the values from 0 up to but not including 2, and the final bin will contain all the values from 2 up to and including 4. The displayed bin value (i.e. the height of the bar in the chart) is the number of values that fall within this bin.

Note: This creates a Histogram that updates more slowly than that created with createHistogramItem(String name, List list, BinDataSource source). Consequently, this method should not be used unless the Histogram will be updated infrequently.

Parameters:
name - the name of this item
list - the list of object on which the specified method is called
listObjMethodName - the name of the method to call on the objects. Should return a Number value.
See Also:
HistogramItem

createHistogramItem

public void createHistogramItem(java.lang.String name,
                                java.util.List list,
                                java.lang.String listObjMethodName,
                                int maxIntegerDigits,
                                int maxFractionDigits)
Creates a HistogramItem to be displayed by this OpenHistogram. The HistogramItem iterates over the specified list calling the specified method on each object in the list. This method must return a value that can be cast into a double (i.e. float, int, double, short, etc.). These values are then distributed across the bins according to the number of bins, the lower bound, and the maximum value. For example, given 2 bins, a lower bound of 0 and a maximum value of 4. The first bin will contain all the values from 0 up to but not including 2, and the final bin will contain all the values from 2 up to and including 4. The displayed bin value (i.e. the height of the bar in the chart) is the number of values that fall within this bin.

Note: This creates a Histogram that updates more slowly than that created with createHistogramItem(String name, List list, BinDataSource source). Consequently, this method should not be used unless the Histogram will be updated infrequently.

Parameters:
name - the name of this item
list - the list of object on which the specified method is called
listObjMethodName - the name of the method to call on the objects. Should return a Number value.
maxIntegerDigits - the maximum number of digits before the decimal point in the bin labels. A value of -1 will record all the digits.
maxFractionDigits - the maximum number of digits after the decimal point in the bin labels. A value of -1 will record all the digits.
See Also:
HistogramItem

record

public void record()
Records data from the HistogramItems without updating the display

Specified by:
record in class OpenGraph

step

public void step()
Records any new data and updates the displayed graph.

Overrides:
step in class OpenGraph

updateGraph

public void updateGraph()
Updates the graph.

Specified by:
updateGraph in class OpenGraph