shady.common.ui.multi
Class ChainIKHotSpot

java.lang.Object
  extended by shady.common.ui.HotSpot
      extended by shady.common.ui.multi.ChainIKHotSpot

public class ChainIKHotSpot
extends HotSpot

A HotSpot that controls a multishady chain by ChainIK.

Copyright (C) 2006 Marsette A. Vona, III

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

Author:
Marsette (Marty) A. Vona, III

Field Summary
protected  Block block
          The chain-end to control.
static java.lang.String CHAIN_PACKAGE
          Package containing the chain classes.
protected  ChainIK chainIK
          The ChainIK currently live.
protected static java.util.List chainIKHotSpots
          All currently active ChainIKHotSpots.
static double CLEAR_ANNOTATIONS_TIME
          Seconds before annotations are cleared.
static boolean DEBUG
          Whether to debug.
static java.lang.String DEFAULT_IK_NAME
          Default IK name.
static int DEFAULT_ITERATIONS_PER_UPDATE
          Default number of iterations per update.
static double DEFAULT_UPDATE_TIME
          Default update time in seconds.
static double DRAG_ANNOTATION_MAG
          Magnitude of drag annotation vector in pixels
protected  java.lang.String dragAnnotationName
          Name of the drag annotation.
protected  boolean dragOngoing
          Whether a drag is in progress.
protected  java.lang.Object graphicsLock
          Synchronization object for graphics updates.
static java.lang.String ikName
          IK name, e.g.
static int iterationsPerUpdate
          Iterations per update.
static double MAX_ANNOTATION_TIME
          Max allowed time to display annotations in seconds.
static double MAX_UPDATE_TIME
          Max allowed time for an update in seconds.
static double TARGET_SLOP_PIXELS
          Max allowed target slop in pixels.
protected  java.lang.Object targetLock
          Synchronization lock for the target variables.
protected  double targetRotation
          Target rotation in radians.
protected  double targetSetTime
          Time of most recent target change.
protected  double targetX
          Target x coord.
protected  double targetY
          Target y coord.
static double TILT_PER_CLICK
          Differential tilt per click in radians.
protected  java.lang.String tiltAnnotationName
          Name of the tilt annotation.
protected static vona.time.Clock updateClock
          Timebase for doUpdate(double).
protected static vona.time.PeriodicThread updateThread
          The update thread.
 
Fields inherited from class shady.common.ui.HotSpot
graphicsDisplay, point, uid, uidCounter
 
Constructor Summary
ChainIKHotSpot(Block block)
          Create a new ChainIKHotSpot.
 
Method Summary
protected  void addAnnotations(GraphicsDisplay graphicsDisplay)
          Update the annotations.
protected  void doUpdate(double currentTime)
          (Re) cons chainIK if necessary and do up to iterationsPerUpdate IK iterations.
protected  double getCurrentRotation()
          Get the current EE rotation in radians.
protected  double getCurrentX()
          Get the current EE x coordinate.
protected  double getCurrentY()
          Get the current EE y coordinate.
 boolean handleDrag(double dx, double dy, java.awt.geom.Point2D startDragPoint, java.awt.geom.Point2D point, int modifiers, boolean accel)
          Subclasses wishing to respond to drags override this.
 void handleDragEnded(java.awt.geom.Point2D startDragPoint, java.awt.geom.Point2D point, int modifiers, boolean accel)
          Subclasses wishing to respond to drags may override this to be told when the drag ends.
protected  boolean isTilt(int modifiers)
          Check whether this is a tilt.
protected  void removeAnnotations(GraphicsDisplay graphicsDisplay)
          Clear the annotations.
 void setGraphicsDisplay(GraphicsDisplay graphicsDisplay)
          Used by GraphicsDisplay to notify this HotSpot when it has been added and removed.
static void setUpdateTime(double updateTime)
          Set the update time for all ChainIKHotSpots.
 
Methods inherited from class shady.common.ui.HotSpot
distanceSq, distanceSq, distanceSq, handleWheel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final boolean DEBUG

Whether to debug.

See Also:
Constant Field Values

DEFAULT_UPDATE_TIME

public static final double DEFAULT_UPDATE_TIME

Default update time in seconds.

See Also:
Constant Field Values

DEFAULT_IK_NAME

public static final java.lang.String DEFAULT_IK_NAME

Default IK name.

See Also:
Constant Field Values

DEFAULT_ITERATIONS_PER_UPDATE

public static final int DEFAULT_ITERATIONS_PER_UPDATE

Default number of iterations per update.

See Also:
Constant Field Values

CHAIN_PACKAGE

public static final java.lang.String CHAIN_PACKAGE

Package containing the chain classes.

See Also:
Constant Field Values

TILT_PER_CLICK

public static final double TILT_PER_CLICK

Differential tilt per click in radians.


CLEAR_ANNOTATIONS_TIME

public static final double CLEAR_ANNOTATIONS_TIME

Seconds before annotations are cleared.

See Also:
Constant Field Values

DRAG_ANNOTATION_MAG

public static final double DRAG_ANNOTATION_MAG

