public class DefaultGraphSelectionModel extends java.lang.Object implements GraphSelectionModel, java.lang.Cloneable, java.io.Serializable
Modifier and Type | Class and Description |
---|---|
protected class |
DefaultGraphSelectionModel.CellPlaceHolder
Holds a path and whether or not it is new.
|
Modifier and Type | Field and Description |
---|---|
protected java.util.Map |
cellStates
Maps the cells to their selection state.
|
protected javax.swing.event.SwingPropertyChangeSupport |
changeSupport
Used to message registered listeners.
|
protected boolean |
childrenSelectable
Boolean that indicates if the model allows stepping-into groups.
|
protected JGraph |
graph
Reference to the parent graph.
|
protected javax.swing.event.EventListenerList |
listenerList
Event listener list.
|
static int |
SELECTED
Value that represents selected state in cellStates.
|
protected java.util.Set |
selection
List that contains the selected items.
|
static java.lang.String |
SELECTION_MODE_PROPERTY
Property name for selectionMode.
|
protected int |
selectionMode
Mode for the selection, will be either SINGLE_TREE_SELECTION,
CONTIGUOUS_TREE_SELECTION or DISCONTIGUOUS_TREE_SELECTION.
|
static java.lang.Integer |
UNSELECTED
Object value that represents the unselected state in cellStates.
|
MULTIPLE_GRAPH_SELECTION, SINGLE_GRAPH_SELECTION
Constructor and Description |
---|
DefaultGraphSelectionModel(JGraph graph)
Constructs a DefaultGraphSelectionModel for the specified graph.
|
Modifier and Type | Method and Description |
---|---|
void |
addGraphSelectionListener(GraphSelectionListener x)
Adds x to the list of listeners that are notified each time the set of
selected TreePaths changes.
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list.
|
void |
addSelectionCell(java.lang.Object cell)
Adds the specified cell to the current selection
|
void |
addSelectionCells(java.lang.Object[] cells)
Adds cells to the current selection.
|
void |
clearSelection()
Empties the current selection.
|
java.lang.Object |
clone()
Returns a clone of this object with the same selection.
|
protected boolean |
deselect(java.lang.Object cell)
Deselects a single cell and updates all datastructures.
|
protected void |
fireValueChanged(GraphSelectionEvent e)
Notifies all listeners that are registered for tree selection events on
this object.
|
java.util.EventListener[] |
getListeners(java.lang.Class listenerType)
Returns an array of all the listeners of the given type that were added
to this model.
|
java.lang.Object[] |
getSelectables()
Returns the cells that are currently selectable.
|
protected int |
getSelectedChildCount(java.lang.Object cell)
Returns the number of selected childs for
cell . |
java.lang.Object |
getSelectionCell()
Returns the first cell in the selection.
|
java.lang.Object[] |
getSelectionCells()
Returns the cells in the selection.
|
int |
getSelectionCount()
Returns the number of paths that are selected.
|
int |
getSelectionMode()
Returns the selection mode, one of
SINGLE_TREE_SELECTION ,
DISCONTIGUOUS_TREE_SELECTION or
CONTIGUOUS_TREE_SELECTION . |
boolean |
isCellSelected(java.lang.Object cell)
Returns true if the cell,
cell , is in the current
selection. |
boolean |
isChildrenSelectable()
Returns true if the selection model allows the selection of children.
|
protected boolean |
isChildrenSelectable(java.lang.Object cell)
Hook for subclassers for fine-grained control over stepping-into cells.
|
boolean |
isChildrenSelected(java.lang.Object cell)
Returns true if the cell,
cell , has selected children. |
boolean |
isSelectionEmpty()
Returns true if the selection is currently empty.
|
protected void |
notifyCellChange(java.util.Vector changedCells)
Notifies listeners of a change in path.
|
void |
removeGraphSelectionListener(GraphSelectionListener x)
Removes x from the list of listeners that are notified each time the set
of selected TreePaths changes.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list.
|
void |
removeSelectionCell(java.lang.Object cell)
Removes the specified cell from the selection.
|
void |
removeSelectionCells(java.lang.Object[] cells)
Removes the specified cells from the selection.
|
protected boolean |
select(java.util.Set set,
java.lang.Object cell)
Selects a single cell and updates all datastructures.
|
void |
setChildrenSelectable(boolean flag)
Sets if the selection model allows the selection of children.
|
protected void |
setSelectedChildCount(java.lang.Object cell,
int count)
Sets the number of selected childs for
cell to
count . |
void |
setSelectionCell(java.lang.Object cell)
Selects the specified cell.
|
void |
setSelectionCells(java.lang.Object[] cells)
Sets the selection to
cells . |
void |
setSelectionMode(int mode)
Sets the selection mode, which must be one of SINGLE_TREE_SELECTION,
|
public static final java.lang.String SELECTION_MODE_PROPERTY
public static final int SELECTED
public static final java.lang.Integer UNSELECTED
protected JGraph graph
protected javax.swing.event.SwingPropertyChangeSupport changeSupport
protected javax.swing.event.EventListenerList listenerList
protected int selectionMode
protected boolean childrenSelectable
protected java.util.Map cellStates
protected java.util.Set selection
public DefaultGraphSelectionModel(JGraph graph)
public void setSelectionMode(int mode)
setSelectionMode
in interface GraphSelectionModel
public int getSelectionMode()
SINGLE_TREE_SELECTION
,
DISCONTIGUOUS_TREE_SELECTION
or
CONTIGUOUS_TREE_SELECTION
.getSelectionMode
in interface GraphSelectionModel
public void setChildrenSelectable(boolean flag)
setChildrenSelectable
in interface GraphSelectionModel
public boolean isChildrenSelectable()
isChildrenSelectable
in interface GraphSelectionModel
protected boolean isChildrenSelectable(java.lang.Object cell)
childrenSelectable
&&
isCellSelected.public void setSelectionCell(java.lang.Object cell)
setSelectionCell
in interface GraphSelectionModel
cell
- the cell to selectpublic void setSelectionCells(java.lang.Object[] cells)
cells
. 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.setSelectionCells
in interface GraphSelectionModel
cells
- new selectionpublic void addSelectionCell(java.lang.Object cell)
addSelectionCell
in interface GraphSelectionModel
cell
- the cell to add to the current selectionpublic void addSelectionCells(java.lang.Object[] cells)
addSelectionCells
in interface GraphSelectionModel
cells
- the cells to be added to the current selectionpublic void removeSelectionCell(java.lang.Object cell)
removeSelectionCell
in interface GraphSelectionModel
cell
- the cell to remove from the current selectionpublic void removeSelectionCells(java.lang.Object[] cells)
removeSelectionCells
in interface GraphSelectionModel
cells
- the cells to remove from the current selectionpublic java.lang.Object[] getSelectables()
getSelectables
in interface GraphSelectionModel
public java.lang.Object getSelectionCell()
getSelectionCell
in interface GraphSelectionModel
public java.lang.Object[] getSelectionCells()
getSelectionCells
in interface GraphSelectionModel
public int getSelectionCount()
getSelectionCount
in interface GraphSelectionModel
public boolean isCellSelected(java.lang.Object cell)
cell
, is in the current
selection.isCellSelected
in interface GraphSelectionModel
public boolean isChildrenSelected(java.lang.Object cell)
cell
, has selected children.isChildrenSelected
in interface GraphSelectionModel
public boolean isSelectionEmpty()
isSelectionEmpty
in interface GraphSelectionModel
public void clearSelection()
clearSelection
in interface GraphSelectionModel
protected int getSelectedChildCount(java.lang.Object cell)
cell
.protected void setSelectedChildCount(java.lang.Object cell, int count)
cell
to
count
.protected boolean select(java.util.Set set, java.lang.Object cell)
protected boolean deselect(java.lang.Object cell)
public void addGraphSelectionListener(GraphSelectionListener x)
addGraphSelectionListener
in interface GraphSelectionModel
x
- the new listener to be addedpublic void removeGraphSelectionListener(GraphSelectionListener x)
removeGraphSelectionListener
in interface GraphSelectionModel
x
- the listener to removeprotected void fireValueChanged(GraphSelectionEvent e)
addGraphSelectionListener(org.jgraph.event.GraphSelectionListener)
,
EventListenerList
public java.util.EventListener[] getListeners(java.lang.Class listenerType)
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
A PropertyChangeEvent will get fired when the selection mode changes.
addPropertyChangeListener
in interface GraphSelectionModel
listener
- the PropertyChangeListener to be addedpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener
in interface GraphSelectionModel
listener
- the PropertyChangeListener to be removedprotected void notifyCellChange(java.util.Vector changedCells)
changePaths
should
contain instances of PathPlaceHolder.public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- never thrown by instances of this classCopyright (C) 2001-2009 JGraph Ltd. All rights reserved.