Package org.opensourcephysics.display
Class Arrow
java.lang.Object
org.opensourcephysics.display.Arrow
- All Implemented Interfaces:
Drawable
A Drawable arrow that uses Java 2D drawing.
- Version:
- 1.0
- Author:
- Wolfgang Christian
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionArrow
(double _x, double _y, double _a, double _b) Constructs an Arrow with the given postion and components. -
Method Summary
Modifier and TypeMethodDescriptionvoid
draw
(DrawingPanel panel, Graphics g) Draws the arrow.protected Shape
getHead
(Point2D.Double ptA, double theta) Gets the arrowhead shape.float
Gets the headsize for the arrow.static XML.ObjectLoader
Gets a loader that allows a Circle to be represented as XML data.double
getX()
Gets the x coordinate.double
Gets the horizontal component.double
getY()
Gets the y coordinate.double
Gets the vertical component.void
Sets the arrow's color.void
setHeadSize
(float size) Sets the headsize for the arrow.void
setX
(double x) Sets the x coordinate.void
setXlength
(double dx) Sets the arrow's horizontal component.void
setXY
(double x, double y) Sets the x and y coordinates.void
setY
(double y) Sets the y coordinate.void
setYlength
(double dy) Sets the arrows vertical component.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.opensourcephysics.display.Drawable
isInteractive
-
Field Details
-
headSize
protected float headSize -
color
-
x
protected double x -
y
protected double y -
a
protected double a -
b
protected double b
-
-
Constructor Details
-
Arrow
public Arrow(double _x, double _y, double _a, double _b) Constructs an Arrow with the given postion and components.- Parameters:
_x
- postion_y
- position_a
- horizontal component_b
- vertical component
-
-
Method Details
-
getX
public double getX()Gets the x coordinate.- Returns:
- double x
-
setX
public void setX(double x) Sets the x coordinate.- Parameters:
x
-
-
getY
public double getY()Gets the y coordinate.- Returns:
- double y
-
setY
public void setY(double y) Sets the y coordinate.- Parameters:
y
-
-
setXY
public void setXY(double x, double y) Sets the x and y coordinates.- Parameters:
y
-
-
setColor
Sets the arrow's color.- Parameters:
c
-
-
setXlength
public void setXlength(double dx) Sets the arrow's horizontal component.- Parameters:
dx
-
-
setYlength
public void setYlength(double dy) Sets the arrows vertical component.- Parameters:
dy
-
-
getXlength
public double getXlength()Gets the horizontal component.- Returns:
- horizontal
-
getYlength
public double getYlength()Gets the vertical component.- Returns:
- vertical
-
getHeadSize
public float getHeadSize()Gets the headsize for the arrow.- Returns:
- float
-
setHeadSize
public void setHeadSize(float size) Sets the headsize for the arrow.- Parameters:
size
- float the head size in pixels.
-
draw
Draws the arrow. -
getHead
Gets the arrowhead shape.- Parameters:
ptA2
-theta
- double the angle of the arrow- Returns:
- Shape
-
getLoader
Gets a loader that allows a Circle to be represented as XML data. Objects without XML loaders cannot be saved and retrieved from an XML file.- Returns:
- ObjectLoader
-