optics.graphics
Class SpotDiagram2D

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector<Spot>
              extended by optics.graphics.SpotDiagram2D
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<Spot>, java.util.Collection<Spot>, java.util.List<Spot>, java.util.RandomAccess, Diagram2DComponent

public class SpotDiagram2D
extends java.util.Vector<Spot>
implements Diagram2DComponent

Class to implement a SpotDiagram2D using the Diagram2DComponent interface scheme.

The diagram consists of a java.util.Vector of Spots that can be added to a Diagram2D

See Also:
Serialized Form

Field Summary
protected  javax.vecmath.Point2d centre
          The centre of the diagram
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
SpotDiagram2D(double range)
          Form SpotDiagram2D with specifed range and centre at (0,0).
SpotDiagram2D(double x, double y, double range)
          Form a SpotDiagram2D with a specific centre and range.
SpotDiagram2D(javax.vecmath.Point2d c, double range)
          Form a SpotDiagram2D with a specific centre and range.
 
Method Summary
 void addSpot(double x, double y)
          Method to add a spot to the diagram in default colour Colour.SpotColour.
 void addSpot(double x, double y, java.awt.Color c)
          Method to add a spot to the diagram in specified colour
 void addSpot(javax.vecmath.Point2d p)
          Method to add a spot to the diagram in default colour Colour.SpotColour.
 void addSpot(javax.vecmath.Point2d p, java.awt.Color c)
          Method to add spot to the diagram specifting the colour
 void addSpot(Spot s)
          Method to add a predefned Spot to the diagram.
 void addToCentre(double dx, double dy)
          Method to add to the current centre
 void addToCentre(javax.vecmath.Point2d delta)
          Method to add to the current centre
 void draw(java.awt.Graphics2D g)
          Method to draw the spot diagram in a Graphics2D context.
 java.awt.geom.Rectangle2D getBounds()
          Method to calculate the bounds of the diagram taking into account the centre and range.
 javax.vecmath.Point2d getCentre()
          Method get the current centre of the diagram
 int getNumber()
          Method to get the number of spots, being just the length of the underlying vector.
 double getRange()
          Method to get the current range
 Spot getSpot(int i)
          Method to get a specified Spot
 void setCentre(double x, double y)
          Method to set centre with two doubles.
 void setCentre(javax.vecmath.Point2d c)
          Method to set the centre
 void setCrossAxis(boolean b)
          Method to control if a cross is drawn in the centre of the diagram, default is on (true).
 void setRange(double r)
          Method to set the range of the diagram.
 void setRings(int n)
          Void to set the number of rings drwen on the diagram, the default is 2.
 void setSpotSize(double f)
          Method to set the spot size as fraction of width of the diagram.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Field Detail

centre

protected javax.vecmath.Point2d centre
The centre of the diagram

Constructor Detail

SpotDiagram2D

public SpotDiagram2D(javax.vecmath.Point2d c,
                     double range)
Form a SpotDiagram2D with a specific centre and range.

Parameters:
c - the centre of the diagram
range - the range

SpotDiagram2D

public SpotDiagram2D(double x,
                     double y,
                     double range)
Form a SpotDiagram2D with a specific centre and range.

Parameters:
x - x-location of centre
y - y-location of centre
range - the range

SpotDiagram2D

public SpotDiagram2D(double range)
Form SpotDiagram2D with specifed range and centre at (0,0).

Parameters:
range - the range
Method Detail

setRings

public void setRings(int n)
Void to set the number of rings drwen on the diagram, the default is 2.

The colour of the rings is controlled by Colour.AxisColour.

Parameters:
n - Number of rings

setCrossAxis

public void setCrossAxis(boolean b)
Method to control if a cross is drawn in the centre of the diagram, default is on (true).

The colour of the cross is controlled by Colour.AxisColour.

Parameters:
b - on/off switch (default is on)

setCentre

public void setCentre(javax.vecmath.Point2d c)
Method to set the centre

Parameters:
c - the centre point of the diagram.

setCentre

public void setCentre(double x,
                      double y)
Method to set centre with two doubles.

Parameters:
x - the x location.
y - the y location.

addToCentre

public void addToCentre(javax.vecmath.Point2d delta)
Method to add to the current centre

Parameters:
delta - x/y values added to centre

addToCentre

public void addToCentre(double dx,
                        double dy)
Method to add to the current centre

Parameters:
dx - the delta x value
dy - the delta y value

getCentre

public javax.vecmath.Point2d getCentre()
Method get the current centre of the diagram

Returns:
Point2d the centre

setRange

public void setRange(double r)
Method to set the range of the diagram. The size of the diagram will be +1 r about the centre.

Parameters:
r - the range

getRange

public double getRange()
Method to get the current range

Returns:
double current range

setSpotSize

public void setSpotSize(double f)
Method to set the spot size as fraction of width of the diagram. The default is 0.02.

Parameters:
f - the factional size

addSpot

public void addSpot(javax.vecmath.Point2d p)
Method to add a spot to the diagram in default colour Colour.SpotColour.

Parameters:
p - the point

addSpot

public void addSpot(double x,
                    double y)
Method to add a spot to the diagram in default colour Colour.SpotColour.

Parameters:
x - The x component
y - The y component

addSpot

public void addSpot(javax.vecmath.Point2d p,
                    java.awt.Color c)
Method to add spot to the diagram specifting the colour

Parameters:
p - the point
c - the Color.

addSpot

public void addSpot(double x,
                    double y,
                    java.awt.Color c)
Method to add a spot to the diagram in specified colour

Parameters:
x - The x component
y - The y component
c - The colour

addSpot

public void addSpot(Spot s)
Method to add a predefned Spot to the diagram.

Parameters:
s - The Spot

getSpot

public Spot getSpot(int i)
Method to get a specified Spot

Parameters:
i - the index
Returns:
Spot the specified Spot.

getNumber

public int getNumber()
Method to get the number of spots, being just the length of the underlying vector.

Returns:
int number of spots

getBounds

public java.awt.geom.Rectangle2D getBounds()
Method to calculate the bounds of the diagram taking into account the centre and range.

Specified by:
getBounds in interface Diagram2DComponent
Returns:
Rectangle bounding rectangle.

draw

public void draw(java.awt.Graphics2D g)
Method to draw the spot diagram in a Graphics2D context.

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