com.tensegrity.graphics.interaction
Class DefaultInteractionContext

java.lang.Object
  extended bycom.tensegrity.graphics.interaction.DefaultInteractionContext
All Implemented Interfaces:
InteractionContext

public class DefaultInteractionContext
extends java.lang.Object
implements InteractionContext

The default implementation of the InteractionContext interface.

Version:
$Id: DefaultInteractionContext.java,v 1.114 2006/06/02 13:07:28 MichaelKegel Exp $
Author:
MichaelKegel
See Also:
InteractionContext

Constructor Summary
DefaultInteractionContext()
          Constructor for DefaultInteractionContext.
 
Method Summary
 int act(InteractionInfo interactionInfo)
          This method has to be called from the object that holds an instance of InteractionContext to move or manipulate the current selection.
 int act(InteractionInfo interactionInfo, java.util.List interactables_fixed)
           
 int getCursorID(InteractionInfo interactionInfo, java.util.List interactables)
          Returns a identifier for a mouse cursor that should be displayed for the given coordinate.
 int getInteractionProviderCount()
          Returns the number of InteractionProviders that have a sub selection.
 java.util.List getInteractionProviders()
          Returns a List of InteractionProviders that have a selection.
 java.util.List getSelection()
          Returns the currently selected BaseInteractables in a List.
 Boundary getSelectionBoundingBox()
          Returns the bounding box of the currently selected objects.
 int getSelectionCount()
          Returns the number of the currently selected BaseInteractables.
 boolean hasMultiSelection()
          Returns a flag that indicates whether more than one object is selected or not.
 boolean hasSelection()
          Returns a flag that indicates whether something is selected or not.
 boolean hasSubSelection()
          Returns a flag that indicates whether this InteractionContext has a sub selection or not.
 int hits(InteractionInfo interactionInfo, java.util.List interactables)
          Checks if an BaseInteractable is hit.
 void internalAddInteractionProvider(InteractionProvider interactionProvider)
          Internal method of the selection api.
 void internalChangeDescriptor(BaseInteractable interactable, java.util.List interactables_fixed, InteractionDescriptor newDescriptor, InteractionItem newItem)
          Internal method of the selection api.
 InteractionItem internalGetCurrentInteractionItemFor(BaseInteractable interactable)
          Internal method of the selection api.
 void internalRemoveInteractionProvider(InteractionProvider interactionProvider)
          Internal method of the selection api.
 boolean isInteractionCycleComplete()
           
 boolean isInteractionStarted()
          Returns a boolean that indicates whether an interaction has been started on this InteractionContext.
 int mouseClick(InteractionInfo interactionInfo, java.util.List interactables)
          This method has to be called from the object that holds an instance of InteractionContext when a mouse button has been clicked.
 int mouseDown(InteractionInfo interactionInfo, java.util.List interactables)
          This method has to be called from the object that holds an instance of InteractionContext when a mouse button has been pressed.
 int mouseMove(InteractionInfo interactionInfo, java.util.List interactables)
          This method has to be called from the object that holds an instance of InteractionContext when the mouse has been moved.
 int mouseUp(InteractionInfo interactionInfo, java.util.List interactables)
          This method has to be called from the object that holds an instance of InteractionContext when a mouse button has been released.
 void paint(Renderer renderer, Device device, Transform2D xform_context)
          This method has to be called from the objects that holds an instance of InteractionContext to paint the current selection.
 int postAction(InteractionInfo interactionInfo, java.util.List interactables)
          TODO : comment
 void preAction(InteractionInfo interactionInfo, java.util.List interactables)
          TODO : comment
 void select(BaseInteractable interactable, boolean adjustSelectionFlag)
          Selects the BaseInteractable given by interactable and adds it to the InteractionContext.
 void select(BaseInteractable interactable, InteractionItem interactionItem)
          Select the BaseInteractable given by interactable and adds it to the InteractionContext.
 int select(InteractionInfo interactionInfo, java.util.List interactables)
          This method has to be called from the object that holds an instance of InteractionContext to select a BaseInteractable if it lies at the given point.
 int select(InteractionInfo interactionInfo, java.util.List interactables, Boundary boundary)
          This method has to be called from the object that holds an instance of InteractionContext to select all BaseInteractable objects that lie within the given Boundary.
 void select(java.util.List interactables)
          This method has to be called to select the given List of BaseInteractable objects.
 void selectSubsequent(InteractionProvider interactionProvider)
          Adds the InteractionProvider given by interactionProvider to the InteractionContext.
 void startAction(InteractionInfo interactionInfo)
          This method has to be called from the object that holds an instance of InteractionContext before movement or manipulation of the current selection starts.
 int stopAction(InteractionInfo interactionInfo)
          This method has to be called from the object that holds an instance of InteractionContext when movement or manipulation of the current selection is done.
 void unselect()
          This method has to be called to unselect each BaseInteractable that is currently selected.
 void unselect(BaseInteractable interactable, boolean adjustSelectionFlag)
          Unselects the BaseInteractable given by interactable and removes it from the InteractionContext.
 void unselect(java.util.List interactables)
          This method has to be called to unselect the given List of BaseInteractable objects.
 void unselectSubsequent(InteractionProvider interactionProvider)
          Removes the InteractionProvider given by interactionProvider from the InteractionContext.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultInteractionContext

