org.wilmascope.view
Class Renderer2D

java.lang.Object
  extended by org.wilmascope.view.Renderer2D

public class Renderer2D
extends java.lang.Object

Author:
dwyer Given the corners of the 3D bounding box given to the constructor, this class defines methods for converting points to a 2D window

Constructor Summary
Renderer2D(javax.vecmath.Point3f bottomLeft, javax.vecmath.Point3f topRight, int w, int h)
           
 
Method Summary
 void arrowPath(java.awt.Graphics2D g, float width, javax.vecmath.Point3f start, javax.vecmath.Point3f end)
          Draws an arrow head (a triangle) with the base at start and the head at end
 void curvePath(java.awt.geom.GeneralPath path, java.awt.geom.Point2D.Float[] p2f)
          Draws a curve in the 2D window
 void drawRect(java.awt.Graphics2D g, javax.vecmath.Point3f pos, float width, float height)
           
 void fillCircle(java.awt.Graphics2D g, javax.vecmath.Point3f pos, float size)
           
 void fillRect(java.awt.Graphics2D g, javax.vecmath.Point3f pos, float width, float height)
           
 void fillSquare(java.awt.Graphics2D g, javax.vecmath.Point3f pos, float size)
           
 javax.vecmath.Point2f getScreenPoint(float x, float y)
          Converts a x and y floats to a 2D point in the window of specified size
 javax.vecmath.Point2f getScreenPoint(java.awt.geom.Point2D.Float p2f)
          Converts a 2D float point to a 2D point in the window of specified size
 javax.vecmath.Point2f getScreenPoint(javax.vecmath.Point3f p3f)
          Converts a 3D point to a 2D point in the window of specified size
 void linePath(java.awt.Graphics2D g, javax.vecmath.Point3f start, javax.vecmath.Point3f end)
           
 float scaleX(float x)
          scales a value such as a radius to fit the screen horizontal
 float scaleY(float y)
          scales a value such as a radius to fit the screen vertical
 void taperedLinePath(java.awt.Graphics2D g, float startWidth, float endWidth, javax.vecmath.Point3f start, javax.vecmath.Point3f end)
          Draws a tapered line from start to end with end widths as specified
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Renderer2D

public Renderer2D(javax.vecmath.Point3f bottomLeft,
                  javax.vecmath.Point3f topRight,
                  int w,
                  int h)
Parameters:
bottomLeft - bottom left corner of bounding box
topRight - top right corner of bounding box
w - width of target screen
h - height of target screen
Method Detail

getScreenPoint

public javax.vecmath.Point2f getScreenPoint(javax.vecmath.Point3f p3f)
Converts a 3D point to a 2D point in the window of specified size

Parameters:
p3f - 3D Point to render to the window
Returns:
the converted 2D point

getScreenPoint

public javax.vecmath.Point2f getScreenPoint(java.awt.geom.Point2D.Float p2f)
Converts a 2D float point to a 2D point in the window of specified size

Parameters:
p2f - 2D float Point to render to the window
Returns:
the converted 2D point

getScreenPoint

public javax.vecmath.Point2f getScreenPoint(float x,
                                            float y)
Converts a x and y floats to a 2D point in the window of specified size

Parameters:
x - horizontal float coord to render to the window
y - vertical float coord to render to the window
Returns:
the converted 2D point

curvePath

public void curvePath(java.awt.geom.GeneralPath path,
                      java.awt.geom.Point2D.Float[] p2f)
Draws a curve in the 2D window

Parameters:
path - add the curve to this path
p2f - array of points (will be converted to screen points)

fillSquare

public void fillSquare(java.awt.Graphics2D g,
                       javax.vecmath.Point3f pos,
                       float size)

fillRect

public void fillRect(java.awt.Graphics2D g,
                     javax.vecmath.Point3f pos,
                     float width,
                     float height)

drawRect

public void drawRect(java.awt.Graphics2D g,
                     javax.vecmath.Point3f pos,
                     float width,
                     float height)

fillCircle

public void fillCircle(java.awt.Graphics2D g,
                       javax.vecmath.Point3f pos,
                       float size)

linePath

public void linePath(java.awt.Graphics2D g,
                     javax.vecmath.Point3f start,
                     javax.vecmath.Point3f end)

arrowPath

public void arrowPath(java.awt.Graphics2D g,
                      float width,
                      javax.vecmath.Point3f start,
                      javax.vecmath.Point3f end)
Draws an arrow head (a triangle) with the base at start and the head at end

Parameters:
g -
width -
start -
end -

taperedLinePath

public void taperedLinePath(java.awt.Graphics2D g,
                            float startWidth,
                            float endWidth,
                            javax.vecmath.Point3f start,
                            javax.vecmath.Point3f end)
Draws a tapered line from start to end with end widths as specified

Parameters:
g -
startWidth -
endWidth -
start -
end -

scaleX

public float scaleX(float x)
scales a value such as a radius to fit the screen horizontal

Parameters:
x - value to scale
Returns:
scaled value

scaleY

public float scaleY(float y)
scales a value such as a radius to fit the screen vertical

Parameters:
x - value to scale
Returns:
scaled value