gishur.gui2
Class ScreenTransformation

java.lang.Object
  |
  +--gishur.gui2.ScreenTransformation
Direct Known Subclasses:
ScreenGraphTransformation, ScreenX2Transformation, ScreenX2Transformation

public abstract class ScreenTransformation
extends java.lang.Object

ScreenTransformation is the abstract root class for all transformation classes that have to convert some objects in user space to screen coordinates. A ScreenTransformation should be able to convert screen coordinate points to some objects in user space vice versa. The visible (rectangular) area can should be transformable via simple affine transformations (to allow zooming, rotation and panning of the view port).

Version:
1.0
Author:
Thomas Wolf

Constructor Summary
ScreenTransformation()
           
 
Method Summary
 java.awt.Rectangle bounds()
          Returns the bounds of the screen in screen coordinates.
abstract  java.awt.Point deltaTransform(java.lang.Object point)
          Transforms a relative distance vector object in user space to a relative distance vector in screen coordinates.
 java.awt.Point[] deltaTransform(java.lang.Object[] points)
          Transforms an array of relative distance vector objects in user space to a relative distance vector array in screen coordinates.
abstract  java.awt.Point[] deltaTransform(java.lang.Object[] points, int off, int len)
          Transforms a subarray of relative distance vector objects in user space to a relative distance vector array in screen coordinates.
abstract  java.lang.Object inverseDeltaTransform(java.awt.Point point)
          Transforms a relative distance vector in screen coordinates to a relative distance vector object in user space.
 java.lang.Object inverseDeltaTransform(java.awt.Point[] points)
          Transforms an array of relative distance vectors in screen coordinates to an array of relative distance vector objects in user space.
abstract  java.lang.Object inverseDeltaTransform(java.awt.Point[] points, int off, int len)
          Transforms a subarray of relative distance vectors in screen coordinates to an array of relative distance vector objects in user space.
abstract  java.lang.Object inverseTransform(int x, int y)
          Transforms one point on the screen to a point object in user space.
 java.lang.Object inverseTransform(java.awt.Point point)
          Transforms one point on the screen to a point object in user space.
 java.lang.Object[] inverseTransform(java.awt.Point[] points)
          Transforms an array of points in screen coordinates to an array of point objects in user space.
abstract  java.lang.Object[] inverseTransform(java.awt.Point[] points, int off, int len)
          Transforms a subarray of points in screen coordinates to an array of point objects in user space.
abstract  void resetTransform()
          Resets the ScreenTransformation to its initial values (identity).
 void restoreStatus(java.lang.Object status)
          Restores a state saved via saveStatus().
 void rotate(double angle)
          Rotates the ScreenTransformation around the origin.
 void rotate(java.awt.Point center, double angle)
          Rotates the ScreenTransformation around an anchor point.
 void rotate(java.awt.Point center, java.awt.Point start, java.awt.Point end)
          Rotates the ScreenTransformation around an anchor point with the angle of rotation given by the two points start and end.
 java.lang.Object saveStatus()
          Returns the status of the ScreenTransformation to restore it via restoreStatus(java.lang.Object).
 void scale(double xscale, double yscale)
          Scales the ScreenTransformation with the given scale factors.
 void scale(java.awt.Point center, double xscale, double yscale)
          Scales the ScreenTransformation with leaving the given center point unchanged.
abstract  void screenTransform(double m00, double m01, double m02, double m10, double m11, double m12)
          Transforms the ScreenTransformation with the given transformation matrix.
abstract  java.awt.Point transform(java.lang.Object point)
          Transforms one point object in user space to a point on the screen.
 java.awt.Point[] transform(java.lang.Object[] points)
          Transforms an array of point objects in user space to a point array in screen coordinates.
abstract  java.awt.Point[] transform(java.lang.Object[] points, int off, int len)
          Transforms a subarray of point objects in user space to a point array in screen coordinates.
 java.lang.Object[] transformedBounds()
          Returns the corner points of the screen bounds transformed into user space point objects.
 void translate(int dx, int dy)
          Translates the ScreenTransformation by the given vector.
 void zoomTo(java.awt.Rectangle border, java.awt.Rectangle source, boolean maintain_aspect_ration)
          Scales the ScreenTransformation in that manner that the given source rectangle fully filles the specified border rectangle. if maintain_aspect_ration is true the aspect ratio will be maintained and the zoomed source rectangle will be centered in border.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScreenTransformation

public ScreenTransformation()
Method Detail

bounds

public java.awt.Rectangle bounds()
Returns the bounds of the screen in screen coordinates.
Returns:
Bounding rectangle of the screen in screen coordinates.

transformedBounds

public java.lang.Object[] transformedBounds()
Returns the corner points of the screen bounds transformed into user space point objects. The bounding points are reported in counterclockwise order.
Returns:
Array of point objects in user space that represent the corners of the screen rectangle.

saveStatus

public java.lang.Object saveStatus()
Returns the status of the ScreenTransformation to restore it via restoreStatus(java.lang.Object).
Returns:
the status of the ScreenTransformation.

restoreStatus

public void restoreStatus(java.lang.Object status)
Restores a state saved via saveStatus().
Parameters:
status - the status to restore (must be saved via saveStatus()).

transform

public abstract java.awt.Point transform(java.lang.Object point)
Transforms one point object in user space to a point on the screen.
Parameters:
point - point object in user space
Returns:
Point in screen coordinates.

transform

public abstract java.awt.Point[] transform(java.lang.Object[] points,
                                           int off,
                                           int len)
Transforms a subarray of point objects in user space to a point array in screen coordinates.
Parameters:
points - array of point objects in user space
off - offset of the subarray
len - length of the subarray
Returns:
Array of points in screen coordinates.

transform

public java.awt.Point[] transform(java.lang.Object[] points)
Transforms an array of point objects in user space to a point array in screen coordinates.
Parameters:
points - array of point objects in user space
Returns:
Array of points in screen coordinates.

inverseTransform

public abstract java.lang.Object inverseTransform(int x,
                                                  int y)
Transforms one point on the screen to a point object in user space.
Parameters:
point - point in screen coordinates
Returns:
x,y point in screen coordinates.

inverseTransform

public java.lang.Object inverseTransform(java.awt.Point point)
Transforms one point on the screen to a point object in user space.
Parameters:
point - point in screen coordinates
Returns:
Point object in user space.

inverseTransform

public abstract java.lang.Object[] inverseTransform(java.awt.Point[] points,
                                                    int off,
                                                    int len)
Transforms a subarray of points in screen coordinates to an array of point objects in user space.
Parameters:
points - array of points in screen coordinates
off - offset of the subarray
len - length of the subarray
Returns:
Array of point objects in user space.

inverseTransform

public java.lang.Object[] inverseTransform(java.awt.Point[] points)
Transforms an array of points in screen coordinates to an array of point objects in user space.
Parameters:
points - array of points in screen coordinates
Returns:
Array of point objects in user space.

deltaTransform

public abstract java.awt.Point deltaTransform(java.lang.Object point)
Transforms a relative distance vector object in user space to a relative distance vector in screen coordinates.
Parameters:
point - vector in user space
Returns:
Vector in screen coordinates.

deltaTransform

public abstract java.awt.Point[] deltaTransform(java.lang.Object[] points,
                                                int off,
                                                int len)
Transforms a subarray of relative distance vector objects in user space to a relative distance vector array in screen coordinates.
Parameters:
points - array of relative distance vector objects in user space
off - offset of the subarray
len - length of the subarray
Returns:
Array of relative distance vectors in screen coordinates.

deltaTransform

public java.awt.Point[] deltaTransform(java.lang.Object[] points)
Transforms an array of relative distance vector objects in user space to a relative distance vector array in screen coordinates.
Parameters:
points - array of relative distance vector objects in user space
Returns:
Array of relative distance vectors in screen coordinates.

inverseDeltaTransform

public abstract java.lang.Object inverseDeltaTransform(java.awt.Point point)
Transforms a relative distance vector in screen coordinates to a relative distance vector object in user space.
Parameters:
point - vector in user space
Returns:
Vector in screen coordinates.

inverseDeltaTransform

public abstract java.lang.Object inverseDeltaTransform(java.awt.Point[] points,
                                                       int off,
                                                       int len)
Transforms a subarray of relative distance vectors in screen coordinates to an array of relative distance vector objects in user space.
Parameters:
points - array of relative distance vectors in screen coordinates
off - offset of the subarray
len - length of the subarray
Returns:
Array of relative distance vector objects in user space.

inverseDeltaTransform

public java.lang.Object inverseDeltaTransform(java.awt.Point[] points)
Transforms an array of relative distance vectors in screen coordinates to an array of relative distance vector objects in user space.
Parameters:
points - array of relative distance vectors in screen coordinates
Returns:
Array of relative distance vector objects in user space.

resetTransform

public abstract void resetTransform()
Resets the ScreenTransformation to its initial values (identity).

screenTransform

public abstract void screenTransform(double m00,
                                     double m01,
                                     double m02,
                                     double m10,
                                     double m11,
                                     double m12)
Transforms the ScreenTransformation with the given transformation matrix.
Parameters:
m00,m01,m02 - first row of the transformation matrix
m10,m11,m12 - second row of the transformation matrix

scale

public void scale(java.awt.Point center,
                  double xscale,
                  double yscale)
Scales the ScreenTransformation with leaving the given center point unchanged.
Parameters:
center - the center point (will be unchanged)
xscale - scale factor for the x-axis
yscale - scale factor for the y-axis

scale

public void scale(double xscale,
                  double yscale)
Scales the ScreenTransformation with the given scale factors.
Parameters:
xscale - scale factor for the x-axis
yscale - scale factor for the y-axis

rotate

public void rotate(java.awt.Point center,
                   double angle)
Rotates the ScreenTransformation around an anchor point.
Parameters:
center - anchor point
angle - the angle of rotation in radians

rotate

public void rotate(java.awt.Point center,
                   java.awt.Point start,
                   java.awt.Point end)
Rotates the ScreenTransformation around an anchor point with the angle of rotation given by the two points start and end.
Parameters:
center - anchor point
start - start point
end - end point

rotate

public void rotate(double angle)
Rotates the ScreenTransformation around the origin.
Parameters:
angle - the angle of rotation

translate

public void translate(int dx,
                      int dy)
Translates the ScreenTransformation by the given vector.
Parameters:
(dx,dy) - the translational vector

zoomTo

public void zoomTo(java.awt.Rectangle border,
                   java.awt.Rectangle source,
                   boolean maintain_aspect_ration)
Scales the ScreenTransformation in that manner that the given source rectangle fully filles the specified border rectangle. if maintain_aspect_ration is true the aspect ratio will be maintained and the zoomed source rectangle will be centered in border.
Parameters:
source - rectangluar area to zoom
border - to zoom on
maintain_aspect_ration - maintaining aspect ratio if true