Class TShape

All Implemented Interfaces:
Serializable, Cloneable, Drawable, Interactive, Measurable, Trackable
Direct Known Subclasses:
TCircle, TCoordAxes, TLine, TVector

public class TShape extends TPoint
This is the base class for all TPoint objects that draw a Shape.
Version:
1.0
Author:
Douglas Brown
See Also:
  • Field Details

    • hitRect

      protected static Rectangle hitRect
    • color

      protected Color color
    • visible

      protected boolean visible
    • fillShape

      protected Shape fillShape
    • stroke

      protected BasicStroke stroke
  • Constructor Details

    • TShape

      public TShape()
      Constructs a TPoint object with coordinates (0, 0).
    • TShape

      public TShape(double x, double y)
      Constructs a TPoint object with specified image coordinates.
      Parameters:
      x - the x coordinate
      y - the y coordinate
    • TShape

      public TShape(Point2D.Double point)
      Constructs a TPoint object with image coordinates specified by a Point2D (commonly another TPoint).
      Parameters:
      point - the Point2D
  • Method Details

    • setColor

      public void setColor(Color color)
      Sets the color of the shape.
      Parameters:
      color - the desired color
    • getColor

      public Color getColor()
      Gets the color of the shape.
      Returns:
      the color
    • setStroke

      public void setStroke(BasicStroke stroke)
      Sets the stroke.
      Parameters:
      stroke - the desired stroke
    • getStroke

      public BasicStroke getStroke()
      Gets the stroke.
      Returns:
      the color
    • getBounds

      public Rectangle getBounds(VideoPanel vidPanel)
      Gets the screen bounds of the shape.
      Overrides:
      getBounds in class TPoint
      Parameters:
      vidPanel - the video panel
      Returns:
      the bounding rectangle
    • setVisible

      public void setVisible(boolean visible)
      Sets the visible state.
      Parameters:
      visible - true to make this visible.
    • isVisible

      public boolean isVisible()
      Gets the current visible state.
      Returns:
      true if this is visible.
    • draw

      public void draw(DrawingPanel panel, Graphics _g)
      Overrides TPoint draw method.
      Specified by:
      draw in interface Drawable
      Overrides:
      draw in class TPoint
      Parameters:
      panel - the drawing panel requesting the drawing
      _g - the graphics context on which to draw
    • findInteractive

      public Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
      Overrides TPoint findInteractive method.
      Specified by:
      findInteractive in interface Interactive
      Overrides:
      findInteractive in class TPoint
      Parameters:
      panel - the drawing panel
      xpix - the x pixel position on the panel
      ypix - the y pixel position on the panel
      Returns:
      the interactive drawable object
    • toString

      public String toString()
      Returns a String describing this TPoint.
      Overrides:
      toString in class TPoint
      Returns:
      a descriptive string
    • getShape

      protected Shape getShape(VideoPanel vidPanel)
      Gets the shape to be filled in the draw method.
      Parameters:
      vidPanel - the video panel
      Returns:
      the fill shape
    • setHitRectCenter

      protected void setHitRectCenter(int xpix, int ypix)
      Centers the hit testing rectangle on the specified screen point.
      Parameters:
      xpix - the x pixel position
      ypix - the y pixel position