jhplot.jadraw
Class JaAxes

java.lang.Object
  extended by jhplot.jadraw.JaObject
      extended by jhplot.jadraw.JaFillObject
          extended by jhplot.jadraw.JaAxes
All Implemented Interfaces:
Serializable

public class JaAxes
extends JaFillObject

Main class to build a pad with axes, ticks, labels.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class jhplot.jadraw.JaObject
BB_MAX_X, BB_MAX_Y, BB_MIN_X, BB_MIN_Y, COPY, D_FORMAT, INIT_SIZE, LENGTH, MOVE, RESIZE, SELECT_BODY, SELECT_LL, SELECT_LR, SELECT_NONE, SELECT_P1, SELECT_P2, SELECT_P3, SELECT_UL, SELECT_UR
 
Constructor Summary
JaAxes(int padX, int padY)
          Constructor: sets the width, height, getRelw() and getRelh() to a default value of 25.
 
Method Summary
 void addData(jplot.DataArray d, int plotType)
          Add data to this plot.
 void addData(H2D h2d, int plotType)
          Add h2d data set.
 String axisExponent(int axis)
          Get exponent for the axis
 void clear()
          Clear.
 JaObject copy()
          Returns an exact copy of this Label.
 void drawData(org.freehep.graphics2d.VectorGraphics g2)
          Draw data points
 void drawHandles(org.freehep.graphics2d.VectorGraphics g2)
          Draws the handles of this box object.
 boolean editPanel()
          Brings up the edit panel that allows to change the parameters of this object.
 String formatNumber(double num, int n)
          formats a double precision number such that it is correctly rounded for output.
 int getAxesArrow(int axis)
          Is arrow to be shown
 int getContourBinX()
          Get number of bins in X for contour plot
 int getContourBinY()
          Get number of bins in Y for contour plot
 int getContourLevels()
          Get the number of levels to show contour plot
 Vector<jplot.DataArray> getData()
          Get the vector which keeps all the data
 int getExpForm()
          Get exponential form
 int getGrabbedHandle(int clickX, int clickY, int editmode)
          Determines where on this JaObject a mouse click has ocurred.
 Color getGridColor()
          Get grid color (gray is default)
 Color getLabelColor()
          Get label color
 void getLabelDimension(FontMetrics fmX, int axis)
          Get the lastst lavel size
 Font getLabelFont()
          Get label font
 double getLabelRotation()
          Get label rotation
 double getLabelSpace(int axis)
          Get label space
 double getMarginBottom()
          Get bottom margin
 double getMarginLeft()
          Get left margin
 double getMarginRight()
          Get right margin
 double getMarginTop()
          Get top margin
 double getMax(int axis)
          Get max value
 double getMin(int axis)
          Get min value
 int getNumDigits(double num)
          Return the number of digits required to display the given number.
 int getPad(int axis)
          Get ID of the current pad
 int getPlotType()
           
 Vector<jplot.PlotPoint> getPoints(jplot.DataArray da)
           
 Vector<jplot.PlotPoint> getPointsNoCuts(jplot.DataArray da)
           
 boolean getRotateTicks(int axis)
          Set true if ticks should be rotated
 String[] getStatistics()
          Get strings representing the statistics of the object
 int getSubTicksNumber(int axis)
          Get the number of sub-ticks
 double getSubTicksSize(int axis)
          Get sub-tick size
 int getTicksNumber(int axis)
          Get number of main ticks
 double getTicksSize(int axis)
          Get subtick size
 String[][] getTicLabel()
           
 boolean isAutoRange(int axis)
          Is the graph axis were done with the aoutorange option?
 boolean isContour()
          Is contour plot shown?
 boolean isContourBar()
          is a bar showing levels should be shown?
 boolean isCopy(JaObject comp)
          Returns true if all serializable variables of this JaObject and those of the specified one are equal.
 boolean isGridFront()
          is grid should be shown in front of all drawn objects?
 boolean isLogScale(int axis)
           
 boolean isShow(int axis)
          Is a particular axis should be shown?
 boolean isShowGrid(int axis)
          Is grid to be shown?
 boolean isShowKey()
          is key should be shown?
 boolean isShowMirror(int axis)
          Is axis mirror is shown?
 boolean isTicksLabels(int axis)
          Is ticks should be drawn
 void jaxoDraw(org.freehep.graphics2d.VectorGraphics g2, boolean drawToScreen)
          The method that draws this Jaxo Axes.
 String latexCommand(float scale, Dimension canvasDim)
          The LaTeX command that is necessary to draw the given JaAxes using the axodraw.sty package.
 void parseContour()
          Prepare a contour plot
 void parseH2D()
          Prepare a contour plot to display H2D histograms
 void rescaleObject(int orx, int ory, float scale)
          Rescales this JaAxes by the scale factor scale, keeping the point (orx, ory) fixed.
 void setAutoRange()
          Set auto-range on all axes
 void setAutoRange(int axis, boolean autoRange)
          Set autorange for a particular axis
 void setAxesArrow(int axis, int type)
          Set arrow type
 void setContour(boolean isContour)
          Set the contour style and parse the data.
 void setContourBar(boolean bar)
          Show or not a bar with color levels
 void setContourBins(int binsX, int binsY)
          How many bins used to slice the data in X (and Y)
 void setContourGray(boolean gray)
          Color style to show contour plot.
 void setContourLevels(int levels)
          How many color levels should be shown (10 default)
 void setData(Vector<jplot.DataArray> data)
          Set data in form of vector
 void setExpForm(int expForm)
          Set exponential form.
 void setGridColor(Color gridColor)
          Set grid color
 void setGridFront(boolean isGridFront)
          Set grid to be drown in fron of all graphic objects
 void setLabelColor(Color labelColor)
          Set the color for labels indicating the ticks
 void setLabelFont(Font labelFont)
          Set label fonts
 void setLabelRotation(double labelRotation)
          Set rotation for labels
 void setLabelSpace(int axis, double labelSpace)
          Set a space between axis and labels for ticks
 void setLogScale(int axis, boolean set)
          Sets true or false to plot on a log scale.
 void setMax(int axis, double value)
          Set min values
 void setMin(int axis, double value)
          Set max value
 void setPad(int axis, int pad)
          Set pad ID
 void setRange(int axis, double minValue, double maxValue)
          Set the ranges for the current pad
 void setRotateTicks(int axis, boolean angle)
          Set true if ticks should be rotated
 void setShow(int axis, boolean show)
          Set true if you want to show a particular axis
 void setShowGrid(int axis, boolean showGrid)
          Is grid to be shown?
 void setShowKey(boolean show)
          Set true if keys are shown
 void setShowMirror(int axis, boolean showMirror)
          Set true if a mirror axis to be shown
 void setStatistics(String[] s)
          Set a strings representing the full statistics
 void setSubTicksNumber(int axis, int maxSubTicks)
          Set the number of sub-ticks
 void setSubTicksSize(int axis, double subTicsSize)
          Set the size of subtics in NDC
 void setTicksLabels(int axis, boolean draw)
          Set or not tick labels
 void setTicksNumber(int axis, int maxTicks)
          Set the number of main ticks.
 void setTicksSize(int axis, double ticsSize)
          Set the size of the ticks in NDC format.
 void setTicLabel(String[][] ticLabel)
           
 double toUserX(int Xpic)
          Move to User coordinates
 double toUserY(int Ypic)
          Move to User coordinates
 int toX(double x)
          Convert the user coordinate X to the pixel coordinate
 int toY(double y)
          Convert the user coordinate Y to the pixel coordinate
 
