net.sf.jaxodraw.object.line
Class JaxoLineObject

java.lang.Object
  extended by net.sf.jaxodraw.object.JaxoObject
      extended by net.sf.jaxodraw.object.JaxoExtendedObject
          extended by net.sf.jaxodraw.object.JaxoParticleObject
              extended by net.sf.jaxodraw.object.line.JaxoLineObject
All Implemented Interfaces:
Shape, PropertyChangeListener, Serializable, Cloneable, EventListener
Direct Known Subclasses:
JaxoDashLine, JaxoFLine, JaxoGlLine, JaxoPLine, JaxoZigZagLine

public abstract class JaxoLineObject
extends JaxoParticleObject

A general line object.

Since:
2.0
See Also:
Serialized Form

Field Summary
static int SELECT_P0
          Center point of a line.
 
Fields inherited from class net.sf.jaxodraw.object.JaxoParticleObject
GHOST_DASH, GLUON_FREQ, PHOTON_FREQ, SCALAR_DASH
 
Fields inherited from class net.sf.jaxodraw.object.JaxoExtendedObject
SELECT_DX, SELECT_DY, SELECT_P2
 
Fields inherited from class net.sf.jaxodraw.object.JaxoObject
D_FORMAT, GRAY_SCALE_FORMAT, SELECT_NONE, SELECT_P1
 
Constructor Summary
JaxoLineObject()
           
 
Method Summary
 JaxoArrow.Coordinates arrowCoordinates()
          Returns the coordinates of the arrow of the current object.
 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.
protected abstract  String getAxo4JOptions(float scale)
          Return the option part of the LaTeX command for this line.
 Rectangle getBounds()
          Returns the bounding box of this line.
 int getGrabbedHandle(int clickX, int clickY, JaxoHandle h)
          Determines which handle the user has selected to move/resize/edit an object.
protected  Point2D getLatexDLOffSet(float scaleFactor)
          Returns the amount this line is offset in double-line mode.
protected  Point2D getLaTexEndPoint(float scaleFactor, int canvasHeight)
          Returns the end point of this line in latex (ie axodraw) coordinates.
protected  Point2D getLaTexStartPoint(float scaleFactor, int canvasHeight)
          Returns the first point of this line in latex (ie axodraw) coordinates.
protected abstract  GeneralPath getObjectPath()
          Get the GeneralPath that paints this line.
 boolean isCopy(JaxoObject comp)
          Determines if this JaxoObject is a copy of the specified one.
 String latexCommand(float scale, Dimension canvasDim)
          The LaTeX command that is necessary to draw the given JaxoObject using the axodraw.sty package.
 double length()
          Returns the length of this line.
 void paint(JaxoGraphics2D g2)
          The method that paints the JaxoObject.
 void paintHandles(JaxoGraphics2D g2, JaxoHandle h, int editMode)
          Paints the handles of this JaxoObject that allow to move/resize/edit it.
 void rescaleObject(int orx, int ory, float scale)
          Rescale this JaxoObject by the scale factor scale, keeping the point (orx, ory) fixed.
 void setState(JaxoObject o)
          Restore state to the values of 'o'.
 float smallestDistanceTo(int px, int py)
          Determines the smallest distance of any of the handles of this JaxoObject from the given point.
 
Methods inherited from class net.sf.jaxodraw.object.JaxoParticleObject
arrowPositionIs, copy, copyFrom, dashIs, dlSepIs, getAmp, getArrow, getArrowPosition, getDash, getDLSeparation, getWiggles, isDoubleLine, isFlip, isPaintArrow, paintArrow, setAmp, setArrow, setArrowPosition, setDash, setDLSeparation, setDoubleLine, setFlip, setPaintArrow, setPreferences, setWiggles
 
Methods inherited from class net.sf.jaxodraw.object.JaxoExtendedObject
copyFrom, getHeight, getPointCount, getRadius, getRelh, getRelSize, getRelw, getSize, getStroke, getStrokeWidth, getWidth, getX, getX2, getY, getY2, latexWidth, moveBy, resetStroke, setLocation, setRadius, setRelativeHeight, setRelativeWidth, setRelWAndH, setStroke, setStrokeWidth, setX, setX2, setY, setY2, strokeIs
 
Methods inherited from class net.sf.jaxodraw.object.JaxoObject
addPropertyChangeListener, contains, contains, contains, contains, copyFrom, firePropertyChange, getBounds2D, getBoundsWithHandles, getColor, getGeneralPath, getLaTexLocation, getName, getPathIterator, getPathIterator, getPoints, getX, getY, intersects, intersects, isAround, isMarked, paintVisualAid, prepareEditPanel, propertyChange, removePropertyChangeListener, setAsMarked, setColor, setLocation, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setPointCount, setPoints, setTransient, setX, setXPosition, setY, setYPosition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECT_P0

public static final int SELECT_P0
Center point of a line.

See Also:
Constant Field Values
Constructor Detail

JaxoLineObject

public JaxoLineObject()
Method Detail

isCopy

public boolean isCopy(JaxoObject comp)
Determines if this JaxoObject is a copy of the specified one.

Overrides:
isCopy in class JaxoParticleObject
Parameters:
comp - The JaxoObject to compare against.
Returns:
True if the JaxoObjects are identical.

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 by JaxoObject.copy().

Overrides:
setState in class JaxoParticleObject
Parameters:
o - the object to copy from.

getGrabbedHandle

public int getGrabbedHandle(int clickX,
                            int clickY,
                            JaxoHandle h)
Determines which handle the user has selected to move/resize/edit an object.

Overrides:
getGrabbedHandle in class JaxoExtendedObject
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 final void paintHandles(JaxoGraphics2D g2,
                               JaxoHandle h,
                               int editMode)
Paints the handles of this JaxoObject that allow to move/resize/edit it.

Overrides:
paintHandles in class JaxoExtendedObject
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.

Overrides:
canBeSelected in class JaxoExtendedObject
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.

smallestDistanceTo

public final 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 class JaxoExtendedObject
Parameters:
px - The x coordinate of the test point.
py - The y coordinate of the test point.
Returns:
The smallest distance.

paint

public void paint(JaxoGraphics2D g2)
The method that paints the JaxoObject.

Specified by:
paint in class JaxoObject
Parameters:
g2 - The graphics context where the object has to be painted.

getBounds

public Rectangle getBounds()
Returns the bounding box of this line.

Returns:
the bounding box of this line.

latexCommand

public String latexCommand(float scale,
                           Dimension canvasDim)
The LaTeX command that is necessary to draw the given JaxoObject using the axodraw.sty package.

Specified by:
latexCommand in class JaxoObject
Parameters:
scale - A scale factor to translate Java coordinates to LaTeX coordinates.
canvasDim - The current dimension of the canvas.
Returns:
The corresponding axodraw LaTeX command.

getLaTexStartPoint

protected Point2D getLaTexStartPoint(float scaleFactor,
                                     int canvasHeight)
Returns the first point of this line in latex (ie axodraw) coordinates.

Parameters:
scaleFactor - A scale factor.
canvasHeight - The height of the current canvas.
Returns:
A Point2D object holding the start point.

getLaTexEndPoint

protected Point2D getLaTexEndPoint(float scaleFactor,
                                   int canvasHeight)
Returns the end point of this line in latex (ie axodraw) coordinates.

Parameters:
scaleFactor - A scale factor.
canvasHeight - The height of the current canvas.
Returns:
A Point2D object holding the end point.

getLatexDLOffSet

protected Point2D getLatexDLOffSet(float scaleFactor)
Returns the amount this line is offset in double-line mode.

Parameters:
scaleFactor - A scale factor.
Returns:
A Point2D object holding offset.

arrowCoordinates

public JaxoArrow.Coordinates arrowCoordinates()
Returns the coordinates of the arrow of the current object.

Specified by:
arrowCoordinates in class JaxoParticleObject
Returns:
The coordinates of the arrow of the current object.

rescaleObject

public final void rescaleObject(int orx,
                                int ory,
                                float scale)
Rescale this JaxoObject by the scale factor scale, keeping the point (orx, ory) fixed.

Specified by:
rescaleObject in class JaxoObject
Parameters:
orx - The x-coordinate of the fixed point.
ory - The y-coordinate of the fixed point.
scale - The scale parameter.

length

public double length()
Returns the length of this line.

Returns:
The length.

getObjectPath

protected abstract GeneralPath getObjectPath()
Get the GeneralPath that paints this line.

Returns:
GeneralPath.

getAxo4JOptions

protected abstract String getAxo4JOptions(float scale)
Return the option part of the LaTeX command for this line.

Parameters:
scale - the axodraw4j scale factor.
Returns:
the option String.


Copyright © 2003-2011 The JaxoDraw team. All Rights Reserved.