public class VUI
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.lang.Integer |
lastDragX
The last horizontal position of the mouse when dragging
|
protected java.lang.Integer |
lastDragY
The last vertical position of the mouse when dragging
|
protected double |
zoom
The value of the zoom. 100 means 1/1 scale
|
Modifier and Type | Method and Description |
---|---|
void |
add(Drawable d)
Add an object to the VUI and repaint it
|
DrawableImage |
createImage(double dx,
double dy,
java.lang.String filename)
Create an image and start rendering it
|
DrawablePoint |
createPoint(double dx,
double dy)
Create a point and start rendering it
|
DrawableRectangle |
createRectangle(double x,
double y,
double w,
double h)
Create a rectangle and start rendering it
|
DrawableString |
createString(int dx,
int dy,
java.lang.String text)
Create a string and start rendering it
|
static VUI |
get()
Get the default VUI
|
static VUI |
get(java.lang.String id)
Create or get a VUI
|
double |
getCanvasHeight()
Get the height of the canvas
|
double |
getCanvasWidth()
Get the width of the canvas
|
double |
getWorldOffsetX()
Get the value that must be added to the X coordinate of in world object
|
double |
getWorldOffsetY()
Get the value that must be added to the Y coordinate of in world object
|
double |
getZoomFactor()
A value that must be multiplied to scale objects
|
double |
screenToWorldDistance(int d)
Convert a distance on the screen to its equivalent in the world
|
double |
screenToWorldX(double x)
Convert a X on the screen to its equivalent in the world
|
double |
screenToWorldY(double y)
Convert a Y on the screen to its equivalent in the world
|
void |
setDefaultView(double zoom,
double worldCenterX,
double worldCenterY)
Set the default configuration of the view
|
void |
setWorldOffsetX(double offsetX)
Set the value that must be added to the X coordinate of in world object
|
void |
setWorldOffsetY(double offsetY)
Set the value that must be added to the Y coordinate of in world object
|
void |
updateCanvas()
Refresh the canvas
|
int |
worldToScreenDistance(double d)
Convert a distance in the world to its equivalent on the screen
|
int |
worldToScreenX(double x)
Convert a X in the world to its equivalent on the screen
|
int |
worldToScreenY(double y)
Convert a Y in the world to its equivalent on the screen
|
protected java.lang.Integer lastDragX
protected java.lang.Integer lastDragY
protected double zoom
public static VUI get()
public static VUI get(java.lang.String id)
id
- The unique id of the VUIpublic int worldToScreenDistance(double d)
d
- the in world distancepublic double screenToWorldDistance(int d)
d
- the on screen distancepublic int worldToScreenX(double x)
x
- the X in worldpublic double getZoomFactor()
public int worldToScreenY(double y)
y
- the Y in worldpublic double screenToWorldX(double x)
x
- the X on screenpublic double screenToWorldY(double y)
y
- the Y on screenpublic void add(Drawable d)
d
- the new objectpublic void updateCanvas()
public double getCanvasWidth()
public double getCanvasHeight()
public double getWorldOffsetX()
public void setWorldOffsetX(double offsetX)
offsetX
- the X offsetpublic double getWorldOffsetY()
public void setWorldOffsetY(double offsetY)
offsetY
- the Y offsetpublic DrawablePoint createPoint(double dx, double dy)
dx
- the x coordinatedy
- the y coordinatepublic DrawableRectangle createRectangle(double x, double y, double w, double h)
x
- the x coordinatey
- the y coordinatew
- the widthh
- the heightpublic void setDefaultView(double zoom, double worldCenterX, double worldCenterY)
zoom
- the initial zoom valueworldCenterX
- the initial X center valueworldCenterY
- the initial Y center valuepublic DrawableImage createImage(double dx, double dy, java.lang.String filename)
dx
- the x coordinatedy
- the y coordinatefilename
- the filename of the imagepublic DrawableString createString(int dx, int dy, java.lang.String text)
dx
- the x coordinatedy
- the y coordinatetext
- the text to display