public class ScreenTransform
extends java.lang.Object
Constructor and Description |
---|
ScreenTransform(double minX,
double minY,
double maxX,
double maxY)
Create a ScreenTransform that covers a particular world coordinate range.
|
Modifier and Type | Method and Description |
---|---|
java.awt.geom.Rectangle2D |
getViewBounds()
Get the current view bounds in world coordinates.
|
boolean |
isInView(java.awt.geom.Point2D p)
Find out if a point is inside the current view bounds.
|
boolean |
isInView(java.awt.Shape s)
Find out if a shape is inside the current view bounds.
|
void |
makeCentreRelativeTo(double x,
double y,
int screenX,
int screenY)
Set the on-screen center point relative to another point.
|
void |
rescale(int width,
int height)
Recalculate the transform based on screen geometry.
|
void |
resetZoom()
Reset the zoom level to one.
|
double |
screenToX(int x)
Convert a screen X coordinate to a world coordinate.
|
double |
screenToY(int y)
Convert a screen Y coordinate to a world coordinate.
|
void |
setCentrePoint(double x,
double y)
Set the on-screen centre point.
|
void |
setFixedAspectRatio(boolean b)
Set whether to use a fixed aspect ratio or not.
|
void |
show(java.awt.geom.Rectangle2D bounds)
Zoom and translate to show a particular rectangle.
|
int |
xToScreen(double x)
Convert a world X coordinate to a screen coordinate.
|
int |
yToScreen(double y)
Convert a world Y coordinate to a screen coordinate.
|
void |
zoomIn()
Increase the zoom level by one step.
|
void |
zoomOut()
Decrease the zoom level by one step.
|
public ScreenTransform(double minX, double minY, double maxX, double maxY)
minX
- The minimum X world coordinate.minY
- The minimum Y world coordinate.maxX
- The maximum X world coordinate.maxY
- The maximum Y world coordinate.public void setCentrePoint(double x, double y)
x
- The X world coordinate to put in the centre.y
- The Y world coordinate to put in the centre.public void makeCentreRelativeTo(double x, double y, int screenX, int screenY)
x
- The world X coordinate.y
- The world Y coordinate.screenX
- The screen X coordinate.screenY
- The screen Y coordinate.public void setFixedAspectRatio(boolean b)
b
- True to use a fixed aspect ratio, false otherwise.public void zoomIn()
public void zoomOut()
public void resetZoom()
public void show(java.awt.geom.Rectangle2D bounds)
bounds
- The bounds of the rectangle to show.public void rescale(int width, int height)
width
- The width of the screen.height
- The height of the screen.public boolean isInView(java.awt.Shape s)
s
- The shape to test.public boolean isInView(java.awt.geom.Point2D p)
p
- The point to test.public java.awt.geom.Rectangle2D getViewBounds()
public int xToScreen(double x)
x
- The world X coordinate.public int yToScreen(double y)
y
- The world Y coordinate.public double screenToX(int x)
x
- The screen X coordinate.public double screenToY(int y)
y
- The screen Y coordinate.