Class JLAxis
java.lang.Object
fr.esrf.tangoatk.widget.util.chart.JLAxis
- All Implemented Interfaces:
Serializable
Class which handles chart axis.
- Author:
- JL Pons
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intUse default compiler format to display doublestatic final intDisplay integer using binary formatstatic final intDisplay value as datestatic final intDisplay integer using decimal formatstatic final StringFrench date format to format labels as datesstatic final intDisplay integer using haxadecimal formatstatic final intHorizontal axis at bottom of the chartstatic final intHorizontal axis at 0 position (on Y1)static final intHorizontal axis at 0 position (on Y2)static final intHorizontal axis at top of the chartstatic final intUse linear scale for this axisstatic final intUse logarithmic scale for this axisstatic final intDisplay value using exponential representation (x.xxEyy)static final intDisplay value using exponential representation (xEyy)static final intDraw time annotation for x axis.static final intDisplay number of second as HH:MM:SSstatic final StringUS date format to format labels as datesstatic final intDraw formated annotationstatic final intVertical left axisstatic final intVertical axis at X=0static final intVertical right axis -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDisplays a DataView on this axis.voidaddDataViewAt(int index, JLDataView v) Add the given dataView at the specifed index.voidapplyConfiguration(String prefix, CfFileReader f) Apply axis configuration.booleancanApplyTimeSpan(int x1, int x2) booleanRemoves dataview from this axis and returns true if the dataview has been found for this AxisvoidClear all dataview from this axisvoidExpert usage.computeMediumColor(Color c1, Color c2) Compute the medium color of c1,c2voidcomputeXScale(Vector views) Expert usage.voiddirectZoom(double min, double max) Enter zoom mode and set min and maxvoiddrawFast(Graphics g, Point lp, Point p, JLDataView v) Expert Usage.static voiddrawSampleLine(Graphics g, int x, int y, JLDataView v) Expert usage.static StringformatTimeValue(double vt) Returns a representation of the double in time format "EEE, d MMM yyyy HH:mm:ss".formatValue(double vt, double prec) Returns a representation of the double acording to the formatintGets the axis label.Returns the axis color.Returns the bouding rectangle of this axis.getConfiguration(String prefix) Builds a configuration string that can be write into a file and is compatible with CfFileReader.getDataView(int index) Get the dataView of this axis at the specified index.getFont()Gets the label fontintDeprecated.Use getLabelFontDimension() insteadintintReturns the current grid style.static StringintExpert usage.intReturns the axis label format.intExpert usage.doublegetMax()Expert usage.doubleGets maximum axis valuedoublegetMin()Expert usage.doubleGets minimum axis valuegetName()Gets the axis label.intdoubleGets the percent scrollbackintgetScale()Gets the scale mdoe for this axis.intExpert usage.intgetTick()Deprecated.Use getTickSpacingintdoubleintintReturns the number if dataview in this axis.getViews()Gets all dataViews displayed on this axis.intbooleanDetermines whether the axis is autoscaled.booleanDetermines whether the axis at the opposite side is visiblebooleanbooleanDetermines whether the axis is showing the gridbooleanbooleanDetermines whether the axis is showing the sub gridbooleanbooleanisXY()Determines whether the axis is in XY mode.booleanAllows user to know if the 0 value will always be visible in case of auto scalebooleanisZoomed()Determines whether the axis is zoomed.voidmeasureAxis(FontRenderContext frc, int desiredWidth, int desiredHeight) Expert usage.voidpaintAxisDirect(Graphics g, FontRenderContext frc, int x0, int y0, Color back, int tr, int la) Paint this axis.voidpaintAxisOpposite(Graphics g, FontRenderContext frc, int x0, int y0, Color back, int tr, int la) voidpaintAxisOppositeDouble(Graphics g, FontRenderContext frc, int x0, int y0, Color back, int tr, int la) static voidpaintMarker(Graphics g, int mType, int mSize, int x, int y) Expert usage.voidRemoves dataview from this axissearchNearest(int x, int y, JLAxis xAxis) Search the nearest point in the dataViews.searchNearestNormal(int x, int y, JLAxis xAxis) Expert usage.searchNearestXY(int x, int y, JLAxis xAxis) Expert usage.voidsetAnnotation(int a) Set the annotation methodvoidsetAutoScale(boolean b) Sets the autoscale mode for this axis.voidsetAxeName(String s) Sets the axis name.voidSets the axis color.voidsetAxisDuration(double d) Expert usage.voidsetDateFormat(String dateFormat) Sets date format chen chosen label format is DATE_FORMATvoidsetDrawOpposite(boolean b) Draw a second axis at the opposite side.voidsetFitXAxisToDisplayDuration(boolean b) Fit the x axis to display duration (Horizontal axis only).voidSets the label fontvoidsetGridStyle(int s) Sets the grid style.voidsetGridVisible(boolean b) Shows the grid.voidsetInverted(boolean i) Invert this axis.voidsetLabelFormat(int l) Sets the axis label format.voidsetLabelOffset(int x, int y) Sets the label offset (in pixel)voidCustomize axis labels.voidsetMaximum(double d) Sets maximum axis value.voidsetMinimum(double d) Sets minimum axis value.voidSets the axis label.voidsetOrientation(int orientation) Sets the axis orientation and reset position.voidsetPercentScrollback(double d) Sets the percent scrollback.voidsetPosition(int o) Sets the axis positionvoidsetScale(int s) Sets scale modevoidsetSubGridVisible(boolean b) Shows the sub grid.voidsetTick(int s) Deprecated.Use setTickSpacingvoidsetTickLength(int lgth) Sets the tick length (in pixel).voidsetTickSpacing(double spacing) Sets the minimum tick spacing (in pixel).voidsetTimeAnnoSubTickInterval(int nb) Sets the number of sub tick interval in TIME_ANNOvoidsetVisible(boolean b) Display or hide the axis.voidsetVLabelWidth(int width) Overrides the calculated vertical label width Use this to align several charts verticallyvoidsetZeroAlwaysVisible(boolean zeroAlwaysVisible) Sets if 0 must always be visible in case of auto scale or nottoScientific(double d) Return a scientific (exponential) representation of the double.toScientificInt(double d) Expert usage.voidtranslate(int x) Translatet axis.voidunzoom()Unzoom the axis and restores last state.voidzoom(double r) Zoom axis.voidzoom(int x1, int x2) Zoom axis.
-
Field Details
-
HORIZONTAL_DOWN
public static final int HORIZONTAL_DOWNHorizontal axis at bottom of the chart- See Also:
-
HORIZONTAL_UP
public static final int HORIZONTAL_UPHorizontal axis at top of the chart- See Also:
-
HORIZONTAL_ORG1
public static final int HORIZONTAL_ORG1Horizontal axis at 0 position (on Y1)- See Also:
-
HORIZONTAL_ORG2
public static final int HORIZONTAL_ORG2Horizontal axis at 0 position (on Y2)- See Also:
-
VERTICAL_RIGHT
public static final int VERTICAL_RIGHTVertical right axis- See Also:
-
VERTICAL_LEFT
public static final int VERTICAL_LEFTVertical left axis- See Also:
-
VERTICAL_ORG
public static final int VERTICAL_ORGVertical axis at X=0- See Also:
-
TIME_ANNO
public static final int TIME_ANNODraw time annotation for x axis.- See Also:
-
VALUE_ANNO
public static final int VALUE_ANNODraw formated annotation- See Also:
-
LINEAR_SCALE
public static final int LINEAR_SCALEUse linear scale for this axis- See Also:
-
LOG_SCALE
public static final int LOG_SCALEUse logarithmic scale for this axis- See Also:
-
AUTO_FORMAT
public static final int AUTO_FORMATUse default compiler format to display double- See Also:
-
SCIENTIFIC_FORMAT
public static final int SCIENTIFIC_FORMATDisplay value using exponential representation (x.xxEyy)- See Also:
-
TIME_FORMAT
public static final int TIME_FORMATDisplay number of second as HH:MM:SS- See Also:
-
DECINT_FORMAT
public static final int DECINT_FORMATDisplay integer using decimal format- See Also:
-
HEXINT_FORMAT
public static final int HEXINT_FORMATDisplay integer using haxadecimal format- See Also:
-
BININT_FORMAT
public static final int BININT_FORMATDisplay integer using binary format- See Also:
-
SCIENTIFICINT_FORMAT
public static final int SCIENTIFICINT_FORMATDisplay value using exponential representation (xEyy)- See Also:
-
DATE_FORMAT
public static final int DATE_FORMATDisplay value as date- See Also:
-
US_DATE_FORMAT
US date format to format labels as dates- See Also:
-
FR_DATE_FORMAT
French date format to format labels as dates- See Also:
-
-
Constructor Details
-
JLAxis
Axis constructor (Expert usage).- Parameters:
orientation- Default Axis placement (cannot be ..._ORG).parent- (deprecated, not used).- See Also:
-
-
Method Details
-
getHelpString
-
setPercentScrollback
public void setPercentScrollback(double d) Sets the percent scrollback. When usingJLChart.addDataand TIME_ANNO mode for the horizontal axis this property allows to avoid a full graph repaint for every new data entered.- Parameters:
d- Scrollback percent [0..100]
-
getPercentScrollback
public double getPercentScrollback()Gets the percent scrollback- Returns:
- scrollback percent
-
setAxisColor
Sets the axis color.- Parameters:
c- Axis color- See Also:
-
getAxisColor
Returns the axis color.- Returns:
- Axis color
- See Also:
-
setLabelFormat
public void setLabelFormat(int l) Sets the axis label format.- Parameters:
l- Format of values displayed on axis and in tooltips.- See Also:
-
getLabelFormat
public int getLabelFormat()Returns the axis label format.- Returns:
- Axis value format
- See Also:
-
setGridVisible
public void setGridVisible(boolean b) Shows the grid.- Parameters:
b- true to make the grid visible; false to hide it- See Also:
-
setFitXAxisToDisplayDuration
public void setFitXAxisToDisplayDuration(boolean b) Fit the x axis to display duration (Horizontal axis only).- Parameters:
b- true to fit x axis false otherwise
-
isFitXAxisToDisplayDuration
public boolean isFitXAxisToDisplayDuration()- Returns:
- true if the x axis fit to display duration.
-
isGridVisible
public boolean isGridVisible()Determines whether the axis is showing the grid- Returns:
- true if the grid is visible, false otherwise
- See Also:
-
setDrawOpposite
public void setDrawOpposite(boolean b) Draw a second axis at the opposite side.- Parameters:
b- true to enable the opposite axis.
-
isDrawOpposite
public boolean isDrawOpposite()Determines whether the axis at the opposite side is visible- Returns:
- true if opposite axis is visible.
- See Also:
-
setSubGridVisible
public void setSubGridVisible(boolean b) Shows the sub grid. More accurate grid displayed with a soft color.- Parameters:
b- true to make the subgrid visible; false to hide it- See Also:
-
isSubGridVisible
public boolean isSubGridVisible()Determines whether the axis is showing the sub grid- Returns:
- true if the subgrid is visible, false otherwise
- See Also:
-
setGridStyle
public void setGridStyle(int s) Sets the grid style.- Parameters:
s- Style of the grid. Can be one of the following:- See Also:
-
getGridStyle
public int getGridStyle()Returns the current grid style.- Returns:
- the current grid style
- See Also:
-
setFont
Sets the label font- Parameters:
f- Sets the font for this components- See Also:
-
getFont
Gets the label font- Returns:
- The current label font
- See Also:
-
setAnnotation
public void setAnnotation(int a) Set the annotation method- Parameters:
a- Annotation for this axis- See Also:
-
getAnnotation
public int getAnnotation()- Returns:
- the annotation method
- See Also:
-
setVisible
public void setVisible(boolean b) Display or hide the axis.- Parameters:
b- True to make the axis visible.
-
isVisible
public boolean isVisible()- Returns:
- true if the axis is visble, false otherwise
-
isZoomed
public boolean isZoomed()Determines whether the axis is zoomed.- Returns:
- true if the axis is zoomed, false otherwise
- See Also:
-
isXY
public boolean isXY()Determines whether the axis is in XY mode. Use only with HORIZONTAL axis.- Returns:
- true if the axis is in XY mode, false otherwise
- See Also:
-
setMinimum
public void setMinimum(double d) Sets minimum axis value. This value is ignored when using autoscale.- Parameters:
d- Minimum value for this axis. Must be strictly positive for LOG_SCALE.- See Also:
-
getMinimum
public double getMinimum()Gets minimum axis value- Returns:
- The minimum value for this axis.
- See Also:
-
setMaximum
public void setMaximum(double d) Sets maximum axis value. This value is ignored when using autoscale.- Parameters:
d- Maximum value for this axis. Must be strictly positive for LOG_SCALE.- See Also:
-
getMaximum
public double getMaximum()Gets maximum axis value- Returns:
- The maximum value for this axis.
- See Also:
-
getMin
public double getMin()Expert usage. Get minimum axis value (according to auto scale transformation).- Returns:
- The minimum value for this axis.
-
getMax
public double getMax()Expert usage. Get maximum axis value (according to auto scale transformation).- Returns:
- The maximum value for this axis.
-
isAutoScale
public boolean isAutoScale()Determines whether the axis is autoscaled.- Returns:
- true if the axis is autoscaled, false otherwise
- See Also:
-
setAutoScale
public void setAutoScale(boolean b) Sets the autoscale mode for this axis.- Parameters:
b- true if the axis is autoscaled, false otherwise- See Also:
-
getScale
public int getScale()Gets the scale mdoe for this axis.- Returns:
- scale mdoe
- See Also:
-
setScale
public void setScale(int s) Sets scale mode- Parameters:
s- Scale mode for this axis- See Also:
-
setOrientation
public void setOrientation(int orientation) Sets the axis orientation and reset position.- Parameters:
orientation- Orientation value- See Also:
-
getOrientation
public int getOrientation()- Returns:
- the orientation of this axis.
- See Also:
-
setTimeAnnoSubTickInterval
public void setTimeAnnoSubTickInterval(int nb) Sets the number of sub tick interval in TIME_ANNO- Parameters:
nb- Number of interval (0 to disable)
-
getTimeAnnoSubTickInterval
public int getTimeAnnoSubTickInterval()- Returns:
- the number of sub tick interval in TIME_ANNO
- See Also:
-
canApplyTimeSpan
public boolean canApplyTimeSpan(int x1, int x2) -
directZoom
public void directZoom(double min, double max) Enter zoom mode and set min and max- Parameters:
min- New minimum value for this axismax- New maximum value for this axis- See Also:
-
isZoomedunzoom()
-
zoom
public void zoom(int x1, int x2) Zoom axis.- Parameters:
x1- New minimum value for this axisx2- New maximum value for this axis- See Also:
-
isZoomedunzoom()
-
zoom
public void zoom(double r) Zoom axis.- Parameters:
r- ratio- See Also:
-
isZoomedunzoom()
-
translate
public void translate(int x) Translatet axis.- Parameters:
x- translation- See Also:
-
isZoomedunzoom()
-
unzoom
public void unzoom()Unzoom the axis and restores last state.- See Also:
-
isZoomedunzoom()
-
getTick
public int getTick()Deprecated.Use getTickSpacing- Returns:
- minTickStep
- See Also:
-
getTickSpacing
public double getTickSpacing()- Returns:
- the current minimum tick spacing (in pixel).
-
setTickSpacing
public void setTickSpacing(double spacing) Sets the minimum tick spacing (in pixel). Allows to control the number of generated labels.- Parameters:
spacing- Minimum tick spacing
-
setTick
public void setTick(int s) Deprecated.Use setTickSpacing- Parameters:
s- minTickStep- See Also:
-
setTickLength
public void setTickLength(int lgth) Sets the tick length (in pixel).- Parameters:
lgth- Length
-
getTickLength
public int getTickLength()- Returns:
- the tick length (in pixel).
-
getName
Gets the axis label.- Returns:
- Axis name.
- See Also:
-
setName
Sets the axis label. Label is displayed along or above the axis.- Parameters:
s- Name of this axis.- See Also:
-
setPosition
public void setPosition(int o) Sets the axis position- Parameters:
o- Axis position- See Also:
-
getAxeName
Gets the axis label.- Returns:
- Axis name.
- See Also:
-
setAxeName
Sets the axis name. Name is displayed in tooltips when clicking on the graph.- Parameters:
s- Name of this axis.- See Also:
-
addDataView
Displays a DataView on this axis. The graph switches in XY monitoring mode when adding a dataView to X axis. Only one view is allowed on HORIZONTAL Axis. In case of a view plotted along this horizontal axis doesn't have the same number of point as this x view, points are correlated according to their x values.- Parameters:
v- The dataview to map along this axis.- See Also:
-
addDataViewAt
Add the given dataView at the specifed index.- Parameters:
index- Insertion positionv- DataView to add- See Also:
-
getDataView
Get the dataView of this axis at the specified index.- Parameters:
index- DataView index- Returns:
- Null if index out of bounds.
-
removeDataView
Removes dataview from this axis- Parameters:
v- dataView to remove from this axis.- See Also:
-
checkRemoveDataView
Removes dataview from this axis and returns true if the dataview has been found for this Axis- Parameters:
v- dataView to remove from this axis.- Returns:
- true if Axis contained the dataview and false if this dataview did not belong to the axis
- See Also:
-
clearDataView
public void clearDataView()Clear all dataview from this axis -
getViews
Gets all dataViews displayed on this axis. Do not modify the returned vector (Use as read only).- Returns:
- Vector of JLDataView.
- See Also:
-
getViewNumber
public int getViewNumber()Returns the number if dataview in this axis.- Returns:
- DataView number.
-
setInverted
public void setInverted(boolean i) Invert this axis.- Parameters:
i- true to invert the axis
-
isInverted
public boolean isInverted()- Returns:
- true if this axis is inverted.
-
getBoundRect
Returns the bouding rectangle of this axis.- Returns:
- The bounding rectangle
-
toScientific
Return a scientific (exponential) representation of the double.- Parameters:
d- double to convert- Returns:
- A string continaing a scientific representation of the given double.
-
toScientificInt
-
formatTimeValue
Returns a representation of the double in time format "EEE, d MMM yyyy HH:mm:ss".- Parameters:
vt- number of millisec since epoch- Returns:
- A string continaing a time representation of the given double.
-
setLabelOffset
public void setLabelOffset(int x, int y) Sets the label offset (in pixel)- Parameters:
x- Horizontal offsety- Vertical offset
-
setLabels
Customize axis labels.- Parameters:
labels- Label valueslabelPos- Label positions (in axis coordinates)
-
setVLabelWidth
public void setVLabelWidth(int width) Overrides the calculated vertical label width Use this to align several charts vertically- Parameters:
width- label width
-
getVLabelWidth
public int getVLabelWidth()- Returns:
- the vertical label width
- See Also:
-
formatValue
Returns a representation of the double acording to the format- Parameters:
vt- double to convertprec- Desired precision (Pass 0 to not perform prec rounding).- Returns:
- A string continaing a formated representation of the given double.
-
computeAutoScale
public void computeAutoScale()Expert usage. Used to compute auto scale values, only once, for the Axis which are not autoScaled How to use : axis.setAutoScale(true); axis.setMinimum(pAxis.getMin()); axis.setMaximum(pAxis.getMax()); axis.setAutoScale(false); -
setAxisDuration
public void setAxisDuration(double d) Expert usage. Sets the preferred scale for time axis (HORIZONTAL axis only)- Parameters:
d- Duration (millisec)
-
computeXScale
Expert usage. Compute X auto scale (HORIZONTAL axis only)- Parameters:
views- All views displayed along all Y axis.
-
getFontHeight
Deprecated.Use getLabelFontDimension() instead- Parameters:
g- Graphics- Returns:
- getLabelFontDimension
-
getLabelFontDimension
Expert usage.- Parameters:
frc- FontRenderContext- Returns:
- Axis font dimension.
-
getFontOverWidth
public int getFontOverWidth() -
getThickness
public int getThickness()Expert usage. Returns axis tichkness in pixel ( shorter side )- Returns:
- Axis tichkness
- See Also:
-
getLength
public int getLength()Expert usage. Returns axis lenght in pixel ( larger side ).- Returns:
- Axis lenght.
- See Also:
-
measureAxis
Expert usage. Computes labels and measures axis dimension.- Parameters:
frc- Font render contextdesiredWidth- Desired widthdesiredHeight- Desired height
-
transform
Expert usage. Transfrom given coordinates (real space) into pixel coordinates- Parameters:
x- The x coordinates (Real space)y- The y coordinates (Real space)xAxis- The axis corresponding to x coordinates.- Returns:
- Point(-100,-100) when cannot transform
-
searchNearestNormal
Expert usage. Search the nearest point in the dataViews in normal monitoring mode- Parameters:
x- The x coordinates (Real space)y- The y coorsinates (Real space)xAxis- The axis corresponding to x coordinates.- Returns:
- A structure containing search result.
- See Also:
-
searchNearestXY
Expert usage. Search the nearest point in the dataViews in XY monitoring mode- Parameters:
x- The x coordinates (Real space)y- The y coorsinates (Real space)xAxis- The axis corresponding to x coordinates.- Returns:
- A structure containing search result.
- See Also:
-
searchNearest
Search the nearest point in the dataViews.- Parameters:
x- The x coordinates (Real space)y- The y coordinates (Real space)xAxis- The axis corresponding to x coordinates.- Returns:
- A structure containing search result.
-
drawFast
Expert Usage. Paint last point of a dataView.- Parameters:
g- Graphics objectlp- last pointp- new pointv- view containing the lp and p.
-
paintMarker
Expert usage. Paint a marker a the specified position- Parameters:
g- Graphics objectmType- Marker typemSize- Marker sizex- x coordinates (pixel space)y- y coordinates (pixel space)
-
drawSampleLine
Expert usage. Draw a sample line of a dataview- Parameters:
g- Graphics objectx- x coordinates (pixel space)y- y coordinates (pixel space)v- dataview
-
computeMediumColor
Compute the medium color of c1,c2- Parameters:
c1- Color 1c2- Color 2- Returns:
- Averaged color.
-
paintAxisDirect
public void paintAxisDirect(Graphics g, FontRenderContext frc, int x0, int y0, Color back, int tr, int la) Paint this axis.- Parameters:
g- Graphics contextfrc- Font render contextx0- Axis positiony0- Axis positionback- background Color (used to compute subTick color)tr- Translation from x0 to axis.la- Translation to opposite axis (used by grid).
-
paintAxisOpposite
public void paintAxisOpposite(Graphics g, FontRenderContext frc, int x0, int y0, Color back, int tr, int la) -
paintAxisOppositeDouble
public void paintAxisOppositeDouble(Graphics g, FontRenderContext frc, int x0, int y0, Color back, int tr, int la) -
applyConfiguration
Apply axis configuration.- Parameters:
prefix- Axis settings prefixf- CfFileReader object wich contains axis parametters- See Also:
-
getConfiguration
Builds a configuration string that can be write into a file and is compatible with CfFileReader.- Parameters:
prefix- Axis settings prefix- Returns:
- A string containing param
- See Also:
-
isZeroAlwaysVisible
public boolean isZeroAlwaysVisible()Allows user to know if the 0 value will always be visible in case of auto scale- Returns:
- a boolean value
-
setZeroAlwaysVisible
public void setZeroAlwaysVisible(boolean zeroAlwaysVisible) Sets if 0 must always be visible in case of auto scale or not- Parameters:
zeroAlwaysVisible- a boolean value. True for always visible, false otherwise.
-
getDateFormat
-
setDateFormat
Sets date format chen chosen label format is DATE_FORMAT- Parameters:
dateFormat- Date format- See Also:
-