Package org.opensourcephysics.media.core
Class TShape
java.lang.Object
java.awt.geom.Point2D
java.awt.geom.Point2D.Double
org.opensourcephysics.media.core.TPoint
org.opensourcephysics.media.core.TShape
- All Implemented Interfaces:
Serializable
,Cloneable
,Drawable
,Interactive
,Measurable
,Trackable
- Direct Known Subclasses:
TCircle
,TCoordAxes
,TLine
,TVector
This is the base class for all TPoint objects that draw a Shape.
- Version:
- 1.0
- Author:
- Douglas Brown
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.awt.geom.Point2D
Point2D.Double, Point2D.Float
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Color
protected Shape
protected static Rectangle
protected BasicStroke
protected boolean
Fields inherited from class org.opensourcephysics.media.core.TPoint
attachedTo, coordsEditTrigger, coordsVisibleInMouseBox, enabled, isAdjusting, prevX, prevY, screenPt, stepEditTrigger, support, toScreen, trackEditTrigger, worldPt, xyStringBuilder
Fields inherited from class java.awt.geom.Point2D.Double
x, y
Fields inherited from interface org.opensourcephysics.media.core.Trackable
PROPERTY_ADJUSTING
-
Constructor Summary
ConstructorsConstructorDescriptionTShape()
Constructs a TPoint object with coordinates (0, 0).TShape
(double x, double y) Constructs a TPoint object with specified image coordinates.TShape
(Point2D.Double point) Constructs a TPoint object with image coordinates specified by a Point2D (commonly another TPoint). -
Method Summary
Modifier and TypeMethodDescriptionvoid
draw
(DrawingPanel panel, Graphics _g) Overrides TPoint draw method.findInteractive
(DrawingPanel panel, int xpix, int ypix) Overrides TPoint findInteractive method.getBounds
(VideoPanel vidPanel) Gets the screen bounds of the shape.getColor()
Gets the color of the shape.protected Shape
getShape
(VideoPanel vidPanel) Gets the shape to be filled in the draw method.Gets the stroke.boolean
Gets the current visible state.void
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
(BasicStroke stroke) Sets the stroke.void
setVisible
(boolean visible) Sets the visible state.toString()
Returns a String describing this TPoint.Methods inherited from class org.opensourcephysics.media.core.TPoint
addPropertyChangeListener, addPropertyChangeListener, angle, angle, attachTo, center, cos, cos, detach, equals, getFrameNumber, getScreenPosition, getWorldPosition, getXMax, getXMin, getYMax, getYMin, isAdjusting, isAttached, isCoordsEditTrigger, isEnabled, isMeasured, isStepEditTrigger, isTrackEditTrigger, removePropertyChangeListener, removePropertyChangeListener, setAdjusting, setCoordsEditTrigger, setEnabled, setLocation, setPositionOnLine, setScreenPosition, setScreenPosition, setStepEditTrigger, setTrackEditTrigger, setWorldPosition, 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, isInteractive
-
Field Details
-
hitRect
-
color
-
visible
protected boolean visible -
fillShape
-
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 coordinatey
- the y coordinate
-
TShape
Constructs a TPoint object with image coordinates specified by a Point2D (commonly another TPoint).- Parameters:
point
- the Point2D
-
-
Method Details
-
setColor
Sets the color of the shape.- Parameters:
color
- the desired color
-
getColor
Gets the color of the shape.- Returns:
- the color
-
setStroke
Sets the stroke.- Parameters:
stroke
- the desired stroke
-
getStroke
Gets the stroke.- Returns:
- the color
-
getBounds
Gets the screen bounds of the shape. -
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
Overrides TPoint draw method. -
findInteractive
Overrides TPoint findInteractive method.- Specified by:
findInteractive
in interfaceInteractive
- Overrides:
findInteractive
in classTPoint
- Parameters:
panel
- the drawing panelxpix
- the x pixel position on the panelypix
- the y pixel position on the panel- Returns:
- the interactive drawable object
-
toString
Returns a String describing this TPoint. -
getShape
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 positionypix
- the y pixel position
-