java.lang.Object
org.openpatch.scratch.extensions.shape.Shape
Direct Known Subclasses:
Circle, Ellipse, Polygon, Rectangle, Triangle

public class Shape extends Object
Represents a generic shape that can be transformed and drawn. This class serves as a base for specific shapes like Rectangle, Circle, and Ellipse.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Shape
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(double x, double y)
    Check if the shape contains a point defined by its x and y coordinates.
    void
    draw(processing.core.PGraphics buffer)
     
    Get the bounds of the shape.
    boolean
    Check if the shape intersects with another shape.
    rotate(double theta, double anchorX, double anchorY)
    Rotate the shape by the specified angle around a given anchor point.
    scale(double scaleX, double scaleY)
    Check if the shape is empty.
    translate(double dx, double dy)
    Translate the shape by the specified distances in the x and y directions.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • awtShape

      protected Shape awtShape
  • Constructor Details

    • Shape

      protected Shape()
  • Method Details

    • contains

      public boolean contains(double x, double y)
      Check if the shape contains a point defined by its x and y coordinates.
      Parameters:
      x - the x-coordinate of the point
      y - the y-coordinate of the point
      Returns:
      true if the shape contains the point, false otherwise
    • intersects

      public boolean intersects(Shape other)
      Check if the shape intersects with another shape.
      Parameters:
      other - the other shape to check intersection with
      Returns:
      true if the shapes intersect, false otherwise
    • scale

      public Shape scale(double scaleX, double scaleY)
      Check if the shape is empty.
      Returns:
      true if the shape is empty, false otherwise
    • translate

      public Shape translate(double dx, double dy)
      Translate the shape by the specified distances in the x and y directions.
      Parameters:
      dx - the distance to translate in the x direction
      dy - the distance to translate in the y direction
      Returns:
      a new Shape object that is translated
    • rotate

      public Shape rotate(double theta, double anchorX, double anchorY)
      Rotate the shape by the specified angle around a given anchor point.
      Parameters:
      theta - the angle in degrees to rotate
      anchorX - the x-coordinate of the anchor point
      anchorY - the y-coordinate of the anchor point
      Returns:
      a new Shape object that is rotated
    • getBounds

      public Bounds getBounds()
      Get the bounds of the shape.
      Returns:
      a Bounds object representing the bounding box of the shape
    • draw

      public void draw(processing.core.PGraphics buffer)