|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--nl.kun.Engine3D.Viewport
This class can be used to draw on a canvas using physical coordinates, while the viewport translates these to screen coordinates.
Field Summary | |
java.awt.Dimension |
CanvasSize
The size of the canvas in screen coordinates |
double |
zoom
zoom parameter. |
Constructor Summary | |
|
Viewport()
Empty constructor. |
(package private) |
Viewport(java.awt.Dimension _d,
double _xmi,
double _ymi,
double _xma,
double _yma,
boolean _corrFlag,
java.awt.Graphics g)
Constructor |
Method Summary | |
void |
ArcDraw(double _centerX,
double _centerY,
double _radius,
double _beginAngle,
double _endAngle,
java.awt.Color _color)
Draws an arc on screen. |
void |
Line(double _x1,
double _y1,
double _x2,
double _y2,
java.awt.Color _color)
Draws a line on screen. |
void |
LineArr(double[] Xpoints,
double[] Ypoints,
java.awt.Color _color)
Draws a set of lines between points in an array. |
boolean |
OnScreen(double _x,
double _y)
Boolean function to determine if a point (_x,_y) in physical coordinates is within the screen limits |
void |
Plane(double[] _Xpoints,
double[] _Ypoints,
java.awt.Color _color)
Draw a filled polygon on screen. |
int |
ScaleCanvasX(double _R)
Scales an x value in physical coordinates to screen coordinates (needed when determining distances for circle drawing) |
int |
ScaleCanvasY(double _R)
Scales an y value in physical coordinates to screen coordinates (needed when determining distances for circle drawing) |
void |
Sphere(double _x,
double _y,
double _R,
java.awt.Color _color)
Draws a sphere on screen |
void |
StringDraw(double _string,
int _x,
int _y)
Draws a string on screen in screen coordinates |
void |
StringDraw(java.lang.String _string,
double _x,
double _y,
java.awt.Color _color)
Draws a string on screen in physical coordinates |
void |
UpdateGr(java.awt.Graphics g)
Update the graphics object. |
int |
Xcanvas(double _x)
Translates x position in physical coordinates to screen coordinates |
int |
Ycanvas(double _y)
Translates y position in physical coordinates to screen coordinates |
Methods inherited from class java.lang.Object |
|
Field Detail |
public java.awt.Dimension CanvasSize
public double zoom
Constructor Detail |
Viewport(java.awt.Dimension _d, double _xmi, double _ymi, double _xma, double _yma, boolean _corrFlag, java.awt.Graphics g)
_d
- The dimension of the canvas on which the viewport works in screen coordinates_xmi
- minimum X position in physical coordinates._ymi
- minimum Y position in physical coordinates._xma
- maximum X position in physical coordinates._yma
- maximum Y position in physical coordinates._corrFlag
- boolean to determine if the physical limits of the viewport should be corrected to
create rectangular pixels (true), or if they should obey the physical limits put in by the users (false).g
- The graphics object of the canvas (or any other drawable surface).public Viewport()
Method Detail |
public final int Xcanvas(double _x)
_x
- x position in physical coordinatespublic final int Ycanvas(double _y)
_y
- y position in physical coordinatespublic int ScaleCanvasX(double _R)
_R
- x value in physical coordinatespublic int ScaleCanvasY(double _R)
_R
- y value in physical coordinatespublic boolean OnScreen(double _x, double _y)
_x
- x coordinate of the point_y
- y coordinate of the point
returns true if it is onscreen and false if not.public void UpdateGr(java.awt.Graphics g)
g
- Graphics object of the canvas (or other drawable surface)public void Line(double _x1, double _y1, double _x2, double _y2, java.awt.Color _color)
_x1
- x coordinate of first point of the line in physical coordinates_y1
- y coordinate of first point of the line in physical coordinates_x2
- x coordinate of second point of the line in physical coordinates_y2
- y coordinate of second point of the line in physical coordinates_color
- Color of the linepublic void LineArr(double[] Xpoints, double[] Ypoints, java.awt.Color _color)
Xpoints
- array of x valuesYpoints
- array of y values_color
- Color of the lines.public void Plane(double[] _Xpoints, double[] _Ypoints, java.awt.Color _color)
_Xpoints[]
- Array of X values of the polygon in physical coordinates_Ypoints[]
- Array of Y values of the polygon in physical coordinates_color
- color of the polygonpublic void Sphere(double _x, double _y, double _R, java.awt.Color _color)
_x
- x coordinate of the center of the sphere in physical coordinates_y
- y coordinate of the center of the sphere in physical coordinates_R
- Radius of the sphere in physical coordinatespublic void StringDraw(double _string, int _x, int _y)
_string
- String with the text that is to be printed_x
- x coordinate of lower left corner of the text in screen coordinates_y
- y coordinate of lower left corner of the text in screen coordinatespublic void StringDraw(java.lang.String _string, double _x, double _y, java.awt.Color _color)
_string
- String with the text that is to be printed_x
- x coordinate of lower left corner of the text in physical coordinates_y
- y coordinate of lower left corner of the text in physical coordinates_color
- Color of the text.public void ArcDraw(double _centerX, double _centerY, double _radius, double _beginAngle, double _endAngle, java.awt.Color _color)
_centerX
- x coordinate of the center of the arc in physical coordinates_centerY
- y coordinate of the center of the arc in physical coordinates_radius
- Radius of the arc in physical coordinates_beginAngle
- starting angle of arc in radians_beginAngle
- ending angle of arc in radians
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |