|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.util.Observable
|
+--edu.brook.ascape.util.VectorSelection
A selection imposed on a Vector. Methods are provided for selecting elements, and notifying observers of changes in selction status, but not changes in the underlying vector class. (This class will be generalized for all collections, and collection observer functionality will probably be provided when collections are integrated into the main engine, which should happen after Java 2 (JDK 1.2) becomes commonplace.) Important: because Vectors are not observable, underlying vectors must call the update method on any enclosing vector selection if any changes are made to them. If you want to be able to select Vector elements based on name, implement the HasName interface. Should be thread safe, but not tested. Performance emphasis is on accessing selected elements, not setting selection. Accessing selected elements should be quite fast since an array of selected elements is stored locally.
HasName,
DataSelection, Serialized Form| Field Summary | |
protected boolean[] |
elemsSelected
An array for selection status for all elements in the vector. |
protected int |
selectedCount
The number of elements currently selected. |
protected java.lang.Object[] |
selectedElems
An array of selected elements of the vector. |
protected java.util.Vector |
vector
The underlying vector that we are imposing a seleciton upon. |
| Constructor Summary | |
VectorSelection()
Construct a new VectorSelection. |
|
VectorSelection(java.util.Vector vector)
Construct a new VectorSelection. |
|
| Method Summary | |
void |
addElement(java.lang.Object object)
Add an elelemnt to the underlying vector. |
void |
addElement(java.lang.Object object,
boolean select)
Add an elelemnt to the underlying vector. |
void |
clear()
Sets selection to none, unselecting every element in the vector. |
void |
clearSelection()
Sets selection to none, unselecting every element in the vector. |
java.lang.Object |
clone()
Performs shallow copy, cloning this vector selection, with a shared backing vector. |
int |
getIndexInVector(int index)
Returns the index in the vector of the object at the provided selection index. |
java.lang.Object |
getSelectedElement(int index)
Returns the object at the provided selection index. |
java.lang.Object[] |
getSelection()
Returns the current complete seleciton of vector elements. |
int |
getSelectionSize()
Returns the number of selected elements. |
java.util.Vector |
getVector()
Returns the underlying vector. |
boolean |
isSelected(int index)
Is the object at the supplied index selected in this selection? |
boolean |
isSelected(java.lang.Object elem)
Is the supplied object selected in this selection? |
void |
select(java.lang.String name)
Selects the object with the supplied name. |
void |
selectAll()
Selects every element in the vector. |
void |
setSelected(int index,
boolean select)
Sets the object at the supplied index to the selection status indicated. |
void |
setSelected(java.lang.Object elem,
boolean select)
Sets the supplied object to the selection status indicated. |
void |
setSelected(java.lang.String name,
boolean select)
Sets the object with the supplied name to the selection status indicated. |
void |
setVector(java.util.Vector vector)
Set the underlying vector for this selection. |
java.lang.String |
toString()
Returns a string represention of the vector selection. |
void |
unselect(java.lang.String name)
Unselects the object with the supplied name. |
void |
update()
Updates the entire vector, retaining current element selection status and relative selection order. |
void |
update(java.util.Observable observed,
java.lang.Object arg)
Normally, notifies the selection that a change in the backing vector 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,
wait,
wait,
wait |
| Field Detail |
protected java.util.Vector vector
protected java.lang.Object[] selectedElems
protected boolean[] elemsSelected
protected int selectedCount
| Constructor Detail |
public VectorSelection()
public VectorSelection(java.util.Vector vector)
vector - the underlying vector| Method Detail |
public void setVector(java.util.Vector vector)
public java.util.Vector getVector()
public java.lang.Object[] getSelection()
public void addElement(java.lang.Object object,
boolean select)
the - object to addshould - the object be intitially selected?public void addElement(java.lang.Object object)
public void update()
public boolean isSelected(java.lang.Object elem)
elem - the object to determine selection status forpublic boolean isSelected(int index)
index - the vector index of the object to determine selection status forpublic void selectAll()
public void clearSelection()
public void clear()
public void select(java.lang.String name)
name - the name of the series to set select status forpublic void unselect(java.lang.String name)
name - the name of the series to set select status for
public void setSelected(int index,
boolean select)
index - the vector index of the object to set select status forselect - true to select the item, false to unselect it
public void setSelected(java.lang.String name,
boolean select)
HaveName.name - the name of the series to set select status forselect - true to select the item, false to unselect it
public void setSelected(java.lang.Object elem,
boolean select)
elem - the object to set selection status forselect - true to select the item, false to unselect itpublic int getSelectionSize()
public int getIndexInVector(int index)
index - the selection index to get the vector index forpublic java.lang.Object getSelectedElement(int index)
index - the index in this selection of the series
public void update(java.util.Observable observed,
java.lang.Object arg)
public java.lang.Object clone()
public java.lang.String toString()
|
(c) 1998-2000 The Brookings Insitution Webpage |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||