public DefaultInteractionContext()
Constructor for DefaultInteractionContext.

Method Detail

hasSelection

public boolean hasSelection()
Description copied from interface: InteractionContext
Returns a flag that indicates whether something is selected or not.

Specified by:
hasSelection in interface InteractionContext
Returns:
boolean that indicates a selection

hasMultiSelection

public boolean hasMultiSelection()
Description copied from interface: InteractionContext
Returns a flag that indicates whether more than one object is selected or not.

Specified by:
hasMultiSelection in interface InteractionContext
Returns:
boolean that indicates a multi selection

getSelectionCount

public int getSelectionCount()
Description copied from interface: InteractionContext
Returns the number of the currently selected BaseInteractables.

Specified by:
getSelectionCount in interface InteractionContext
Returns:
int the number of the currently selected BaseInteractables

getSelection

public java.util.List getSelection()
Description copied from interface: InteractionContext
Returns the currently selected BaseInteractables in a List.

Specified by:
getSelection in interface InteractionContext
Returns:
List a List of the currently selected objects

hasSubSelection

public boolean hasSubSelection()
Description copied from interface: InteractionContext
Returns a flag that indicates whether this InteractionContext has a sub selection or not. A sub selection means that an InteractionProvider that belongs to this InteractionContext has a selection.

Specified by:
hasSubSelection in interface InteractionContext
Returns:
boolean that indicates a sub selection

isInteractionStarted

public boolean isInteractionStarted()
Description copied from interface: InteractionContext
Returns a boolean that indicates whether an interaction has been started on this InteractionContext.

Specified by:
isInteractionStarted in interface InteractionContext
Returns:
boolean a flag indicating a started interaction process

isInteractionCycleComplete

public boolean isInteractionCycleComplete()
Specified by:
isInteractionCycleComplete in interface InteractionContext

getInteractionProviderCount

public int getInteractionProviderCount()
Description copied from interface: InteractionContext
Returns the number of InteractionProviders that have a sub selection.

Specified by:
getInteractionProviderCount in interface InteractionContext
Returns:
int the number of InteractionProviders with a sub selection

getInteractionProviders

public java.util.List getInteractionProviders()
Description copied from interface: InteractionContext
Returns a List of InteractionProviders that have a selection.
Notice that InteractionProviders that have a selection must not be selected by itself and therefore they must not but can be part of the List returned by InteractionContext.getSelection().

Specified by:
getInteractionProviders in interface InteractionContext
Returns:
List a List of InteractionProviders that have a selection

getCursorID

public int getCursorID(InteractionInfo interactionInfo,
                       java.util.List interactables)
Description copied from interface: InteractionContext
Returns a identifier for a mouse cursor that should be displayed for the given coordinate. If no cursor should be displayed it returns -1. The cursor identifiers are defined in GraphicConstants.

Specified by:
getCursorID in interface InteractionContext
Parameters:
interactionInfo - the info values needed to find the right cursor.
interactables - the List of BaseInteractables to check for.
Returns:
int the cursor identifier or -1

hits

public int hits(InteractionInfo interactionInfo,
                java.util.List interactables)
Description copied from interface: InteractionContext
Checks if an BaseInteractable is hit. The informations needed therefore have to be given by the interactionInfo parameter. The BaseInteractables to check have to be given by the interactables parameter. A constant is returned that identifies what has been hit.

Specified by:
hits in interface InteractionContext
Parameters:
interactionInfo - the info values needed to check for a hit
interactables - the List of BaseInteractables to check for.
Returns:
constant that identifies what has been hit.
See Also:
hit identifiers

select

public int select(InteractionInfo interactionInfo,
                  java.util.List interactables)
Description copied from interface: InteractionContext
This method has to be called from the object that holds an instance of InteractionContext to select a BaseInteractable if it lies at the given point.

Specified by:
select in interface InteractionContext
Parameters:
interactables - the list of BaseInteractable objects that can be selected.
interactionInfo - the InteractionInfo holding information on the manipulation.
Returns:
constant that indicates what effect the selection had
See Also:
selection identifiers

