Class Axis

java.lang.Object
org.swtchart.internal.axis.Axis
All Implemented Interfaces:
IAxis

public class Axis extends Object implements IAxis
An axis.
  • Field Details

    • MARGIN

      public static final int MARGIN
      the margin in pixels
      See Also:
    • DEFAULT_MIN

      public static final double DEFAULT_MIN
      the default minimum value of range
      See Also:
    • DEFAULT_MAX

      public static final double DEFAULT_MAX
      the default maximum value of range
      See Also:
    • DEFAULT_LOG_SCALE_MIN

      public static final double DEFAULT_LOG_SCALE_MIN
      the default minimum value of log scale range
      See Also:
    • DEFAULT_LOG_SCALE_MAX

      public static final double DEFAULT_LOG_SCALE_MAX
      the default maximum value of log scale range
      See Also:
  • Constructor Details

    • Axis

      public Axis(int id, IAxis.Direction direction, Chart chart)
      Constructor.
      Parameters:
      id - the axis index
      direction - the axis direction (X or Y)
      chart - the chart
  • Method Details

    • getId

      public int getId()
      Description copied from interface: IAxis
      Gets the axis id.

      An axis id is automatically assigned when axis is created.

      Specified by:
      getId in interface IAxis
      Returns:
      the axis id
    • getDirection

      public IAxis.Direction getDirection()
      Description copied from interface: IAxis
      Gets the axis direction.

      The axis direction is set when axis is created, and won't be changed.

      Specified by:
      getDirection in interface IAxis
      Returns:
      the axis direction
    • getPosition

      public IAxis.Position getPosition()
      Description copied from interface: IAxis
      Gets the axis position.
      Specified by:
      getPosition in interface IAxis
      Returns:
      the axis position
    • setPosition

      public void setPosition(IAxis.Position position)
      Description copied from interface: IAxis
      Sets the axis position.
      Specified by:
      setPosition in interface IAxis
      Parameters:
      position - the axis position
    • setRange

      public void setRange(Range range)
      Description copied from interface: IAxis
      Sets the axis range.
      Specified by:
      setRange in interface IAxis
      Parameters:
      range - the axis range
    • setRange

      public void setRange(Range range, boolean update)
      Sets the axis range.
      Parameters:
      range - the axis range
      update - true if updating the chart layout
    • getRange

      public Range getRange()
      Description copied from interface: IAxis
      Gets the axis range.
      Specified by:
      getRange in interface IAxis
      Returns:
      the axis range
    • getTitle

      public ITitle getTitle()
      Description copied from interface: IAxis
      Gets the axis title.
      Specified by:
      getTitle in interface IAxis
      Returns:
      the axis title
    • getTick

      public AxisTick getTick()
      Description copied from interface: IAxis
      Gets the axis tick.
      Specified by:
      getTick in interface IAxis
      Returns:
      the axis tick
    • enableLogScale

      public void enableLogScale(boolean enabled) throws IllegalStateException
      Description copied from interface: IAxis
      Enables the log scale. If enabling log scale, stacking trace and category axis will be disabled.
      Specified by:
      enableLogScale in interface IAxis
      Parameters:
      enabled - true if enabling log scales
      Throws:
      IllegalStateException - if minimum value of series belonging to this axis is less than zero.
    • isLogScaleEnabled

      public boolean isLogScaleEnabled()
      Description copied from interface: IAxis
      Gets the state indicating if log scale is enabled.
      Specified by:
      isLogScaleEnabled in interface IAxis
      Returns:
      true if log scale is enabled
    • getGrid

      public IGrid getGrid()
      Description copied from interface: IAxis
      Gets the grid. The gird interval is identical with the position of axis tick marks. The horizontal grid is accessible from vertical axis, and the vertical grid is accessible from horizontal axis.
      Specified by:
      getGrid in interface IAxis
      Returns:
      grid the grid
    • adjustRange

      public void adjustRange()
      Description copied from interface: IAxis
      Adjusts the axis range to the series belonging to the axis, so that all series are completely shown.
      Specified by:
      adjustRange in interface IAxis
    • adjustRange

      public void adjustRange(boolean update)
      Adjusts the axis range to the series belonging to the axis.
      Parameters:
      update - true if updating chart layout
    • zoomIn

      public void zoomIn()
      Description copied from interface: IAxis
      Zooms in the axis.
      Specified by:
      zoomIn in interface IAxis
    • zoomIn

      public void zoomIn(double coordinate)
      Description copied from interface: IAxis
      Zooms in the axis at the given coordinate.
      Specified by:
      zoomIn in interface IAxis
      Parameters:
      coordinate - the coordinate
    • zoomOut

      public void zoomOut()
      Description copied from interface: IAxis
      Zooms out the axis.
      Specified by:
      zoomOut in interface IAxis
    • zoomOut

      public void zoomOut(double coordinate)
      Description copied from interface: IAxis
      Zooms out the axis at the given coordinate.
      Specified by:
      zoomOut in interface IAxis
      Parameters:
      coordinate - the coordinate
    • scrollUp

      public void scrollUp()
      Description copied from interface: IAxis
      Scrolls up the axis.
      Specified by:
      scrollUp in interface IAxis
    • scrollDown

      public void scrollDown()
      Description copied from interface: IAxis
      Scrolls up the axis.
      Specified by:
      scrollDown in interface IAxis
    • isCategoryEnabled

      public boolean isCategoryEnabled()
      Description copied from interface: IAxis
      Gets the state indicating if category is enabled.
      Specified by:
      isCategoryEnabled in interface IAxis
      Returns:
      true if category is enabled
    • isValidCategoryAxis

      public boolean isValidCategoryAxis()
      Gets the state indicating if the axis is valid category axis.
      Returns:
      true if the axis is valid category axis
    • enableCategory

      public void enableCategory(boolean enabled)
      Description copied from interface: IAxis
      Enables category. Category is applicable only for X axis. If enabling category, log scale will be disabled. If category series are not yet set, category won't be enabled.
      Specified by:
      enableCategory in interface IAxis
      Parameters:
      enabled - true if enabling category
    • setCategorySeries

      public void setCategorySeries(String[] series)
      Description copied from interface: IAxis
      Sets the category series. In order to enable category series, enableCategoryAxis(true) has to be invoked.
      Specified by:
      setCategorySeries in interface IAxis
      Parameters:
      series - the category series
    • getCategorySeries

      public String[] getCategorySeries()
      Description copied from interface: IAxis
      Gets the category series. If the category series haven't been set yet, null will be returned.
      Specified by:
      getCategorySeries in interface IAxis
      Returns:
      the category series
    • getPixelCoordinate

      public int getPixelCoordinate(double dataCoordinate)
      Description copied from interface: IAxis
      Gets the pixel coordinate corresponding to the given data coordinate.
      Specified by:
      getPixelCoordinate in interface IAxis
      Parameters:
      dataCoordinate - the data coordinate
      Returns:
      the pixel coordinate on plot area
    • getPixelCoordinate

      public int getPixelCoordinate(double dataCoordinate, double lower, double upper)
      Gets the pixel coordinate corresponding to the given data coordinate.
      Parameters:
      dataCoordinate - the data coordinate
      lower - the min value of range
      upper - the max value of range
      Returns:
      the pixel coordinate on plot area
    • getDataCoordinate

      public double getDataCoordinate(int pixelCoordinate)
      Description copied from interface: IAxis
      Gets the data coordinate corresponding to the given pixel coordinate on plot area.
      Specified by:
      getDataCoordinate in interface IAxis
      Parameters:
      pixelCoordinate - the pixel coordinate on plot area
      Returns:
      the data coordinate
    • getDataCoordinate

      public double getDataCoordinate(int pixelCoordinate, double lower, double upper)
      Gets the data coordinate corresponding to the given pixel coordinate on plot area.
      Parameters:
      pixelCoordinate - the pixel coordinate on plot area
      lower - the min value of range
      upper - the max value of range
      Returns:
      the data coordinate
    • setNumRisers

      public void setNumRisers(int numRisers)
      Sets the number of risers per category.
      Parameters:
      numRisers - the number of risers per category
    • getNumRisers

      public int getNumRisers()
      Gets the number of risers per category.
      Returns:
      number of riser per category
    • isHorizontalAxis

      public boolean isHorizontalAxis()
      Checks if the axis is horizontal. X axis is not always horizontal. Y axis can be horizontal with Chart.setOrientation(SWT.VERTICAL).
      Returns:
      true if the axis is horizontal
    • dispose

      protected void dispose()
      Disposes the resources.
    • addDisposeListener

      public void addDisposeListener(IDisposeListener listener)
      Description copied from interface: IAxis
      Adds the dispose listener. The newly created color or font for axis can be disposed with the dispose listener when they are no longer needed.
      Specified by:
      addDisposeListener in interface IAxis
      Parameters:
      listener - the dispose listener
    • updateLayoutData

      public void updateLayoutData()
      Updates the layout data.
    • refresh

      public void refresh()
      Refreshes the cache.
    • isDateEnabled

      public boolean isDateEnabled()
      Gets the state indicating if date is enabled.
      Returns:
      true if date is enabled