org.opensourcephysics.media.core
Class TVector

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
                  extended by org.opensourcephysics.media.core.TVector
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Drawable, Interactive, Measurable, Trackable

public class TVector
extends TShape

This is a TShape that draws a vector.

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.Shape head
           
protected  int length
           
protected  java.awt.geom.Line2D line
           
protected  java.awt.geom.GeneralPath path
           
protected  java.awt.geom.AffineTransform rotation
           
protected  java.awt.Shape shaft
           
protected  TPoint tail
           
protected  TPoint tip
           
protected  boolean tipEnabled
           
protected  java.awt.Rectangle tipRect
           
protected  int width
           
 
Fields inherited from class org.opensourcephysics.media.core.TShape
color, fillShape, hitRect, stroke, 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
TVector()
          Constructs a default TVector with tail position (0, 0) and components (0, 0).
TVector(double xt, double yt, double xc, double yc)
          Constructs a TVector with specified tail and components.
 
Method Summary
 Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
          Returns the interactive drawable object at the specified pixel position.
protected  java.awt.Shape getShape(VideoPanel vidPanel)
          Gets the shape to be filled in the draw method.
 TPoint getTail()
          Gets the tail.
 TPoint getTip()
          Gets the tip.
 double getXComponent()
          Gets the x component.
 double getYComponent()
          Gets the y component.
 boolean isTipEnabled()
          Gets whether the tip is enabled.
 void setStroke(java.awt.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, 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, 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

path

protected java.awt.geom.GeneralPath path

line

protected java.awt.geom.Line2D line

head

protected java.awt.Shape head

shaft

protected java.awt.Shape shaft

length

protected int length

width

protected int width

rotation

protected java.awt.geom.AffineTransform rotation

tail

protected TPoint tail

tip

protected TPoint tip

tipRect

protected java.awt.Rectangle tipRect

tipEnabled

protected boolean tipEnabled
Constructor Detail

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 tail
yt - y position of tail
xc - x component
yc - y component
Method Detail

getTip

public TPoint getTip()
Gets the tip.

Returns:
the tip

getTail

public TPoint 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 component
y - 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 interface Interactive
Overrides:
setXY in class TPoint
Parameters:
x - the x position
y - 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

public void setStroke(java.awt.BasicStroke stroke)
Overrides TPoint setStroke method.

Overrides:
setStroke in class TShape
Parameters:
stroke - the desired stroke

findInteractive

public Interactive findInteractive(DrawingPanel panel,
                                   int xpix,
                                   int ypix)
Returns the interactive drawable object at the specified pixel position.

Specified by:
findInteractive in interface Interactive
Overrides:
findInteractive in class TShape
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

getShape

protected java.awt.Shape getShape(VideoPanel vidPanel)
Gets the shape to be filled in the draw method.

Overrides:
getShape in class TShape
Parameters:
vidPanel - the video panel
Returns:
the line shape