Package org.opensourcephysics.display
Class DrawableShape
java.lang.Object
org.opensourcephysics.display.DrawableShape
- All Implemented Interfaces:
Drawable
A class that draws shapes using the Java 2D API.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDrawableShape(Shape shape, double x, double y) Constructs a DrawableShape with the given coordinates. -
Method Summary
Modifier and TypeMethodDescriptionstatic DrawableShapecreateCircle(double x, double y, double d) Creates a drawable circle.static DrawableShapecreateRectangle(double x, double y, double w, double h) Creates a drawable rectangle.voiddraw(DrawingPanel panel, Graphics g) Draws the shape.static XML.ObjectLoaderGets the XML object loader for this class.doublegetTheta()Gets the value of the roation angle theta.doublegetX()Gets the value of x.doublegetY()Gets the value of y.voidsetMarkerColor(Color fillColor, Color edgeColor) Sets the shape's drawing colors.voidsetTheta(double theta) Sets the rotation angle in radians.voidsetX(double _x) Sets the x coordinate.voidsetXY(double _x, double _y) Sets the x and y coordinates.voidsetY(double _y) Sets the y coordinate.toString()Returns a string representation of the circle.voidtranform(double[][] mat) Transforms the shape using the given matrix.voidtransform(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, waitMethods inherited from interface org.opensourcephysics.display.Drawable
isInteractive
-
Field Details
-
color
-
edgeColor
-
shapeClass
-
-
Constructor Details
-
DrawableShape
Constructs a DrawableShape with the given coordinates.- Parameters:
shape-x- coordinatey- coordinate
-
-
Method Details
-
createCircle
Creates a drawable circle.- Parameters:
x-y-d- the diameter- Returns:
- the DrawableShape
-
createRectangle
Creates a drawable rectangle.- Parameters:
x-y-w-h-- Returns:
- the drawable rectangle
-
setMarkerColor
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
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
Returns a string representation of the circle. -
draw
Draws the shape. -
getLoader
Gets the XML object loader for this class.- Returns:
- ObjectLoader
-