Methods inherited from class jhplot.jadraw.JaFillObject
getFillColor, getStroke, latexWidth, setFillColor, setStroke
 
Methods inherited from class jhplot.jadraw.JaObject
drawVisualAid, getBoundingBox, getColor, getGeneralPath, getHeight, getRelh, getRelHndc, getRelHuser, getRelSize, getRelw, getRelWndc, getRelWuser, getSize, getWidth, getX, getXndc, getXuser, getY, getYndc, getYuser, isMarked, isUser, moveBy, scalePoint, setAsMarked, setBoundingBox, setColor, setLocation, setLocation, setRelh, setRelw, setRelWAndH, setRelWH, setSize, setX, setY, updateCoor, updateNDC
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JaAxes

public JaAxes(int padX,
              int padY)
Constructor: sets the width, height, getRelw() and getRelh() to a default value of 25.

Method Detail

isGridFront

public boolean isGridFront()
is grid should be shown in front of all drawn objects?

Returns:
true if grid in front

setGridFront

public void setGridFront(boolean isGridFront)
Set grid to be drown in fron of all graphic objects

Parameters:
isGridFront - true, if in front

getMarginLeft

public double getMarginLeft()
Get left margin

Returns:
left margin size

getMarginRight

public double getMarginRight()
Get right margin

