jhplot.jadraw
Class JaObject

java.lang.Object
  extended by jhplot.jadraw.JaObject
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
JaArcObject, JaFillObject, JaKey, JaLatexText, JaLineObject, JaLoopObject, JaText, JaVertex

public abstract class JaObject
extends Object
implements Serializable

A general JaObject.

See Also:
Serialized Form

Field Summary
static int BB_MAX_X
          The component of the boundingbox array that contains the upper x value of the boundingbox.
static int BB_MAX_Y
          The component of the boundingbox array that contains the upper y value of the boundingbox.
static int BB_MIN_X
          The component of the boundingbox array that contains the lower x value of the boundingbox.
static int BB_MIN_Y
          The component of the boundingbox array that contains the lower y value of the boundingbox.
static int COPY
          An integer that indicates the current edit mode COPY.
static DecimalFormat D_FORMAT
          The decimal format used for numbers in LaTeX output.
static int INIT_SIZE
          An integer that gives the initial size of an object.
static int LENGTH
          An integer that gives the length of the handle sides.
static int MOVE
          An integer that indicates the current edit mode MOVE.
static int RESIZE
          An integer that indicates the current edit mode RESIZE.
static int SELECT_BODY
          An integer that indicates that the user grabbed the body of an object.
static int SELECT_LL
          An integer that indicates that the user grabbed the lower left handle of an object.
static int SELECT_LR
          An integer that indicates that the user grabbed the lower right handle of an object.
static int SELECT_NONE
          An integer that indicates that the user did not grab any object.
static int SELECT_P1
          An integer that specifies the first point of an arc object.
static int SELECT_P2
          An integer that specifies the second point of an arc object.
static int SELECT_P3
          An integer that specifies the third point of an arc object.
static int SELECT_UL
          An integer that indicates that the user grabbed the upper left handle of an object.
static int SELECT_UR
          An integer that indicates that the user grabbed the upper right handle of an object.
 
Constructor Summary
JaObject()
           
 
Method Summary
abstract  JaObject copy()
          Returns an exact copy of the given JaObject.
abstract  void drawHandles(org.freehep.graphics2d.VectorGraphics g2)
          Draws the handles of this JaObject that allow to move/resize/edit it.
 void drawVisualAid(org.freehep.graphics2d.VectorGraphics g2)
          Draws a visual aid for the user during dragging of certain JaxoObjects.
abstract  boolean editPanel()
          Brings up the edit panel that allows to change the parameters of this object.
 double[] getBoundingBox()
          Returns the bounding box of this JaObject.
 Color getColor()
          Returns the color of this object.
 GeneralPath getGeneralPath()
          Returns the GeneralPath that draws this JaObject.
abstract  int getGrabbedHandle(int clickX, int clickY, int editmode)
          Determines which handle the user has selected to move/resize/edit an object.
 int getHeight()
          Returns the height of this object.
 int getRelh()
          Returns the relative height of this object.
 double getRelHndc()
          Returns the relative height of this object in NDC.
 double getRelHuser()
          Returns the relative height of this object in USER.
 Dimension getRelSize()
          Returns the relative width and height of this object.
 int getRelw()
          Returns the relative width of this object.
 double getRelWndc()
          Returns the relative width of this object in NDC.
 double getRelWuser()
          Returns the relative width of this object in USER.
 Dimension getSize()
          Returns the width and height of this object.
 int getWidth()
          Returns the width of this object.
 int getX()
          Returns the x coordinate of this object.
 double getXndc()
          Returns the NDC x coordinate of this object.
 double getXuser()
          Returns the USER x coordinate of this object.
 int getY()
          Returns the y coordinate of this object.
 double getYndc()
          Returns the NDC y coordinate of this object.
 double getYuser()
          Returns the USER y coordinate of this object.
abstract  boolean isCopy(JaObject testObject)
          Determines if this JaObject is a copy of the specified one.
 boolean isMarked()
          Determines whether this JaObject is marked as an element of a group or not.
 boolean isUser()
          Set to true if coordinates were set using USER coordinate system attached to axes
