|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.geom.Point2D java.awt.geom.Point2D.Double org.opensourcephysics.media.core.TPoint
public class TPoint
This is a Point2D that implements the Interactive and Trackable interfaces with additional utility methods. Classes that extend TPoint should interpret the stored x and y values as image coordinates. TPoint has an empty draw method.
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 static VidCartesianCoordinateStringBuilder |
coordinateStrBuilder
|
protected boolean |
coordsEditTrigger
|
protected static boolean |
coordsVisibleInMouseBox
|
protected boolean |
enabled
|
protected java.awt.Point |
screenPt
|
protected boolean |
stepEditTrigger
|
protected java.beans.PropertyChangeSupport |
support
|
protected boolean |
trackEditTrigger
|
protected java.awt.geom.Point2D |
worldPt
|
Fields inherited from class java.awt.geom.Point2D.Double |
---|
x, y |
Constructor Summary | |
---|---|
TPoint()
Constructs a TPoint with image coordinates (0, 0). |
|
TPoint(double x,
double y)
Constructs a TPoint with specified image coordinates. |
|
TPoint(java.awt.geom.Point2D point)
Constructs a TPoint with image coordinates specified by a Point2D (commonly another TPoint). |
Method Summary | |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener. |
void |
addPropertyChangeListener(java.lang.String property,
java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener for a specified property. |
double |
angle(double x,
double y)
Returns the angle measured ccw from the positive x-axis to the line between this TPoint and the specified coordinates. |
double |
angle(java.awt.geom.Point2D pt)
Returns the angle measured ccw from the positive x-axis to a line that goes from this TPoint to the specified Point2D. |
void |
center(java.awt.geom.Point2D pt1,
java.awt.geom.Point2D pt2)
Centers this TPoint between the two specified points. |
double |
cos(double x,
double y)
Returns the cosine of the angle measured ccw from the positive x-axis to the line between this TPoint and the specified coordinates. |
double |
cos(java.awt.geom.Point2D pt)
Returns the cosine of the angle measured ccw from the positive x-axis to the line between this TPoint and the specified Point2D. |
void |
draw(DrawingPanel panel,
java.awt.Graphics _g)
Empty draw method. |
boolean |
equals(java.lang.Object object)
Compares this to the specified object. |
Interactive |
findInteractive(DrawingPanel panel,
int xpix,
int ypix)
Returns null. |
java.awt.Rectangle |
getBounds(VideoPanel vidPanel)
Gets the screen bounds of this object. |
int |
getFrameNumber(VideoPanel vidPanel)
Gets the frame number this TPoint uses for coordinate system transforms and other identification. |
java.awt.Point |
getScreenPosition(VideoPanel vidPanel)
Gets the screen position of this TPoint on the specified VideoPanel. |
java.awt.geom.Point2D |
getWorldPosition(VideoPanel vidPanel)
Gets the world position of this TPoint on the specified VideoPanel. |
double |
getXMax()
Gets the maximum x needed to draw this object. |
double |
getXMin()
Gets the minimum x needed to draw this object. |
double |
getYMax()
Gets the maximum y needed to draw this object. |
double |
getYMin()
Gets the minimum y needed to draw this object. |
boolean |
isCoordsEditTrigger()
Reports whether this is a coordsEditTrigger. |
boolean |
isEnabled()
Gets whether this responds to mouse hits. |
boolean |
isMeasured()
Reports whether information is available to set min/max values. |
boolean |
isStepEditTrigger()
Reports whether this is a stepEditTrigger. |
boolean |
isTrackEditTrigger()
Reports whether this is a trackEditTrigger. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener. |
void |
removePropertyChangeListener(java.lang.String property,
java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener for a specified property. |
void |
setCoordsEditTrigger(boolean edit)
Sets the coordsEditTrigger property. |
void |
setEnabled(boolean enabled)
Sets whether this responds to mouse hits. |
void |
setLocation(double x,
double y)
Overrides Point2D.Double setLocation method. |
void |
setPositionOnLine(int xScreen,
int yScreen,
VideoPanel vidPanel,
TPoint end1,
TPoint end2)
Sets the position of this point on the line between end1 and end2 nearest the specified screen position. |
void |
setScreenPosition(int x,
int y,
VideoPanel vidPanel)
Sets the screen position of this TPoint on the specified VideoPanel. |
void |
setScreenPosition(int x,
int y,
VideoPanel vidPanel,
java.awt.event.InputEvent e)
Sets the screen position of this TPoint. |
void |
setStepEditTrigger(boolean stepEditTrigger)
Sets the stepEditTrigger property. |
void |
setTrackEditTrigger(boolean edit)
Sets the trackEditTrigger property. |
void |
setX(double x)
Sets the x position in imagespace. |
void |
setXY(double x,
double y)
Sets the x and y positions in imagespace. |
void |
setY(double y)
Sets the y position in imagespace. |
void |
showCoordinates(VideoPanel vidPanel)
Shows the world coordinates of this TPoint in the mouse box of the specified VideoPanel. |
double |
sin(double x,
double y)
Returns the sine of the angle measured ccw from the positive x-axis to the line between this TPoint and the specified coordinates. |
double |
sin(java.awt.geom.Point2D pt)
Returns the sine of the angle measured ccw from the positive x-axis to the line between this TPoint and the specified Point2D. |
java.lang.String |
toString()
Returns a String describing this. |
void |
translate(double dx,
double dy)
Translates this TPoint by the specified displacement. |
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 |
---|
protected static boolean coordsVisibleInMouseBox
protected static VidCartesianCoordinateStringBuilder coordinateStrBuilder
protected boolean enabled
protected boolean trackEditTrigger
protected boolean coordsEditTrigger
protected boolean stepEditTrigger
protected java.awt.Point screenPt
protected java.awt.geom.Point2D worldPt
protected java.beans.PropertyChangeSupport support
Constructor Detail |
---|
public TPoint()
public TPoint(double x, double y)
x
- the x coordinatey
- the y coordinatepublic TPoint(java.awt.geom.Point2D point)
point
- the Point2DMethod Detail |
---|
public void draw(DrawingPanel panel, java.awt.Graphics _g)
draw
in interface Drawable
panel
- the drawing panel requesting the drawing_g
- the graphics context on which to drawpublic Interactive findInteractive(DrawingPanel panel, int xpix, int ypix)
findInteractive
in interface Interactive
panel
- the drawing panelxpix
- the x pixel position on the panelypix
- the y pixel position on the panel
public void setX(double x)
setX
in interface Interactive
x
- the x positionpublic void setY(double y)
setY
in interface Interactive
y
- the y positionpublic void setXY(double x, double y)
setXY
in interface Interactive
x
- the x positiony
- the y positionpublic void setLocation(double x, double y)
setLocation
in class java.awt.geom.Point2D.Double
x
- the x positiony
- the y positionpublic int getFrameNumber(VideoPanel vidPanel)
vidPanel
- the video panel
public java.awt.Point getScreenPosition(VideoPanel vidPanel)
vidPanel
- the video panel
public void setScreenPosition(int x, int y, VideoPanel vidPanel)
x
- the screen x coordinatey
- the screen y coordinatevidPanel
- the video panelpublic void setScreenPosition(int x, int y, VideoPanel vidPanel, java.awt.event.InputEvent e)
x
- the screen x coordinatey
- the screen y coordinatevidPanel
- the video panele
- the input event making the requestpublic java.awt.geom.Point2D getWorldPosition(VideoPanel vidPanel)
vidPanel
- the video panel
public void showCoordinates(VideoPanel vidPanel)
vidPanel
- the video panelpublic void setEnabled(boolean enabled)
setEnabled
in interface Interactive
enabled
- true
if this responds to mouse hits.public boolean isEnabled()
isEnabled
in interface Interactive
true
if this responds to mouse hits.public void setTrackEditTrigger(boolean edit)
edit
- true
to make this a trackEditTrigger.public boolean isTrackEditTrigger()
true
if this is a trackEditTrigger.public void setCoordsEditTrigger(boolean edit)
edit
- true
to make this a coordsEditTrigger.public boolean isCoordsEditTrigger()
true
if this is a coordsEditTrigger.public void setStepEditTrigger(boolean stepEditTrigger)
stepEditTrigger
- true
to make this a stepEditTrigger.public boolean isStepEditTrigger()
true
if this is a stepEditTrigger.public java.awt.Rectangle getBounds(VideoPanel vidPanel)
vidPanel
- the video panel
public boolean isMeasured()
isMeasured
in interface Measurable
false
public double getXMin()
getXMin
in interface Measurable
public double getXMax()
getXMax
in interface Measurable
public double getYMin()
getYMin
in interface Measurable
public double getYMax()
getYMax
in interface Measurable
public double angle(double x, double y)
x
- the x coordinatey
- the x coordinate
public double angle(java.awt.geom.Point2D pt)
pt
- the Point2D
public double sin(double x, double y)
x
- the x coordinatey
- the x coordinate
public double sin(java.awt.geom.Point2D pt)
pt
- the Point2D
public double cos(double x, double y)
x
- the x coordinatey
- the x coordinate
public double cos(java.awt.geom.Point2D pt)
pt
- the Point2D
public void center(java.awt.geom.Point2D pt1, java.awt.geom.Point2D pt2)
pt1
- the first Point2Dpt2
- the second Point2Dpublic void translate(double dx, double dy)
dx
- the x displacement in imagespacedy
- the y displacement in imagespacepublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- the object requesting property change notificationpublic void addPropertyChangeListener(java.lang.String property, java.beans.PropertyChangeListener listener)
property
- the name of the property of interest to the listenerlistener
- the object requesting property change notificationpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- the listener requesting removalpublic void removePropertyChangeListener(java.lang.String property, java.beans.PropertyChangeListener listener)
property
- the name of the propertylistener
- the listener to removepublic java.lang.String toString()
toString
in class java.awt.geom.Point2D.Double
public boolean equals(java.lang.Object object)
equals
in class java.awt.geom.Point2D
object
- the object
true
if this equals the specified objectpublic void setPositionOnLine(int xScreen, int yScreen, VideoPanel vidPanel, TPoint end1, TPoint end2)
xScreen
- the x screen positionyScreen
- the y screen positionvidPanel
- the videoPanel drawing this pointend1
- one end of the lineend2
- the other end of the line
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |