gumbo.graphic.impl.swing
Class SwingSpaceMapper

java.lang.Object
  |
  +--gumbo.graphic.impl.swing.SwingSpaceMapper
All Implemented Interfaces:
Graphic, SpaceMapper

public class SwingSpaceMapper
extends java.lang.Object
implements SpaceMapper

A stateless SpaceMapper for Swing graphics. In Swing, spatial transformation is constrained to 2D translation. All methods throw an exception if the from and to space node graphic is not a Component.

Version:
$Revision: 1.1 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.

Field Summary
static SpaceMapper INSTANCE
           
 
Constructor Summary
protected SwingSpaceMapper()
           
 
Method Summary
 java.lang.Object getGraphic()
          Returns this object (no Swing graphic equivalent).
 Matrix4 getGraphicTransform(SpaceNode from, SpaceNode to, Matrix4 retVal)
          Default implementation: Recursively computes a new transform using matrix multiplication, updates the cache with it, and returns it.
 Point3 transformGraphic(Point3 point, SpaceNode from, SpaceNode to, Point3 retVal)
          Transforms a point from one local space to another.
 Vector3 transformGraphic(Vector3 vector, SpaceNode from, SpaceNode to, Vector3 retVal)
          Copies vector to retVal (Swing only translates, hence null op).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final SpaceMapper INSTANCE
Constructor Detail

SwingSpaceMapper

protected SwingSpaceMapper()
Method Detail

transformGraphic

public Point3 transformGraphic(Point3 point,
                               SpaceNode from,
                               SpaceNode to,
                               Point3 retVal)
Description copied from interface: SpaceMapper
Transforms a point from one local space to another. Consistent with the definition of a point, the point's W component is assumed to be one. For efficiency the transform may be cached.

Specified by:
transformGraphic in interface SpaceMapper
Parameters:
point - Value of a point in the from space. Never null.
from - The source space. If null, the tree's absolute space.
to - The target space. If null, the tree's absolute space.
retVal - The return value object. The transformed point Never null.
Returns:
Reference to retVal. Never null.

transformGraphic

public Vector3 transformGraphic(Vector3 vector,
                                SpaceNode from,
                                SpaceNode to,
                                Vector3 retVal)
Copies vector to retVal (Swing only translates, hence null op).

Specified by:
transformGraphic in interface SpaceMapper
Parameters:
vector - Value of a vector in the from space. Never null.
from - The source space. If null, the tree's absolute space.
to - The target space. If null, the tree's absolute space.
retVal - The return value object. The transformed vector Never null.
Returns:
Reference to retVal. Never null.

getGraphicTransform

public Matrix4 getGraphicTransform(SpaceNode from,
                                   SpaceNode to,
                                   Matrix4 retVal)
Default implementation: Recursively computes a new transform using matrix multiplication, updates the cache with it, and returns it. As required by SpaceMapper, the resulting transform is never stale.

Specified by:
getGraphicTransform in interface SpaceMapper
Parameters:
from - The source space. If null, the tree's absolute space.
to - The target space. If null, the tree's absolute space.
retVal - The return value object. The transform matrix. Never null.
Returns:
Reference to retVal. Never null.

getGraphic

public java.lang.Object getGraphic()
Returns this object (no Swing graphic equivalent).

Specified by:
getGraphic in interface Graphic
Returns:
The target graphic object. Possibly this object (self-proxy, direct implementation), but never null.