Package org.graffiti.selection
Class Selection
java.lang.Object
org.graffiti.selection.Selection
public class Selection extends Object
Contains selected nodes and edges.
Even if there are fundamental changes to the selection, don't use something like that:
Selection newSel = new Selection(SelectionModel.ACTIVE);
editorSession. getSelectionModel().add(SelectionModel.ACTIVE);
editorSession.
getSelectionModel().setActiveSelection(SelectionModel.ACTIVE);
Instead, remove all entries within the selection by calling
clear() on the active selection (editorSession.
getSelectionModel().getActiveSelection()) and add the new selection
elements to it. After all changes have been made and the system should be
updated, call editorSession.getSelectionmodel().
selectionChanged()
- Version:
- $Revision: 1.12 $
-
Constructor Summary
Constructors Constructor Description Selection()Constructs a newSelectioninstance with the given name.Selection(String name)Constructs a newSelectioninstance with the given name.Selection(String name, Collection<?> newElements)Selection(Collection<?> newElements) -
Method Summary
Modifier and Type Method Description voidadd(Edge edge)Adds the given edge to the list of selected edges.voidadd(GraphElement ge)Adds the given node or edge to the selection.voidadd(Node node)Adds the given node to the list of selected nodes.voidaddAll(Collection<?> newElements)Adds all (graph)elements of the given collection to this selection.voidaddSelection(Selection sel)Adds all elements from the given selection to this selection.voidclear()Remove all elements from this selection.Objectclone()booleancontains(GraphElement ge)Collection<Edge>getEdges()Returns the list of selected edges.List<GraphElement>getElements()Returns a list containing all edges and nodes in this selection.Collection<Graph>getGraph()StringgetName()Returns the name of this selection.Map<GraphElement,GraphElement>getNewMarked()Returns the map holding graph elements that have been marked since the last selectionChanged event.Map<GraphElement,GraphElement>getNewUnmarked()Returns the map holding graph elements that have been unmarked since the last selectionChanged event.Collection<Node>getNodes()Returns the list of selected nodes.intgetNumberOfEdges()intgetNumberOfNodes()booleanisEmpty()Returnstrueif no nodes or edges are selected.voidremove(GraphElement ge)Removes the given node or edge from the selection.voidremoveAll(Collection<?> elements)voidsetName(String name)Sets the name.voidsetNewMarked(Map<GraphElement,GraphElement> newMarked)Sets the list of graph elements that have been marked but the selection listeners have not yet been notified.voidsetNewUnmarked(Map<GraphElement,GraphElement> newUnmarked)Sets the list of graph elements that have been unmarked but the selection listeners have not yet been notified.StringtoString()Gets a string describing the selection.
-
Constructor Details
-
Selection
public Selection()Constructs a newSelectioninstance with the given name. -
Selection
Constructs a newSelectioninstance with the given name.- Parameters:
name- the name of this selection.
-
Selection
-
Selection
-
-
Method Details
-
getEdges
Returns the list of selected edges.- See Also:
Edge
-
getElements
Returns a list containing all edges and nodes in this selection.- Returns:
- a list containing all edges and nodes in this selection.
-
isEmpty
public boolean isEmpty()Returnstrueif no nodes or edges are selected.- Returns:
trueif no nodes or edges are selected.
-
setName
Sets the name.- Parameters:
name- The name to set- Throws:
FieldAlreadySetException- DOCUMENT ME!
-
getName
Returns the name of this selection.- Returns:
- the name of this selection.
-
setNewMarked
Sets the list of graph elements that have been marked but the selection listeners have not yet been notified.- Parameters:
newMarked- list of newly marked graph elements
-
getNewMarked
Returns the map holding graph elements that have been marked since the last selectionChanged event.- Returns:
- map holding graph elements that have been marked since the last selectionChanged event.
-
setNewUnmarked
Sets the list of graph elements that have been unmarked but the selection listeners have not yet been notified.- Parameters:
newUnmarked- list of newly unmarked graph elements
-
getNewUnmarked
Returns the map holding graph elements that have been unmarked since the last selectionChanged event.- Returns:
- the map holding graph elements that have been unmarked since the last selectionChanged event.
-
getNodes
Returns the list of selected nodes.- See Also:
Node
-
add
Adds the given node or edge to the selection.- Parameters:
ge- the node or edge to add to the selection.
-
add
Adds the given node to the list of selected nodes.- Parameters:
node- the node to add to the list of selected nodes.
-
add
Adds the given edge to the list of selected edges.- Parameters:
edge- the edge to add to the list of selected edges.
-
addAll
Adds all (graph)elements of the given collection to this selection.- Parameters:
newElements-
-
removeAll
-
addSelection
Adds all elements from the given selection to this selection.- Parameters:
sel-
-
clear
public void clear()Remove all elements from this selection. -
clone
- See Also:
Object.clone()
-
remove
Removes the given node or edge from the selection.- Parameters:
ge- the node or edge to remove from the selection.
-
toString
Gets a string describing the selection. Default: number of selected nodes and edges in a sentence. -
contains
-
getNumberOfNodes
public int getNumberOfNodes() -
getGraph
-
getNumberOfEdges
public int getNumberOfEdges()
-