Class JLAxis

java.lang.Object
fr.esrf.tangoatk.widget.util.chart.JLAxis
All Implemented Interfaces:
Serializable

public class JLAxis extends Object implements Serializable
Class which handles chart axis.
Author:
JL Pons
See Also:
  • Field Details

    • HORIZONTAL_DOWN

      public static final int HORIZONTAL_DOWN
      Horizontal axis at bottom of the chart
      See Also:
    • HORIZONTAL_UP

      public static final int HORIZONTAL_UP
      Horizontal axis at top of the chart
      See Also:
    • HORIZONTAL_ORG1

      public static final int HORIZONTAL_ORG1
      Horizontal axis at 0 position (on Y1)
      See Also:
    • HORIZONTAL_ORG2

      public static final int HORIZONTAL_ORG2
      Horizontal axis at 0 position (on Y2)
      See Also:
    • VERTICAL_RIGHT

      public static final int VERTICAL_RIGHT
      Vertical right axis
      See Also:
    • VERTICAL_LEFT

      public static final int VERTICAL_LEFT
      Vertical left axis
      See Also:
    • VERTICAL_ORG

      public static final int VERTICAL_ORG
      Vertical axis at X=0
      See Also:
    • TIME_ANNO

      public static final int TIME_ANNO
      Draw time annotation for x axis.
      See Also:
    • VALUE_ANNO

      public static final int VALUE_ANNO
      Draw formated annotation
      See Also:
    • LINEAR_SCALE

      public static final int LINEAR_SCALE
      Use linear scale for this axis
      See Also:
    • LOG_SCALE

      public static final int LOG_SCALE
      Use logarithmic scale for this axis
      See Also:
    • AUTO_FORMAT

      public static final int AUTO_FORMAT
      Use default compiler format to display double
      See Also:
    • SCIENTIFIC_FORMAT

      public static final int SCIENTIFIC_FORMAT
      Display value using exponential representation (x.xxEyy)
      See Also:
    • TIME_FORMAT

      public static final int TIME_FORMAT
      Display number of second as HH:MM:SS
      See Also:
    • DECINT_FORMAT

      public static final int DECINT_FORMAT
      Display integer using decimal format
      See Also:
    • HEXINT_FORMAT

      public static final int HEXINT_FORMAT
      Display integer using haxadecimal format
      See Also:
    • BININT_FORMAT

      public static final int BININT_FORMAT
      Display integer using binary format
      See Also:
    • SCIENTIFICINT_FORMAT

      public static final int SCIENTIFICINT_FORMAT
      Display value using exponential representation (xEyy)
      See Also:
    • DATE_FORMAT

      public static final int DATE_FORMAT
      Display value as date
      See Also:
    • US_DATE_FORMAT

      public static final String US_DATE_FORMAT
      US date format to format labels as dates
      See Also:
    • FR_DATE_FORMAT

      public static final String FR_DATE_FORMAT
      French date format to format labels as dates
      See Also:
  • Constructor Details

  • Method Details

    • getHelpString

      public static String getHelpString()
    • setPercentScrollback

      public void setPercentScrollback(double d)
      Sets the percent scrollback. When using JLChart.addData and 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

      public void setAxisColor(Color c)
      Sets the axis color.
      Parameters:
      c - Axis color
      See Also:
    • getAxisColor

      public Color 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

      public void setFont(Font f)
      Sets the label font
      Parameters:
      f - Sets the font for this components
      See Also:
    • getFont

      public Font 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 axis
      max - New maximum value for this axis
      See Also:
    • zoom

      public void zoom(int x1, int x2)
      Zoom axis.
      Parameters:
      x1 - New minimum value for this axis
      x2 - New maximum value for this axis
      See Also:
    • zoom

      public void zoom(double r)
      Zoom axis.
      Parameters:
      r - ratio
      See Also:
    • translate

      public void translate(int x)
      Translatet axis.
      Parameters:
      x - translation
      See Also:
    • unzoom

      public void unzoom()
      Unzoom the axis and restores last state.
      See Also:
    • 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

      public String getName()
      Gets the axis label.
      Returns:
      Axis name.
      See Also:
    • setName

      public void setName(String s)
      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

      public String getAxeName()
      Gets the axis label.
      Returns:
      Axis name.
      See Also:
    • setAxeName

      public void setAxeName(String s)
      Sets the axis name. Name is displayed in tooltips when clicking on the graph.
      Parameters:
      s - Name of this axis.
      See Also:
    • addDataView

      public void addDataView(JLDataView v)
      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

      public void addDataViewAt(int index, JLDataView v)
      Add the given dataView at the specifed index.
      Parameters:
      index - Insertion position
      v - DataView to add
      See Also:
    • getDataView

      public JLDataView getDataView(int index)
      Get the dataView of this axis at the specified index.
      Parameters:
      index - DataView index
      Returns:
      Null if index out of bounds.
    • removeDataView

      public void removeDataView(JLDataView v)
      Removes dataview from this axis
      Parameters:
      v - dataView to remove from this axis.
      See Also:
    • checkRemoveDataView

      public boolean checkRemoveDataView(JLDataView v)
      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
      See Also:
    • getViews

      public Vector<JLDataView> 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

      public Rectangle getBoundRect()
      Returns the bouding rectangle of this axis.
      Returns:
      The bounding rectangle
    • toScientific

      public String toScientific(double d)
      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

      public String toScientificInt(double d)
    • formatTimeValue

      public static String formatTimeValue(double vt)
      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 offset
      y - Vertical offset
    • setLabels

      public void setLabels(String[] labels, double[] labelPos)
      Customize axis labels.
      Parameters:
      labels - Label values
      labelPos - 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

      public String formatValue(double vt, double prec)
      Returns a representation of the double acording to the format
      Parameters:
      vt - double to convert
      prec - 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

      public void computeXScale(Vector views)
      Expert usage. Compute X auto scale (HORIZONTAL axis only)
      Parameters:
      views - All views displayed along all Y axis.
    • getFontHeight

      public int getFontHeight(Graphics g)
      Deprecated.
      Use getLabelFontDimension() instead
      Parameters:
      g - Graphics
      Returns:
      getLabelFontDimension
    • getLabelFontDimension

      public int getLabelFontDimension(FontRenderContext frc)
      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

      public void measureAxis(FontRenderContext frc, int desiredWidth, int desiredHeight)
      Expert usage. Computes labels and measures axis dimension.
      Parameters:
      frc - Font render context
      desiredWidth - Desired width
      desiredHeight - Desired height
    • transform

      public Point transform(double x, double y, JLAxis xAxis)
      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

      public SearchInfo searchNearestNormal(int x, int y, JLAxis xAxis)
      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

      public SearchInfo searchNearestXY(int x, int y, JLAxis xAxis)
      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

      public SearchInfo searchNearest(int x, int y, JLAxis xAxis)
      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

      public void drawFast(Graphics g, Point lp, Point p, JLDataView v)
      Expert Usage. Paint last point of a dataView.
      Parameters:
      g - Graphics object
      lp - last point
      p - new point
      v - view containing the lp and p.
    • paintMarker

      public static void paintMarker(Graphics g, int mType, int mSize, int x, int y)
      Expert usage. Paint a marker a the specified position
      Parameters:
      g - Graphics object
      mType - Marker type
      mSize - Marker size
      x - x coordinates (pixel space)
      y - y coordinates (pixel space)
    • drawSampleLine

      public static void drawSampleLine(Graphics g, int x, int y, JLDataView v)
      Expert usage. Draw a sample line of a dataview
      Parameters:
      g - Graphics object
      x - x coordinates (pixel space)
      y - y coordinates (pixel space)
      v - dataview
    • computeMediumColor

      public Color computeMediumColor(Color c1, Color c2)
      Compute the medium color of c1,c2
      Parameters:
      c1 - Color 1
      c2 - 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 context
      frc - Font render context
      x0 - Axis position
      y0 - Axis position
      back - 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

      public void applyConfiguration(String prefix, CfFileReader f)
      Apply axis configuration.
      Parameters:
      prefix - Axis settings prefix
      f - CfFileReader object wich contains axis parametters
      See Also:
    • getConfiguration

      public String getConfiguration(String prefix)
      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

      public String getDateFormat()
    • setDateFormat

      public void setDateFormat(String dateFormat)
      Sets date format chen chosen label format is DATE_FORMAT
      Parameters:
      dateFormat - Date format
      See Also: