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 Details

    • 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.
    • Selection

      public Selection​(String name, Collection<?> newElements)
    • Selection

      public Selection​(Collection<?> newElements)
  • Method Details

    • getEdges

      public Collection<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,​GraphElement> 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,​GraphElement> 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,​GraphElement> 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,​GraphElement> 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 Collection<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<?> newElements)
      Adds all (graph)elements of the given collection to this selection.
      Parameters:
      newElements -
    • removeAll

      public void removeAll​(Collection<?> elements)
    • 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()
      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.
    • 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.
    • contains

      public boolean contains​(GraphElement ge)
    • getNumberOfNodes

      public int getNumberOfNodes()
    • getGraph

      public Collection<Graph> getGraph()
    • getNumberOfEdges

      public int getNumberOfEdges()