select

public int select(InteractionInfo interactionInfo,
                  java.util.List interactables,
                  Boundary boundary)
Description copied from interface: InteractionContext
This method has to be called from the object that holds an instance of InteractionContext to select all BaseInteractable objects that lie within the given Boundary.

Specified by:
select in interface InteractionContext
Parameters:
interactionInfo - the InteractionInfo holding information on the manipulation.
interactables - the list of BaseInteractable objects that should process the mouse move interaction.
boundary - the rectangle to select within
Returns:
constant that indicates what effect the selection had
See Also:
selection identifiers

select

public void select(BaseInteractable interactable,
                   boolean adjustSelectionFlag)
Description copied from interface: InteractionContext
Selects the BaseInteractable given by interactable and adds it to the InteractionContext.
NOTICE:This method is an internal method of the selection api and it is strongly recommended not to make use of it.

Specified by:
select in interface InteractionContext
Parameters:
interactable -
adjustSelectionFlag -

select

public void select(BaseInteractable interactable,
                   InteractionItem interactionItem)
Description copied from interface: InteractionContext
Select the BaseInteractable given by interactable and adds it to the InteractionContext. The InteractionItem given by interactionItem is used for further interaction.
NOTICE:This method is an internal method of the selection api and it is strongly recommended not to make use of it.

Specified by:
select in interface InteractionContext
Parameters:
interactable -
interactionItem -

select

public void select(java.util.List interactables)
Description copied from interface: InteractionContext
This method has to be called to select the given List of BaseInteractable objects.

Specified by:
select in interface InteractionContext
Parameters:
interactables - the list of BaseInteractable objects that should be selected

unselect

public void unselect()
Description copied from interface: InteractionContext
This method has to be called to unselect each BaseInteractable that is currently selected.

Specified by:
unselect in interface InteractionContext

unselect

public void unselect(BaseInteractable interactable,
                     boolean adjustSelectionFlag)
Description copied from interface: InteractionContext
Unselects the BaseInteractable given by interactable and removes it from the InteractionContext.
NOTICE:This method is an internal method of the selection api and it is strongly recommended not to make use of it.

Specified by:
unselect in interface InteractionContext
Parameters:
interactable -
adjustSelectionFlag -

unselect

public void unselect(java.util.List interactables)
Description copied from interface: InteractionContext
This method has to be called to unselect the given List of BaseInteractable objects.

Specified by:
unselect in interface InteractionContext
Parameters:
interactables - the list of BaseInteractable objects that should process the mouse button down interaction.

selectSubsequent

public void selectSubsequent(InteractionProvider interactionProvider)
Description copied from interface: InteractionContext
Adds the InteractionProvider given by interactionProvider to the InteractionContext.
NOTICE:This method is an internal method of the selection api and it is strongly recommended not to make use of it.

Specified by:
selectSubsequent in interface InteractionContext
Parameters:
interactionProvider -

unselectSubsequent

public void unselectSubsequent(InteractionProvider interactionProvider)
Description copied from interface: InteractionContext
Removes the InteractionProvider given by interactionProvider from the InteractionContext.
NOTICE:This method is an internal method of the selection api and it is strongly recommended not to make use of it.

Specified by:
unselectSubsequent in interface InteractionContext
Parameters:
interactionProvider - the InteractionProvider to remove

getSelectionBoundingBox

public Boundary getSelectionBoundingBox()
Description copied from interface: InteractionContext
Returns the bounding box of the currently selected objects.

Specified by:
getSelectionBoundingBox in interface InteractionContext
Returns:
Boundary the currents selection bounding box

mouseDown

public int mouseDown(InteractionInfo interactionInfo,
                     java.util.List interactables)
Description copied from interface: InteractionContext
This method has to be called from the object that holds an instance of InteractionContext when a mouse button has been pressed.

Specified by:
mouseDown in interface InteractionContext
Parameters:
interactionInfo - the InteractionInfo holding information on the manipulation.
interactables - the list of BaseInteractable objects that should process the mouse button down interaction.
Returns:
int constant that indicates what effect the interaction had
See Also:
mouse interaction identifiers

mouseUp

public int mouseUp(InteractionInfo interactionInfo,
                   java.util.List interactables)
Description copied from interface: InteractionContext
This method has to be called from the object that holds an instance of InteractionContext when a mouse button has been released.

Specified by:
mouseUp in interface InteractionContext
Parameters:
interactionInfo - the InteractionInfo holding information on the manipulation.
interactables - the list of BaseInteractable objects that should process the mouse button up interaction.
Returns:
int constant that indicates what effect the interaction had
See Also:
mouse interaction identifiers

