The Physiologist's Friend Simulation API

ch.unizh.ini.friend.graphics
Class ConcreteSeparateTransforms

java.lang.Object
  extended by ch.unizh.ini.friend.graphics.ConcreteSeparateTransforms
All Implemented Interfaces:
BufferedTransform, SeparateTransforms, Transformable, Cloneable

public class ConcreteSeparateTransforms
extends Object
implements SeparateTransforms

Provides the facilities to keep a geometric object in its original state while buffering applied transformations. A transformed geometric object will only be created on request. The individual transformations 'general', 'scaling', 'rotation', 'translation' are kept atored individuallly each and are applied in that order.

Version:
$Revision: 1.6 $
Author:
Christof Marti

Field Summary
protected  Transformable geometry
          Transformable against which transformations are buffered
protected  AffineTransform rotation
          The rotations.
protected  AffineTransform scaling
          The scalings.
protected  AffineTransform transformation
          The generic transformations.
protected  Transformable transformed
          A transformed clone, null if uncached.
protected  AffineTransform translation
          The translations.
 
Constructor Summary
ConcreteSeparateTransforms(Transformable geometry)
          Creates a new instance with the given geometric object
 
Method Summary
 Transformable apply(AffineTransform at)
          Applies the given transformation to the geometric object.
 Object clone()
          Clones this geometric object.
 Transformable getGeometry()
          Returns the original geometric object.
 AffineTransform getRotation()
          Returns the buffered rotation.
 AffineTransform getScaling()
          Returns the buffered scaling.
 AffineTransform getTransformation()
          Returns the buffered generic transformation.
 Transformable getTransformed()
          Returns the transformed geometric object.
 AffineTransform getTranslation()
          Returns the buffered translation.
 Transformable rotate(float phi)
          Rotates the geometric object by the given angle around the origin.
 Transformable rotate(float phi, float x, float y)
          Rotates the geometric object by the given angle around the given point.
 Transformable rotateTo(float phi)
          Rotates the geometric object by the given angle around the origin.
 Transformable rotateTo(float phi, float x, float y)
          Rotates the geometric object by the given angle around the given point.
 Transformable scale(float sx, float sy)
          Scales the geometric object by the given values in x- and y-coordinates with the origin as center.
 Transformable scale(float sx, float sy, float x, float y)
          Scales the geometric object by the given values in x- and y-coordinates with the given center (x, y).
 Transformable scaleTo(float sx, float sy)
          Scales the geomtric object by the given values in x- and y-coordinates with the origin as center.
 Transformable scaleTo(float sx, float sy, float x, float y)
          Scales the geomtric object by the given values in x- and y-coordinates with the given center (x, y).
 void setGeometry(Transformable geometry)
          Sets the original geometric object.
 void setRotation(AffineTransform rotation)
          Sets the buffered rotation.
 void setScaling(AffineTransform scaling)
          Sets the buffered scaling.
 void setTransformation(AffineTransform transformation)
          Sets the buffered generic transformation.
 void setTranslation(AffineTransform translation)
          Sets the buffered translation.
 String toString()
          return string representation of the transforms
 Transformable translate(float dx, float dy)
          Translates the geometric object by the given coordinates.
 Transformable translateTo(float dx, float dy)
          Translates the geometric object by the given coordinates.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

geometry

protected Transformable geometry
Transformable against which transformations are buffered


transformed

protected Transformable transformed
A transformed clone, null if uncached.


transformation

protected AffineTransform transformation
The generic transformations.


scaling

protected AffineTransform scaling
The scalings.


rotation

protected AffineTransform rotation
The rotations.


translation

protected AffineTransform translation
The translations.

Constructor Detail

ConcreteSeparateTransforms

public ConcreteSeparateTransforms(Transformable geometry)
Creates a new instance with the given geometric object

Parameters:
geometry - The geometric object the transformations will be buffered against
Method Detail

apply

public Transformable apply(AffineTransform at)
Applies the given transformation to the geometric object. Does not necessarily copy the passed transform.

Specified by:
apply in interface Transformable
Parameters:
at - The affine transformation to apply.
Returns:
this for easy concatenation or a transformed clone.

rotate

public Transformable rotate(float phi)
Rotates the geometric object by the given angle around the origin.

Specified by:
rotate in interface Transformable
Parameters:
phi - Rotation angle.
Returns:
this for easy concatenation or a transformed clone.

rotate

public Transformable rotate(float phi,
                            float x,
                            float y)
Rotates the geometric object by the given angle around the given point.

Specified by:
rotate in interface Transformable
Parameters:
phi - Rotation angle.
x - x-coordinate of the rotation center.
y - y-coordinate of the rotation center.
Returns:
this for easy concatenation or a transformed clone.

scale

public Transformable scale(float sx,
                           float sy)
Scales the geometric object by the given values in x- and y-coordinates with the origin as center.

Specified by:
scale in interface Transformable
Parameters:
sx - Scalar for x-coordinates.
sy - Scalar for y-coordinates.
Returns:
this for easy concatenation or a transformed clone.

