gumbo.graphic.space
Class AbstractSpaceMapper

java.lang.Object
  |
  +--gumbo.graphic.space.AbstractSpaceMapper
All Implemented Interfaces:
Graphic, SpaceMapper

public class AbstractSpaceMapper
extends java.lang.Object
implements SpaceMapper

A full implementation of the SpaceMapper interface. Implementations should override these methods to take advantage of native graphic constraints and capabilities.

The default implementation caches (automatically saves) the last source space, target space, and transform used by any transform method. Caching greatly improves the performance of a series of point and vector transformations along the same transform path. If the cached transform is suspected of being stale (a transform node along the path may have changed), first call a transform method with null as the source and target space to effectively clear the cache.

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

Constructor Summary
AbstractSpaceMapper()
          Creates an instance.
 
Method Summary
 java.lang.Object getGraphic()
          Default implementation: Returns this object (non-native direct implementation).
 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)
          Default implementation: Transforms the input point with the cached transform using matrix multiplication.
 Vector3 transformGraphic(Vector3 vector, SpaceNode from, SpaceNode to, Vector3 retVal)
          Default implementation: Transforms the input vector with the cached transform using matrix multiplication.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSpaceMapper

public AbstractSpaceMapper()
Creates an instance. Master constructor.

Method Detail

transformGraphic

public Point3 transformGraphic(Point3 point,
                               SpaceNode from,
                               SpaceNode to,
                               Point3 retVal)
Default implementation: Transforms the input point with the cached transform using matrix multiplication. If a new transform path, first calls getGraphicTransform() and caches the new transform data.

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)
Default implementation: Transforms the input vector with the cached transform using matrix multiplication. If a new transform path, first calls getGraphicTransform() and caches the new transform data.

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()
Default implementation: Returns this object (non-native direct implementation).

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