Class AbstractParticleObject
- java.lang.Object
-
- net.sf.jaxodraw.graph.object.AbstractJaxoObject
-
- net.sf.jaxodraw.graph.object.AbstractExtendedObject
-
- net.sf.jaxodraw.graph.object.AbstractParticleObject
-
- All Implemented Interfaces:
PropertyChangeListener
,Serializable
,EventListener
,JaxoObject
- Direct Known Subclasses:
Abstract3PointObject
,AbstractLineObject
,AbstractLoopObject
public abstract class AbstractParticleObject extends AbstractExtendedObject
The mother of all particle objects (arcs, lines and loops).- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.sf.jaxodraw.graph.object.JaxoObject
JaxoObject.EditMode, JaxoObject.Handle
-
-
Field Summary
-
Fields inherited from class net.sf.jaxodraw.graph.object.AbstractJaxoObject
SERIAL_VERSION_UID
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractParticleObject()
Default.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Rectangle
arrowBounds()
Bounding box of arrows.abstract JaxoArrow.Coordinates
arrowCoordinates(int number)
Returns the coordinates of the arrow of the current object.boolean
arrowPositionIs(float comp)
Compares the arrowPosition of this AbstractParticleObject to the given float, taking into account a 0.1% error margin.protected void
copyFrom(AbstractParticleObject temp)
Sets all parameters from the given object to the current one.boolean
dlSepIs(float comp)
Compares the dlSeparation of this AbstractParticleObject to the given float, taking into account a 0.1% error margin.JaxoArrow
getArrow()
Returns the arrow of this particle object.int
getArrowCount()
The number of arrows in this particle object.float
getArrowPosition()
Returns the arrowPosition property of this particle object.Rectangle
getBounds()
Returns the bounding box of this object.float
getDLSeparation()
Returns the double line separation of this object.protected abstract GeneralPath
getObjectPath()
Get the GeneralPath that paints this object.boolean
isCopy(JaxoObject obj)
Determines if this JaxoObject is a copy of the specified one.boolean
isDoubleLine()
Returns the double line property.boolean
isFlip()
Returns the flip property of this particle object.boolean
isPaintable()
Specify whether the object is actually paintable in a specific configuration.boolean
isPaintArrow()
Determines whether the arrow property of this particle object is set or not.abstract double
length()
Calculates the length of this particle object.protected GeneralPath
linepath()
Return a Path that is a line from the first Point to the last click Point of this Object.void
paint(Graphics2D g2)
The method that paints the JaxoObject.protected void
paintArrow(Graphics2D g2)
Paints an arrow on this object.void
propertyChange(PropertyChangeEvent evt)
Set a new property.void
setArrow(JaxoArrow newArrow)
Sets the dash property of this particle object.void
setArrowCount(int newArrowCount)
Set the number of arrows in this particle object.void
setArrowPosition(float newArrowPosition)
Sets the arrowPosition property of this particle object.void
setDLSeparation(float dlsep)
Sets the double line separation property.void
setDoubleLine(boolean dline)
Sets the double line property.void
setFlip(boolean newFlip)
Sets the flip property of this particle object.void
setPaintArrow(boolean arr)
Sets the arrow property of this particle object.void
setPreferences()
Applies default values to this JaxoObject.-
Methods inherited from class net.sf.jaxodraw.graph.object.AbstractExtendedObject
canBeSelected, copyFrom, curveParameter, getHeight, getLastClickPoint, getPoint, getPoint2, getRadius, getRelh, getRelw, getStroke, getStrokeWidth, getWidth, getX2, getY2, hasHandle, resetStroke, setLocation, setPoint, setPoint2, setRadius, setRelativeHeight, setRelativeWidth, setRelWAndH, setStroke, setStrokeWidth, setX2, setY2, strokeIs
-
Methods inherited from class net.sf.jaxodraw.graph.object.AbstractJaxoObject
addPropertyChangeListener, copyFrom, equal, equal, firePropertyChange, getColor, getGeneralPath, getPoint1, getPointCount, getPoints, getSelectedHandle, getX, getY, hasClickPoint, isAround, isMarked, paintVisualAid, removePropertyChangeListener, scale, setAsMarked, setColor, setLocation, setPoint1, setPoints, setTransient, setX, setXPosition, setY, setYPosition, translate, zero
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.jaxodraw.graph.object.JaxoObject
copy, copyFrom, prepareEditPanel
-
-
-
-
Method Detail
-
isPaintArrow
public boolean isPaintArrow()
Determines whether the arrow property of this particle object is set or not.- Returns:
- The arrow property of this particle object.
-
setPaintArrow
public void setPaintArrow(boolean arr)
Sets the arrow property of this particle object.- Parameters:
arr
- The arrow property of this particle object.
-
isFlip
public boolean isFlip()
Returns the flip property of this particle object.- Returns:
- The flip property of this particle object.
-
setFlip
public void setFlip(boolean newFlip)
Sets the flip property of this particle object.- Parameters:
newFlip
- The flip property of this particle object.
-
getArrowPosition
public float getArrowPosition()
Returns the arrowPosition property of this particle object.- Returns:
- The arrowPosition property of this particle object.
-
setArrowPosition
public void setArrowPosition(float newArrowPosition)
Sets the arrowPosition property of this particle object. Throws IllegalArgumentException if the parameter is not between 0 and 1.- Parameters:
newArrowPosition
- The new arrowPosition property measured as a float number between 0 and 1.
-
getArrowCount
public int getArrowCount()
The number of arrows in this particle object.- Returns:
- defaults to 1.
-
setArrowCount
public void setArrowCount(int newArrowCount)
Set the number of arrows in this particle object.- Parameters:
newArrowCount
- a positive number.
-
setDoubleLine
public void setDoubleLine(boolean dline)
Sets the double line property.- Parameters:
dline
- The double line boolean variable.
-
isDoubleLine
public boolean isDoubleLine()
Returns the double line property.- Returns:
- The double line boolean variable of this object.
-
setDLSeparation
public void setDLSeparation(float dlsep)
Sets the double line separation property.- Parameters:
dlsep
- The double line separation to be set.
-
getDLSeparation
public float getDLSeparation()
Returns the double line separation of this object.- Returns:
- The double line separation.
-
getArrow
public JaxoArrow getArrow()
Returns the arrow of this particle object.- Returns:
- The arrow of this particle object.
-
setArrow
public void setArrow(JaxoArrow newArrow)
Sets the dash property of this particle object.- Parameters:
newArrow
- The arrow of this particle object.
-
isCopy
public boolean isCopy(JaxoObject obj)
Determines if this JaxoObject is a copy of the specified one.Two JaxoObjects are copies of each other if all their editable properties are equal. This method should be synchronized with
JaxoObject.copy()
such that for any non-null JaxoObjectob
, a call likeisCopy(ob.copy())
must return true.Finally, this method implements an equivalence relation on non-null object references, it should satisfy the same constraints as the
Object.equals(java.lang.Object)
method.- Specified by:
isCopy
in interfaceJaxoObject
- Overrides:
isCopy
in classAbstractExtendedObject
- Parameters:
obj
- The JaxoObject to compare against. May be null in which case false is returned.- Returns:
- True if this JaxoObject is a copy of the given one, false otherwise.
- See Also:
JaxoObject.copy()
-
copyFrom
protected void copyFrom(AbstractParticleObject temp)
Sets all parameters from the given object to the current one.- Parameters:
temp
- The object to copy from.
-
length
public abstract double length()
Calculates the length of this particle object.The result depends on the number of points this object has.
- Returns:
- The length of this particle object.
-
setPreferences
public void setPreferences()
Applies default values to this JaxoObject.All fields except location points are initialized with values taken from the
preferences
.- Specified by:
setPreferences
in interfaceJaxoObject
- Overrides:
setPreferences
in classAbstractExtendedObject
-
propertyChange
public void propertyChange(PropertyChangeEvent evt)
Description copied from class:AbstractJaxoObject
Set a new property. The propertyName of the PropertyChangeEvent must match one of the bean properties of this object, otherwise the event is ignored.- Specified by:
propertyChange
in interfacePropertyChangeListener
- Overrides:
propertyChange
in classAbstractJaxoObject
- Parameters:
evt
- the PropertyChangeEvent.
-
dlSepIs
public boolean dlSepIs(float comp)
Compares the dlSeparation of this AbstractParticleObject to the given float, taking into account a 0.1% error margin.- Parameters:
comp
- The float to compare to.- Returns:
- True, if the dlSeparation matches within 0.1%.
-
arrowPositionIs
public boolean arrowPositionIs(float comp)
Compares the arrowPosition of this AbstractParticleObject to the given float, taking into account a 0.1% error margin.- Parameters:
comp
- The float to compare to.- Returns:
- True, if the arrowPosition matches within 0.1%.
-
paintArrow
protected void paintArrow(Graphics2D g2)
Paints an arrow on this object.- Parameters:
g2
- The graphics context.
-
arrowBounds
protected Rectangle arrowBounds()
Bounding box of arrows.- Returns:
- the bounding box, or null if arrows are not painted.
-
isPaintable
public boolean isPaintable()
Specify whether the object is actually paintable in a specific configuration.For some parameter values the object might not be reasonably represented on screen, or produce no visible output, e.g. a text with zero length, a singular arc, or a line with equal end points, etc. Such objects may be removed from a graph.
- Specified by:
isPaintable
in interfaceJaxoObject
- Overrides:
isPaintable
in classAbstractExtendedObject
- Returns:
- true if the object in the current state is paintable.
-
paint
public void paint(Graphics2D g2)
The method that paints the JaxoObject.- Parameters:
g2
- The graphics context where the object has to be painted.
-
getBounds
public Rectangle getBounds()
Returns the bounding box of this object.- Returns:
- the bounding box of this object.
- See Also:
JaxoObject.getPoint(net.sf.jaxodraw.graph.object.JaxoObject.Handle)
,JaxoObject.setPoint(net.sf.jaxodraw.graph.object.JaxoObject.Handle, java.awt.Point)
-
getObjectPath
protected abstract GeneralPath getObjectPath()
Get the GeneralPath that paints this object.This is used for painting and bounding box calculation.
- Returns:
- GeneralPath. May be null for an object that cannot be painted.
-
linepath
protected GeneralPath linepath()
Return a Path that is a line from the first Point to the last click Point of this Object.- Returns:
- a GeneralPath. Not null.
-
arrowCoordinates
public abstract JaxoArrow.Coordinates arrowCoordinates(int number)
Returns the coordinates of the arrow of the current object.- Parameters:
number
- the number of the arrow to be returned. Has to be between 1 andarrowCount
.- Returns:
- The coordinates of the arrow of the current object.
-
-