edu.brook.ascape.view
Class ChartViewModel

java.lang.Object
  |
  +--java.util.Observable
        |
        +--jclass.chart.ChartDataModel
              |
              +--edu.brook.ascape.view.ChartViewModel
Direct Known Subclasses:
HistogramViewModel, PieViewModel, TimeSeriesViewModel

public abstract class ChartViewModel
extends jclass.chart.ChartDataModel
implements ScapeListener, java.util.Observer

Class responsible for proivding data style of a chart view. Requires KLGroup JCChart.

Since:
1.0
Version:
1.0.1
See Also:
Serialized Form

Field Summary
protected  ChartView chart
          The chart view delegating to this model.
protected  DataViewSelection dataSelection
          The selected series for this data model.
protected  java.lang.String name
          The name of the chart.
protected  Scape scape
          The scape the model is primarily viewing; delegated from chart view.
 
Constructor Summary
ChartViewModel()
          Constructs the model.
 
Method Summary
 void addScape(Scape scape)
          Sets the scape to view.
 ChartView getChart()
          Returns the chart view this model is responsible for.
 int getDataInterpretation()
          Data method for JCChart.
 java.lang.Object getDataItem(int row, int column)
          Data method for JCChart.
 DataViewSelection getDataSelection()
          Returns the viewed data group selection for this chart model.
 java.lang.String getName()
          Returns the name of this chart view model.
 int getNumRows()
          Data method for JCChart.
 java.lang.String[] getPointLabels()
          Data method for JCChart.
 Scape getScape()
          Returns the scape this chart views.
 java.lang.String getSeriesLabel(int row)
          Data method for JCChart.
 java.lang.String getSeriesName(int row)
          Data method for JCChart.
 void initialize()
          Provides initial settings for the chart; including colors, min and max, headers, labels, etc..
protected  void onChange()
          Should be called whenever a change is made to the view model that could effect view.
 void onIterate()
          Called when scape is iterated.
 void onSetup()
          Method called when the scape is ready for setup.
 void onStart()
          Method called when the scape is started.
 void onStop()
          Method called when the scape is stopped.
 void onUpdate()
          Called when scape reports an update event.
 void removeScape(Scape scape)
          Removes the scape from this listener.
 void scapeUpdated(ScapeEvent scapeEvent)
          Informs this view model that the scape has been changed.
 void setChart(ChartView chart)
          Sets the chart view this model will be responsible for.
 boolean setDataItem(int row, int column, java.lang.Object o)
          Data method for JCChart.
 void setDataSelection(DataSelection dataSelection)
          Sets the viewed data group selection for this chart model.
 void setName(java.lang.String name)
          Sets the name of this chart view model.
 void update(java.util.Observable observed, java.lang.Object arg)
          Notifies this view model that a change (in the selected group, typically) has occured.
 void updateChart()
          Updates chart selection, color and label settings.
 void updated()
          Called (automatically from paint) when this view has been updated.
 
Methods inherited from class jclass.chart.ChartDataModel
getRow
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scape

protected Scape scape
The scape the model is primarily viewing; delegated from chart view.

dataSelection

protected DataViewSelection dataSelection
The selected series for this data model.

chart

protected ChartView chart
The chart view delegating to this model.

name

protected java.lang.String name
The name of the chart.
Constructor Detail

ChartViewModel

public ChartViewModel()
Constructs the model.
Method Detail

getChart

public ChartView getChart()
Returns the chart view this model is responsible for.

setChart

public void setChart(ChartView chart)
Sets the chart view this model will be responsible for.
Parameters:
chart - the chart view

getDataSelection

public DataViewSelection getDataSelection()
Returns the viewed data group selection for this chart model.

setDataSelection

public void setDataSelection(DataSelection dataSelection)
Sets the viewed data group selection for this chart model.

initialize

public void initialize()
Provides initial settings for the chart; including colors, min and max, headers, labels, etc..

updateChart

public void updateChart()
Updates chart selection, color and label settings.

onIterate

public void onIterate()
Called when scape is iterated.

onUpdate

public void onUpdate()
Called when scape reports an update event. (No need to call this method after updating panel.)

onSetup

public void onSetup()
Method called when the scape is ready for setup.

onStop

public void onStop()
Method called when the scape is stopped.

onStart

public void onStart()
Method called when the scape is started.

setDataItem

public boolean setDataItem(int row,
                           int column,
                           java.lang.Object o)
Data method for JCChart. Unused, throws RuntimeException if used. (So don't call it!)
Overrides:
setDataItem in class jclass.chart.ChartDataModel

getDataItem

public java.lang.Object getDataItem(int row,
                                    int column)
Data method for JCChart.
Overrides:
getDataItem in class jclass.chart.ChartDataModel

getDataInterpretation

public int getDataInterpretation()
Data method for JCChart. Returns ARRAY as default.
Overrides:
getDataInterpretation in class jclass.chart.ChartDataModel

getNumRows

public int getNumRows()
Data method for JCChart.
Overrides:
getNumRows in class jclass.chart.ChartDataModel

getPointLabels

public java.lang.String[] getPointLabels()
Data method for JCChart. Returns null by default.
Overrides:
getPointLabels in class jclass.chart.ChartDataModel

getSeriesName

public java.lang.String getSeriesName(int row)
Data method for JCChart. Returns series name.
Overrides:
getSeriesName in class jclass.chart.ChartDataModel

getSeriesLabel

public java.lang.String getSeriesLabel(int row)
Data method for JCChart. Returns series name.
Overrides:
getSeriesLabel in class jclass.chart.ChartDataModel

getName

public java.lang.String getName()
Returns the name of this chart view model. Not currently used.
Overrides:
getName in class jclass.chart.ChartDataModel

setName

public void setName(java.lang.String name)
Sets the name of this chart view model. Not currently used.

getScape

public Scape getScape()
Returns the scape this chart views.

addScape

public void addScape(Scape scape)
              throws java.util.TooManyListenersException
Sets the scape to view. Note that it doesn't really matter what scape you add, as the chart view model will have access to every statistic available for the entire model, but all views still need to be controlled by one particular scape. One and only one scape may be added.
Specified by:
addScape in interface ScapeListener
Parameters:
the - scape this chart is viewing

removeScape

public void removeScape(Scape scape)
Removes the scape from this listener. Null expected.
Specified by:
removeScape in interface ScapeListener
Parameters:
scape - the scape to remove

onChange

protected void onChange()
Should be called whenever a change is made to the view model that could effect view.

scapeUpdated

public void scapeUpdated(ScapeEvent scapeEvent)
Informs this view model that the scape has been changed. Called for any changes, but most typically for setup, iteration, and model run state changes.
Specified by:
scapeUpdated in interface ScapeListener

updated

public void updated()
Called (automatically from paint) when this view has been updated. The view calls its observed scape and notifies it that the view has finished updating its state.

update

public void update(java.util.Observable observed,
                   java.lang.Object arg)
Notifies this view model that a change (in the selected group, typically) has occured.
Specified by:
update in interface java.util.Observer

(c) 1998-2000 The Brookings Insitution
Webpage