abstract  void jaxoDraw(org.freehep.graphics2d.VectorGraphics g2, boolean drawToScreen)
          The method that draws the JaObject.
abstract  String latexCommand(float scale, Dimension canvasDim)
          The LaTeX command that is necessary to draw the given JaObject using the axodraw.sty package.
abstract  String latexWidth()
          The LaTeX command that sets the width for this JaObject, using the axodraw.sty package.
 void moveBy(int deltaX, int deltaY)
          Reset the x, and y coordinates of the object when it is moved by deltaX and deltaY.
abstract  void rescaleObject(int orx, int ory, float scale)
          Abstract class to rescale this JaObject by the scale factor scale, keeping the point (orx, ory) fixed.
 Point2D scalePoint(double orx, double ory, double scale, double px, double py)
          Returns a point that is obtained from a point (px, py) after a scale transformation scale, keeping the point (orx, ory) fixed.
 void setAsMarked(boolean mark)
          Sets this JaObject as element of a group.
 void setBoundingBox(double[] bb)
          Sets the bounding box of this JaObject.
 void setColor(Color c)
          Sets the color of this object.
 void setLocation(double xc, double yc, String what)
          Set location of the object in the NDC or USER coordinates.
 void setLocation(int newX, int newY)
          Sets the x and y coordinate of this object.
 void setRelh(int newRelh)
          Sets the relative height of this object.
 void setRelw(int newRelw)
          Sets the relative width of this object.
 void setRelWAndH(int w, int h)
          Sets the relative width and height of this object.
 void setRelWH(double w, double h, String what)
          Set relative size in the NDC or USER coordinates
 void setSize(int w, int h, int rw, int rh)
          Reset the size (width, height, relative width and height) of this object.
 void setX(int newX)
          Sets the x coordinate of this object.
 void setY(int newY)
          Sets the y coordinate of this object.
 void updateCoor()
           
 void updateNDC()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECT_NONE

public static final int SELECT_NONE
An integer that indicates that the user did not grab any object.

See Also:
Constant Field Values

SELECT_BODY

public static final int SELECT_BODY
An integer that indicates that the user grabbed the body of an object.

See Also:
Constant Field Values

SELECT_UL

public static final int SELECT_UL
An integer that indicates that the user grabbed the upper left handle of an object.

See Also:
Constant Field Values

SELECT_UR

public static final int SELECT_UR
An integer that indicates that the user grabbed the upper right handle of an object.

See Also:
Constant Field Values

SELECT_LR

public static final int SELECT_LR
An integer that indicates that the user grabbed the lower right handle of an object.

See Also:
Constant Field Values

SELECT_LL

public static final int SELECT_LL
An integer that indicates that the user grabbed the lower left handle of an object.

See Also:
Constant Field Values

MOVE

public static final int MOVE
An integer that indicates the current edit mode MOVE.

See Also:
Constant Field Values

RESIZE

public static final int RESIZE
An integer that indicates the current edit mode RESIZE.

See Also:
Constant Field Values

COPY

public static final int COPY
An integer that indicates the current edit mode COPY.

See Also:
Constant Field Values

LENGTH

public static final int LENGTH
An integer that gives the length of the handle sides.

See Also:
Constant Field Values

INIT_SIZE

public static final int INIT_SIZE
An integer that gives the initial size of an object.

See Also:
Constant Field Values

SELECT_P1

public static final int SELECT_P1
An integer that specifies the first point of an arc object.

See Also:
Constant Field Values

SELECT_P2

public static final int SELECT_P2
An integer that specifies the second point of an arc object.

See Also:
Constant Field Values

SELECT_P3

public static final int SELECT_P3
An integer that specifies the third point of an arc object.

See Also:
Constant Field Values

BB_MIN_X

public static final int BB_MIN_X
The component of the boundingbox array that contains the lower x value of the boundingbox.

See Also:
Constant Field Values

BB_MIN_Y

public static final int BB_MIN_Y
The component of the boundingbox array that contains the lower y value of the boundingbox.

