SciLib.Grp
Class Graphics2D

java.lang.Object
  extended by SciLib.Grp.Graphics2D
Direct Known Subclasses:
Graphics3D

public class Graphics2D
extends java.lang.Object

This class contains some methods to draw a 2D graphics.


Field Summary
protected static int height
           
static double Pi
          The constant value Pi = 3.141592
protected static int width
           
 
Constructor Summary
Graphics2D()
           
 
Method Summary
 void box(java.awt.Graphics g, double minx, double miny, double maxx, double maxy)
          Plot a rectangle.
 void changeWindowSize(java.awt.Dimension d)
          change graphics window size
 void changeWindowSize(int w, int h)
          change graphics window size
 void coord(java.awt.Graphics g, double minx, double miny, double maxx, double maxy)
          Draw a 2D coordinate system in a frame window.
 void coord2D(java.awt.Graphics g, double minx, double miny, double maxx, double maxy)
          Make a 2D coordinate system without drawing it in a frame window.
 void coord2D(java.awt.Graphics g, vector xv, vector yv)
          Make a 2D coordinate system and plot it in a frame window.
 void coord2D(java.awt.Graphics g, vector xv, vector yv, java.lang.String specific)
          Make a 2D coordinate system and plot it in a frame window with a specific
 void drawLine(java.awt.Graphics g, double x1, double y1, double x2, double y2)
          draw a line from (x1,y1) to (x2,y2)
 matrix getView2D()
          Return the view matrix.
 void grid(java.awt.Graphics g, double minx, double miny, double maxx, double maxy, double oX, double oY)
          Draw a 2D grid coordinate system in a frame window.
 void halfGrid(java.awt.Graphics g, double minx, double miny, double maxx, double maxy, double oX, double oY)
          Draw a 2D halfGrid coordinate system in a frame window.
 void lineTo(java.awt.Graphics g, double x, double y)
          draw line from the current position to a point (x,y)
 void moveTo(double x, double y)
          move pen to a real position (x, y)
 matrix rotation(double theta)
          Make 2D rotation matrix by an angle
 matrix scale(double[] scaleVec)
          Make 2D scale matrix by vector scaleVec
 void screenPos(java.awt.Point p, double x, double y)
          Compute the position on the screen, values are stored in p
 void setView2D(double xLen, double yLen)
          generate 2D view matrix
 void setView2D(matrix v)
          generate 2D view matrix form a matrix v
 matrix translate(double[] transVec)
          Make 2D translation matrix by vector transVec
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Pi

public static final double Pi
The constant value Pi = 3.141592

See Also:
Constant Field Values

width

protected static int width

height

protected static int height
Constructor Detail

Graphics2D

public Graphics2D()
Method Detail

getView2D

public matrix getView2D()
Return the view matrix.

Returns:
A matrix

setView2D

public void setView2D(double xLen,
                      double yLen)
generate 2D view matrix

Parameters:
xLen - The length of x-Axis
yLen - The length of y-Axis

setView2D

public void setView2D(matrix v)
generate 2D view matrix form a matrix v

Parameters:
v - A 3 x 3 matrix

screenPos

public void screenPos(java.awt.Point p,
                      double x,
                      double y)
Compute the position on the screen, values are stored in p

Parameters:
p - A Point object
x - The x-coordinate
y - The y-coordinate

moveTo

public void moveTo(double x,
                   double y)
move pen to a real position (x, y)

Parameters:
x - The x-coordinate
y - The y-coordinate

lineTo

public void lineTo(java.awt.Graphics g,
                   double x,
                   double y)
draw line from the current position to a point (x,y)

Parameters:
g - Graphics
x - The x-coordinate
y - The y-coordinate

changeWindowSize

public void changeWindowSize(java.awt.Dimension d)
change graphics window size

Parameters:
d - New Dimension

changeWindowSize

public void changeWindowSize(int w,
                             int h)
change graphics window size

Parameters:
w - An integer, the width
h - An integer, the height

drawLine

public void drawLine(java.awt.Graphics g,
                     double x1,
                     double y1,
                     double x2,
                     double y2)
draw a line from (x1,y1) to (x2,y2)

Parameters:
g - Graphics
x1 - The x-coordinate of the first point
y1 - The y-coordinate of the first point
x2 - The x-coordinate of the second point
y2 - The y-coordinate of the first point

box

public void box(java.awt.Graphics g,
                double minx,
                double miny,
                double maxx,
                double maxy)
Plot a rectangle.

Parameters:
g - Graphics
minx - The x-coordinate of the down-left point
miny - The y-coordinate of the down-left point
maxx - The x-coordinate of the up-right point
maxy - The y-coordinate of the up-right point

coord

public void coord(java.awt.Graphics g,
                  double minx,
                  double miny,
                  double maxx,
                  double maxy)
Draw a 2D coordinate system in a frame window.

Parameters:
g - Graphics
minx - The x-coordinate of the down-left point
miny - The y-coordinate of the down-left point
maxx - The x-coordinate of the up-right point
maxy - The y-coordinate of the up-right point

halfGrid

public void halfGrid(java.awt.Graphics g,
                     double minx,
                     double miny,
                     double maxx,
                     double maxy,
                     double oX,
                     double oY)
Draw a 2D halfGrid coordinate system in a frame window.

Parameters:
g - Graphics
minx - The x-coordinate of the down-left point
miny - The y-coordinate of the down-left point
maxx - The x-coordinate of the up-right point
maxy - The y-coordinate of the up-right point
oX - The origin x-coordinate
oY - The origin y-coordinate

grid

public void grid(java.awt.Graphics g,
                 double minx,
                 double miny,
                 double maxx,
                 double maxy,
                 double oX,
                 double oY)
Draw a 2D grid coordinate system in a frame window.

Parameters:
g - Graphics
minx - The x-coordinate of the down-left point
miny - The y-coordinate of the down-left point
maxx - The x-coordinate of the up-right point
maxy - The y-coordinate of the up-right point
oX - The origin x-coordinate
oY - The origin y-coordinate

coord2D

public void coord2D(java.awt.Graphics g,
                    double minx,
                    double miny,
                    double maxx,
                    double maxy)
Make a 2D coordinate system without drawing it in a frame window.

Parameters:
g - Graphics
minx - The x-coordinate of the down-left point
miny - The y-coordinate of the down-left point
maxx - The x-coordinate of the up-right point
maxy - The y-coordinate of the up-right point

coord2D

public void coord2D(java.awt.Graphics g,
                    vector xv,
                    vector yv)
Make a 2D coordinate system and plot it in a frame window.

Parameters:
g - Graphics
xv - A vector that contains x-coordinates
yv - A vector that contains y-coordinates

coord2D

public void coord2D(java.awt.Graphics g,
                    vector xv,
                    vector yv,
                    java.lang.String specific)
Make a 2D coordinate system and plot it in a frame window with a specific

Parameters:
g - Graphics
xv - A vector that contains x-coordinates
yv - A vector that contains y-coordinates
specific - A String that can have some values as "grid", "coord", "box" or empty

translate

public matrix translate(double[] transVec)
Make 2D translation matrix by vector transVec

Parameters:
transVec - the translate vector

scale

public matrix scale(double[] scaleVec)
Make 2D scale matrix by vector scaleVec

Parameters:
scaleVec - the scale vector

rotation

public matrix rotation(double theta)
Make 2D rotation matrix by an angle

Parameters:
theta - the rotation angle in degrees