jview
Class Transform2D

java.lang.Object
  extended by jview.Transform2D
All Implemented Interfaces:
CoordinateTransforming

public class Transform2D
extends Object
implements CoordinateTransforming

A simple class that directly scales user-space coordinates into normalized coordinates.


Field Summary
private  Rectangle2D bounds
          All we have to know for the coordinate transformation.
 
Constructor Summary
Transform2D(double xmin, double xmax, double ymin, double ymax)
          Constructs a 2D transformation with the specified x/y bounds.
Transform2D(Rectangle2D rect)
          Constructs a 2D transformation with the specified x/y bounds.
 
Method Summary
 Point2D toNormalizedSpace(VectorG twodim)
          Converts a user coordinate into normalized coordinates.
 VectorG toUserSpace(Point2D norm)
          Converts normalized coordinates to user space.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bounds

private Rectangle2D bounds
All we have to know for the coordinate transformation.

Constructor Detail

Transform2D

public Transform2D(double xmin,
                   double xmax,
                   double ymin,
                   double ymax)
Constructs a 2D transformation with the specified x/y bounds.

Parameters:
xmin - The user-space x-coordinate that translates to zero.
xmax - The user-space x-coordinate that translates to one.
ymin - The user-space y-coordinate that translates to zero.
ymax - The user-space y-coordinate that translates to one.

Transform2D

public Transform2D(Rectangle2D rect)
Constructs a 2D transformation with the specified x/y bounds.

Parameters:
rect - The bounding rectangle.
Method Detail

toNormalizedSpace

public Point2D toNormalizedSpace(VectorG twodim)
Converts a user coordinate into normalized coordinates.

Specified by:
toNormalizedSpace in interface CoordinateTransforming
Parameters:
twodim - A vector of user coordinates.
Returns:
A point in normalized screen coordinate, with 0≤x,y≤1

toUserSpace

public VectorG toUserSpace(Point2D norm)
Converts normalized coordinates to user space.

Specified by:
toUserSpace in interface CoordinateTransforming
Parameters:
norm - A pixel in normalized coordinates.
Returns:
A Vector2D.