org.opensourcephysics.media.core
Class TShape

java.lang.Object
  extended by java.awt.geom.Point2D
      extended by java.awt.geom.Point2D.Double
          extended by org.opensourcephysics.media.core.TPoint
              extended by org.opensourcephysics.media.core.TShape
All Implemented Interfaces:
java.io.Serializable, java.lang.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:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.geom.Point2D
java.awt.geom.Point2D.Double, java.awt.geom.Point2D.Float
 
Field Summary
protected  java.awt.Color color
           
protected  java.awt.Shape fillShape
           
protected static java.awt.Rectangle hitRect
           
protected  java.awt.BasicStroke stroke
           
protected  boolean visible
           
 
Fields inherited from class org.opensourcephysics.media.core.TPoint
coordinateStrBuilder, coordsEditTrigger, coordsVisibleInMouseBox, enabled, screenPt, stepEditTrigger, support, trackEditTrigger, worldPt
 
Fields inherited from class java.awt.geom.Point2D.Double
x, y
 
Constructor Summary
TShape()
          Constructs a TPoint object with coordinates (0, 0).
TShape(double x, double y)
          Constructs a TPoint object with specified image coordinates.
TShape(java.awt.geom.Point2D point)
          Constructs a TPoint object with image coordinates specified by a Point2D (commonly another TPoint).
 
Method Summary
 void draw(DrawingPanel panel, java.awt.Graphics _g)
          Overrides TPoint draw method.
 Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
          Overrides TPoint findInteractive method.
 java.awt.Rectangle getBounds(VideoPanel vidPanel)
          Gets the screen bounds of the shape.
 java.awt.Color getColor()
          Gets the color of the shape.
protected  java.awt.Shape getShape(VideoPanel vidPanel)
          Gets the shape to be filled in the draw method.
 java.awt.BasicStroke getStroke()
          Gets the stroke.
 boolean isVisible()
          Gets the current visible state.
 void setColor(java.awt.Color color)
          Sets the color of the shape.
protected  void setHitRectCenter(int xpix, int ypix)
          Centers the hit testing rectangle on the specified screen point.
 void setStroke(java.awt.BasicStroke stroke)
          Sets the stroke.
 void setVisible(boolean visible)
          Sets the visible state.
 java.lang.String toString()
          Returns a String describing this TPoint.
 
Methods inherited from class org.opensourcephysics.media.core.TPoint
addPropertyChangeListener, addPropertyChangeListener, angle, angle, center, cos, cos, equals, getFrameNumber, getScreenPosition, getWorldPosition, getXMax, getXMin, getYMax, getYMin, isCoordsEditTrigger, isEnabled, isMeasured, isStepEditTrigger, isTrackEditTrigger, removePropertyChangeListener, removePropertyChangeListener, setCoordsEditTrigger, setEnabled, setLocation, setPositionOnLine, setScreenPosition, setScreenPosition, setStepEditTrigger, setTrackEditTrigger, setX, setXY, setY, showCoordinates, sin, sin, translate
 
Methods inherited from class java.awt.geom.Point2D.Double
getX, getY
 
Methods inherited from class java.awt.geom.Point2D
clone, distance, distance, distance, distanceSq, distanceSq, distanceSq, hashCode, setLocation
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opensourcephysics.display.Interactive
getX, getY
 

Field Detail

hitRect

protected static java.awt.Rectangle hitRect

color

protected java.awt.Color color

visible

protected boolean visible

fillShape

protected java.awt.Shape fillShape

stroke

protected java.awt.BasicStroke stroke
Constructor Detail

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(java.awt.geom.Point2D point)
Constructs a TPoint object with image coordinates specified by a Point2D (commonly another TPoint).

Parameters:
point - the Point2D
Method Detail

setColor

public void setColor(java.awt.Color color)
Sets the color of the shape.

Parameters:
color - the desired color

getColor

public java.awt.Color getColor()
Gets the color of the shape.

Returns:
the color

setStroke

public void setStroke(java.awt.BasicStroke stroke)
Sets the stroke.

Parameters:
stroke - the desired stroke

getStroke

public java.awt.BasicStroke getStroke()
Gets the stroke.

Returns:
the color

getBounds

public java.awt.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,
                 java.awt.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 java.lang.String toString()
Returns a String describing this TPoint.

Overrides:
toString in class TPoint
Returns:
a descriptive string

getShape

protected java.awt.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