Class Arrow

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

public class Arrow extends Object implements Drawable
A Drawable arrow that uses Java 2D drawing.
Version:
1.0
Author:
Wolfgang Christian
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected double
     
    protected double
     
    protected Color
     
    protected float
     
    protected double
     
    protected double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Arrow(double _x, double _y, double _a, double _b)
    Constructs an Arrow with the given postion and components.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Draws the arrow.
    protected Shape
    getHead(Point2D.Double ptA, double theta)
    Gets the arrowhead shape.
    float
    Gets the headsize for the arrow.
    Gets a loader that allows a Circle to be represented as XML data.
    double
    Gets the x coordinate.
    double
    Gets the horizontal component.
    double
    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

      protected Color 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

      public void setColor(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, 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
    • getHead

      protected Shape getHead(Point2D.Double ptA, double theta)
      Gets the arrowhead shape.
      Parameters:
      ptA2 -
      theta - double the angle of the arrow
      Returns:
      Shape
    • 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