org.jaitools.jiffle.runtime
Class CoordinateTransforms

java.lang.Object
  extended by org.jaitools.jiffle.runtime.CoordinateTransforms

public class CoordinateTransforms
extends java.lang.Object

Utility class to create CoordinateTransform objects for simple cases.

Since:
0.1
Version:
$Id: CoordinateTransforms.java 1653 2011-06-16 10:23:02Z michael.bedward $
Author:
Michael Bedward

Constructor Summary
CoordinateTransforms()
           
 
Method Summary
static CoordinateTransform getTransform(java.awt.geom.Rectangle2D worldBounds, java.awt.Rectangle imageBounds)
          Gets the transform which converts from worldBounds to imageBounds.
static CoordinateTransform getTransform(java.awt.geom.Rectangle2D worldBounds, java.awt.Rectangle imageBounds, boolean reverseX, boolean reverseY)
          Gets the transform which converts from worldBounds to imageBounds.
static CoordinateTransform identity()
          Creates an identity transform.
static CoordinateTransform scale(double xscale, double yscale)
          Creates a scaling transform.
static CoordinateTransform translation(double dx, double dy)
          Creates a translation transform.
static CoordinateTransform unitBounds(java.awt.Rectangle imageBounds)
          Creates a transform for working in the unit rectangle, ie.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoordinateTransforms

public CoordinateTransforms()
Method Detail

identity

public static CoordinateTransform identity()
Creates an identity transform.

Returns:
a new transform instance

scale

public static CoordinateTransform scale(double xscale,
                                        double yscale)
Creates a scaling transform.

Parameters:
xscale - scale on the X axis
yscale - scale on the Y axis
Returns:
a new transform instance

translation

public static CoordinateTransform translation(double dx,
                                              double dy)
Creates a translation transform.

Parameters:
dx - translation in the X direction
dy - translation in the Y direction
Returns:
a new transform instance

unitBounds

public static CoordinateTransform unitBounds(java.awt.Rectangle imageBounds)
Creates a transform for working in the unit rectangle, ie. proportional image coordinates where both X and Y ordinates vary from 0 to 1.

Parameters:
imageBounds - the image bounds
Returns:
a new transform instance
Throws:
java.lang.IllegalArgumentException - if imageBounds is null or empty

getTransform

public static CoordinateTransform getTransform(java.awt.geom.Rectangle2D worldBounds,
                                               java.awt.Rectangle imageBounds)
Gets the transform which converts from worldBounds to imageBounds. This method is a shortcut for getTransform(worldBounds, imageBounds, false, false).

Parameters:
worldBounds - the coordinate bounds in world (user-defined) units
imageBounds - the image bounds
Returns:
a new transform instance
Throws:
java.lang.IllegalArgumentException - if either argument is null or empty

getTransform

public static CoordinateTransform getTransform(java.awt.geom.Rectangle2D worldBounds,
                                               java.awt.Rectangle imageBounds,
                                               boolean reverseX,
                                               boolean reverseY)
Gets the transform which converts from worldBounds to imageBounds. The two boolean arguments provide the option of treating the world X and/or Y axis direction as reversed in relation to the corresponding image axis direction.

Example: for an image representing a geographic area, aligned such that the image Y-axis was parallel with the world north-south axis, then setting reverseY to true will result in correct transformation of world to image coordinates.

Parameters:
worldBounds - the coordinate bounds in world (user-defined) units
imageBounds - the image bounds
reverseX - whether to treat the direction of the world X axis as reversed in relation to the image X axis
reverseY - whether to treat the direction of the world Y axis as reversed in relation to the image Y axis
Returns:
a new transform instance
Throws:
java.lang.IllegalArgumentException - if either argument is null or empty


Copyright © 2011. All Rights Reserved.