Returns:
right margin

getMarginTop

public double getMarginTop()
Get top margin

Returns:
top margin size

getMarginBottom

public double getMarginBottom()
Get bottom margin

Returns:
size of bottom margin

setExpForm

public void setExpForm(int expForm)
Set exponential form. By deafult, if the number is larger than 1000, it will be shown using exponent.

Parameters:
expForm -

getExpForm

public int getExpForm()
Get exponential form

Returns:

setLabelSpace

public void setLabelSpace(int axis,
                          double labelSpace)
Set a space between axis and labels for ticks

Parameters:
axis - axis (0: for X or 1: for Y)
labelSpace - space in NDC (0-1)

getLabelSpace

public double getLabelSpace(int axis)
Get label space

Parameters:
axis - axis (0: for X or 1: for Y)
Returns:
space

setGridColor

public void setGridColor(Color gridColor)
Set grid color

Parameters:
gridColor - color used to draw grid

setSubTicksNumber

public void setSubTicksNumber(int axis,
                              int maxSubTicks)
Set the number of sub-ticks

Parameters:
axis - axis (0: for X or 1: for Y)
maxSubTicks - max number of subticks

setTicksNumber

public void setTicksNumber(int axis,
                           int maxTicks)
Set the number of main ticks. Usually, the program tries to find the best number, so the actual number of main ticks can be less

Parameters:
axis - axis (0: for X or 1: for Y)
maxTicks - max number of tics

setShowGrid

public void setShowGrid(int axis,
                        boolean showGrid)
Is grid to be shown?

Parameters:
axis - axis (0: for X or 1: for Y)
showGrid - true if shown.

setShow

public void setShow(int axis,
                    boolean show)
Set true if you want to show a particular axis

Parameters:
axis - axis (0: for X or 1: for Y) to be shown
show - set true if the axis should be drawn

setShowMirror

public void setShowMirror(int axis,
                          boolean showMirror)
Set true if a mirror axis to be shown

Parameters:
axis - axis (0: for X or 1: for Y)
showMirror - true if mirror axis will be shown

setTicksSize

public void setTicksSize(int axis,
                         double ticsSize)
Set the size of the ticks in NDC format.

Parameters:
axis - axis (0: for X or 1: for Y)
ticsSize - tick size in NDC form

setSubTicksSize

public void setSubTicksSize(int axis,
                            double subTicsSize)
Set the size of subtics in NDC

Parameters:
axis - axis (0: for X or 1: for Y)
subTicsSize - subtick size

setLabelColor

public void setLabelColor(Color labelColor)
Set the color for labels indicating the ticks

Parameters:
labelColor - color

getLabelColor

public Color getLabelColor()
Get label color

Returns:
color

setLabelFont

public void setLabelFont(Font labelFont)
Set label fonts

Parameters:
labelFont - font

getLabelFont

public Font getLabelFont()
Get label font

Returns:
font

setLabelRotation

public void setLabelRotation(double labelRotation)
Set rotation for labels

Parameters:
labelRotation -

getLabelRotation

public double getLabelRotation()
Get label rotation

Returns:
rotation

setPad

public void setPad(int axis,
                   int pad)
Set pad ID

Parameters:
axis - axis axis (0: for X or 1: for Y)
pad - pad ID

getPad

public int getPad(int axis)
Get ID of the current pad

Parameters:
axis - axis (0: for X or 1: for Y)
Returns:
pad ID

getGridColor

public Color getGridColor()
Get grid color (gray is default)

Returns:
color

getRotateTicks

public boolean getRotateTicks(int axis)
Set true if ticks should be rotated

Parameters:
axis -
Returns:

setRotateTicks

public void setRotateTicks(int axis,
                           boolean angle)
Set true if ticks should be rotated

Parameters:
axis - axis (0: for X or 1: for Y)
angle - angle

getSubTicksNumber

public int getSubTicksNumber(int axis)
Get the number of sub-ticks

Parameters:
axis - axis (0: for X or 1: for Y)
Returns:
number of sub-ticks

getTicksNumber

public int getTicksNumber(int axis)
Get number of main ticks