See Also:
Constant Field Values

BB_MAX_X

public static final int BB_MAX_X
The component of the boundingbox array that contains the upper x value of the boundingbox.

See Also:
Constant Field Values

BB_MAX_Y

public static final int BB_MAX_Y
The component of the boundingbox array that contains the upper y value of the boundingbox.

See Also:
Constant Field Values

D_FORMAT

public static final DecimalFormat D_FORMAT
The decimal format used for numbers in LaTeX output.

Constructor Detail

JaObject

public JaObject()
Method Detail

getGeneralPath

public final GeneralPath getGeneralPath()
Returns the GeneralPath that draws this JaObject.

Returns:
The GeneralPath of this JaObject.

updateCoor

public void updateCoor()

updateNDC

public void updateNDC()

getBoundingBox

public double[] getBoundingBox()
Returns the bounding box of this JaObject.

Returns:
The bounding box of this JaObject.

setBoundingBox

public final void setBoundingBox(double[] bb)
Sets the bounding box of this JaObject.

Parameters:
bb - The bounding box to be set for this JaObject.

setAsMarked

public final void setAsMarked(boolean mark)
Sets this JaObject as element of a group.

Parameters:
mark - A boolean variable indicating whether this JaObject should be set as an element of a group or not.

isMarked

public final boolean isMarked()
Determines whether this JaObject is marked as an element of a group or not.

Returns:
Boolean variable telling whether this JaObject is part of a group or not

isUser

public boolean isUser()
Set to true if coordinates were set using USER coordinate system attached to axes

Returns:
true if user

getX

public final int getX()
Returns the x coordinate of this object.

Returns:
The x coordinate of this object.

getXndc

public final double getXndc()
Returns the NDC x coordinate of this object.

Returns:
The x coordinate of this object.

getXuser

public final double getXuser()
Returns the USER x coordinate of this object.

Returns:
The x coordinate of this object in the current axes frame

setX

public final void setX(int newX)
Sets the x coordinate of this object.

Parameters:
newX - The x coordinate of this object.

getY

public final int getY()
Returns the y coordinate of this object.

Returns:
The y coordinate of this object.

getYndc

public final double getYndc()
Returns the NDC y coordinate of this object.

Returns:
The NDC y coordinate of this object.

getYuser

public final double getYuser()
Returns the USER y coordinate of this object.

Returns:
The USER y coordinate of this object in the current axis frame

setY

public final void setY(int newY)
Sets the y coordinate of this object.

Parameters:
newY - The y coordinate of this object.

setLocation

public void setLocation(double xc,
                        double yc,
                        String what)
Set location of the object in the NDC or USER coordinates.

Parameters:
xc - X location
yc - Y location
what - if "NDC", coordinate in NDC (from 0 to 1), if "USER" coordinates are in the user system given by the axes.

setRelWH

public void setRelWH(double w,
                     double h,
                     String what)
Set relative size in the NDC or USER coordinates

Parameters:
w - width of the object
h - height of the object
what - if "NDC", coordinate in NDC (from 0 to 1), if "USER" coordinates are in the user system given by the axes.

getWidth

public final int getWidth()
Returns the width of this object.

Returns:
The width of this object.

getHeight

public final int getHeight()
Returns the height of this object.

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.

setRelw

public final void setRelw(int newRelw)
Sets the relative width of this object.

Parameters:
newRelw - 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.

getRelHndc

public final double getRelHndc()
Returns the relative height of this object in NDC.

Returns:
The relative height of this object.

getRelHuser

public final double getRelHuser()
Returns the relative height of this object in USER.

Returns:
The relative height of this object.

getRelWndc

public final double getRelWndc()
Returns the relative width of this object in NDC.

Returns:
The relative height of this object.

getRelWuser

public final double getRelWuser()
Returns the relative width of this object in USER.

Returns:
The relative height of this object.

setRelh

public final void setRelh(int newRelh)
Sets the relative height of this object.

Parameters:
newRelh - The relative height of this object.

getColor