mouseClick

public int mouseClick(InteractionInfo interactionInfo,
                      java.util.List interactables)
Description copied from interface: InteractionContext
This method has to be called from the object that holds an instance of InteractionContext when a mouse button has been clicked. Clicked means in this case that a mouse buttin has been pressed and released.

Specified by:
mouseClick in interface InteractionContext
Parameters:
interactionInfo - the InteractionInfo holding information on the manipulation.
interactables - the list of BaseInteractable objects that should process the mouse move interaction.
Returns:
int constant that indicates what effect the interaction had
See Also:
mouse interaction identifiers

mouseMove

public int mouseMove(InteractionInfo interactionInfo,
                     java.util.List interactables)
Description copied from interface: InteractionContext
This method has to be called from the object that holds an instance of InteractionContext when the mouse has been moved.

Specified by:
mouseMove in interface InteractionContext
Parameters:
interactionInfo - the InteractionInfo holding information on the manipulation.
interactables - the list of BaseInteractable objects that should process the mouse move interaction.
Returns:
int constant that indicates what effect the interaction had
See Also:
mouse interaction identifiers

preAction

public void preAction(InteractionInfo interactionInfo,
                      java.util.List interactables)
Description copied from interface: InteractionContext
TODO : comment

Specified by:
preAction in interface InteractionContext
Parameters:
interactionInfo -
interactables -

startAction

public void startAction(InteractionInfo interactionInfo)
Description copied from interface: InteractionContext
This method has to be called from the object that holds an instance of InteractionContext before movement or manipulation of the current selection starts.

Specified by:
startAction in interface InteractionContext
Parameters:
interactionInfo - the InteractionInfo holding information on the manipulation.

act

public int act(InteractionInfo interactionInfo)
Description copied from interface: InteractionContext
This method has to be called from the object that holds an instance of InteractionContext to move or manipulate the current selection.

Specified by:
act in interface InteractionContext
Parameters:
interactionInfo - the InteractionInfo holding information on the manipulation.
Returns:
int constant that indicates what effect the interaction had
See Also:
interaction identifiers

act

public int act(InteractionInfo interactionInfo,
               java.util.List interactables_fixed)
Specified by:
act in interface InteractionContext

stopAction

public int stopAction(InteractionInfo interactionInfo)
Description copied from interface: InteractionContext
This method has to be called from the object that holds an instance of InteractionContext when movement or manipulation of the current selection is done.

Specified by:
stopAction in interface InteractionContext
Parameters:
interactionInfo - the InteractionInfo holding information on the manipulation.
Returns:
int constant that indicates what effect the interaction had
See Also:
interaction identifiers

postAction

public int postAction(InteractionInfo interactionInfo,
                      java.util.List interactables)
Description copied from interface: InteractionContext
TODO : comment

Specified by:
postAction in interface InteractionContext
Parameters:
interactionInfo -
interactables -
Returns:

paint

public void paint(Renderer renderer,
                  Device device,
                  Transform2D xform_context)
Description copied from interface: InteractionContext
This method has to be called from the objects that holds an instance of InteractionContext to paint the current selection.

Specified by:
paint in interface InteractionContext
Parameters:
renderer - the Renderer to render with
device - the Device to paint onto
xform_context - the transformation of the context

internalRemoveInteractionProvider

public void internalRemoveInteractionProvider(InteractionProvider interactionProvider)
Description copied from interface: InteractionContext
Internal method of the selection api. It is strongly recommended not to make use of it.

Specified by:
internalRemoveInteractionProvider in interface InteractionContext

internalAddInteractionProvider

public void internalAddInteractionProvider(InteractionProvider interactionProvider)
Description copied from interface: InteractionContext
Internal method of the selection api. It is strongly recommended not to make use of it.

Specified by:
internalAddInteractionProvider in interface InteractionContext

internalGetCurrentInteractionItemFor

public InteractionItem internalGetCurrentInteractionItemFor(BaseInteractable interactable)
Description copied from interface: InteractionContext
Internal method of the selection api. It is strongly recommended not to make use of it.

Specified by:
internalGetCurrentInteractionItemFor in interface InteractionContext
Parameters:
interactable -
Returns:

internalChangeDescriptor

public void internalChangeDescriptor(BaseInteractable interactable,
                                     java.util.List interactables_fixed,
                                     InteractionDescriptor newDescriptor,
                                     InteractionItem newItem)
Description copied from interface: InteractionContext
Internal method of the selection api. It is strongly recommended not to make use of it.

Specified by:
internalChangeDescriptor in interface InteractionContext
Parameters:
interactable - |param interactables_fixed
newDescriptor -
newItem -


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.