Parameters:
axis - axis (0: for X or 1: for Y)
Returns:
number of main ticks

getSubTicksSize

public double getSubTicksSize(int axis)
Get sub-tick size

Parameters:
axis - axis (0: for X or 1: for Y)
Returns:
size

getTicksSize

public double getTicksSize(int axis)
Get subtick size

Parameters:
axis - axis (0: for X or 1: for Y)
Returns:
size

getAxesArrow

public int getAxesArrow(int axis)
Is arrow to be shown

Parameters:
axis - axis (0: for X or 1: for Y)
Returns:
error type

setAxesArrow

public void setAxesArrow(int axis,
                         int type)
Set arrow type

Parameters:
axis - axis (0: for X or 1: for Y)
type - of arrow

isTicksLabels

public boolean isTicksLabels(int axis)
Is ticks should be drawn

Parameters:
axis - axis (0: for X or 1: for Y)
Returns:

setTicksLabels

public void setTicksLabels(int axis,
                           boolean draw)
Set or not tick labels

Parameters:
axis - axis (0: for X or 1: for Y)
draw - true if shown

isShowKey

public boolean isShowKey()
is key should be shown?

Returns:
true if shown

setShowKey

public void setShowKey(boolean show)
Set true if keys are shown

Parameters:
show -

isShow

public boolean isShow(int axis)
Is a particular axis should be shown?

Parameters:
axis - axis (0: for X or 1: for Y)
Returns:
true if shown

isShowGrid

public boolean isShowGrid(int axis)
Is grid to be shown?

Parameters:
axis - axis (0: for X or 1: for Y)
Returns:
true if shown

isShowMirror

public boolean isShowMirror(int axis)
Is axis mirror is shown?

Parameters:
axis - axis (0: for X or 1: for Y)
Returns:
true if shown

axisExponent

public String axisExponent(int axis)
Get exponent for the axis

Parameters:
axis - axis (0: for X or 1: for Y)
Returns:

setContour

public void setContour(boolean isContour)
Set the contour style and parse the data.

Parameters:
isContour - true if contour style is set.

isContour

public boolean isContour()
Is contour plot shown?

Returns:
true if shown

setContourBar

public void setContourBar(boolean bar)
Show or not a bar with color levels

Parameters:
bar - true if the bar is shown

isContourBar

public boolean isContourBar()
is a bar showing levels should be shown?

Returns:

getContourBinX

public int getContourBinX()
Get number of bins in X for contour plot

Returns:
number of bins in X

getContourBinY

public int getContourBinY()
Get number of bins in Y for contour plot

Returns:
number of bins in Y

getContourLevels

public int getContourLevels()
Get the number of levels to show contour plot

Returns:
number of levels

setStatistics

public void setStatistics(String[] s)
Set a strings representing the full statistics

Parameters:
s - strings with statistics

getStatistics

public String[] getStatistics()
Get strings representing the statistics of the object

Returns:
statistics

setContourLevels

public void setContourLevels(int levels)
How many color levels should be shown (10 default)

Parameters:
levels - number of color levels

setContourBins

public void setContourBins(int binsX,
                           int binsY)
How many bins used to slice the data in X (and Y)

Parameters:
binsX - number of bins in X
binsY - number of bins in Y

setContourGray

public void setContourGray(boolean gray)
Color style to show contour plot. The default is color style.

Parameters:
gray - set to true to show in black-white

setData

public void setData(Vector<jplot.DataArray> data)
Set data in form of vector

Parameters:
data - input data

toX

public int toX(double x)
Convert the user coordinate X to the pixel coordinate

Parameters:
x - user coordinate X for conversion

toUserX

public double toUserX(int Xpic)
Move to User coordinates

Parameters:
Xpic -
Returns:

toY

public int toY(double y)
Convert the user coordinate Y to the pixel coordinate

Parameters:
y - user coordinate Y for conversion

toUserY

public double toUserY(int Ypic)
Move to User coordinates

Parameters:
Ypic -
Returns:

setTicLabel

public void setTicLabel(String[][] ticLabel)

getTicLabel

public String[][] getTicLabel()

setLogScale

public void setLogScale(int axis,
                        boolean set)
Sets true or false to plot on a log scale.

Parameters:
axis - defines to which axis this function applies (0 if X, 1 if Y).
b - toggle, true if the scaling is logarithmic

isLogScale

public boolean isLogScale(int axis)

