optics.graphics
Class Label2D

java.lang.Object
  extended by javax.vecmath.Tuple2d
      extended by javax.vecmath.Point2d
          extended by optics.graphics.Label2D
All Implemented Interfaces:
Serializable, Cloneable, Diagram2DComponent

public class Label2D
extends Point2d
implements Diagram2DComponent

Class to implement a Label on a Daigram2D

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.vecmath.Tuple2d
x, y
 
Constructor Summary
Label2D(double x, double y, String s)
          Form a label at a specific location and default colour set by {#link Colour.TextColour}.
Label2D(double x, double y, String s, Color c)
          Form a label at a specific location and Colour.
Label2D(Point2d p, String s)
          Form a label at a specific location and Colour.
Label2D(Point2d p, String s, Color c)
          Form a label at a specific location and Colour.
Label2D(String s)
          Form a label with specified String with default (0,0) location.
Label2D(String s, Color c)
          Form a label with specifed colour and defaults (0,0) location.
 
Method Summary
 void draw(Graphics2D g)
          Method draw the String on the diagram
 Rectangle2D getBounds()
          Method to get the bounds, being the label location
 String getText()
          Method to get the current String
 void setText(String s)
          Method to set the text of the label
 
Methods inherited from class javax.vecmath.Point2d
distance, distanceL1, distanceLinf, distanceSquared
 
Methods inherited from class javax.vecmath.Tuple2d
absolute, absolute, add, add, clamp, clamp, clampMax, clampMax, clampMin, clampMin, clone, epsilonEquals, equals, equals, get, getX, getY, hashCode, interpolate, interpolate, negate, negate, scale, scale, scaleAdd, scaleAdd, set, set, set, set, setX, setY, sub, sub, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Label2D

public Label2D(double x,
               double y,
               String s,
               Color c)
Form a label at a specific location and Colour.

Parameters:
x - the x location
y - the y location
s - the label text
c - the colour

Label2D

public Label2D(Point2d p,
               String s,
               Color c)
Form a label at a specific location and Colour.

Parameters:
p - the label location
s - the label text
c - the colour

Label2D

public Label2D(String s,
               Color c)
Form a label with specifed colour and defaults (0,0) location.

Parameters:
s - the label text
c - the colour

Label2D

public Label2D(double x,
               double y,
               String s)
Form a label at a specific location and default colour set by {#link Colour.TextColour}.

Parameters:
x - the x location
y - the y location
s - the label text

Label2D

public Label2D(Point2d p,
               String s)
Form a label at a specific location and Colour.

Parameters:
p - the location.
s - the label text

Label2D

public Label2D(String s)
Form a label with specified String with default (0,0) location.

Parameters:
s - the label String.
Method Detail

getText

public String getText()
Method to get the current String

Returns:
String the test String

setText

public void setText(String s)
Method to set the text of the label

Parameters:
s - the text String.

getBounds

public Rectangle2D getBounds()
Method to get the bounds, being the label location

Specified by:
getBounds in interface Diagram2DComponent
Returns:
Rectange2D.Float the label box.

draw

public void draw(Graphics2D g)
Method draw the String on the diagram

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