Class Axis<ST extends AxesChartStyler,S extends AxesChartSeries>
- java.lang.Object
-
- org.knowm.xchart.internal.chartpart.Axis<ST,S>
-
- All Implemented Interfaces:
ChartPart
public class Axis<ST extends AxesChartStyler,S extends AxesChartSeries> extends java.lang.Object implements ChartPart
Axis
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAxis.DirectionAn axis direction
-
Field Summary
Fields Modifier and Type Field Description private STaxesChartStylerprivate AxisTick<ST,S>axisTickthe axis tickprivate AxisTickCalculatoraxisTickCalculatorthe axis tick calculatorprivate AxisTitle<ST,S>axisTitlethe axis titleprivate java.awt.geom.Rectangle2D.Doubleboundsprivate Chart<ST,S>chartprivate Series.DataTypedataTypethe dataTypeprivate Axis.Directiondirectionthe axis directionprivate intindexthe axis group index *private doublemaxprivate doublemin-
Fields inherited from interface org.knowm.xchart.internal.chartpart.ChartPart
SOLID_STROKE
-
-
Constructor Summary
Constructors Constructor Description Axis(Chart<ST,S> chart, Axis.Direction direction, int index)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidaddMinMax(double min, double max)(package private) AxisTick<ST,S>getAxisTick()AxisTickCalculatorgetAxisTickCalculator()private AxisTickCalculatorgetAxisTickCalculator(double workingSpace)private AxisTickCalculator_getAxisTickCalculatorForX(double workingSpace)private AxisTickCalculatorgetAxisTickCalculatorForY(double workingSpace)(package private) AxisTitle<ST,S>getAxisTitle()java.awt.geom.Rectangle2DgetBounds()doublegetChartValue(double screenPoint)Converts a screen coordinate to chart coordinate value.(package private) Series.DataTypegetDataType()private Axis.DirectiongetDirection()(package private) doublegetMax()(package private) doublegetMin()doublegetScreenValue(double chartPoint)Converts a chart coordinate value to screen coordinate.doublegetScreenValueForMax()doublegetScreenValueForMin()private doublegetXAxisHeightHint(double workingSpace)The vertical Y-Axis is drawn first, but to know the lower bounds of it, we need to know how high the X-Axis paint zone is going to be.private doublegetYAxisWidthHint(double workingSpace)intgetYIndex()voidpaint(java.awt.Graphics2D g)voidpreparePaint()(package private) voidresetMinMax()Reset the default min and max values in preparation for calculating the actual min and maxvoidsetDataType(Series.DataType dataType)(package private) voidsetMax(double max)(package private) voidsetMin(double min)
-
-
-
Field Detail
-
chart
private final Chart<ST extends AxesChartStyler,S extends AxesChartSeries> chart
-
bounds
private final java.awt.geom.Rectangle2D.Double bounds
-
axesChartStyler
private final ST extends AxesChartStyler axesChartStyler
-
axisTitle
private final AxisTitle<ST extends AxesChartStyler,S extends AxesChartSeries> axisTitle
the axis title
-
axisTick
private final AxisTick<ST extends AxesChartStyler,S extends AxesChartSeries> axisTick
the axis tick
-
direction
private final Axis.Direction direction
the axis direction
-
index
private final int index
the axis group index *
-
dataType
private Series.DataType dataType
the dataType
-
axisTickCalculator
private AxisTickCalculator axisTickCalculator
the axis tick calculator
-
min
private double min
-
max
private double max
-
-
Constructor Detail
-
Axis
public Axis(Chart<ST,S> chart, Axis.Direction direction, int index)
Constructor- Parameters:
chart- the Chartdirection- the axis direction (X or Y)index- the y-axis index (not relevant for x-axes)
-
-
Method Detail
-
resetMinMax
void resetMinMax()
Reset the default min and max values in preparation for calculating the actual min and max
-
addMinMax
void addMinMax(double min, double max)- Parameters:
min-max-
-
preparePaint
public void preparePaint()
-
getXAxisHeightHint
private double getXAxisHeightHint(double workingSpace)
The vertical Y-Axis is drawn first, but to know the lower bounds of it, we need to know how high the X-Axis paint zone is going to be. Since the tick labels could be rotated, we need to actually determine the tick labels first to get an idea of how tall the X-Axis tick labels will be.- Returns:
- the x-axis height hint
-
getYAxisWidthHint
private double getYAxisWidthHint(double workingSpace)
-
getAxisTickCalculator
private AxisTickCalculator getAxisTickCalculator(double workingSpace)
-
getAxisTickCalculatorForY
private AxisTickCalculator getAxisTickCalculatorForY(double workingSpace)
-
getAxisTickCalculatorForX
private AxisTickCalculator_ getAxisTickCalculatorForX(double workingSpace)
-
getDataType
Series.DataType getDataType()
-
setDataType
public void setDataType(Series.DataType dataType)
-
getMin
double getMin()
-
setMin
void setMin(double min)
-
getMax
double getMax()
-
setMax
void setMax(double max)
-
getDirection
private Axis.Direction getDirection()
-
getAxisTickCalculator
public AxisTickCalculator getAxisTickCalculator()
-
getBounds
public java.awt.geom.Rectangle2D getBounds()
-
getYIndex
public int getYIndex()
-
getScreenValue
public double getScreenValue(double chartPoint)
Converts a chart coordinate value to screen coordinate. Same as AxisTickCalculators calculation.- Parameters:
chartPoint- value in chart coordinate system- Returns:
- Coordinate of screen. eg: MouseEvent.getX(), MouseEvent.getY()
-
getScreenValueForMin
public double getScreenValueForMin()
-
getScreenValueForMax
public double getScreenValueForMax()
-
getChartValue
public double getChartValue(double screenPoint)
Converts a screen coordinate to chart coordinate value. Reverses the AxisTickCalculators calculation.- Parameters:
screenPoint- Coordinate of screen. eg: MouseEvent.getX(), MouseEvent.getY()- Returns:
- value in chart coordinate system
-
-