edu.psu.geovista.app.parvis.model
Class SimpleParallelSpaceModel

java.lang.Object
  extended byedu.psu.geovista.app.parvis.model.SimpleParallelSpaceModel
All Implemented Interfaces:
ParallelSpaceModel
Direct Known Subclasses:
STFDataSet, STFFile

public class SimpleParallelSpaceModel
extends java.lang.Object
implements ParallelSpaceModel

Provides a basic implementation of ParallelSpaceModel. Values are stored in a two-dimensionsl array, labels are stored in arrays.

Version:
0.1
Author:
Flo Ledermann flo@subnet.at

Field Summary
protected  java.lang.String[] axisLabels
          Contains the axis label Strings.
protected  javax.swing.event.EventListenerList listeners
          List to store our event subscribers.
protected  int numDimensions
          Number of dimensions of the model.
protected  java.util.Vector recordLabels
          Contains the record label Strings.
protected  java.util.Hashtable[] valueLabels
          Contains the value label Hashtables.
protected  java.util.Vector values
          Contains the float[] values.
 
Constructor Summary
SimpleParallelSpaceModel()
          Default Constructor.
SimpleParallelSpaceModel(float[][] values)
          Initializes the model with a given float[][] array of values.
 
Method Summary
 void addChangeListener(javax.swing.event.ChangeListener l)
          Subscribes a ChangeListener with the model.
 void addRecord(float[] values)
          Adds a record.
 void addRecord(float[] values, java.lang.String label)
          Adds a record.
 java.lang.String getAxisLabel(int dimension)
          Returns a String label for a specific dimension.
 float getMaxValue(int dimension)
          Returns the maximum value for the given dimension.
 float getMinValue(int dimension)
          Returns the minimum value for the given dimension.
 int getNumDimensions()
          Returns the number of dimnesions.
 int getNumRecords()
          Returns the number of records.
 java.lang.String getRecordLabel(int num)
          Returns a human-readable label for a specific record.
 float getValue(int record, int dimension)
          Returns a specific value of the dataset.
 java.lang.String getValueLabel(int dimension, float value)
          Returns the label for a single value in a specific dimension, if present.
 java.util.Hashtable getValueLabels(int dimension)
          Returns a Hashtable with labels for specific values.
 float[] getValues(int recordnum)
          Returns all values of a specific record.
protected  void initNumDimensions(int num)
          Sets up all internal variables for the given number of dimensions.
 void removeChangeListener(javax.swing.event.ChangeListener l)
          Removes a previously subscribed changeListener.
 void setAxisLabel(int dimension, java.lang.String label)
          Sets the label of a single axis.
 void setAxisLabels(java.lang.String[] labels)
          Sets the labels for all axes.
 void setValueLabel(int dimension, float value, java.lang.String label)
          Sets a single value label for a specific axis.
 void setValueLabels(int dimension, float[] values, java.lang.String[] labels)
          Sets the value labels for a dimension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

values

protected java.util.Vector values
Contains the float[] values.


recordLabels

protected java.util.Vector recordLabels
Contains the record label Strings.


axisLabels

protected java.lang.String[] axisLabels
Contains the axis label Strings.


valueLabels

protected java.util.Hashtable[] valueLabels
Contains the value label Hashtables.


numDimensions

protected int numDimensions
Number of dimensions of the model.


listeners

protected javax.swing.event.EventListenerList listeners
List to store our event subscribers.

Constructor Detail

SimpleParallelSpaceModel

public SimpleParallelSpaceModel()
Default Constructor.


SimpleParallelSpaceModel

public SimpleParallelSpaceModel(float[][] values)
Initializes the model with a given float[][] array of values.

Parameters:
values - A float[][] containing records (first index) with float values for each dimension (second index).
All records must have the same number of dimensions!
Method Detail

addRecord

public void addRecord(float[] values,
                      java.lang.String label)
Adds a record. The record must have the same number of dimensions as the currently stored records.

Parameters:
values - The float values of the record.
label - A String label for the record.

addRecord

public void addRecord(float[] values)
Adds a record. The record must have the same number of dimensions as the currently stored records.

Parameters:
values - The float values of the record.

initNumDimensions

protected void initNumDimensions(int num)
Sets up all internal variables for the given number of dimensions. This must be done only once, usually in the constructor or by the first addRecord(). After the first call the number of dimensions is fixed and cannot be changed!

