Package net.sf.jaxodraw.object
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 int
A point with coordinates (x,y2).static final int
A point with coordinates (x2,y).static final int
Second point (index 1).Fields inherited from class net.sf.jaxodraw.object.JaxoObject
D_FORMAT, GRAY_SCALE_FORMAT, SELECT_NONE, SELECT_P1
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
canBeSelected
(int handle, int mode) Determines if the object can be selected (moved, edited, etc) from the given point in a given edit mode.void
copyFrom
(JaxoExtendedObject temp) Sets all parameters from the given object to the current one.int
getGrabbedHandle
(int clickX, int clickY, JaxoHandle h) Determines which handle the user has selected to move/resize/edit an object.final int
Returns the height of this object.int
Returns the number of points it takes to draw this object.double
Convenience method for getting the radius of a 2 point object, ie the distance between the first two points.final int
getRelh()
Returns the relative height of this object.final Dimension
Returns the relative width and height of this object.final int
getRelw()
Returns the relative width of this object.final Dimension
getSize()
Returns the width and height of this object.protected final BasicStroke
Returns the stroke of this particle object.final float
Returns the stroke width property of this particle object.final int
getWidth()
Returns the width of this object.int
getX
(int index) X coordinate of Point 0 <= index < getPointCount().final int
getX2()
Returns the x2 coordinate of this object.int
getY
(int index) Y coordinate of Point 0 <= index < getPointCount().final int
getY2()
Returns the y2 coordinate of this object.boolean
isCopy
(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.void
moveBy
(int deltaX, int deltaY) Reset the coordinates of the object when it is moved by deltaX and deltaY.void
paintHandles
(JaxoGraphics2D g2, JaxoHandle h, int editMode) Paints the handles of this JaxoObject that allow to move/resize/edit it.protected void
Resets the stroke to a default BasicStroke with current width.final void
setLocation
(int newX, int newY, int newX2, int newY2) Sets the position coordinates of this object.void
Applies default values to this JaxoObject.void
setRadius
(float newRadius) Convenience method for setting the 'radius' of a 2 point object.final void
setRelativeHeight
(int h) Deprecated.unused.final void
setRelativeWidth
(int w) Deprecated.unused.final void
setRelWAndH
(int w, int h) Sets the relative width and height of this object.void
Restore state to the values of 'o'.protected final void
setStroke
(BasicStroke newStroke) Sets the stroke of this particle object.void
setStrokeWidth
(float newStroke) Sets the stroke width property of this particle object.void
setX
(int index, int value) Set X coordinate of Point 0 <= index < getPointCount() to 'value'.final void
setX2
(int newX2) Sets the x2 coordinate of this object.void
setY
(int index, int value) Set Y coordinate of Point 0 <= index < getPointCount() to 'value'.final void
setY2
(int newY2) Sets the y2 coordinate of this object.float
smallestDistanceTo
(int px, int py) Determines the smallest distance of any of the handles of this JaxoObject from the given point.final boolean
strokeIs
(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 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:
getPointCount
in classJaxoObject
- Returns:
- 2.
-
getX
public int getX(int index) X coordinate of Point 0 <= index < getPointCount().- Overrides:
getX
in 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:
getY
in 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:
setX
in 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:
setY
in 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:
getWidth
in classJaxoObject
- Returns:
- The width of this object.
-
getHeight
public final int getHeight()Returns the height of this object.- Overrides:
getHeight
in 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:
moveBy
in 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:
isCopy
in 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:
setState
in 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:
smallestDistanceTo
in 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:
getGrabbedHandle
in 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:
paintHandles
in 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:
canBeSelected
in 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:
latexWidth
in 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:
setPreferences
in 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.
-