Class JaxoExtendedObject
java.lang.Object
net.sf.jaxodraw.object.JaxoObject
net.sf.jaxodraw.object.JaxoExtendedObject
- All Implemented Interfaces:
Shape, PropertyChangeListener, Serializable, Cloneable, EventListener
- Direct Known Subclasses:
JaxoFillObject, JaxoGroup, JaxoParticleObject, JaxoVertex
A JaxoObject with at least two points.
- Since:
- 2.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intA point with coordinates (x,y2).static final intA point with coordinates (x2,y).static final intSecond point (index 1).Fields inherited from class JaxoObject
D_FORMAT, GRAY_SCALE_FORMAT, SELECT_NONE, SELECT_P1 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanBeSelected(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.final intReturns the height of this object.intReturns the number of points it takes to draw this object.doubleConvenience method for getting the radius of a 2 point object, ie the distance between the first two points.final intgetRelh()Returns the relative height of this object.final DimensionReturns the relative width and height of this object.final intgetRelw()Returns the relative width of this object.final DimensiongetSize()Returns the width and height of this object.protected final BasicStrokeReturns the stroke of this particle object.final floatReturns the stroke width property of this particle object.final intgetWidth()Returns the width of this object.intgetX(int index) X coordinate of Point 0 invalid input: '<'= index invalid input: '<' getPointCount().final intgetX2()Returns the x2 coordinate of this object.intgetY(int index) Y coordinate of Point 0 invalid input: '<'= index invalid input: '<' getPointCount().final intgetY2()Returns the y2 coordinate of this object.booleanisCopy(JaxoObject comp) Determines if this JaxoObject is a copy of the specified one.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 voidResets the stroke to a default BasicStroke with current width.final voidsetLocation(int newX, int newY, int newX2, int newY2) Sets the position coordinates of this object.voidApplies default values to this JaxoObject.voidsetRadius(float newRadius) Convenience method for setting the 'radius' of a 2 point object.final voidsetRelativeHeight(int h) Deprecated.unused.final voidsetRelativeWidth(int w) Deprecated.unused.final voidsetRelWAndH(int w, int h) Sets the relative width and height of this object.voidRestore state to the values of 'o'.protected final voidsetStroke(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 invalid input: '<'= index invalid input: '<' getPointCount() to 'value'.final voidsetX2(int newX2) Sets the x2 coordinate of this object.voidsetY(int index, int value) Set Y coordinate of Point 0 invalid input: '<'= index invalid input: '<' getPointCount() to 'value'.final 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.final 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 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 Details
-
SELECT_DX
public static final int SELECT_DXA point with coordinates (x,y2).- See Also:
-
SELECT_DY
public static final int SELECT_DYA point with coordinates (x2,y).- See Also:
-
SELECT_P2
public static final int SELECT_P2Second point (index 1).- See Also:
-
-
Constructor Details
-
JaxoExtendedObject
public JaxoExtendedObject()
-
-
Method Details
-
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 invalid input: '<'= index invalid input: '<' 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 invalid input: '<'= index invalid input: '<' 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 invalid input: '<'= index invalid input: '<' 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 invalid input: '<'= index invalid input: '<' 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
Returns the width and height of this object.- Returns:
- A dimension with the size of the object.
-
getRelSize
Returns the relative width and height of this object.- Returns:
- A dimension with the relative size of the object.
-
isCopy
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
Sets all parameters from the given object to the current one.- Parameters:
temp- The object to copy from.
-
setState
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
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
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
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
Returns the stroke of this particle object.- Returns:
- The stroke of this particle object.
-
setStroke
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.
-