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 TypeMethodDescriptionvoiddraw(DrawingPanel panel, Graphics g) Draws the arrow.protected ShapegetHead(Point2D.Double ptA, double theta) Gets the arrowhead shape.floatGets the headsize for the arrow.static XML.ObjectLoaderGets a loader that allows a Circle to be represented as XML data.doublegetX()Gets the x coordinate.doubleGets the horizontal component.doublegetY()Gets the y coordinate.doubleGets the vertical component.voidSets the arrow's color.voidsetHeadSize(float size) Sets the headsize for the arrow.voidsetX(double x) Sets the x coordinate.voidsetXlength(double dx) Sets the arrow's horizontal component.voidsetXY(double x, double y) Sets the x and y coordinates.voidsetY(double y) Sets the y coordinate.voidsetYlength(double dy) Sets the arrows vertical component.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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
-