public abstract class JaxoObject
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable, java.awt.Shape, java.beans.PropertyChangeListener
| Modifier and Type | Field and Description |
|---|---|
static java.text.DecimalFormat |
D_FORMAT
The decimal format used for numbers in LaTeX output.
|
static java.text.DecimalFormat |
GRAY_SCALE_FORMAT
The decimal format used gray scales in LaTeX output.
|
static int |
SELECT_NONE
An integer that indicates that the user did not grab any object.
|
static int |
SELECT_P1
First point (index 0).
|
| Constructor and Description |
|---|
JaxoObject() |
| Modifier and Type | Method and Description |
|---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener to this object.
|
abstract boolean |
canBeSelected(int handle,
int mode)
Determines if the object can be selected (moved, edited, etc)
from the given point in a given edit mode.
|
boolean |
contains(double x0,
double y0)
Tests if the specified coordinates are inside the
boundary of this JaxoObject.
|
boolean |
contains(double x0,
double y0,
double w,
double h)
Tests if the specified rectangular shape is entirely inside the
boundary of this JaxoObject.
|
boolean |
contains(java.awt.geom.Point2D p)
Tests if the specified point is inside the
boundary of this JaxoObject.
|
boolean |
contains(java.awt.geom.Rectangle2D r)
Tests if the specified rectangle is entirely inside the
boundary of this JaxoObject.
|
JaxoObject |
copy()
Returns an exact copy of the given JaxoObject.
|
void |
copyFrom(JaxoObject temp)
Sets all parameters from the given object to the current one.
|
protected void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Notify all registered listeners of a changed property.
|
java.awt.geom.Rectangle2D |
getBounds2D()
Return a high-precision bounding box of this JaxoObject.
|
java.awt.geom.Rectangle2D |
getBoundsWithHandles(JaxoHandle h)
Return a Rectangle that contains this object and all its handles.
|
java.awt.Color |
getColor()
Returns the color of this object.
|
protected java.awt.geom.GeneralPath |
getGeneralPath()
Returns the GeneralPath that can be used while painting this JaxoObject.
|
int |
getGrabbedHandle(int clickX,
int clickY,
JaxoHandle h)
Determines which handle the user has selected to move/resize/edit
an object.
|
int |
getHeight()
Returns the height of this object.
|
protected java.awt.geom.Point2D |
getLaTexLocation(float scaleFactor,
int canvasHeight)
Returns the latex (ie axodraw) coordinates of the first point
of this JaxoObject.
|
java.lang.String |
getName()
Returns the name of this JaxoObject.
|
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform at)
Returns an iterator that iterates along the the shape boundary
of this JaxoObject.
|
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform at,
double flatness)
Returns an iterator that iterates along the the shape boundary
of this JaxoObject.
|
int |
getPointCount()
Returns the number of points it takes to draw this object.
|
java.awt.Point[] |
getPoints()
All points, in order.
|
int |
getWidth()
Returns the width of this object.
|
int |
getX()
Returns the x coordinate of this object.
|
int |
getX(int index)
X coordinate of Point 0 <= index < getPointCount().
|
int |
getY()
Returns the y coordinate of this object.
|
int |
getY(int index)
Y coordinate of Point 0 <= index < getPointCount().
|
boolean |
intersects(double x0,
double y0,
double w,
double h)
Test if the interior of this JaxoObject intersects the interior of the
given rectangular area.
|
boolean |
intersects(java.awt.geom.Rectangle2D r)
Test if the interior of this JaxoObject intersects the interior of the
given rectangular area.
|
boolean |
isAround(int select,
int clickX,
int clickY,
JaxoHandle handle)
Determines if the given coordinates are contained within
the given handle at the given point of this object.
|
boolean |
isCopy(JaxoObject comp)
Determines if this JaxoObject is a copy of the specified one.
|
boolean |
isMarked()
Determines whether this JaxoObject is marked as an element
of a group or not.
|
abstract java.lang.String |
latexCommand(float scale,
java.awt.Dimension canvasDim)
The LaTeX command that is necessary to draw the given JaxoObject
using the axodraw.sty package.
|
abstract java.lang.String |
latexWidth()
The LaTeX command that sets the width for this JaxoObject,
using the axodraw.sty package.
|
void |
moveBy(int deltaX,
int deltaY)
Reset the coordinates of the object when it is moved
by deltaX and deltaY.
|
abstract void |
paint(JaxoGraphics2D g2)
The method that paints the JaxoObject.
|
abstract void |
paintHandles(JaxoGraphics2D g2,
JaxoHandle h,
int editMode)
Paints the handles of this JaxoObject that allow
to move/resize/edit it.
|
void |
paintVisualAid(JaxoGraphics2D g2)
Paints a visual aid for the user during dragging
(moving or resizing) of this JaxoObject.
|
abstract void |
prepareEditPanel(JaxoObjectEditPanel editPanel)
Initializes the given editPanel to edit properties of this JaxoObject.
|
void |
propertyChange(java.beans.PropertyChangeEvent evt)
Set a new property.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove the given PropertyChangeListener from this Object.
|
abstract void |
rescaleObject(int orx,
int ory,
float scale)
Rescale this JaxoObject by the scale factor scale,
keeping the point (orx, ory) fixed.
|
void |
setAsMarked(boolean mark)
Sets this JaxoObject as element of a group.
|
void |
setColor(java.awt.Color c)
Sets the color of this object.
|
void |
setLocation(int newX,
int newY)
Sets the x and y coordinate of this object.
|
void |
setParameter(java.lang.String name,
boolean value)
Invokes a setter method for the given parameter name and value.
|
void |
setParameter(java.lang.String name,
java.lang.Class type,
java.lang.Object value)
Invokes a setter method for the given parameter name using reflection.
|
void |
setParameter(java.lang.String name,
java.lang.Class type,
java.lang.Object value,
boolean failOnError)
Invokes a setter method for the given parameter name using reflection.
|
void |
setParameter(java.lang.String name,
java.awt.Color value)
Invokes a setter method for the given parameter name and value.
|
void |
setParameter(java.lang.String name,
float value)
Invokes a setter method for the given parameter name and value.
|
void |
setParameter(java.lang.String name,
int value)
Invokes a setter method for the given parameter name and value.
|
void |
setParameter(java.lang.String name,
java.lang.String value)
Invokes a setter method for the given parameter name and value.
|
void |
setPointCount(int value)
Set point count; currently only used for bean creation of objects,
where setPoints is used.
|
void |
setPoints(java.awt.Point[] value)
Set all points; currently only used for bean creation of objects.
|
void |
setPreferences()
Applies default values to this JaxoObject.
|
void |
setState(JaxoObject o)
Restore state to the values of 'o'.
|
protected static void |
setTransient(java.lang.Class c,
java.lang.String[] propertyNames)
Make all 'properties' in the bean info for class 'c' transient.
|
void |
setX(int newX)
Sets the x coordinate of this object.
|
void |
setX(int index,
int value)
Set X coordinate of Point 0 <= index < getPointCount() to 'value'.
|
void |
setXPosition(int newX)
Moves the object to the given x position.
|
void |
setY(int newY)
Sets the y coordinate of this object.
|
void |
setY(int index,
int value)
Set Y coordinate of Point 0 <= index < getPointCount() to 'value'.
|
void |
setYPosition(int newY)
Moves the object to the given y position.
|
float |
smallestDistanceTo(int px,
int py)
Determines the smallest distance of any of the handles
of this JaxoObject from the given point.
|
public static final int SELECT_NONE
public static final int SELECT_P1
public static final java.text.DecimalFormat D_FORMAT
public static final java.text.DecimalFormat GRAY_SCALE_FORMAT
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener - a listener to add.public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener - the listener to remove.protected void firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
propertyName - the name of the changed property.
This should be equal to the corresponding bean name.oldValue - the old value.newValue - the new value.protected static void setTransient(java.lang.Class c,
java.lang.String[] propertyNames)
c - the class.propertyNames - set of properties to make transient.public int getPointCount()
public void setPointCount(int value)
getPointCount().value - The value to set.public java.awt.Point[] getPoints()
getPointCount(),
getX(int),
getY(int)public void setPoints(java.awt.Point[] value)
value - The points to set.public int getX(int index)
index - The index of the point to get.public int getY(int index)
index - The index of the point to get.public void setX(int index,
int value)
index - The index of the point to set.value - The value to set.public void setY(int index,
int value)
index - The index of the point to set.value - The value to set.public int getX()
public void setX(int newX)
newX - The x coordinate of this object.public int getY()
public void setY(int newY)
newY - The y coordinate of this object.public int getWidth()
public int getHeight()
public java.awt.Color getColor()
public void setColor(java.awt.Color c)
c - The color of this object.public void setLocation(int newX,
int newY)
newX - The x coordinate of this object.newY - The y coordinate of this object.protected final java.awt.geom.GeneralPath getGeneralPath()
public final void setAsMarked(boolean mark)
mark - A boolean variable indicating whether this
JaxoObject should be set as an element of a group or not.public final boolean isMarked()
public void moveBy(int deltaX,
int deltaY)
deltaX - The x displacement.deltaY - The y displacement.public void setXPosition(int newX)
newX - the new x position.public void setYPosition(int newY)
newY - the new y position.public void paintVisualAid(JaxoGraphics2D g2)
g2 - The graphics context to paint the visual aid.public boolean isCopy(JaxoObject comp)
comp - The JaxoObject to compare against.public void copyFrom(JaxoObject temp)
temp - The object to copy from.public void setState(JaxoObject o)
copy().o - the object to copy from.public float smallestDistanceTo(int px,
int py)
px - The x coordinate of the test point.py - The y coordinate of the test point.public JaxoObject copy()
public boolean isAround(int select,
int clickX,
int clickY,
JaxoHandle handle)
select - One of the constants SELECT_* defined for this objects.clickX - The x coordinate of the point.clickY - The y coordinate of the point.handle - The test handle.public int getGrabbedHandle(int clickX,
int clickY,
JaxoHandle h)
clickX - The x coordinate where the mouse click has ocurred.clickY - The y coordinate where the mouse click has ocurred.h - A handle object.public java.awt.geom.Rectangle2D getBoundsWithHandles(JaxoHandle h)
h - the handle.protected java.awt.geom.Point2D getLaTexLocation(float scaleFactor,
int canvasHeight)
scaleFactor - A scalefactor.canvasHeight - The current height of the canvas.public void setPreferences()
preferences.public final java.lang.String getName()
public final void setParameter(java.lang.String name,
java.lang.Class type,
java.lang.Object value,
boolean failOnError)
name - the name of the parameter to set.
Must not be null or empty.type - the class type of the parameter.value - the object value of the parameter to set.failOnError - false if any Exceptions should be swallowed.public final void setParameter(java.lang.String name,
java.lang.Class type,
java.lang.Object value)
name - the name of the parameter to set.type - the class type of the parameter.value - the object value of the parameter to set.public final void setParameter(java.lang.String name,
int value)
name - the name of the parameter to set.value - the object value of the parameter to set.setParameter(String,Class,Object)public final void setParameter(java.lang.String name,
float value)
name - the name of the parameter to set.value - the object value of the parameter to set.setParameter(String,Class,Object)public final void setParameter(java.lang.String name,
boolean value)
name - the name of the parameter to set.value - the object value of the parameter to set.setParameter(String,Class,Object)public final void setParameter(java.lang.String name,
java.awt.Color value)
name - the name of the parameter to set.value - the object value of the parameter to set.setParameter(String,Class,Object)public final void setParameter(java.lang.String name,
java.lang.String value)
name - the name of the parameter to set.value - the object value of the parameter to set.setParameter(String,Class,Object)public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange in interface java.beans.PropertyChangeListenerevt - the PropertyChangeEvent.public boolean contains(double x0,
double y0)
contains in interface java.awt.Shapex0 - the x coordinate to test.y0 - the y coordinate to test.Shape.getBounds() contains the given point.Shape.contains(double,double).public boolean contains(double x0,
double y0,
double w,
double h)
contains in interface java.awt.Shapex0 - the x coordinate to test.y0 - the y coordinate to test.w - the width of the rectangle.h - the height of the rectangle.Shape.getBounds() contains the given rectangle.Shape.contains(double,double,double,double).public boolean contains(java.awt.geom.Point2D p)
contains in interface java.awt.Shapep - the point to test.Shape.getBounds() contains the given point.Shape.contains(java.awt.geom.Point2D).public boolean contains(java.awt.geom.Rectangle2D r)
contains in interface java.awt.Shaper - the rectangle to test.Shape.getBounds() contains the given rectangle.Shape.contains(java.awt.geom.Rectangle2D).public java.awt.geom.Rectangle2D getBounds2D()
getBounds2D in interface java.awt.ShapeShape.getBounds2D().public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)
getPathIterator in interface java.awt.Shapeat - an optional AffineTransformation to be applied to be
applied to the coordinates of this object, or null for untransformed
coordinates.Shape.getPathIterator(java.awt.geom.AffineTransform).public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at,
double flatness)
getPathIterator in interface java.awt.Shapeat - an optional AffineTransformation to be applied to be
applied to the coordinates of this object, or null for untransformed
coordinates.flatness - the flatness parameter.Shape.getPathIterator(java.awt.geom.AffineTransform,double).public boolean intersects(double x0,
double y0,
double w,
double h)
intersects in interface java.awt.Shapex0 - the x-coordinate of the test rectangle.y0 - the y-coordinate of the test rectangle.w - the width of the test rectangle.h - the height of the test rectangle.Shape.intersects(double,double,double,double).public boolean intersects(java.awt.geom.Rectangle2D r)
intersects in interface java.awt.Shaper - the rectangle to test.Shape.intersects(java.awt.geom.Rectangle2D).public abstract void paint(JaxoGraphics2D g2)
g2 - The graphics context where the object has to be painted.public abstract void paintHandles(JaxoGraphics2D g2, JaxoHandle h, int editMode)
g2 - The corresponding graphics context.h - A handle object to be used for painting.editMode - The edit mode that the handles are being painted in.public abstract boolean canBeSelected(int handle,
int mode)
handle - One of the static variables SELECT_* defined for
this JaxoObject.mode - The current edit mode.public abstract java.lang.String latexCommand(float scale,
java.awt.Dimension canvasDim)
scale - A scale factor to translate Java coordinates to
LaTeX coordinates.canvasDim - The current dimension of the canvas.public abstract java.lang.String latexWidth()
public abstract void rescaleObject(int orx,
int ory,
float scale)
orx - The x-coordinate of the fixed point.ory - The y-coordinate of the fixed point.scale - The scale parameter.public abstract void prepareEditPanel(JaxoObjectEditPanel editPanel)
editPanel - the panel to prepare.Licensed under GPL. For more information, see http://jaxodraw.sourceforge.net/license.html or the LICENSE file in the jaxodraw distribution.