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:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<Diagram2DComponent>, java.util.Collection<Diagram2DComponent>, java.util.List<Diagram2DComponent>, java.util.RandomAccess, Diagram2DComponent

public class Diagram2D
extends java.util.Vector<Diagram2DComponent>
implements Diagram2DComponent

Class to a displayable vector of Diagram2DComponents which itself inplements the Diagram2DComponent interface, so allowing complex line diagrams to be assembled

See Also:
Serialized Form

Field Summary
static boolean DynamicBounds
          Public static to determins of 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.
 
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(java.awt.Graphics2D g)
          Method to graw the Compound object in a Graphic2D context.
 java.awt.geom.Rectangle2D getBounds()
          Method to get the Diagram bounds.
 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 determins of the graphical bounds are recalulated on every display update. The default is true.

Constructor Detail

Diagram2D

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

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.

Parameters:
comp - the component

addComponent

public void addComponent(LensSystem lens)
Method to add an LensSystem to the current Diagram. It is added as selfcontained Daigram2D

Parameters:
lens - the Opticalgroup.

clear

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

Specified by:
clear in interface java.util.Collection<Diagram2DComponent>
Specified by:
clear in interface java.util.List<Diagram2DComponent>
Overrides:
clear in class java.util.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.


getBounds

public java.awt.geom.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. Only makes sense if DynamicBounds is false.

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

draw

public void draw(java.awt.Graphics2D g)
Method to graw the Compound object in a Graphic2D context.

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