Parameters:
num - The number of dimensions.

getNumDimensions

public int getNumDimensions()
Returns the number of dimnesions.

Specified by:
getNumDimensions in interface ParallelSpaceModel
Returns:
The number of dimensions of the records in this model.

getNumRecords

public int getNumRecords()
Returns the number of records.

Specified by:
getNumRecords in interface ParallelSpaceModel
Returns:
The number of records currently stored in the model.

getMaxValue

public float getMaxValue(int dimension)
Returns the maximum value for the given dimension.

Specified by:
getMaxValue in interface ParallelSpaceModel
Returns:
Maximum value of all records for the given dimension.

getMinValue

public float getMinValue(int dimension)
Returns the minimum value for the given dimension.

Specified by:
getMinValue in interface ParallelSpaceModel
Returns:
Minimum value of all records for the given dimension.

getValue

public float getValue(int record,
                      int dimension)
Returns a specific value of the dataset.

Specified by:
getValue in interface ParallelSpaceModel
Parameters:
record - The number of the record to be queried.
dimension - The value of the record to be returned.
Returns:
The value specified by record, dimension.

getAxisLabel

public java.lang.String getAxisLabel(int dimension)
Returns a String label for a specific dimension.

Specified by:
getAxisLabel in interface ParallelSpaceModel
Parameters:
dimension - The dimension.
Returns:
A Human-readable label for the dimension.

setAxisLabels

public void setAxisLabels(java.lang.String[] labels)
Sets the labels for all axes. Note that this method is not included in the ParallelSpaceModel interface, which defines only read-only methods. It is used for filling the model before passing it on to a consumer.

Parameters:
labels - An Array of Strings to be used as human-readable labels for the axes.

setAxisLabel

public void setAxisLabel(int dimension,
                         java.lang.String label)
Sets the label of a single axis.

Parameters:
dimension - The dimension this label is for.

getValueLabels

public java.util.Hashtable getValueLabels(int dimension)
Returns a Hashtable with labels for specific values. This is provided for ordinal values, which might be added as keys to the Hashtable, with the corresponding human-readable labels as values.

Specified by:
getValueLabels in interface ParallelSpaceModel
Parameters:
dimension - The dimension to retrieve value labels for.
Returns:
A Hashtable containing value-label pairs.

getValueLabel

public java.lang.String getValueLabel(int dimension,
                                      float value)
Returns the label for a single value in a specific dimension, if present.

Specified by:
getValueLabel in interface ParallelSpaceModel
Parameters:
dimension - The dimension.
value - The value to look up a label for.
Returns:
A String with the label, null if no label is set.

setValueLabels

public void setValueLabels(int dimension,
                           float[] values,
                           java.lang.String[] labels)
Sets the value labels for a dimension. Note that this method is not included in the ParallelSpaceModel interface, which defines only read-only methods. It is used for filling the model before passing it on to a consumer.

Parameters:
dimension - The dimension the labels are to be set for.
values - The values to assign labels to. Note that the number of labels an values must match.
labels - The String labels for the values. Note that the number of labels an values must match.

setValueLabel

public void setValueLabel(int dimension,
                          float value,
                          java.lang.String label)
Sets a single value label for a specific axis.

Parameters:
dimension - The dimension to set the label for.
value - The value to set the label for.
label - The label to set.

getValues

public float[] getValues(int recordnum)
Returns all values of a specific record.

Specified by:
getValues in interface ParallelSpaceModel
Parameters:
recordnum - The number of the record to be returned.
Returns:
All values of the specified record..

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l)
Subscribes a ChangeListener with the model.

Specified by:
addChangeListener in interface ParallelSpaceModel
Parameters:
l - The ChangeListener to be notified when values change.

removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener l)
Removes a previously subscribed changeListener.

Specified by:
removeChangeListener in interface ParallelSpaceModel
Parameters:
l - The ChangeListener to be removed from the model.

getRecordLabel

public java.lang.String getRecordLabel(int num)
Returns a human-readable label for a specific record.

Specified by:
getRecordLabel in interface ParallelSpaceModel
Parameters:
num - The record number.


Copyright © 1996-2003 GeoVista Center. All Rights Reserved.