org.ascape.util.data
Class DataSelection

java.lang.Object
  extended by java.util.Observable
      extended by org.ascape.util.data.DataSelection
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Observer
Direct Known Subclasses:
DataViewSelection

public class DataSelection
extends java.util.Observable
implements java.util.Observer, java.lang.Cloneable, java.io.Serializable

A selection of a group of data series, useful for providing some subset of available data. Methods are provided for selecting data and notifying observers of changes in the selection. Shares much the same interface with VectorSelection, and they will probably be integrated once collections comes into use.

Since:
1.0
Version:
1.0.1
Author:
Miles Parker
See Also:
VectorSelection, Serialized Form

Field Summary
protected  DataGroup dataGroup
          The backing data group for this selection.
 
Constructor Summary
DataSelection()
           
 
Method Summary
 void clearSelection()
          Sets selection to none, unselecting every series in the data group.
 java.lang.Object clone()
          Clones this selectable data group, retaining the original's data group, and copying selection.
 DataGroup getData()
          Returns the backing data group.
 int getIndexOfSelectedIndex(int index)
          Returns the index in the backing data group of the series at the selection index.
 double getMax()
          Returns the maximum value across all series in the selection.
 double getMin()
          Returns the minimum value across all series in the selection.
 int getSelectedIndexOf(java.lang.String name)
          Returns the index in the backing data group of the series at the selection index.
 java.lang.String getSelectedName(int index)
          Returns the name of the series at the selection index.
 java.util.List getSelectedSeries()
          Returns a list of all selected series.
 DataSeries getSelectedSeries(int index)
          Returns the series at the selection index.
 java.util.Vector getSelectedSeriesData(int index)
          Returns the data, as a vector, of the serties at the selection index.
 int getSelectionSize()
          Returns the number of selected series.
 boolean isSelected(DataSeries series)
          Is the supplied series selected in this selection?
 boolean isSelected(int index)
          Is the series at the supplied index selected in this selection?
 void selectAll()
          Selects every series in the data group.
 void setData(DataGroup dataGroup)
          Sets the backing data group for this selection.
 void setSelected(DataSeries series, boolean select)
          Sets the supplied series to the selection status indicated.
 void setSelected(int index, boolean select)
          Sets the series at the supplied index to the selection status indicated.
 void setSelected(java.lang.String name, boolean select)
          Sets the series at the supplied index to the selection status indicated.
 void update()
          Updates the selection in response to a change in the data group.
 void update(java.util.Observable observed, java.lang.Object arg)
          Notifies this selection that a change in the backing data group has occured.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataGroup

protected DataGroup dataGroup
The backing data group for this selection.

Constructor Detail

DataSelection

public DataSelection()
Method Detail

getData

public DataGroup getData()
Returns the backing data group.


setData

public void setData(DataGroup dataGroup)
Sets the backing data group for this selection. Adds this selection as a n observer of its data group. Initializes the selection.

Parameters:
dataGroup - the data group this object is a selection of

update

public void update()
Updates the selection in response to a change in the data group.


isSelected

public boolean isSelected(DataSeries series)
Is the supplied series selected in this selection?

Parameters:
series - the series to determine selection status for
Returns:
true if the item is selected, false if the item is not selected or is not in the list

isSelected

public boolean isSelected(int index)
Is the series at the supplied index selected in this selection?

Parameters:
index - the data group index of the series to determine selection status for
Returns:
true if the item is selected

selectAll

public void selectAll()
Selects every series in the data group.


clearSelection

public void clearSelection()
Sets selection to none, unselecting every series in the data group.


setSelected

public void setSelected(int index,
                        boolean select)
Sets the series at the supplied index to the selection status indicated.

Parameters:
index - the data group index of the series to set select status for
select - true to select the item, false to unselect it

setSelected

public void setSelected(java.lang.String name,
                        boolean select)
Sets the series at the supplied index to the selection status indicated.

Parameters:
name - the name of the series to set select status for
select - true to select the item, false to unselect it

setSelected

public void setSelected(DataSeries series,
                        boolean select)
Sets the supplied series to the selection status indicated.

Parameters:
series - the series to set selection status for
select - true to select the item, false to unselect it

getSelectionSize

public int getSelectionSize()
Returns the number of selected series.


getIndexOfSelectedIndex

public int getIndexOfSelectedIndex(int index)
Returns the index in the backing data group of the series at the selection index.

Parameters:
index - the selected series to get the backing group index for

getSelectedIndexOf

public int getSelectedIndexOf(java.lang.String name)
Returns the index in the backing data group of the series at the selection index.

Parameters:
name - the selected series to get the backing group index for

getSelectedName

public java.lang.String getSelectedName(int index)
Returns the name of the series at the selection index.

Parameters:
index - the index in this selection of the series to get the name of

getSelectedSeries

public DataSeries getSelectedSeries(int index)
Returns the series at the selection index.

Parameters:
index - the index in this selection of the series

getSelectedSeries

public java.util.List getSelectedSeries()
Returns a list of all selected series.


getSelectedSeriesData

public java.util.Vector getSelectedSeriesData(int index)
Returns the data, as a vector, of the serties at the selection index. (Convenience method.)

Parameters:
index - the index in this selection of the series

getMax

public double getMax()
Returns the maximum value across all series in the selection.


getMin

public double getMin()
Returns the minimum value across all series in the selection.


update

public void update(java.util.Observable observed,
                   java.lang.Object arg)
Notifies this selection that a change in the backing data group has occured.

Specified by:
update in interface java.util.Observer

clone

public java.lang.Object clone()
Clones this selectable data group, retaining the original's data group, and copying selection.

Overrides:
clone in class java.lang.Object


Copyright © 1998-2008 The Brookings Institution, NuTech Solutions, Metascape, LLC All Rights Reserved.