JGraph | |
Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.jgraph.graph.DefaultGraphSelectionModel
public class DefaultGraphSelectionModel
extends java.lang.Object
implements GraphSelectionModel, Cloneable, Serializable
Nested Class Summary | |
protected class |
|
Field Summary | |
static int |
|
static String |
|
static Integer |
|
protected Map |
|
protected SwingPropertyChangeSupport |
|
protected boolean |
|
protected JGraph |
|
protected EventListenerList |
|
protected Set |
|
protected int |
|
Fields inherited from interface org.jgraph.graph.GraphSelectionModel | |
MULTIPLE_GRAPH_SELECTION , SINGLE_GRAPH_SELECTION |
Constructor Summary | |
|
Method Summary | |
void |
|
void |
|
void |
|
void |
|
void |
|
Object |
|
protected boolean |
|
protected void |
|
EventListener[] |
|
Object[] |
|
protected int |
|
Object |
|
Object[] |
|
int |
|
int |
|
boolean |
|
boolean |
|
protected boolean |
|
boolean |
|
boolean |
|
protected void |
|
void |
|
void |
|
void |
|
void |
|
protected boolean |
|
void |
|
protected void |
|
void |
|
void |
|
void |
|
public static final int SELECTED
Value that represents selected state in cellStates.
- Field Value:
- -1
public static final String SELECTION_MODE_PROPERTY
Property name for selectionMode.
public static final Integer UNSELECTED
Object value that represents the unselected state in cellStates.
protected Map cellStates
Maps the cells to their selection state.
protected SwingPropertyChangeSupport changeSupport
Used to message registered listeners.
protected boolean childrenSelectable
Boolean that indicates if the model allows stepping-into groups.
protected EventListenerList listenerList
Event listener list.
protected Set selection
List that contains the selected items.
protected int selectionMode
Mode for the selection, will be either SINGLE_TREE_SELECTION, CONTIGUOUS_TREE_SELECTION or DISCONTIGUOUS_TREE_SELECTION.
public DefaultGraphSelectionModel(JGraph graph)
Constructs a DefaultGraphSelectionModel for the specified graph.
public void addGraphSelectionListener(GraphSelectionListener x)
Adds x to the list of listeners that are notified each time the set of selected TreePaths changes.
- Specified by:
- addGraphSelectionListener in interface GraphSelectionModel
- Parameters:
x
- the new listener to be added
public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. The listener is registered for all properties. A PropertyChangeEvent will get fired when the selection mode changes.
- Specified by:
- addPropertyChangeListener in interface GraphSelectionModel
- Parameters:
listener
- the PropertyChangeListener to be added
public void addSelectionCell(Object cell)
Adds the specified cell to the current selection
- Specified by:
- addSelectionCell in interface GraphSelectionModel
- Parameters:
cell
- the cell to add to the current selection
public void addSelectionCells(Object[] cells)
Adds cells to the current selection.
- Specified by:
- addSelectionCells in interface GraphSelectionModel
- Parameters:
cells
- the cells to be added to the current selection
public void clearSelection()
Empties the current selection. If this represents a change in the current selection, the selection listeners are notified.
- Specified by:
- clearSelection in interface GraphSelectionModel
public Object clone() throws CloneNotSupportedException
Returns a clone of this object with the same selection. This method does not duplicate selection listeners and property listeners.
protected boolean deselect(Object cell)
Deselects a single cell and updates all datastructures. No listeners are notified.
protected void fireValueChanged(GraphSelectionEvent e)
Notifies all listeners that are registered for tree selection events on this object.
- See Also:
addGraphSelectionListener(GraphSelectionListener)
,EventListenerList
public EventListener[] getListeners(Class listenerType)
Returns an array of all the listeners of the given type that were added to this model.
- Returns:
- all of the objects receiving listenerType notifications from this model
- Since:
- 1.3
public Object[] getSelectables()
Returns the cells that are currently selectable. The array is ordered so that the top-most cell appears first.
- Specified by:
- getSelectables in interface GraphSelectionModel
protected int getSelectedChildCount(Object cell)
Returns the number of selected childs forcell
.
public Object getSelectionCell()
Returns the first cell in the selection. This is useful if there if only one item currently selected.
- Specified by:
- getSelectionCell in interface GraphSelectionModel
public Object[] getSelectionCells()
Returns the cells in the selection. This will return null (or an empty array) if nothing is currently selected.
- Specified by:
- getSelectionCells in interface GraphSelectionModel
public int getSelectionCount()
Returns the number of paths that are selected.
- Specified by:
- getSelectionCount in interface GraphSelectionModel
public int getSelectionMode()
Returns the selection mode, one ofSINGLE_TREE_SELECTION
,DISCONTIGUOUS_TREE_SELECTION
orCONTIGUOUS_TREE_SELECTION
.
- Specified by:
- getSelectionMode in interface GraphSelectionModel
public boolean isCellSelected(Object cell)
Returns true if the cell,cell
, is in the current selection.
- Specified by:
- isCellSelected in interface GraphSelectionModel
public boolean isChildrenSelectable()
Returns true if the selection model allows the selection of children.
- Specified by:
- isChildrenSelectable in interface GraphSelectionModel
protected boolean isChildrenSelectable(Object cell)
Hook for subclassers for fine-grained control over stepping-into cells. This implementation returnschildrenSelectable
&& isCellSelected.
public boolean isChildrenSelected(Object cell)
Returns true if the cell,cell
, has selected children.
- Specified by:
- isChildrenSelected in interface GraphSelectionModel
public boolean isSelectionEmpty()
Returns true if the selection is currently empty.
- Specified by:
- isSelectionEmpty in interface GraphSelectionModel
protected void notifyCellChange(Vector changedCells)
Notifies listeners of a change in path.changePaths
should contain instances of PathPlaceHolder.
public void removeGraphSelectionListener(GraphSelectionListener x)
Removes x from the list of listeners that are notified each time the set of selected TreePaths changes.
- Specified by:
- removeGraphSelectionListener in interface GraphSelectionModel
- Parameters:
x
- the listener to remove
public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.
- Specified by:
- removePropertyChangeListener in interface GraphSelectionModel
- Parameters:
listener
- the PropertyChangeListener to be removed
public void removeSelectionCell(Object cell)
Removes the specified cell from the selection.
- Specified by:
- removeSelectionCell in interface GraphSelectionModel
- Parameters:
cell
- the cell to remove from the current selection
public void removeSelectionCells(Object[] cells)
Removes the specified cells from the selection.
- Specified by:
- removeSelectionCells in interface GraphSelectionModel
- Parameters:
cells
- the cells to remove from the current selection
protected boolean select(Set set, Object cell)
Selects a single cell and updates all datastructures. No listeners are notified. Override this method to control individual cell selection.
public void setChildrenSelectable(boolean flag)
Sets if the selection model allows the selection of children.
- Specified by:
- setChildrenSelectable in interface GraphSelectionModel
protected void setSelectedChildCount(Object cell, int count)
Sets the number of selected childs forcell
tocount
.
public void setSelectionCell(Object cell)
Selects the specified cell.
- Specified by:
- setSelectionCell in interface GraphSelectionModel
- Parameters:
cell
- the cell to select
public void setSelectionCells(Object[] cells)
Sets the selection tocells
. If this represents a change the GraphSelectionListeners are notified. Potentially paths will be held by this object; in other words don't change any of the objects in the array once passed in.
- Specified by:
- setSelectionCells in interface GraphSelectionModel
- Parameters:
cells
- new selection
public void setSelectionMode(int mode)
Sets the selection mode, which must be one of SINGLE_TREE_SELECTION,
- Specified by:
- setSelectionMode in interface GraphSelectionModel