|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opensourcephysics.media.core.ImageCoordSystem
public class ImageCoordSystem
This manages point and vector transformations between imagespace and worldspace coordinates. Imagespace coordinates of a point refer to its pixel position (to sub-pixel precision) relative to the top left corner of an image. Worldspace coordinates of the point are its scaled position relative to a world reference frame origin and axes. Transformations between coordinate spaces depend on the scale (image units per world unit), the origin (image position of the origin of the world reference frame) and the x-axis direction (angle of the world x-axis measured ccw from the image x-axis). Any or all of these may vary with frame number.
Nested Class Summary | |
---|---|
static class |
ImageCoordSystem.Loader
A class to save and load ImageCoordSystem data. |
Field Summary | |
---|---|
protected static java.text.NumberFormat |
decimal
|
protected boolean |
firePropChange
|
protected static java.text.NumberFormat |
sci
|
protected java.beans.PropertyChangeSupport |
support
|
Constructor Summary | |
---|---|
ImageCoordSystem()
Constructs an ImageCoordSystem with a default initial array length. |
|
ImageCoordSystem(int length)
Constructs an ImageCoordSystem with a specified initial array length. |
Method Summary | |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to this coordinate system. |
void |
addPropertyChangeListener(java.lang.String property,
java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to this coordinate system. |
double |
getAngle(int n)
Gets the angle of the world x-axis measured ccw from the image x-axis for the specified frame number. |
double |
getCosine(int n)
Gets the cosine of the angle of the world x-axis measured ccw from the image x-axis for the specified frame number. |
java.lang.String |
getDataString(int n)
Returns a String containing all the data for a single frame number. |
int |
getLength()
Gets the length of this image coordinate system. |
static XML.ObjectLoader |
getLoader()
Returns an XML.ObjectLoader to save and load ImageCoordSystem data. |
double |
getOriginX(int n)
Gets the image x position of the world origin for the specified frame number. |
double |
getOriginY(int n)
Gets the image y position of the world origin for the specified frame number. |
double |
getScaleX(int n)
Gets the scale factor (image units per world unit) along the image x-axis (width direction) for the specified frame number. |
double |
getScaleY(int n)
Gets the scale factor (image units per world unit) along the image y-axis (height direction) for the specified frame number. |
double |
getSine(int n)
Gets the sine of the angle of the world x-axis measured ccw from the image x-axis for the specified frame number. |
java.awt.geom.AffineTransform |
getToImageTransform(int n)
Gets a copy of the affine transform used to convert from worldspace to imagespace for the specified frame number. |
java.awt.geom.AffineTransform |
getToWorldTransform(int n)
Gets a copy of the affine transform used to convert from imagespace to worldspace for the specified frame number. |
double |
imageToWorldX(int n,
double imageX,
double imageY)
Converts the specified image position to a world x position for the specified frame number. |
double |
imageToWorldXComponent(int n,
double imageX,
double imageY)
Converts the specified image vector components to a world vector x component for the specified frame number. |
double |
imageToWorldY(int n,
double imageX,
double imageY)
Converts the specified image position to a world y position for the specified frame number. |
double |
imageToWorldYComponent(int n,
double imageX,
double imageY)
Converts the specified image vector components to a world vector y component for the specified frame number. |
boolean |
isFixedAngle()
Gets the fixed angle property. |
boolean |
isFixedOrigin()
Gets the fixed origin property. |
boolean |
isFixedScale()
Gets the fixed scale property. |
boolean |
isLocked()
Gets the locked property. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener from this coordinate system. |
void |
removePropertyChangeListener(java.lang.String property,
java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener for a specified property. |
void |
setAllAngles(double theta)
Sets the angle of the world x-axis measured ccw from the image x-axis for all frames. |
void |
setAllCosineSines(double cos,
double sin)
Sets the cosine and sine of the angle of the world x-axis measured ccw from the image x-axis for all frames. |
void |
setAllOriginsX(double value)
Sets the image x position of the world origin for all frames. |
void |
setAllOriginsXY(double valueX,
double valueY)
Sets the image position of the world origin for all frames. |
void |
setAllOriginsY(double value)
Sets the image y position of the world origin for all frames. |
void |
setAllScalesX(double value)
Sets the scale factor (image units per world unit) along the image x-axis (width direction) for all frames. |
void |
setAllScalesXY(double valueX,
double valueY)
Sets the scale factors (image units per world unit) along the x-axis and y-axis of the image for all frames. |
void |
setAllScalesY(double value)
Sets the scale factor (image units per world unit) along the image y-axis (height direction) for all frames. |
void |
setAngle(int n,
double theta)
Sets the angle of the world x-axis measured ccw from the image x-axis for the specified frame number. |
void |
setCosineSine(int n,
double cos,
double sin)
Sets the cosine and sine of the angle of the world x-axis measured ccw from the image x-axis for the specified frame number. |
void |
setFixedAngle(boolean fixed)
Sets the fixed angle property. |
void |
setFixedAngle(boolean fixed,
int n)
Sets the fixed angle property. |
void |
setFixedOrigin(boolean fixed)
Sets the fixed origin property. |
void |
setFixedOrigin(boolean fixed,
int n)
Sets the fixed origin property. |
void |
setFixedScale(boolean fixed)
Sets the fixed scale property. |
void |
setFixedScale(boolean fixed,
int n)
Sets the fixed scale property. |
void |
setLength(int count)
Sets the length of this image coordinate system. |
void |
setLocked(boolean locked)
Sets the locked property. |
void |
setOriginX(int n,
double value)
Sets the image x position of the world origin for the specified frame number. |
void |
setOriginXY(int n,
double valueX,
double valueY)
Sets the image position of the world origin for the specified frame number. |
void |
setOriginY(int n,
double value)
Sets the image y position of the world origin for the specified frame number. |
void |
setScaleX(int n,
double value)
Sets the scale factor (image units per world unit) along the image x-axis (width direction) for the specified frame number. |
void |
setScaleXY(int n,
double valueX,
double valueY)
Sets the scale factors (image units per world unit) along the x-axis and y-axis of the image for the specified frame number. |
void |
setScaleY(int n,
double value)
Sets the scale factor (image units per world unit) along the image y-axis (height direction) for the specified frame number. |
double |
worldToImageX(int n,
double worldX,
double worldY)
Converts the specified world position to an image x position for the specified frame number. |
double |
worldToImageXComponent(int n,
double worldX,
double worldY)
Converts the specified world vector components to an image vector x component for the specified frame number. |
double |
worldToImageY(int n,
double worldX,
double worldY)
Converts the specified world position to an image y position for the specified frame number. |
double |
worldToImageYComponent(int n,
double worldX,
double worldY)
Converts the specified world vector components to an image vector y component for the specified frame number. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static java.text.NumberFormat decimal
protected static java.text.NumberFormat sci
protected java.beans.PropertyChangeSupport support
protected boolean firePropChange
Constructor Detail |
---|
public ImageCoordSystem()
public ImageCoordSystem(int length)
length
- the initial lengthMethod Detail |
---|
public 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 void setLocked(boolean locked)
locked
- true
to lock the coordinate systempublic boolean isLocked()
true
if this is lockedpublic void setFixedOrigin(boolean fixed)
fixed
- true
to fix the originpublic void setFixedOrigin(boolean fixed, int n)
fixed
- true
to fix the originn
- the frame numberpublic boolean isFixedOrigin()
true
if origin is fixedpublic void setFixedAngle(boolean fixed)
fixed
- true
to fix the anglepublic void setFixedAngle(boolean fixed, int n)
fixed
- true
to fix the anglen
- the frame numberpublic boolean isFixedAngle()
true
if angle is fixedpublic void setFixedScale(boolean fixed)
fixed
- true
to fix the scalepublic void setFixedScale(boolean fixed, int n)
fixed
- true
to fix the scalen
- the frame numberpublic boolean isFixedScale()
true
if scale is fixedpublic double getScaleX(int n)
n
- the frame number
public double getScaleY(int n)
n
- the frame number
public void setScaleX(int n, double value)
n
- the frame numbervalue
- the x scale factorpublic void setAllScalesX(double value)
value
- the x scale factorpublic void setScaleY(int n, double value)
n
- the frame numbervalue
- the y scale factorpublic void setAllScalesY(double value)
value
- the y scale factorpublic void setScaleXY(int n, double valueX, double valueY)
n
- the frame numbervalueX
- the x scale factorvalueY
- the y scale factorpublic void setAllScalesXY(double valueX, double valueY)
valueX
- the x scale factorvalueY
- the y scale factorpublic double getOriginX(int n)
n
- the frame number
public double getOriginY(int n)
n
- the frame number
public void setOriginX(int n, double value)
n
- the frame numbervalue
- the image x position of the world originpublic void setAllOriginsX(double value)
value
- the image x position of the world originpublic void setOriginY(int n, double value)
n
- the frame numbervalue
- the image y position of the world originpublic void setAllOriginsY(double value)
value
- the image y position of the world originpublic void setOriginXY(int n, double valueX, double valueY)
n
- the frame numbervalueX
- the image x position of the world originvalueY
- the image y position of the world originpublic void setAllOriginsXY(double valueX, double valueY)
valueX
- the image x position of the world originvalueY
- the image y position of the world originpublic double getCosine(int n)
n
- the frame number
public double getSine(int n)
n
- the frame number
public void setCosineSine(int n, double cos, double sin)
n
- the frame numbercos
- the cosine of the anglesin
- the sine of the anglepublic void setAllCosineSines(double cos, double sin)
cos
- the cosine of the anglesin
- the sine of the anglepublic double getAngle(int n)
n
- the frame number
public void setAngle(int n, double theta)
n
- the frame numbertheta
- the angle in radianspublic void setAllAngles(double theta)
theta
- the angle in radianspublic void setLength(int count)
count
- the total number of framespublic int getLength()
public double imageToWorldX(int n, double imageX, double imageY)
n
- the frame numberimageX
- the image x positionimageY
- the image y position
public double imageToWorldY(int n, double imageX, double imageY)
n
- the frame numberimageX
- the image x positionimageY
- the image y position
public double worldToImageX(int n, double worldX, double worldY)
n
- the frame numberworldX
- the world x positionworldY
- the world y position
public double worldToImageY(int n, double worldX, double worldY)
n
- the frame numberworldX
- the world x positionworldY
- the world y position
public double imageToWorldXComponent(int n, double imageX, double imageY)
n
- the frame numberimageX
- the image x componentsimageY
- the image y components
public double imageToWorldYComponent(int n, double imageX, double imageY)
n
- the frame numberimageX
- the image x componentsimageY
- the image y components
public double worldToImageXComponent(int n, double worldX, double worldY)
n
- the frame numberworldX
- the world x positionworldY
- the world y position
public double worldToImageYComponent(int n, double worldX, double worldY)
n
- the frame numberworldX
- the world x positionworldY
- the world y position
public java.awt.geom.AffineTransform getToImageTransform(int n)
n
- the frame number
public java.awt.geom.AffineTransform getToWorldTransform(int n)
n
- the frame number
public java.lang.String getDataString(int n)
n
- the frame number
public static XML.ObjectLoader getLoader()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |