de.jreality.ui.viewerapp
Class Selection

java.lang.Object
  extended by de.jreality.ui.viewerapp.Selection

public class Selection
extends java.lang.Object

Represents selections in a displayed scene. A selection is a list of objects representing a directed path from a scene graph's root down to some node in the scene graph or arbitrary objects which are somehow linked to nodes of the scene graph (e.g. tools or attribute entities visible in the scene graph's tree view).

In particular, every selection starts with a SceneGraphPath. Adding an object which is not an instance of SceneGraphNode to the selection's path defines the end of the contained SceneGraphPath, i.e any objects added subsequently are not treated as part of the SceneGraphPath.

Selections can be constructed from an existing SceneGraphPaths by using Selection(SceneGraphPath) and truncated to a SceneGraphPath using getSGPath().

Author:
msommer

Constructor Summary
Selection()
          Default constructor, starts with an empty selection path
Selection(SceneGraphPath path)
          Constructs a selection object from the given SceneGraphPath
Selection(Selection s)
          Copy constructor
 
Method Summary
 SceneGraphComponent asComponent()
          Returns the selected component if the current selection is a SceneGraphComponent, null otherwise
 AttributeEntity asEntity()
          Returns the selected entity if the current selection is an AttributeEntity, null otherwise
 SceneGraphNode asNode()
          Returns the selected node if the current selection is a SceneGraphNode, null otherwise
 Tool asTool()
          Returns the selected tool if the current selection is a Tool, null otherwise
 void clear()
          Clear the selection's path
 boolean equals(java.lang.Object s)
           
 SceneGraphNode getFirstElement()
          Get the first element of the selection's path.
Note that selections always start with a SceneGraphPath.
 SceneGraphComponent getLastComponent()
           
 java.lang.Object getLastElement()
           
 SceneGraphNode getLastNode()
           
 int getLength()
           
 SceneGraphPath getSGPath()
          Truncates the selection to SceneGraphNodes.
 int hashCode()
           
 boolean isComponent()
          Returns true iff a SceneGraphComponent was selected
 boolean isEntity()
          Returns true iff an AttributeEntity was selected
 boolean isEqual(Selection anotherSelection)
           
 boolean isNode()
          Returns true iff a SceneGraphNode was selected
 boolean isSGPath()
          Returns true iff the selection corresponds to a SceneGraphPath, i.e.
 boolean isTool()
          Returns true iff a Tool was selected
 java.util.ListIterator<java.lang.Object> iterator()
           
 java.util.ListIterator<java.lang.Object> iterator(int start)
           
 void pop()
           
 void push(java.lang.Object o)
          When pushing a SceneGraphNode, this method treats it as part of the SceneGraphPath the selection's path starts with if no other object was pushed before.
 java.util.Iterator reverseIterator()
           
 java.util.Iterator reverseIterator(int start)
           
 java.util.List<java.lang.Object> toList()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Selection

public Selection()
Default constructor, starts with an empty selection path


Selection

public Selection(Selection s)
Copy constructor


Selection

public Selection(SceneGraphPath path)
Constructs a selection object from the given SceneGraphPath

Method Detail

clear

public void clear()
Clear the selection's path


push

public final void push(java.lang.Object o)
When pushing a SceneGraphNode, this method treats it as part of the SceneGraphPath the selection's path starts with if no other object was pushed before.


pop

public final void pop()

getFirstElement

public SceneGraphNode getFirstElement()
Get the first element of the selection's path.
Note that selections always start with a SceneGraphPath.

Returns:
first SceneGraphNode of the contained path.

getSGPath

public SceneGraphPath getSGPath()
Truncates the selection to SceneGraphNodes.

Returns:
the contained scene graph path

getLastComponent

public SceneGraphComponent getLastComponent()

getLastNode

public SceneGraphNode getLastNode()

getLastElement

public java.lang.Object getLastElement()

isSGPath

public boolean isSGPath()
Returns true iff the selection corresponds to a SceneGraphPath, i.e. consists of SceneGraphNodes.


getLength

public int getLength()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object s)
Overrides:
equals in class java.lang.Object

isEqual

public boolean isEqual(Selection anotherSelection)

iterator

public java.util.ListIterator<java.lang.Object> iterator()

iterator

public java.util.ListIterator<java.lang.Object> iterator(int start)

reverseIterator

public java.util.Iterator reverseIterator()

reverseIterator

public java.util.Iterator reverseIterator(int start)

toList

public java.util.List<java.lang.Object> toList()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isTool

public boolean isTool()
Returns true iff a Tool was selected


asTool

public Tool asTool()
Returns the selected tool if the current selection is a Tool, null otherwise


isComponent

public boolean isComponent()
Returns true iff a SceneGraphComponent was selected


asComponent

public SceneGraphComponent asComponent()
Returns the selected component if the current selection is a SceneGraphComponent, null otherwise


isNode

public boolean isNode()
Returns true iff a SceneGraphNode was selected


asNode

public SceneGraphNode asNode()
Returns the selected node if the current selection is a SceneGraphNode, null otherwise


isEntity

public boolean isEntity()
Returns true iff an AttributeEntity was selected


asEntity

public AttributeEntity asEntity()
Returns the selected entity if the current selection is an AttributeEntity, null otherwise