Package org.opensourcephysics.media.core
Class TVector
java.lang.Object
java.awt.geom.Point2D
java.awt.geom.Point2D.Double
org.opensourcephysics.media.core.TPoint
org.opensourcephysics.media.core.TShape
org.opensourcephysics.media.core.TVector
- All Implemented Interfaces:
Serializable
,Cloneable
,Drawable
,Interactive
,Measurable
,Trackable
This is a TShape that draws a vector.
- 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 Shape
protected int
protected Line2D
protected GeneralPath
protected AffineTransform
protected Shape
protected TPoint
protected TPoint
protected boolean
protected Rectangle
protected int
Fields inherited from class org.opensourcephysics.media.core.TShape
color, fillShape, hitRect, stroke, visible
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindInteractive
(DrawingPanel panel, int xpix, int ypix) Returns the interactive drawable object at the specified pixel position.protected Shape
getShape
(VideoPanel vidPanel) Gets the shape to be filled in the draw method.getTail()
Gets the tail.getTip()
Gets the tip.double
Gets the x component.double
Gets the y component.boolean
Gets whether the tip is enabled.void
setStroke
(BasicStroke stroke) Overrides TPoint setStroke method.void
setTipEnabled
(boolean enabled) Enables and disables the interactivity of the tip.void
setTipLength
(int tipLength) Sets the length of the arrow tip.void
setXComponent
(double x) Sets the x component.void
setXY
(double x, double y) Overrides TPoint setXY method to move both tip and tail.void
setXYComponents
(double x, double y) Sets the x and y components.void
setYComponent
(double y) Sets the y component.Methods inherited from class org.opensourcephysics.media.core.TShape
draw, getBounds, getColor, getStroke, isVisible, setColor, setHitRectCenter, setVisible, toString
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, 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
-
path
-
line
-
head
-
shaft
-
length
protected int length -
width
protected int width -
rotation
-
tail
-
tip
-
tipRect
-
tipEnabled
protected boolean tipEnabled
-
-
Constructor Details
-
TVector
public TVector()Constructs a default TVector with tail position (0, 0) and components (0, 0). -
TVector
public TVector(double xt, double yt, double xc, double yc) Constructs a TVector with specified tail and components.- Parameters:
xt
- x position of tailyt
- y position of tailxc
- x componentyc
- y component
-
-
Method Details
-
getTip
Gets the tip.- Returns:
- the tip
-
getTail
Gets the tail.- Returns:
- the tail
-
setXComponent
public void setXComponent(double x) Sets the x component.- Parameters:
x
- the x component
-
setYComponent
public void setYComponent(double y) Sets the y component.- Parameters:
y
- the y component
-
setXYComponents
public void setXYComponents(double x, double y) Sets the x and y components.- Parameters:
x
- the x componenty
- the y component
-
getXComponent
public double getXComponent()Gets the x component.- Returns:
- the x component
-
getYComponent
public double getYComponent()Gets the y component.- Returns:
- the y component
-
setXY
public void setXY(double x, double y) Overrides TPoint setXY method to move both tip and tail.- Specified by:
setXY
in interfaceInteractive
- Overrides:
setXY
in classTPoint
- Parameters:
x
- the x positiony
- the y position
-
setTipEnabled
public void setTipEnabled(boolean enabled) Enables and disables the interactivity of the tip.- Parameters:
enabled
-true
to enable the tip
-
isTipEnabled
public boolean isTipEnabled()Gets whether the tip is enabled.- Returns:
true
if the tip is enabled
-
setTipLength
public void setTipLength(int tipLength) Sets the length of the arrow tip.- Parameters:
tipLength
- the tip length in pixels
-
setStroke
Overrides TPoint setStroke method. -
findInteractive
Returns the interactive drawable object at the specified pixel position.- Specified by:
findInteractive
in interfaceInteractive
- Overrides:
findInteractive
in classTShape
- Parameters:
panel
- the drawing panelxpix
- the x pixel position on the panelypix
- the y pixel position on the panel- Returns:
- the interactive drawable object
-
getShape
Gets the shape to be filled in the draw method.
-