public class mxGraphSelectionModel extends mxEventSource
edit
property contains the mxUndoableEdit which contains the
mxSelectionChange.
mxEvent.CHANGE fires after the selection changes by executing an
mxSelectionChange. The added
and removed
properties contain Collections of cells that have been added to or removed
from the selection, respectively.
NOTE: Due to a historic bug that cannot be changed at this point the
names of the properties are "reversed".
To add a change listener to the graph selection model:
addListener(
mxEvent.CHANGE, new mxIEventListener()
{
public void invoke(Object sender, mxEventObject evt)
{
mxGraphSelectionModel model = (mxSelectionModel) sender;
Collection added = (Collection) evt.getProperty("added");
Collection removed = (Collection) evt.getProperty("removed");
selectionChanged(model, added, removed);
}
});
Modifier and Type | Class and Description |
---|---|
static class |
mxGraphSelectionModel.mxSelectionChange |
mxEventSource.mxIEventListener
Modifier and Type | Field and Description |
---|---|
protected java.util.Set<java.lang.Object> |
cells
Holds the selection cells.
|
protected mxGraph |
graph
Reference to the enclosing graph.
|
protected boolean |
singleSelection
Specifies if only one selected item at a time is allowed.
|
eventListeners, eventsEnabled, eventSource
Constructor and Description |
---|
mxGraphSelectionModel(mxGraph graph)
Constructs a new selection model for the specified graph.
|
Modifier and Type | Method and Description |
---|---|
void |
addCell(java.lang.Object cell)
Adds the given cell to the selection.
|
void |
addCells(java.lang.Object[] cells) |
protected void |
cellAdded(java.lang.Object cell) |
protected void |
cellRemoved(java.lang.Object cell) |
protected void |
changeSelection(java.util.Collection<java.lang.Object> added,
java.util.Collection<java.lang.Object> removed) |
void |
clear()
Clears the selection.
|
java.lang.Object |
getCell()
Returns the first selected cell.
|
java.lang.Object[] |
getCells()
Returns the selection cells.
|
protected java.lang.Object |
getFirstSelectableCell(java.lang.Object[] cells)
Returns the first selectable cell in the given array of cells.
|
boolean |
isEmpty()
Returns true if no cells are selected.
|
boolean |
isSelected(java.lang.Object cell)
Returns true if the given cell is selected.
|
boolean |
isSingleSelection() |
void |
removeCell(java.lang.Object cell)
Removes the given cell from the selection.
|
void |
removeCells(java.lang.Object[] cells) |
void |
setCell(java.lang.Object cell)
Clears the selection and adds the given cell to the selection.
|
void |
setCells(java.lang.Object[] cells)
Clears the selection and adds the given cells.
|
void |
setSingleSelection(boolean singleSelection) |
int |
size()
Returns the number of selected cells.
|
addListener, fireEvent, fireEvent, getEventSource, isEventsEnabled, removeListener, removeListener, setEventsEnabled, setEventSource
protected mxGraph graph
protected boolean singleSelection
protected java.util.Set<java.lang.Object> cells
public mxGraphSelectionModel(mxGraph graph)
graph
- public boolean isSingleSelection()
public void setSingleSelection(boolean singleSelection)
singleSelection
- the singleSelection to setpublic boolean isSelected(java.lang.Object cell)
cell
- public boolean isEmpty()
public int size()
public void clear()
public java.lang.Object getCell()
public java.lang.Object[] getCells()
public void setCell(java.lang.Object cell)
public void setCells(java.lang.Object[] cells)
protected java.lang.Object getFirstSelectableCell(java.lang.Object[] cells)
cells
- Array of cells to return the first selectable cell for.public void addCell(java.lang.Object cell)
public void addCells(java.lang.Object[] cells)
public void removeCell(java.lang.Object cell)
public void removeCells(java.lang.Object[] cells)
protected void changeSelection(java.util.Collection<java.lang.Object> added, java.util.Collection<java.lang.Object> removed)
protected void cellAdded(java.lang.Object cell)
protected void cellRemoved(java.lang.Object cell)
Copyright (c) 2010-2017 Gaudenz Alder, JGraph Ltd. All rights reserved.