public final Color getColor()
Returns the color of this object.

Returns:
The color of this object.

setColor

public final void setColor(Color c)
Sets the color of this object.

Parameters:
c - The color 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.

setLocation

public final void setLocation(int newX,
                              int newY)
Sets the x and y coordinate of this object.

Parameters:
newX - The x coordinate of this object.
newY - The y coordinate of this object.

moveBy

public void moveBy(int deltaX,
                   int deltaY)
Reset the x, and y coordinates of the object when it is moved by deltaX and deltaY.

Parameters:
deltaX - The x displacement.
deltaY - The y displacement.

setSize

public final void setSize(int w,
                          int h,
                          int rw,
                          int rh)
Reset the size (width, height, relative width and height) of this object.

Parameters:
w - The width of this object.
h - The heightof this object.
rw - The relative width of this object.
rh - The relative height of this object.

getSize

public final Dimension getSize()
Returns the width and height of this object.

Returns:
A dimension with the size of the object.

getRelSize

public final Dimension getRelSize()
Returns the relative width and height of this object.

Returns:
A dimension with the relative size of the object.

drawVisualAid

public void drawVisualAid(org.freehep.graphics2d.VectorGraphics g2)
Draws a visual aid for the user during dragging of certain JaxoObjects. Currently applies for JaxoArcs (draws the center point and a radius line), JaxoLoops, JaxoBlobs and JaxoVertices (draws the center point in each case).

Parameters:
g2 - The graphics context to draw the visual aid.

scalePoint

public Point2D scalePoint(double orx,
                          double ory,
                          double scale,
                          double px,
                          double py)
Returns a point that is obtained from a point (px, py) after a scale transformation scale, keeping the point (orx, ory) fixed.

Parameters:
orx - The x-coordinate of the fixed point.
ory - The y-coordinate of the fixed point.
scale - The scale factor.
px - The x-coordinate of the point to be transformed.
py - The y-coordinate of the point to be transformed.
Returns:
A Point2D containing the x- and y-coordinate of the new point.

jaxoDraw

public abstract void jaxoDraw(org.freehep.graphics2d.VectorGraphics g2,
                              boolean drawToScreen)
The method that draws the JaObject.

Parameters:
g2 - The graphics context where the object has to be drawn.
drawToScreen - A boolean variable that indicates whether the drawing is done on the screen or somewhere else. This is used for exporting/printing, where the object handles should not be painted, even if they are visible on the screen.

drawHandles

public abstract void drawHandles(org.freehep.graphics2d.VectorGraphics g2)
Draws the handles of this JaObject that allow to move/resize/edit it.

Parameters:
g2 - The corresponding graphics context.

getGrabbedHandle

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

Parameters:
clickX - The x coordinate where the mouse click has ocurred.
clickY - The y coordinate where the mouse click has ocurred.
editmode - The current edit mode.
Returns:
One of the static variables SELECT_* defined in JaObject that specifies the handle which the user has clicked.

copy

public abstract JaObject copy()
Returns an exact copy of the given JaObject.

Returns:
The copy of the given JaObject.

isCopy

public abstract boolean isCopy(JaObject testObject)
Determines if this JaObject is a copy of the specified one.

Parameters:
testObject - The JaObject to compare against.
Returns:
True if the JaxoObjects are identical.

latexCommand

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

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.

latexWidth

public abstract String latexWidth()
The LaTeX command that sets the width for this JaObject, using the axodraw.sty package.

Returns:
The corresponding LaTeX command.

rescaleObject

public abstract void rescaleObject(int orx,
                                   int ory,
                                   float scale)
Abstract class to rescale this JaObject by the scale factor scale, keeping the point (orx, ory) fixed.

Parameters:
orx - The x-coordinate of the fixed point.
ory - The y-coordinate of the fixed point.
scale - The scale parameter.

editPanel

public abstract boolean editPanel()
Brings up the edit panel that allows to change the parameters of this object.

Returns:
True if the editing actually changed the object, false if the object has not been changed.


jHepWork 3.1 ©