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 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, Graphics g) Draws the shape.static XML.ObjectLoader
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
(Color fillColor, 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.toString()
Returns a string representation of the circle.void
tranform
(double[][] mat) Transforms the shape using the given matrix.void
transform
(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
Methods 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
-