JGraph X 1.3.0.0

## com.mxgraph.view
Class mxGraphSelectionModel

    java.lang.Object
      com.mxgraph.util.mxEventSource
          com.mxgraph.view.mxGraphSelectionModel

    public class mxGraphSelectionModel

extends mxEventSource

Implements the selection model for a graph. This class fires the following events: mxEvent.UNDO fires after the selection was changed in changeSelection. The `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. To add a change listener to the graph selection model: `addListener( mxEvent.CHANGE, new mxIEventListener() { public void invoke(Object sender, mxEventObject evt) { mxSelectionModel model = (mxSelectionModel) sender; Collection added = (Collection) evt.getArg("added"); Collection removed = (Collection) evt.getArg("removed"); selectionChanged(model, added, removed); } });`

Nested Class Summary
`static class` `mxGraphSelectionModel.mxSelectionChange`

Nested classes/interfaces inherited from class com.mxgraph.util.mxEventSource
`mxEventSource.mxIEventListener`

Field Summary
`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.

Fields inherited from class com.mxgraph.util.mxEventSource
`eventListeners, eventsEnabled, eventSource`

Constructor Summary
`mxGraphSelectionModel(mxGraph graph)` Constructs a new selection model for the specified graph.

Method Summary
`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.

Methods inherited from class com.mxgraph.util.mxEventSource
`addListener, fireEvent, fireEvent, getEventSource, isEventsEnabled, removeListener, removeListener, setEventsEnabled, setEventSource`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### 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 java.util.Set<java.lang.Object> cells

  Holds the selection cells.

Constructor Detail

### mxGraphSelectionModel

    public mxGraphSelectionModel(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(java.lang.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 java.lang.Object getCell()

  Returns the first selected cell.

### getCells

    public java.lang.Object[] getCells()

  Returns the selection cells.

### setCell

    public void setCell(java.lang.Object cell)

  Clears the selection and adds the given cell to the selection.

### setCells

    public void setCells(java.lang.Object[] cells)

  Clears the selection and adds the given cells.

### getFirstSelectableCell

    protected java.lang.Object getFirstSelectableCell(java.lang.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(java.lang.Object cell)

  Adds the given cell to the selection.

### addCells

    public void addCells(java.lang.Object[] cells)

### removeCell

    public void removeCell(java.lang.Object cell)

  Removes the given cell from the selection.

### removeCells

    public void removeCells(java.lang.Object[] cells)

### changeSelection

    protected void changeSelection(java.util.Collection<java.lang.Object> added,
                                   java.util.Collection<java.lang.Object> removed)

### cellAdded

    protected void cellAdded(java.lang.Object cell)

### cellRemoved

    protected void cellRemoved(java.lang.Object cell)

JGraph X 1.3.0.0

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