org.graffiti.selection
Class Selection

java.lang.Object
  extended by org.graffiti.selection.Selection
Direct Known Subclasses:
ClipboardContents

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: 6093 $

Constructor Summary
Selection()
          Constructs a new Selection instance with the given name.
Selection(String name)
          Constructs a new Selection instance with the given name.
 
Method Summary
 void add(Edge edge)
          Adds the given edge to the list of selected edges.
 void add(GraphElement ge)
          Adds the given node or edge to the selection.
 void add(Node node)
          Adds the given node to the list of selected nodes.
 void addAll(Collection<? extends GraphElement> newElements)
          Adds all (graph)elements of the given collection to this selection.
 void addSelection(Selection sel)
          Adds all elements from the given selection to this selection.
 void clear()
          Remove all elements from this selection.
 Object clone()
           
protected  void committedChanges()
          Clears the maps holding any changes since the last selectionChanged event.
 boolean contains(GraphElement graphElement)
           
 List<Edge> getEdges()
          Returns the list of selected edges.
 List<GraphElement> getElements()
          Returns a list containing all edges and nodes in this selection.
 String getName()
          Returns the name of this selection.
 Map<GraphElement,Object> getNewMarked()
          Returns the map holding graph elements that have been marked since the last selectionChanged event.
 Map<GraphElement,Object> getNewUnmarked()
          Returns the map holding graph elements that have been unmarked since the last selectionChanged event.
 List<Node> getNodes()
          Returns the list of selected nodes.
 boolean isEmpty()
          Returns true if no nodes or edges are selected.
 void remove(GraphElement ge)
          Removes the given node or edge from the selection.
 void setName(String name)
          Sets the name.
 void setNewMarked(Map<GraphElement,Object> newMarked)
          Sets the list of graph elements that have been marked but the selection listeners have not yet been notified.
 void setNewUnmarked(Map<GraphElement,Object> newUnmarked)
          Sets the list of graph elements that have been unmarked but the selection listeners have not yet been notified.
 String toString()
          Gets a string describing the selection.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Selection

public Selection()
Constructs a new Selection instance with the given name.


Selection

public Selection(String name)
Constructs a new Selection instance with the given name.

Parameters:
name - the name of this selection.
Method Detail

getEdges

public List<Edge> getEdges()
Returns the list of selected edges.

See Also:
Edge

getElements

public List<GraphElement> 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()
Returns true if no nodes or edges are selected.

Returns:
true if no nodes or edges are selected.

setName

public void setName(String name)
             throws FieldAlreadySetException
Sets the name.

Parameters:
name - The name to set
Throws:
FieldAlreadySetException - DOCUMENT ME!

getName

public String getName()
Returns the name of this selection.

Returns:
the name of this selection.

setNewMarked

public void setNewMarked(Map<GraphElement,Object> newMarked)
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

public Map<GraphElement,Object> 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

public void setNewUnmarked(Map<GraphElement,Object> newUnmarked)
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

public Map<GraphElement,Object> 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

public List<Node> getNodes()
Returns the list of selected nodes.

See Also:
Node

add

public void add(GraphElement ge)
Adds the given node or edge to the selection.

Parameters:
ge - the node or edge to add to the selection.

add

public void add(Node node)
Adds the given node to the list of selected nodes.

Parameters:
node - the node to add to the list of selected nodes.

add

public void add(Edge edge)
Adds the given edge to the list of selected edges.

Parameters:
edge - the edge to add to the list of selected edges.

addAll

public void addAll(Collection<? extends GraphElement> newElements)
Adds all (graph)elements of the given collection to this selection.

Parameters:
newElements -

addSelection

public void addSelection(Selection sel)
Adds all elements from the given selection to this selection.

Parameters:
sel -

clear

public void clear()
Remove all elements from this selection.


clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException
See Also:
Object.clone()

remove

public void remove(GraphElement ge)
Removes the given node or edge from the selection.

Parameters:
ge - the node or edge to remove from the selection.

contains

public boolean contains(GraphElement graphElement)

toString

public String toString()
Gets a string describing the selection. Default: number of selected nodes and edges in a sentence.

Overrides:
toString in class Object
Returns:
a string describing the selection. Default: number of selected nodes and edges in a sentence.

committedChanges

protected void committedChanges()
Clears the maps holding any changes since the last selectionChanged event. Should be called whenever a selectionChanged event has been generated with this selection.



Generated at 2012-05-30 11:00:36 PM CEST