jhplot.jadraw
Class JaAxes
- java.lang.Object
-
- jhplot.jadraw.JaObject
-
- jhplot.jadraw.JaFillObject
-
- jhplot.jadraw.JaAxes
-
- All Implemented Interfaces:
- java.io.Serializable
public class JaAxes extends JaFillObject
Main class to build a pad with axes, ticks, labels.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description JaAxes(int padX, int padY)
Constructor: sets the width, height, getRelw() and getRelh() to a default value of 25.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
addData(jplot.DataArray d, int plotType)
Add data to this plot.void
addData(H2D h2d, int plotType)
Add h2d data set.java.lang.String
axisExponent(int axis)
Get exponent for the axisvoid
clear()
Clear.JaObject
copy()
Returns an exact copy of this Label.void
drawData(org.freehep.graphics2d.VectorGraphics g2)
Draw data pointsvoid
drawHandles(org.freehep.graphics2d.VectorGraphics g2)
Draws the handles of this box object.void
drawMargins(org.freehep.graphics2d.VectorGraphics g2)
boolean
editPanel()
Brings up the edit panel that allows to change the parameters of this object.java.lang.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 shownjava.awt.Color
getBackgroundColor()
Get background color (white is default)int
getContourBinX()
Get number of bins in X for contour plotint
getContourBinY()
Get number of bins in Y for contour plotint
getContourLevels()
Get the number of levels to show contour plotjava.util.Vector<jplot.DataArray>
getData()
Get the vector which keeps all the dataint
getExpForm()
Get exponential formint
getGrabbedHandle(int clickX, int clickY, int editmode)
Determines where on this JaObject a mouse click has ocurred.java.awt.Color
getGridColor()
Get grid color (gray is default)java.awt.Color
getLabelColor()
Get label colorvoid
getLabelDimension(java.awt.FontMetrics fmX, int axis)
Get the lastst lavel sizejava.awt.Font
getLabelFont()
Get label fontdouble
getLabelRotation()
Get label rotationdouble
getLabelSpace(int axis)
Get label spacedouble
getMarginBottom()
Get bottom margindouble
getMarginLeft()
Get left margindouble
getMarginRight()
Get right margindouble
getMarginTop()
Get top margindouble
getMax(int axis)
Get max valuedouble
getMin(int axis)
Get min valueint
getNumDigits(double num)
Return the number of digits required to display the given number.int
getPad(int axis)
Get ID of the current padint
getPlotType()
java.util.Vector<jplot.PlotPoint>
getPoints(jplot.DataArray da)
java.util.Vector<jplot.PlotPoint>
getPointsNoCuts(jplot.DataArray da)
boolean
getRotateTicks(int axis)
Set true if ticks should be rotatedjava.lang.String[]
getStatistics()
Get strings representing the statistics of the objectint
getSubTicksNumber(int axis)
Get the number of sub-ticksdouble
getSubTicksSize(int axis)
Get sub-tick sizeint
getTicksNumber(int axis)
Get number of main ticksdouble
getTicksSize(int axis)
Get subtick sizejava.lang.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 drawnvoid
jaxoDraw(org.freehep.graphics2d.VectorGraphics g2, boolean drawToScreen)
The method that draws this Jaxo Axes.java.lang.String
latexCommand(float scale, java.awt.Dimension canvasDim)
The LaTeX command that is necessary to draw the given JaAxes using the axodraw.sty package.void
parseContour()
Prepare a contour plotvoid
parseH2D()
Prepare a contour plot to display H2D histogramsvoid
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 axesvoid
setAutoRange(int axis, boolean autoRange)
Set autorange for a particular axisvoid
setAxesArrow(int axis, int type)
Set arrow typevoid
setBackgroundColor(java.awt.Color bkgColor)
Set background colorvoid
setContour(boolean isContour)
Set the contour style and parse the data.void
setContourBar(boolean bar)
Show or not a bar with color levelsvoid
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(java.util.Vector<jplot.DataArray> data)
Set data in form of vectorvoid
setExpForm(int expForm)
Set exponential form.void
setGridColor(java.awt.Color gridColor)
Set grid colorvoid
setGridFront(boolean isGridFront)
Set grid to be drown in fron of all graphic objectsvoid
setLabelColor(java.awt.Color labelColor)
Set the color for labels indicating the ticksvoid
setLabelFont(java.awt.Font labelFont)
Set label fontsvoid
setLabelRotation(double labelRotation)
Set rotation for labelsvoid
setLabelSpace(int axis, double labelSpace)
Set a space between axis and labels for ticksvoid
setLogScale(int axis, boolean set)
Sets true or false to plot on a log scale.void
setMax(int axis, double value)
Set min valuesvoid
setMin(int axis, double value)
Set max valuevoid
setPad(int axis, int pad)
Set pad IDvoid
setRange(int axis, double minValue, double maxValue)
Set the ranges for the current padvoid
setRotateTicks(int axis, boolean angle)
Set true if ticks should be rotatedvoid
setShow(int axis, boolean show)
Set true if you want to show a particular axisvoid
setShowGrid(int axis, boolean showGrid)
Is grid to be shown?void
setShowKey(boolean show)
Set true if keys are shownvoid
setShowMirror(int axis, boolean showMirror)
Set true if a mirror axis to be shownvoid
setStatistics(java.lang.String[] s)
Set a strings representing the full statisticsvoid
setSubTicksNumber(int axis, int maxSubTicks)
Set the number of sub-ticksvoid
setSubTicksSize(int axis, double subTicsSize)
Set the size of subtics in NDCvoid
setTicksLabels(int axis, boolean draw)
Set or not tick labelsvoid
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(java.lang.String[][] ticLabel)
double
toUserX(int Xpic)
Move to User coordinatesdouble
toUserY(int Ypic)
Move to User coordinatesint
toX(double x)
Convert the user coordinate X to the pixel coordinateint
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
-
-
-
-
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
-
setBackgroundColor
public void setBackgroundColor(java.awt.Color bkgColor)
Set background color- Parameters:
color
- for background
-
getBackgroundColor
public java.awt.Color getBackgroundColor()
Get background color (white is default)- Returns:
- color
-
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(java.awt.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 shownshow
- 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(java.awt.Color labelColor)
Set the color for labels indicating the ticks- Parameters:
labelColor
- color
-
getLabelColor
public java.awt.Color getLabelColor()
Get label color- Returns:
- color
-
setLabelFont
public void setLabelFont(java.awt.Font labelFont)
Set label fonts- Parameters:
labelFont
- font
-
getLabelFont
public java.awt.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 java.awt.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 java.lang.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(java.lang.String[] s)
Set a strings representing the full statistics- Parameters:
s
- strings with statistics
-
getStatistics
public java.lang.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 XbinsY
- 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(java.util.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(java.lang.String[][] ticLabel)
-
getTicLabel
public java.lang.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 valuemaxValue
- 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.
-
isCopy
public final boolean isCopy(JaObject comp)
Returns true if all serializable variables of this JaObject and those of the specified one are equal.
-
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 classJaObject
- 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 classJaObject
- Parameters:
g2
- The current graphics context.
-
getLabelDimension
public void getLabelDimension(java.awt.FontMetrics fmX, int axis)
Get the lastst lavel size
-
getData
public java.util.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 java.lang.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 formattedn
- 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 classJaObject
- 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 java.lang.String latexCommand(float scale, java.awt.Dimension canvasDim)
The LaTeX command that is necessary to draw the given JaAxes using the axodraw.sty package.- Specified by:
latexCommand
in classJaObject
- 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 classJaObject
- Parameters:
orx
- The x - coordinate of the fixed pointory
- The y - coordinate of the fixed pointscale
- 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 java.util.Vector<jplot.PlotPoint> getPoints(jplot.DataArray da)
-
getPointsNoCuts
public java.util.Vector<jplot.PlotPoint> getPointsNoCuts(jplot.DataArray da)
-
drawMargins
public void drawMargins(org.freehep.graphics2d.VectorGraphics g2)
-
-
DMelt 3.0 © DataMelt by jWork.ORG