|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.Observable org.ascape.util.VectorSelection
public class 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 FormField Summary | |
---|---|
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. |
int |
getSelectedIndex(java.lang.Object object)
|
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 |
moveToBack(java.lang.Object elem)
|
void |
moveToFront(java.lang.Object elem)
|
void |
removeElement(java.lang.Object object)
Removes an elemnt from the underlying vector. |
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
Constructor Detail |
---|
public VectorSelection()
public VectorSelection(java.util.Vector vector)
vector
- the underlying vectorMethod 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)
object
- the object to addselect
- should the object be intitially selected?public void removeElement(java.lang.Object object)
object
- the object to addpublic void addElement(java.lang.Object object)
public boolean isSelected(java.lang.Object elem)
elem
- the object to determine selection status for
public boolean isSelected(int index)
index
- the vector index of the object to determine selection status for
public 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 forpublic 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 itpublic 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
java.lang.ClassCastException
- if vector elements are not instances of HaveNamepublic void setSelected(java.lang.Object elem, boolean select)
elem
- the object to set selection status forselect
- true to select the item, false to unselect it
java.lang.RuntimeException
- if the element does not exist in the vectorpublic int getSelectionSize()
public int getIndexInVector(int index)
index
- the selection index to get the vector index forpublic int getSelectedIndex(java.lang.Object object)
public java.lang.Object getSelectedElement(int index)
index
- the index in this selection of the seriespublic void update(java.util.Observable observed, java.lang.Object arg)
update
in interface java.util.Observer
public void update()
public java.lang.Object clone()
clone
in class java.lang.Object
public void moveToFront(java.lang.Object elem)
public void moveToBack(java.lang.Object elem)
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |