Class BoundedShape

All Implemented Interfaces:
Drawable, Interactive, Measurable, Selectable
Direct Known Subclasses:
BoundedImage, InteractiveArrow, InteractiveCenteredArrow

public class BoundedShape extends InteractiveShape implements Selectable
  • Constructor Details

    • BoundedShape

      public BoundedShape(Shape s, double x, double y)
      Constructs a BoundedShape object for the given shape.
      Parameters:
      s - Shape
      x - double
      y - double
  • Method Details

    • createBoundedRectangle

      public static BoundedShape createBoundedRectangle(double x, double y, double w, double h)
      Creates a bounded rectangle.
      Parameters:
      x -
      y -
      w -
      h -
      Returns:
      the interactive rectangle
    • createBoundedTriangle

      public static BoundedShape createBoundedTriangle(double x, double y, double b, double h)
      Creates a bounded rectangle.
      Parameters:
      x -
      y -
      b - base
      h - height
      Returns:
      the rectangle
    • createBoundedArrow

      public static BoundedShape createBoundedArrow(double x, double y, double w, double h)
      Creates a bounded arrow.
      Parameters:
      x -
      y -
      w - base
      h - height
      Returns:
      the arrow
    • createBoundedCenteredArrow

      public static BoundedShape createBoundedCenteredArrow(double x, double y, double w, double h)
      Creates a bounded arrow.
      Parameters:
      x -
      y -
      w - base
      h - height
      Returns:
      the arrow
    • createBoundedImage

      public static BoundedShape createBoundedImage(Image image, double x, double y)
      Creates a bounded image.
      Parameters:
      x -
      y -
      image -
      Returns:
      the rectangle
    • createBoundedEllipse

      public static BoundedShape createBoundedEllipse(double x, double y, double w, double h)
      Creates a bounded ellipse.
      Parameters:
      x -
      y -
      w -
      h -
      Returns:
      BoundedShape
    • createBoundedCircle

      public static BoundedShape createBoundedCircle(double x, double y, double d)
      Creates a bounded circle.
      Parameters:
      x -
      y -
      d - the diameter
      Returns:
      the circle
    • setSelected

      public void setSelected(boolean selected)
      Specified by:
      setSelected in interface Selectable
    • isSelected

      public boolean isSelected()
      Specified by:
      isSelected in interface Selectable
    • setXYDrag

      public void setXYDrag(boolean enable)
      Sets the xy drag option.
      Parameters:
      enable - boolean
    • isXYDrag

      public boolean isXYDrag()
      Gets the xy drag boolean.
      Returns:
      boolean true if center can be dragged
    • setRotateDrag

      public void setRotateDrag(boolean enable)
      Sets the rotate drag option.
      Parameters:
      enable - boolean
    • isRotateDrag

      public boolean isRotateDrag()
      Gets the rotate drag option.
      Returns:
      boolean
    • setWidthDrag

      public void setWidthDrag(boolean enable)
      Sets the width drag option.
      Parameters:
      enable - boolean
    • isWidthDrag

      public boolean isWidthDrag()
      Gets the width width drag option.
      Returns:
      boolean true if center can be dragged
    • setHeightDrag

      public void setHeightDrag(boolean enable)
      Sets the height drag option.
      Parameters:
      enable - boolean
    • isHeightDrag

      public boolean isHeightDrag()
      Gets the height drag option.
      Returns:
      boolean true if center can be dragged
    • getPreferredCursor

      public Cursor getPreferredCursor()
      Specified by:
      getPreferredCursor in interface Selectable
    • toggleSelected

      public void toggleSelected()
      Specified by:
      toggleSelected in interface Selectable
    • findInteractive

      public Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
      Description copied from class: AbstractInteractive
      Finds the interactive object that will respond to mouse actions.
      Specified by:
      findInteractive in interface Interactive
      Overrides:
      findInteractive in class AbstractInteractive
      Parameters:
      panel - DrawingPanel
      xpix - int
      ypix - int
      Returns:
      Interactive
    • isInside

      public boolean isInside(DrawingPanel panel, int xpix, int ypix)
      Determines if the shape is enabled and if the given pixel coordinates are within the shape.
      Overrides:
      isInside in class InteractiveShape
      Parameters:
      panel - DrawingPanel
      xpix - int
      ypix - int
      Returns:
      boolean
    • getBounds2D

      protected Rectangle2D.Double getBounds2D(Shape temp)
    • draw

      public void draw(DrawingPanel panel, Graphics g)
      Draws the shape.
      Specified by:
      draw in interface Drawable
      Overrides:
      draw in class InteractiveShape
      Parameters:
      panel - the drawing panel
      g - the graphics context
    • toString

      public String toString()
      Gets a description of this object.
      Overrides:
      toString in class InteractiveShape
      Returns:
      String
    • getLoader

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