setAutoRange

public void setAutoRange(int axis,
                         boolean autoRange)
Set autorange for a particular axis

Parameters:
axis - axis (0: for X and 1: for Y)
autoRange - true if autorange

setAutoRange

public void setAutoRange()
Set auto-range on all axes


isAutoRange

public boolean isAutoRange(int axis)
Is the graph axis were done with the aoutorange option?

Parameters:
axis - axis (0: for X and 1: for Y)
Returns:
true if autorange is set

setRange

public void setRange(int axis,
                     double minValue,
                     double maxValue)
Set the ranges for the current pad

Parameters:
axis - axis (0: for X and 1: for Y)
minValue - min value
maxValue - max value

setMax

public void setMax(int axis,
                   double value)
Set min values

Parameters:
axis - axis (0: for X and 1: for Y)
value - min value

setMin

public void setMin(int axis,
                   double value)
Set max value

Parameters:
axis - axis (0: for X and 1: for Y)
value - max value

getMax

public double getMax(int axis)
Get max value

Parameters:
axis - axis (0: for X and 1: for Y)
Returns:
max value

getMin

public double getMin(int axis)
Get min value

Parameters:
axis - axis (0: for X and 1: for Y)
Returns:
min value

copy

public final JaObject copy()
Returns an exact copy of this Label.

Specified by:
copy in class JaObject
Returns:
A copy of this Label.

isCopy

public final boolean isCopy(JaObject comp)
Returns true if all serializable variables of this JaObject and those of the specified one are equal.

Specified by:
isCopy in class JaObject
Parameters:
comp - A JaObject to compare with.
Returns:
True if the objects are equal, false otherwise.

getGrabbedHandle

public final int getGrabbedHandle(int clickX,
                                  int clickY,
                                  int editmode)
Determines where on this JaObject a mouse click has ocurred.

Specified by:
getGrabbedHandle in class JaObject
Parameters:
clickX - The x position of the point where the mouse click ocurred.
clickY - The y position of the point where the mouse click ocurred.
editmode - The current edit mode as defined in JaxoMainPanel.
Returns:
An integer specifying whether the click ocurred on one of the handles and if yes, on which.

drawHandles

public final void drawHandles(org.freehep.graphics2d.VectorGraphics g2)
Draws the handles of this box object.

Specified by:
drawHandles in class JaObject
Parameters:
g2 - The current graphics context.

getLabelDimension

public void getLabelDimension(FontMetrics fmX,
                              int axis)
Get the lastst lavel size


getData

public Vector<jplot.DataArray> getData()
Get the vector which keeps all the data

Returns:
Vector with the data

getNumDigits

public int getNumDigits(double num)
Return the number of digits required to display the given number. If more than 15 digits are required, 15 is returned).


formatNumber

public String formatNumber(double num,
                           int n)
formats a double precision number such that it is correctly rounded for output. Kind of pre-processor for all number for output.

Parameters:
num - number to be formatted
n - number of digits (accuracy) after the decimal point.
Returns:
the formatted number in a string.

jaxoDraw

public final void jaxoDraw(org.freehep.graphics2d.VectorGraphics g2,
                           boolean drawToScreen)
The method that draws this Jaxo Axes.

Specified by:
jaxoDraw in class JaObject
Parameters:
g2 - The graphics context where the JaAxes 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.

latexCommand

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

Specified by:
latexCommand in class JaObject
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.

rescaleObject

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

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

addData

public void addData(jplot.DataArray d,
                    int plotType)
Add data to this plot.

Parameters:
d -
plotType - current plottype

addData

public void addData(H2D h2d,
                    int plotType)
Add h2d data set.

Parameters:
h2d -

parseContour

public void parseContour()
Prepare a contour plot


parseH2D

public void parseH2D()
Prepare a contour plot to display H2D histograms


clear

public void clear()
Clear.


getPlotType

public int getPlotType()

drawData

public void drawData(org.freehep.graphics2d.VectorGraphics g2)
Draw data points


getPoints

public Vector<jplot.PlotPoint> getPoints(jplot.DataArray da)

getPointsNoCuts

public Vector<jplot.PlotPoint> getPointsNoCuts(jplot.DataArray da)

editPanel

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

Specified by:
editPanel in class JaObject
Returns:
True if the editing actually changed the object, false if the object has not been changed.


jHepWork 3.1 ©