Class DrawableShape

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

public class DrawableShape extends Object implements Drawable
A class that draws shapes using the Java 2D API.
  • Field Details

    • color

      public Color color
    • edgeColor

      public Color edgeColor
    • shapeClass

      public String shapeClass
  • Constructor Details

    • DrawableShape

      public DrawableShape(Shape shape, double x, double y)
      Constructs a DrawableShape with the given coordinates.
      Parameters:
      shape -
      x - coordinate
      y - coordinate
  • Method Details

    • createCircle

      public static DrawableShape createCircle(double x, double y, double d)
      Creates a drawable circle.
      Parameters:
      x -
      y -
      d - the diameter
      Returns:
      the DrawableShape
    • createRectangle

      public static DrawableShape createRectangle(double x, double y, double w, double h)
      Creates a drawable rectangle.
      Parameters:
      x -
      y -
      w -
      h -
      Returns:
      the drawable rectangle
    • setMarkerColor

      public void setMarkerColor(Color fillColor, Color edgeColor)
      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

      public void transform(AffineTransform transformation)
      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

      public String toString()
      Returns a string representation of the circle.
      Overrides:
      toString in class Object
      Returns:
      String
    • draw

      public void draw(DrawingPanel panel, Graphics g)
      Draws the shape.
      Specified by:
      draw in interface Drawable
      Parameters:
      panel - DrawingPanel
      g - Graphics
    • getLoader

      public static XML.ObjectLoader getLoader()
      Gets the XML object loader for this class.
      Returns:
      ObjectLoader