com.mxgraph.view.mxGraphSelectionModel Maven / Gradle / Ivy
/*
* Copyright (c) 2001-2005, Gaudenz Alder
*
* All rights reserved.
*
* See LICENSE file for license details. If you are unable to locate
* this file please contact info (at) jgraph (dot) com.
*/
package com.mxgraph.view;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import com.mxgraph.util.mxEvent;
import com.mxgraph.util.mxEventObject;
import com.mxgraph.util.mxEventSource;
import com.mxgraph.util.mxUndoableEdit;
import com.mxgraph.util.mxUndoableEdit.mxUndoableChange;
/**
* 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.
*
* 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);
* }
* });
*
*/
public class mxGraphSelectionModel extends mxEventSource
{
/**
* Reference to the enclosing graph.
*/
protected mxGraph graph;
/**
* Specifies if only one selected item at a time is allowed.
* Default is false.
*/
protected boolean singleSelection = false;
/**
* Holds the selection cells.
*/
protected Set
© 2015 - 2025 Weber Informatics LLC | Privacy Policy