public class Transcaler
extends java.lang.Object
Device coordinates are ints, and the device coordinate rectangle typically corresponds to device bounds. User coordinates are doubles.
In conversion from user to device coordinates, the latter are clipped to lie in the range [-32768,32767], which is the range of a 16-bit short integer. Although device coordinates are represented by ints, they are often limited by an underlying graphics systems to the 16-bit range of shorts.
Conversion from/to user coordinates to/from device coordinates behaves robustly in the cases where the mapping is degenerate. For example, if the device coordinate rectangle has width one, then conversion from any device x-coordinate to user x-coordinate yields the average of the user x-coordinate bounds. Likewise, if the user coordinate rectangle has zero width, then conversion from any user x-coordinate to device x-coordinate yields the average of the device x-coordinate bounds.
Constructor and Description |
---|
Transcaler()
Constructs a transcaler with identity coordinate mapping.
|
Transcaler(double x1u,
double y1u,
double x2u,
double y2u,
int x1d,
int y1d,
int x2d,
int y2d)
Constructs a transcaler with specified coordinate mapping.
|
Transcaler(int width,
int height)
Constructs a transcaler with specified device width and height.
|
Modifier and Type | Method and Description |
---|---|
Transcaler |
combineWith(Projector xp,
Projector yp)
Returns a new transcaler that combines this transcaler with projectors.
|
int |
height(double hu)
Converts the specified user-coordinate height to device-coordinate height.
|
double |
height(int hd)
Converts the specified device-coordinate height to user-coordinate height.
|
void |
setMapping(double x1u,
double y1u,
double x2u,
double y2u)
Sets the user-coordinate part of the mapping for this transcaler.
|
void |
setMapping(double x1u,
double y1u,
double x2u,
double y2u,
int x1d,
int y1d,
int x2d,
int y2d)
Sets the coordinate mapping for this transcaler.
|
void |
setMapping(int width,
int height)
Sets the device-coordinate width and height.
|
void |
setMapping(int x1d,
int y1d,
int x2d,
int y2d)
Sets the device-coordinate part of the mapping for this transcaler.
|
int |
width(double wu)
Converts the specified user-coordinate width to device-coordinate width.
|
double |
width(int wd)
Converts the specified device-coordinate width to user-coordinate width.
|
int |
x(double xu)
Converts the specified user x-coordinate to device x-coordinate.
|
double |
x(int xd)
Converts the specified device x-coordinate to user x-coordinate.
|
int |
y(double yu)
Converts the specified user y-coordinate to device y-coordinate.
|
double |
y(int yd)
Converts the specified device y-coordinate to user y-coordinate.
|
public Transcaler()
public Transcaler(int width, int height)
width
- the width, in device coordinates.height
- the height, in device coordinates.public Transcaler(double x1u, double y1u, double x2u, double y2u, int x1d, int y1d, int x2d, int y2d)
x1u
- the user x-coordinate corresponding to x1d.y1u
- the user y-coordinate corresponding to y1d.x2u
- the user x-coordinate corresponding to x2d.y2u
- the user y-coordinate corresponding to y2d.x1d
- the device x-coordinate corresponding to x1u.y1d
- the device y-coordinate corresponding to y1u.x2d
- the device x-coordinate corresponding to x2u.y2d
- the device y-coordinate corresponding to y2u.public void setMapping(double x1u, double y1u, double x2u, double y2u, int x1d, int y1d, int x2d, int y2d)
x1u
- the user x-coordinate corresponding to x1d.y1u
- the user y-coordinate corresponding to y1d.x2u
- the user x-coordinate corresponding to x2d.y2u
- the user y-coordinate corresponding to y2d.x1d
- the device x-coordinate corresponding to x1u.y1d
- the device y-coordinate corresponding to y1u.x2d
- the device x-coordinate corresponding to x2u.y2d
- the device y-coordinate corresponding to y2u.public void setMapping(double x1u, double y1u, double x2u, double y2u)
x1u
- the user x-coordinate corresponding to the current x1d.y1u
- the user y-coordinate corresponding to the current y1d.x2u
- the user x-coordinate corresponding to the current x2d.y2u
- the user y-coordinate corresponding to the current y2d.public void setMapping(int x1d, int y1d, int x2d, int y2d)
x1d
- the device x-coordinate corresponding to the current x1u.y1d
- the device y-coordinate corresponding to the current y1u.x2d
- the device x-coordinate corresponding to the current x2u.y2d
- the device y-coordinate corresponding to the current y2u.public void setMapping(int width, int height)
public Transcaler combineWith(Projector xp, Projector yp)
xp
- the projector for x coordinates.yp
- the projector for y coordinates.public int x(double xu)
xu
- the user x-coordinate.public int y(double yu)
yu
- the user y-coordinate.public int width(double wu)
wu
- the user-coordinate width.public int height(double hu)
hu
- the user-coordinate height.public double x(int xd)
xd
- the device x-coordinate.public double y(int yd)
yd
- the device y-coordinate.public double width(int wd)
wd
- the device-coordinate width.public double height(int hd)
hd
- the device-coordinate height.