scale

public Transformable scale(float sx,
                           float sy,
                           float x,
                           float y)
Scales the geometric object by the given values in x- and y-coordinates with the given center (x, y).

Specified by:
scale in interface Transformable
Parameters:
sx - Scalar for x-coordinates.
sy - Scalar for y-coordinates.
x - x-coordinate of the center.
y - y-coordinate of the center.
Returns:
this for easy concatenation or a transformed clone.

translate

public Transformable translate(float dx,
                               float dy)
Translates the geometric object by the given coordinates.

Specified by:
translate in interface Transformable
Parameters:
dx - Translation in x-coordinates.
dy - Translation in y-coordinates.
Returns:
this for easy concatenation or a transformed clone.

getGeometry

public Transformable getGeometry()
Returns the original geometric object.

Specified by:
getGeometry in interface SeparateTransforms
Returns:
The geometric object.

setGeometry

public void setGeometry(Transformable geometry)
Sets the original geometric object.

Specified by:
setGeometry in interface SeparateTransforms
Parameters:
geometry - The geometric object.

getTransformed

public Transformable getTransformed()
Returns the transformed geometric object.

Specified by:
getTransformed in interface BufferedTransform
Specified by:
getTransformed in interface SeparateTransforms
Returns:
The geometical object.

getTransformation

public AffineTransform getTransformation()
Returns the buffered generic transformation.

Specified by:
getTransformation in interface SeparateTransforms
Returns:
The generic transformation.

setTransformation

public void setTransformation(AffineTransform transformation)
Sets the buffered generic transformation.

Specified by:
setTransformation in interface SeparateTransforms
Parameters:
transformation - The generic transformation.

getScaling

public AffineTransform getScaling()
Returns the buffered scaling.

Specified by:
getScaling in interface SeparateTransforms
Returns:
The scaling.

setScaling

public void setScaling(AffineTransform scaling)
Sets the buffered scaling.

Specified by:
setScaling in interface SeparateTransforms
Parameters:
scaling - The scaling.

getRotation

public AffineTransform getRotation()
Returns the buffered rotation.

Specified by:
getRotation in interface SeparateTransforms
Returns:
The rotation.

setRotation

public void setRotation(AffineTransform rotation)
Sets the buffered rotation.

Specified by:
setRotation in interface SeparateTransforms
Parameters:
rotation - The rotation.

getTranslation

public AffineTransform getTranslation()
Returns the buffered translation.

Specified by:
getTranslation in interface SeparateTransforms
Returns:
The translation.

setTranslation

public void setTranslation(AffineTransform translation)
Sets the buffered translation.

Specified by:
setTranslation in interface SeparateTransforms
Parameters:
translation - The translation.

clone

public Object clone()
Clones this geometric object.

Specified by:
clone in interface Transformable
Overrides:
clone in class Object
Returns:
The clone.

rotateTo

public Transformable rotateTo(float phi)
Rotates the geometric object by the given angle around the origin. Overwrites the current rotation.

Specified by:
rotateTo in interface SeparateTransforms
Parameters:
phi - Rotation angle.
Returns:
this for easy concatenation or a transformed clone.

rotateTo

public Transformable rotateTo(float phi,
                              float x,
                              float y)
Rotates the geometric object by the given angle around the given point. Overwrites the current rotation.

Specified by:
rotateTo in interface SeparateTransforms
Parameters:
phi - Rotation angle.
x - x-coordinate of the rotation center.
y - y-coordinate of the rotation center.
Returns:
this for easy concatenation or a transformed clone.

scaleTo

public Transformable scaleTo(float sx,
                             float sy)
Scales the geomtric object by the given values in x- and y-coordinates with the origin as center. Overwrites the current scaling.

Specified by:
scaleTo in interface SeparateTransforms
Parameters:
sx - Scalar for x-coordinates.
sy - Scalar for y-coordinates.
Returns:
this for easy concatenation or a transformed clone.

scaleTo

public Transformable scaleTo(float sx,
                             float sy,
                             float x,
                             float y)
Scales the geomtric object by the given values in x- and y-coordinates with the given center (x, y). Overwrites the current scaling.

Specified by:
scaleTo in interface SeparateTransforms
Parameters:
sx - Scalar for x-coordinates.
sy - Scalar for y-coordinates.
x - x-coordinate of the center.
y - y-coordinate of the center.
Returns:
this for easy concatenation or a transformed clone.

translateTo

public Transformable translateTo(float dx,
                                 float dy)
Translates the geometric object by the given coordinates. Overwrites the current translation.

Specified by:
translateTo in interface SeparateTransforms
Parameters:
dx - Translation in x-coordinates.
dy - Translation in y-coordinates.
Returns:
this for easy concatenation or a transformed clone.

toString

public String toString()
return string representation of the transforms

Overrides:
toString in class Object

http://www.ini.unizh.ch/~tobi/friend