Package net.sf.jaxodraw.object
Class JaxoExtendedObject
- java.lang.Object
-
- net.sf.jaxodraw.object.JaxoObject
-
- net.sf.jaxodraw.object.JaxoExtendedObject
-
- All Implemented Interfaces:
java.awt.Shape,java.beans.PropertyChangeListener,java.io.Serializable,java.lang.Cloneable,java.util.EventListener
- Direct Known Subclasses:
JaxoFillObject,JaxoGroup,JaxoParticleObject,JaxoVertex
public abstract class JaxoExtendedObject extends JaxoObject
A JaxoObject with at least two points.- Since:
- 2.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static intSELECT_DXA point with coordinates (x,y2).static intSELECT_DYA point with coordinates (x2,y).static intSELECT_P2Second point (index 1).-
Fields inherited from class net.sf.jaxodraw.object.JaxoObject
D_FORMAT, GRAY_SCALE_FORMAT, SELECT_NONE, SELECT_P1
-
-
Constructor Summary
Constructors Constructor Description JaxoExtendedObject()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleancanBeSelected(int handle, int mode)Determines if the object can be selected (moved, edited, etc) from the given point in a given edit mode.voidcopyFrom(JaxoExtendedObject temp)Sets all parameters from the given object to the current one.intgetGrabbedHandle(int clickX, int clickY, JaxoHandle h)Determines which handle the user has selected to move/resize/edit an object.intgetHeight()Returns the height of this object.intgetPointCount()Returns the number of points it takes to draw this object.doublegetRadius()Convenience method for getting the radius of a 2 point object, ie the distance between the first two points.intgetRelh()Returns the relative height of this object.java.awt.DimensiongetRelSize()Returns the relative width and height of this object.intgetRelw()Returns the relative width of this object.java.awt.DimensiongetSize()Returns the width and height of this object.protected java.awt.BasicStrokegetStroke()Returns the stroke of this particle object.floatgetStrokeWidth()Returns the stroke width property of this particle object.intgetWidth()Returns the width of this object.intgetX(int index)X coordinate of Point 0 <= index < getPointCount().intgetX2()Returns the x2 coordinate of this object.intgetY(int index)Y coordinate of Point 0 <= index < getPointCount().intgetY2()Returns the y2 coordinate of this object.booleanisCopy(JaxoObject comp)Determines if this JaxoObject is a copy of the specified one.java.lang.StringlatexWidth()The LaTeX command that sets the width for this JaxoObject, using the axodraw.sty package.voidmoveBy(int deltaX, int deltaY)Reset the coordinates of the object when it is moved by deltaX and deltaY.voidpaintHandles(JaxoGraphics2D g2, JaxoHandle h, int editMode)Paints the handles of this JaxoObject that allow to move/resize/edit it.protected voidresetStroke()Resets the stroke to a default BasicStroke with current width.voidsetLocation(int newX, int newY, int newX2, int newY2)Sets the position coordinates of this object.voidsetPreferences()Applies default values to this JaxoObject.voidsetRadius(float newRadius)Convenience method for setting the 'radius' of a 2 point object.voidsetRelativeHeight(int h)Deprecated.unused.voidsetRelativeWidth(int w)Deprecated.unused.voidsetRelWAndH(int w, int h)Sets the relative width and height of this object.voidsetState(JaxoObject o)Restore state to the values of 'o'.protected voidsetStroke(java.awt.BasicStroke newStroke)Sets the stroke of this particle object.voidsetStrokeWidth(float newStroke)Sets the stroke width property of this particle object.voidsetX(int index, int value)Set X coordinate of Point 0 <= index < getPointCount() to 'value'.voidsetX2(int newX2)Sets the x2 coordinate of this object.voidsetY(int index, int value)Set Y coordinate of Point 0 <= index < getPointCount() to 'value'.voidsetY2(int newY2)Sets the y2 coordinate of this object.floatsmallestDistanceTo(int px, int py)Determines the smallest distance of any of the handles of this JaxoObject from the given point.booleanstrokeIs(float comp)Compares the stroke of this JaxoExtendedObject to the given float, taking into account a 0.1% error margin.-
Methods inherited from class net.sf.jaxodraw.object.JaxoObject
addPropertyChangeListener, contains, contains, contains, contains, copy, copyFrom, firePropertyChange, getBounds2D, getBoundsWithHandles, getColor, getGeneralPath, getLaTexLocation, getName, getPathIterator, getPathIterator, getPoints, getX, getY, intersects, intersects, isAround, isMarked, latexCommand, paint, paintVisualAid, prepareEditPanel, propertyChange, removePropertyChangeListener, rescaleObject, setAsMarked, setColor, setLocation, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setPointCount, setPoints, setTransient, setX, setXPosition, setY, setYPosition
-
-
-
-
Field Detail
-
SELECT_DX
public static final int SELECT_DX
A point with coordinates (x,y2).- See Also:
- Constant Field Values
-
SELECT_DY
public static final int SELECT_DY
A point with coordinates (x2,y).- See Also:
- Constant Field Values
-
SELECT_P2
public static final int SELECT_P2
Second point (index 1).- See Also:
- Constant Field Values
-
-
Method Detail
-
getPointCount
public int getPointCount()
Returns the number of points it takes to draw this object.- Overrides:
getPointCountin classJaxoObject- Returns:
- 2.
-
getX
public int getX(int index)
X coordinate of Point 0 <= index < getPointCount().- Overrides:
getXin classJaxoObject- Parameters:
index- The index of the point to get.- Returns:
- The x coordinate of the point at the given index.
-
getY
public int getY(int index)
Y coordinate of Point 0 <= index < getPointCount().- Overrides:
getYin classJaxoObject- Parameters:
index- The index of the point to get.- Returns:
- The y coordinate of the point at the given index.
-
setX
public void setX(int index, int value)Set X coordinate of Point 0 <= index < getPointCount() to 'value'. Throws IllegalArgumentException if the index is not valid for the given object.- Overrides:
setXin classJaxoObject- Parameters:
index- The index of the point to set.value- The value to set.
-
setY
public void setY(int index, int value)Set Y coordinate of Point 0 <= index < getPointCount() to 'value'. Throws IllegalArgumentException if the index is not valid for the given object.- Overrides:
setYin classJaxoObject- Parameters:
index- The index of the point to set.value- The value to set.
-
getX2
public final int getX2()
Returns the x2 coordinate of this object.- Returns:
- The x2 coordinate of this object.
-
setX2
public final void setX2(int newX2)
Sets the x2 coordinate of this object.- Parameters:
newX2- The x2 coordinate of this object.
-
getY2
public final int getY2()
Returns the y2 coordinate of this object.- Returns:
- The y2 coordinate of this object.
-
setY2
public final void setY2(int newY2)
Sets the y2 coordinate of this object.- Parameters:
newY2- The y2 coordinate of this object.
-
getStrokeWidth
public final float getStrokeWidth()
Returns the stroke width property of this particle object.- Returns:
- The stroke width property of this particle object.
-
setStrokeWidth
public void setStrokeWidth(float newStroke)
Sets the stroke width property of this particle object.- Parameters:
newStroke- The stroke width property of this particle object.
-
getWidth
public final int getWidth()
Returns the width of this object.- Overrides:
getWidthin classJaxoObject- Returns:
- The width of this object.
-
getHeight
public final int getHeight()
Returns the height of this object.- Overrides:
getHeightin classJaxoObject- Returns:
- The height of this object.
-
getRelw
public final int getRelw()
Returns the relative width of this object.- Returns:
- The relative width of this object.
-
getRelh
public final int getRelh()
Returns the relative height of this object.- Returns:
- The relative height of this object.
-
setRelWAndH
public final void setRelWAndH(int w, int h)Sets the relative width and height of this object.- Parameters:
w- The relative width of this object.h- The relative height of this object.
-
setRelativeWidth
public final void setRelativeWidth(int w)
Deprecated.unused. UsesetX2(int)orsetRelWAndH(int,int)instead.Sets the relative width of this object.- Parameters:
w- The relative width of this object.
-
setRelativeHeight
public final void setRelativeHeight(int h)
Deprecated.unused. UsesetY2(int)orsetRelWAndH(int,int)instead.Sets the relative height of this object.- Parameters:
h- The relative heigh of this object.
-
setRadius
public void setRadius(float newRadius)
Convenience method for setting the 'radius' of a 2 point object. This keeps the first point of this object fixed and adjusts the second point such that the distance between the two is newRadius.- Parameters:
newRadius- The radius to set.
-
getRadius
public double getRadius()
Convenience method for getting the radius of a 2 point object, ie the distance between the first two points.- Returns:
- The radius.
-
setLocation
public final void setLocation(int newX, int newY, int newX2, int newY2)Sets the position coordinates of this object.- Parameters:
newX- The x coordinate of this object.newY- The y coordinate of this object.newX2- The x2 coordinate of this object.newY2- The y2 coordinate of this object.
-
moveBy
public void moveBy(int deltaX, int deltaY)Reset the coordinates of the object when it is moved by deltaX and deltaY.- Overrides:
moveByin classJaxoObject- Parameters:
deltaX- The x displacement.deltaY- The y displacement.
-
getSize
public final java.awt.Dimension getSize()
Returns the width and height of this object.- Returns:
- A dimension with the size of the object.
-
getRelSize
public final java.awt.Dimension getRelSize()
Returns the relative width and height of this object.- Returns:
- A dimension with the relative size of the object.
-
isCopy
public boolean isCopy(JaxoObject comp)
Determines if this JaxoObject is a copy of the specified one.- Overrides:
isCopyin classJaxoObject- Parameters:
comp- The JaxoObject to compare against.- Returns:
- True if the JaxoObjects are identical.
-
copyFrom
public void copyFrom(JaxoExtendedObject temp)
Sets all parameters from the given object to the current one.- Parameters:
temp- The object to copy from.
-
setState
public void setState(JaxoObject o)
Restore state to the values of 'o'. The object 'o' must be an object of the same "type" obtained byJaxoObject.copy().- Overrides:
setStatein classJaxoObject- Parameters:
o- the object to copy from.
-
smallestDistanceTo
public float smallestDistanceTo(int px, int py)Determines the smallest distance of any of the handles of this JaxoObject from the given point.- Overrides:
smallestDistanceToin classJaxoObject- Parameters:
px- The x coordinate of the test point.py- The y coordinate of the test point.- Returns:
- The smallest distance.
-
getGrabbedHandle
public int getGrabbedHandle(int clickX, int clickY, JaxoHandle h)Determines which handle the user has selected to move/resize/edit an object.- Overrides:
getGrabbedHandlein classJaxoObject- Parameters:
clickX- The x coordinate where the mouse click has ocurred.clickY- The y coordinate where the mouse click has ocurred.h- A handle object.- Returns:
- One of the static variables SELECT_* defined for this JaxoObject that specifies the handle which the user has clicked.
-
paintHandles
public void paintHandles(JaxoGraphics2D g2, JaxoHandle h, int editMode)
Paints the handles of this JaxoObject that allow to move/resize/edit it.- Specified by:
paintHandlesin classJaxoObject- Parameters:
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.
-
canBeSelected
public 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.- Specified by:
canBeSelectedin classJaxoObject- Parameters:
handle- One of the static variables SELECT_* defined for this JaxoObject.mode- The current edit mode.- Returns:
- True if the object may be selected from the given point, false otherwise.
-
latexWidth
public java.lang.String latexWidth()
The LaTeX command that sets the width for this JaxoObject, using the axodraw.sty package.- Specified by:
latexWidthin classJaxoObject- Returns:
- The corresponding LaTeX command.
-
setPreferences
public void setPreferences()
Applies default values to this JaxoObject. All fields except location points are initialized with values taken from thepreferences.- Overrides:
setPreferencesin classJaxoObject
-
strokeIs
public final boolean strokeIs(float comp)
Compares the stroke of this JaxoExtendedObject to the given float, taking into account a 0.1% error margin.- Parameters:
comp- The float to compare to.- Returns:
- True, if the stroke matches within 0.1%.
-
getStroke
protected final java.awt.BasicStroke getStroke()
Returns the stroke of this particle object.- Returns:
- The stroke of this particle object.
-
setStroke
protected final void setStroke(java.awt.BasicStroke newStroke)
Sets the stroke of this particle object.- Parameters:
newStroke- The strokeof this particle object.
-
resetStroke
protected void resetStroke()
Resets the stroke to a default BasicStroke with current width. This should be overridden by objects that use a different stroke.
-
-