Package org.swtchart.internal.axis
Class Axis
- java.lang.Object
-
- org.swtchart.internal.axis.Axis
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.swtchart.IAxis
IAxis.Direction, IAxis.Position
-
-
Field Summary
Fields Modifier and Type Field Description static doubleDEFAULT_LOG_SCALE_MAXthe default maximum value of log scale rangestatic doubleDEFAULT_LOG_SCALE_MINthe default minimum value of log scale rangestatic doubleDEFAULT_MAXthe default maximum value of rangestatic doubleDEFAULT_MINthe default minimum value of rangestatic intMARGINthe margin in pixels
-
Constructor Summary
Constructors Constructor Description Axis(int id, IAxis.Direction direction, Chart chart)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDisposeListener(IDisposeListener listener)Adds the dispose listener.voidadjustRange()Adjusts the axis range to the series belonging to the axis, so that all series are completely shown.voidadjustRange(boolean update)Adjusts the axis range to the series belonging to the axis.protected voiddispose()Disposes the resources.voidenableCategory(boolean enabled)Enables category.voidenableLogScale(boolean enabled)Enables the log scale.java.lang.String[]getCategorySeries()Gets the category series.doublegetDataCoordinate(int pixelCoordinate)Gets the data coordinate corresponding to the given pixel coordinate on plot area.doublegetDataCoordinate(int pixelCoordinate, double lower, double upper)Gets the data coordinate corresponding to the given pixel coordinate on plot area.IAxis.DirectiongetDirection()Gets the axis direction.IGridgetGrid()Gets the grid.intgetId()Gets the axis id.intgetNumRisers()Gets the number of risers per category.intgetPixelCoordinate(double dataCoordinate)Gets the pixel coordinate corresponding to the given data coordinate.intgetPixelCoordinate(double dataCoordinate, double lower, double upper)Gets the pixel coordinate corresponding to the given data coordinate.IAxis.PositiongetPosition()Gets the axis position.RangegetRange()Gets the axis range.AxisTickgetTick()Gets the axis tick.ITitlegetTitle()Gets the axis title.booleanisCategoryEnabled()Gets the state indicating if category is enabled.booleanisDateEnabled()Gets the state indicating if date is enabled.booleanisHorizontalAxis()Checks if the axis is horizontal.booleanisLogScaleEnabled()Gets the state indicating if log scale is enabled.booleanisValidCategoryAxis()Gets the state indicating if the axis is valid category axis.voidrefresh()Refreshes the cache.voidscrollDown()Scrolls up the axis.voidscrollUp()Scrolls up the axis.voidsetCategorySeries(java.lang.String[] series)Sets the category series.voidsetNumRisers(int numRisers)Sets the number of risers per category.voidsetPosition(IAxis.Position position)Sets the axis position.voidsetRange(Range range)Sets the axis range.voidsetRange(Range range, boolean update)Sets the axis range.voidupdateLayoutData()Updates the layout data.voidzoomIn()Zooms in the axis.voidzoomIn(double coordinate)Zooms in the axis at the given coordinate.voidzoomOut()Zooms out the axis.voidzoomOut(double coordinate)Zooms out the axis at the given coordinate.
-
-
-
Field Detail
-
MARGIN
public static final int MARGIN
the margin in pixels- See Also:
- Constant Field Values
-
DEFAULT_MIN
public static final double DEFAULT_MIN
the default minimum value of range- See Also:
- Constant Field Values
-
DEFAULT_MAX
public static final double DEFAULT_MAX
the default maximum value of range- See Also:
- Constant Field Values
-
DEFAULT_LOG_SCALE_MIN
public static final double DEFAULT_LOG_SCALE_MIN
the default minimum value of log scale range- See Also:
- Constant Field Values
-
DEFAULT_LOG_SCALE_MAX
public static final double DEFAULT_LOG_SCALE_MAX
the default maximum value of log scale range- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Axis
public Axis(int id, IAxis.Direction direction, Chart chart)Constructor.- Parameters:
id- the axis indexdirection- the axis direction (X or Y)chart- the chart
-
-
Method Detail
-
getId
public int getId()
Description copied from interface:IAxisGets the axis id.An axis id is automatically assigned when axis is created.
-
getDirection
public IAxis.Direction getDirection()
Description copied from interface:IAxisGets the axis direction.The axis direction is set when axis is created, and won't be changed.
- Specified by:
getDirectionin interfaceIAxis- Returns:
- the axis direction
-
getPosition
public IAxis.Position getPosition()
Description copied from interface:IAxisGets the axis position.- Specified by:
getPositionin interfaceIAxis- Returns:
- the axis position
-
setPosition
public void setPosition(IAxis.Position position)
Description copied from interface:IAxisSets the axis position.- Specified by:
setPositionin interfaceIAxis- Parameters:
position- the axis position
-
setRange
public void setRange(Range range)
Description copied from interface:IAxisSets the axis range.
-
setRange
public void setRange(Range range, boolean update)
Sets the axis range.- Parameters:
range- the axis rangeupdate- true if updating the chart layout
-
enableLogScale
public void enableLogScale(boolean enabled) throws java.lang.IllegalStateExceptionDescription copied from interface:IAxisEnables the log scale. If enabling log scale, stacking trace and category axis will be disabled.- Specified by:
enableLogScalein interfaceIAxis- Parameters:
enabled- true if enabling log scales- Throws:
java.lang.IllegalStateException- if minimum value of series belonging to this axis is less than zero.
-
isLogScaleEnabled
public boolean isLogScaleEnabled()
Description copied from interface:IAxisGets the state indicating if log scale is enabled.- Specified by:
isLogScaleEnabledin interfaceIAxis- Returns:
- true if log scale is enabled
-
getGrid
public IGrid getGrid()
Description copied from interface:IAxisGets 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.
-
adjustRange
public void adjustRange()
Description copied from interface:IAxisAdjusts the axis range to the series belonging to the axis, so that all series are completely shown.- Specified by:
adjustRangein interfaceIAxis
-
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:IAxisZooms in the axis.
-
zoomIn
public void zoomIn(double coordinate)
Description copied from interface:IAxisZooms in the axis at the given coordinate.
-
zoomOut
public void zoomOut()
Description copied from interface:IAxisZooms out the axis.
-
zoomOut
public void zoomOut(double coordinate)
Description copied from interface:IAxisZooms out the axis at the given coordinate.
-
scrollUp
public void scrollUp()
Description copied from interface:IAxisScrolls up the axis.
-
scrollDown
public void scrollDown()
Description copied from interface:IAxisScrolls up the axis.- Specified by:
scrollDownin interfaceIAxis
-
isCategoryEnabled
public boolean isCategoryEnabled()
Description copied from interface:IAxisGets the state indicating if category is enabled.- Specified by:
isCategoryEnabledin interfaceIAxis- 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:IAxisEnables 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:
enableCategoryin interfaceIAxis- Parameters:
enabled- true if enabling category
-
setCategorySeries
public void setCategorySeries(java.lang.String[] series)
Description copied from interface:IAxisSets the category series. In order to enable category series, enableCategoryAxis(true) has to be invoked.- Specified by:
setCategorySeriesin interfaceIAxis- Parameters:
series- the category series
-
getCategorySeries
public java.lang.String[] getCategorySeries()
Description copied from interface:IAxisGets the category series. If the category series haven't been set yet, null will be returned.- Specified by:
getCategorySeriesin interfaceIAxis- Returns:
- the category series
-
getPixelCoordinate
public int getPixelCoordinate(double dataCoordinate)
Description copied from interface:IAxisGets the pixel coordinate corresponding to the given data coordinate.- Specified by:
getPixelCoordinatein interfaceIAxis- 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 coordinatelower- the min value of rangeupper- the max value of range- Returns:
- the pixel coordinate on plot area
-
getDataCoordinate
public double getDataCoordinate(int pixelCoordinate)
Description copied from interface:IAxisGets the data coordinate corresponding to the given pixel coordinate on plot area.- Specified by:
getDataCoordinatein interfaceIAxis- 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 arealower- the min value of rangeupper- 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:IAxisAdds 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:
addDisposeListenerin interfaceIAxis- 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
-
-