org.opensourcephysics.display
Class Arrow

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

public class Arrow
extends java.lang.Object
implements Drawable

A Drawable arrow that uses Java 2D drawing.

Version:
1.0
Author:
Wolfgang Christian

Constructor Summary
Arrow(double _x, double _y, double _a, double _b)
          Constructs an Arrow with the given postion and components.
 
Method Summary
 void draw(DrawingPanel panel, java.awt.Graphics g)
          Draws the arrow.
 float getHeadSize()
          Gets the headsize for the arrow.
static XML.ObjectLoader getLoader()
          Gets a loader that allows a Circle to be represented as XML data.
 double getX()
          Gets the x coordinate.
 double getXlength()
          Gets the horizontal component.
 double getY()
          Gets the y coordinate.
 double getYlength()
          Gets the vertical component.
 void setColor(java.awt.Color c)
          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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 Detail

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

public void setColor(java.awt.Color c)
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

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

Specified by:
draw in interface Drawable
Parameters:
panel - the drawing panel in which the arrow is viewed
g - the graphics context upon which to draw

getLoader

public static XML.ObjectLoader 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