Magnitude of drag annotation vector in pixels

See Also:
Constant Field Values

TARGET_SLOP_PIXELS

public static final double TARGET_SLOP_PIXELS

Max allowed target slop in pixels.

See Also:
Constant Field Values

MAX_UPDATE_TIME

public static final double MAX_UPDATE_TIME

Max allowed time for an update in seconds.

See Also:
Constant Field Values

MAX_ANNOTATION_TIME

public static final double MAX_ANNOTATION_TIME

Max allowed time to display annotations in seconds.

See Also:
Constant Field Values

block

protected Block block

The chain-end to control.


chainIK

protected ChainIK chainIK

The ChainIK currently live.


ikName

public static java.lang.String ikName

IK name, e.g. "Transpose" for "shady.common.multi.chain.TransposeIK".


iterationsPerUpdate

public static int iterationsPerUpdate

Iterations per update.


targetX

protected double targetX

Target x coord.


targetY

protected double targetY

Target y coord.


targetRotation

protected double targetRotation

Target rotation in radians.


targetSetTime

protected double targetSetTime

Time of most recent target change.


targetLock

protected java.lang.Object targetLock

Synchronization lock for the target variables.


dragOngoing

protected boolean dragOngoing

Whether a drag is in progress.


tiltAnnotationName

protected java.lang.String tiltAnnotationName

Name of the tilt annotation.


dragAnnotationName

protected java.lang.String dragAnnotationName

Name of the drag annotation.


chainIKHotSpots

protected static final java.util.List chainIKHotSpots

All currently active ChainIKHotSpots.


updateClock

protected static final vona.time.Clock updateClock

Timebase for doUpdate(double).


updateThread

protected static final vona.time.PeriodicThread updateThread

The update thread.


graphicsLock

protected java.lang.Object graphicsLock

Synchronization object for graphics updates.

Constructor Detail

ChainIKHotSpot

public ChainIKHotSpot(Block block)

Create a new ChainIKHotSpot.

Parameters:
block - the chain-end to control, not null
Method Detail

getCurrentX

protected double getCurrentX()

Get the current EE x coordinate.

Returns:
the current EE x coordinate

getCurrentY

protected double getCurrentY()

Get the current EE y coordinate.

Returns:
the current EE y coordinate

getCurrentRotation

protected double getCurrentRotation()

Get the current EE rotation in radians.

Returns:
the current EE rotation in radians

setUpdateTime

public static void setUpdateTime(double updateTime)

Set the update time for all ChainIKHotSpots.

Parameters:
updateTime - the update time for all ChainIKHotSpots, in seconds

handleDrag

public boolean handleDrag(double dx,
                          double dy,
                          java.awt.geom.Point2D startDragPoint,
                          java.awt.geom.Point2D point,
                          int modifiers,
                          boolean accel)

Subclasses wishing to respond to drags override this.

This method will be called at each mouse event during a drag which started over the hotspot.

Default impl just returns false.

This impl sets targetX and targetY from point.

.

Overrides:
handleDrag in class HotSpot
Parameters:
dx - horizontal pixels moved since last call, view frame
dy - vertical pixels moved since last call, view frame
startDragPoint - the drag start point in world frame, not null
point - the current drag point in world frame, not null
modifiers - modifiersEx of the mouse event
accel - whether the user is indicating this is an accelerated gesture
Returns:
true iff the event should be "swallowed"

isTilt

protected boolean isTilt(int modifiers)

Check whether this is a tilt.

Current impl just looks for CTRL down.


addAnnotations

protected void addAnnotations(GraphicsDisplay graphicsDisplay)

Update the annotations.

Parameters:
graphicsDisplay - the GraphicsDisplay in which to draw

removeAnnotations

protected void removeAnnotations(GraphicsDisplay graphicsDisplay)

Clear the annotations.

Parameters:
graphicsDisplay - the GraphicsDisplay in which to draw

handleDragEnded

public void handleDragEnded(java.awt.geom.Point2D startDragPoint,
                            java.awt.geom.Point2D point,
                            int modifiers,
                            boolean accel)

Subclasses wishing to respond to drags may override this to be told when the drag ends.

This method will be called when a drag which started over the hotspot ends.

Default impl just returns false.

This impl clears dragOngoing.

Overrides:
handleDragEnded in class HotSpot
Parameters:
startDragPoint - the drag start point in world frame, not null
point - the end drag point in world frame, not null
modifiers - modifiersEx of the mouse event
accel - whether the user is indicating this is an accelerated gesture

doUpdate

protected void doUpdate(double currentTime)

(Re) cons chainIK if necessary and do up to iterationsPerUpdate IK iterations.

Does nothing unless an update is needed.

Parameters:
currentTime - the current time according to updateClock

setGraphicsDisplay

public void setGraphicsDisplay(GraphicsDisplay graphicsDisplay)

Used by GraphicsDisplay to notify this HotSpot when it has been added and removed.

This impl removes us from consideration for update.

Overrides:
setGraphicsDisplay in class HotSpot
Parameters:
graphicsDisplay - the GraphicsDisplay or null for none