optics.graphics
Class Diagram2D

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

public class Diagram2D
extends Vector<Diagram2DComponent>
implements Diagram2DComponent

Class to implement a two-dimensional diagram being vector of Diagram2DComponents. This class which itself inplements the Diagram2DComponent interface, so allowing complex line diagrams to be assembled.

Since this class extends the standard java.util.Vector the standard inderited methods can be used to manipulare the vector.

See Also:
Serialized Form

Field Summary
static boolean DynamicBounds
          Public static to determine if the graphical bounds are recalulated on every display update.
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
Diagram2D()
          Form a blank Diagram2D to which components can be added.
Diagram2D(Diagram2DComponent comp)
          Form a Diagram2D with an initial specifed component.
Diagram2D(LensSystem lens)
          Form a Diagram2D containing the specifed LensSystem.
 
Method Summary
 void addComponent(Diagram2DComponent comp)
          Method to add a DiagramComponent to the current Diagram.
 void addComponent(LensSystem lens)
          Method to add an LensSystem to the current Diagram.
 void clear()
          Method to clear the Diagram and reset the bounds to zero.
 void draw(Graphics2D g)
          Method to graw the Compound object in a Graphic2D context.
 Rectangle2D getBounds()
          Method to get the Diagram bounds.
static void main(String[] args)
          Test method to for the Diagram2D of an off-axis doublet and print out information about its bounds.
 void setAutoBounds()
          Method to reset autoBounds, so they will be caualuted automatically (this is the default).
 void setBounds(double x, double y, double w, double h)
          Method to set the Bound to specifed value.
 void setDynamicBounds(boolean b)
          Method to set the static DynamicBounds flag.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, 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

DynamicBounds

public static boolean DynamicBounds
Public static to determine if the graphical bounds are recalulated on every display update. The default is true.

For complex diagrams over slow ssh links, this may result in poor graphic update speeds.

Constructor Detail

Diagram2D

public Diagram2D()
Form a blank Diagram2D to which components can be added.


Diagram2D

public Diagram2D(Diagram2DComponent comp)
Form a Diagram2D with an initial specifed component.

Parameters:
comp - the inital component

Diagram2D

public Diagram2D(LensSystem lens)
Form a Diagram2D containing the specifed LensSystem.

Parameters:
lens - the specifed lens system
Method Detail

addComponent

public void addComponent(Diagram2DComponent comp)
Method to add a DiagramComponent to the current Diagram.

Use this is preference to the underlying addElement() as to ensure the bounds are correct especially if using the static bounds option.

Parameters:
comp - the component

addComponent

public void addComponent(LensSystem lens)
Method to add an LensSystem to the current Diagram. It is added as a self contained Diagram2D.

Parameters:
lens - the lens system.

clear

public void clear()
Method to clear the Diagram and reset the bounds to zero.

Specified by:
clear in interface Collection<Diagram2DComponent>
Specified by:
clear in interface List<Diagram2DComponent>
Overrides:
clear in class Vector<Diagram2DComponent>

setDynamicBounds

public void setDynamicBounds(boolean b)
Method to set the static DynamicBounds flag. if true (the default), then diagram bounds will be recalculated on each repaint. If set false the bounds will be calcualted once as the digagram is formed and then cashed.

Setting to false will result is faster diagram refresh rates, but will result in display problems if componets are interactively added/removed/changed in the diagram. Use this feature only if you are finding display updates to be too slow.


getBounds

public Rectangle2D getBounds()
Method to get the Diagram bounds.

Specified by:
getBounds in interface Diagram2DComponent
Returns:
Rectangle the bounds

setBounds

public void setBounds(double x,
                      double y,
                      double w,
                      double h)
Method to set the Bound to specifed value. This will also stop automatic bounds calcualtion. This can be re-started with {#link setAutoBounds()}.

Parameters:
x - x location of rectangle
y - y location of rectange
w - width
h - height

setAutoBounds

public void setAutoBounds()
Method to reset autoBounds, so they will be caualuted automatically (this is the default).


draw

public void draw(Graphics2D g)
Method to graw the Compound object in a Graphic2D context. Normnally called automatically by the renteding class.

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

main

public static void main(String[] args)
Test method to for the Diagram2D of an off-axis doublet and print out information about its bounds.