optics
Class RayPath

java.lang.Object
  extended by optics.Optics
      extended by optics.RayPath
All Implemented Interfaces:
Diagram2DComponent, RayMonitor

public class RayPath
extends Optics
implements RayMonitor, Diagram2DComponent

Class to monitor a RayPath by recording the positions of the Ray using the RayMonitor interface. This class also implements the Diagram2DComponent interface so can be directly added to a Diagram2D.


Field Summary
protected  java.util.Vector<Position> path
          The actual path held in a Vector
protected  double waveLength
          The wavelength of the ray taking this path.
 
Fields inherited from class optics.Optics
DEFAULT_WAVELENGTH, errorStream, fmt, MICRONS
 
Constructor Summary
RayPath()
          Default constructor to form a blank RayPath not connected to any ray.
RayPath(Ray r)
          Constructor to form blank RayPath and attach it to a specified Ray as a RayMonitor.
 
Method Summary
 void addPosition(Position p)
          Method to add a Position to the path.
 void clear()
          Method to clear the RayPath of all points.
 void draw(java.awt.Graphics2D g)
          Method to draw the component in Graphics2D context.
 java.awt.geom.Rectangle2D getBounds()
          Method to get the bounds of the object in the y/z plane This is called automatically from within Diagram2D.
 java.awt.Color getColour()
          Methed to get the current Color of the of the ray
 Position getNext()
          Get the next valid Point from the Raypath, null if there are none.
 java.util.Vector<Position> getPath()
          Method to get the actual path whis is a Vector of Positions
 Position getPosition(int i)
          Method of to get a point from the path
 double getWaveLength()
          Method to get the wavelength
 void reset()
          Method to reset the nextRay counter
 void setColour(java.awt.Color c)
          Method to manually set the colour of the raypath.
 void setWaveLength(double lambda)
          Method to set the wavelength.
 int size()
          Method to get the size (number of points) in the current path.
 java.lang.String toString()
          Default toString method to format the RayPath as a String containing the Ray positions.
 void update(Ray r)
          Update Monitor method specified in RayMonitor interface called automatrcally every time position changes.
 
Methods inherited from class optics.Optics
getDefaultWaveLength, getErrorStream, getFormatString, getName, getStaticName, getVersion, printError, setDefaultWaveLength, setErrorStream, setFormatString, setMicrons
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

path

protected java.util.Vector<Position> path
The actual path held in a Vector


waveLength

protected double waveLength
The wavelength of the ray taking this path.

Constructor Detail

RayPath

public RayPath()
Default constructor to form a blank RayPath not connected to any ray.


RayPath

public RayPath(Ray r)
Constructor to form blank RayPath and attach it to a specified Ray as a RayMonitor. The is the normal method of using this class and and the Ray is traced the path will be automatically recorded.

Parameters:
r - the Ray
Method Detail

reset

public void reset()
Method to reset the nextRay counter


setWaveLength

public void setWaveLength(double lambda)
Method to set the wavelength. This also set the ray colout to Colour.WavelengthColour(double)

Parameters:
lambda - the wavelength

getWaveLength

public double getWaveLength()
Method to get the wavelength

Returns:
double the wavelength

getColour

public java.awt.Color getColour()
Methed to get the current Color of the of the ray

Returns:
Color the current ray Color.

setColour

public void setColour(java.awt.Color c)
Method to manually set the colour of the raypath. The color is normally automatically set by the wavelength, and changes here will be overwritten by subsequent updates of the wavelength.

Parameters:
c - the Color
See Also:
setWaveLength(double)

size

public int size()
Method to get the size (number of points) in the current path.

Returns:
int size of path

addPosition

public void addPosition(Position p)
Method to add a Position to the path. Not normally called by the user, but automatically via the update method

Parameters:
p - the Position to be added.
See Also:
update(optics.Ray)

getPosition

public Position getPosition(int i)
Method of to get a point from the path

Parameters:
i - the point index
Returns:
Point3d the path point.

getPath

public java.util.Vector<Position> getPath()
Method to get the actual path whis is a Vector of Positions

Returns:
Vector the actual path.

getNext

public Position getNext()
Get the next valid Point from the Raypath, null if there are none.

Returns:
Position next point on Raypath

toString

public java.lang.String toString()
Default toString method to format the RayPath as a String containing the Ray positions.

Overrides:
toString in class java.lang.Object
Returns:
String the formatted String

clear

public void clear()
Method to clear the RayPath of all points.


update

public void update(Ray r)
Update Monitor method specified in RayMonitor interface called automatrcally every time position changes.

Specified by:
update in interface RayMonitor
Parameters:
r - the calling Ray.

getBounds

public java.awt.geom.Rectangle2D getBounds()
Method to get the bounds of the object in the y/z plane This is called automatically from within Diagram2D.

Specified by:
getBounds in interface Diagram2DComponent
Returns:
Rectangle2D the bounding Rectangle

draw

public void draw(java.awt.Graphics2D g)
Method to draw the component in Graphics2D context. This is called automatically from within Diagram2D.

Specified by:
draw in interface Diagram2DComponent
Parameters:
g - the Graphics2D context