JGraph X 0.15.0.3


com.mxgraph.view
Class mxSelectionModel

java.lang.Object
  extended by com.mxgraph.util.mxEventSource
      extended by com.mxgraph.view.mxSelectionModel

public class mxSelectionModel
extends mxEventSource


Nested Class Summary
static class mxSelectionModel.mxSelectionChange
           
 
Nested classes/interfaces inherited from class com.mxgraph.util.mxEventSource
mxEventSource.mxEventListener, mxEventSource.mxIEventSource
 
Field Summary
protected  Set cells
          Holds the selection cells.
static String EVENT_CHANGE
          Holds the name for the change event.
static String EVENT_UNDO
           
protected  mxGraph graph
          Reference to the enclosing graph.
protected  boolean singleSelection
          Specifies if only one selected item at a time is allowed.
 
Fields inherited from class com.mxgraph.util.mxEventSource
EMPTY_ARRAY, eventListeners, eventsEnabled, source
 
Constructor Summary
mxSelectionModel(mxGraph graph)
          Constructs a new selection model for the specified graph.
 
Method Summary
 void addCell(Object cell)
          Adds the given cell to the selection.
 void addCells(Object[] cells)
           
protected  void cellAdded(Object cell)
           
protected  void cellRemoved(Object cell)
           
protected  void changeSelection(Collection added, Collection removed)
           
 void clear()
          Clears the selection.
 Object getCell()
          Returns the first selected cell.
 Object[] getCells()
          Returns the selection cells.
protected  Object getFirstSelectableCell(Object[] cells)
          Returns the first selectable cell in the given array of cells.
 boolean isEmpty()
          Returns true if no cells are selected.
 boolean isSelected(Object cell)
          Returns true if the given cell is selected.
 boolean isSingleSelection()
           
 void removeCell(Object cell)
          Removes the given cell from the selection.
 void removeCells(Object[] cells)
           
 void setCell(Object cell)
          Clears the selection and adds the given cell to the selection.
 void setCells(Object[] cells)
          Clears the selection and adds the given cells.
 void setSingleSelection(boolean singleSelection)
           
 int size()
          Returns the number of selected cells.
 
Methods inherited from class com.mxgraph.util.mxEventSource
addListener, fireEvent, fireEvent, fireEvent, isEventsEnabled, removeListener, removeListener, setEventsEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EVENT_CHANGE

public static String EVENT_CHANGE
Holds the name for the change event. First argument in the argument array is the collection of added cells, second argument is the collection of removed cells. To add a change listener to the graph model: addListener( mxSelectionModel.EVENT_CHANGE, new mxEventListener() { public void invoke(Object source, Object[] args) { selectionChanged((mxSelectionModel) source, (Collection) args[0], (Collection) args[1]); } });


EVENT_UNDO

public static String EVENT_UNDO

graph

protected mxGraph graph
Reference to the enclosing graph.


singleSelection

protected boolean singleSelection
Specifies if only one selected item at a time is allowed. Default is false.


cells

protected Set cells
Holds the selection cells.

Constructor Detail

mxSelectionModel

public mxSelectionModel(mxGraph graph)
Constructs a new selection model for the specified graph.

Parameters:
graph -
Method Detail

isSingleSelection

public boolean isSingleSelection()
Returns:
the singleSelection

setSingleSelection

public void setSingleSelection(boolean singleSelection)
Parameters:
singleSelection - the singleSelection to set

isSelected

public boolean isSelected(Object cell)
Returns true if the given cell is selected.

Parameters:
cell -
Returns:
Returns true if the given cell is selected.

isEmpty

public boolean isEmpty()
Returns true if no cells are selected.


size

public int size()
Returns the number of selected cells.


clear

public void clear()
Clears the selection.


getCell

public Object getCell()
Returns the first selected cell.


getCells

public Object[] getCells()
Returns the selection cells.


setCell

public void setCell(Object cell)
Clears the selection and adds the given cell to the selection.


setCells

public void setCells(Object[] cells)
Clears the selection and adds the given cells.


getFirstSelectableCell

protected Object getFirstSelectableCell(Object[] cells)
Returns the first selectable cell in the given array of cells.

Parameters:
cells - Array of cells to return the first selectable cell for.
Returns:
Returns the first cell that may be selected.

addCell

public void addCell(Object cell)
Adds the given cell to the selection.


addCells

public void addCells(Object[] cells)

removeCell

public void removeCell(Object cell)
Removes the given cell from the selection.


removeCells

public void removeCells(Object[] cells)

changeSelection

protected void changeSelection(Collection added,
                               Collection removed)

cellAdded

protected void cellAdded(Object cell)

cellRemoved

protected void cellRemoved(Object cell)

JGraph X 0.15.0.3


Copyright (c) 2008 Gaudenz Alder. All rights reserved.