org.opensourcephysics.display
Class DrawableShape

java.lang.Object
  extended by org.opensourcephysics.display.DrawableShape
All Implemented Interfaces:
Drawable

public class DrawableShape
extends java.lang.Object
implements Drawable

A class that draws shapes using the Java 2D API.


Field Summary
 java.awt.Color color
           
 java.awt.Color edgeColor
           
 java.lang.String shapeClass
           
 
Constructor Summary
DrawableShape(java.awt.Shape shape, double x, double y)
          Constructs a DrawableShape with the given coordinates.
 
Method Summary
static DrawableShape createCircle(double x, double y, double d)
          Creates a drawable circle.
static DrawableShape createRectangle(double x, double y, double w, double h)
          Creates a drawable rectangle.
 void draw(DrawingPanel panel, java.awt.Graphics g)
          Draws the shape.
static XML.ObjectLoader getLoader()
          Gets the XML object loader for this class.
 double getTheta()
          Gets the value of the roation angle theta.
 double getX()
          Gets the value of x.
 double getY()
          Gets the value of y.
 void setMarkerColor(java.awt.Color fillColor, java.awt.Color edgeColor)
          Sets the shape's drawing colors.
 void setTheta(double theta)
          Sets the rotation angle in radians.
 void setX(double _x)
          Sets the x coordinate.
 void setXY(double _x, double _y)
          Sets the x and y coordinates.
 void setY(double _y)
          Sets the y coordinate.
 java.lang.String toString()
          Returns a string representation of the circle.
 void tranform(double[][] mat)
          Transforms the shape using the given matrix.
 void transform(java.awt.geom.AffineTransform transformation)
          Transforms the shape using the given transformation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

color

public java.awt.Color color

edgeColor

public java.awt.Color edgeColor

shapeClass

public java.lang.String shapeClass
Constructor Detail

DrawableShape

public DrawableShape(java.awt.Shape shape,
                     double x,
                     double y)
Constructs a DrawableShape with the given coordinates.

Parameters:
shape -
x - coordinate
y - coordinate
Method Detail

createCircle

public static DrawableShape createCircle(double x,
                                         double y,
                                         double d)
Creates a drawable circle.

Parameters:
x -
y -
d - the diameter
Returns:
the DrawableShape

createRectangle

public static DrawableShape createRectangle(double x,
                                            double y,
                                            double w,
                                            double h)
Creates a drawable rectangle.

Parameters:
x -
y -
w -
h -
Returns:
the drawable rectangle

setMarkerColor

public void setMarkerColor(java.awt.Color fillColor,
                           java.awt.Color edgeColor)
Sets the shape's drawing colors. The error bar color is set equal to the edge color.

Parameters:
fillColor -
edgeColor -

setTheta

public void setTheta(double theta)
Sets the rotation angle in radians.

Parameters:
theta - the new angle

getTheta

public double getTheta()
Gets the value of the roation angle theta.

Returns:
double

transform

public void transform(java.awt.geom.AffineTransform transformation)
Transforms the shape using the given transformation.

Parameters:
transformation - AffineTransform

tranform

public void tranform(double[][] mat)
Transforms the shape using the given matrix.

Parameters:
mat - double[][]

setXY

public void setXY(double _x,
                  double _y)
Sets the x and y coordinates.

Parameters:
_x -
_y -

setX

public void setX(double _x)
Sets the x coordinate.

Parameters:
_x -

getX

public double getX()
Gets the value of x.

Returns:
double

setY

public void setY(double _y)
Sets the y coordinate.

Parameters:
_y -

getY

public double getY()
Gets the value of y.

Returns:
double

toString

public java.lang.String toString()
Returns a string representation of the circle.

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

draw

public void draw(DrawingPanel panel,
                 java.awt.Graphics g)
Draws the shape.

Specified by:
draw in interface Drawable
Parameters:
panel - DrawingPanel
g - Graphics

getLoader

public static XML.ObjectLoader getLoader()
Gets the XML object loader for this class.

Returns:
ObjectLoader