Package org.jCharts.axisChart.axis.scale
Class ScaleCalculator
- java.lang.Object
-
- org.jCharts.axisChart.axis.scale.ScaleCalculator
-
- Direct Known Subclasses:
AutomaticScaleCalculator,UserDefinedScaleCalculator
public abstract class ScaleCalculator extends java.lang.ObjectBase class for the logic used to compute the scale on the charts. There are two implementations provided and you are free to implement your own if you do not like the default implementations provided.
-
-
Field Summary
Fields Modifier and Type Field Description protected doubleincrementprivate doublemaxValueprivate doubleminValueprivate intnumberOfScaleItemsprivate introundingPowerOfTen
-
Constructor Summary
Constructors Constructor Description ScaleCalculator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidcomputeIncrement()Computes the scale increment.voidcomputeScaleValues()Drives the computation of the axis increment and related values taking into account the user specified rounding criteria.doublegetIncrement()doublegetMaxValue()doublegetMinValue()intgetNumberOfScaleItems()intgetRoundingPowerOfTen()protected doubleround(double value, double powerOfTen)Rounds the passed value by the power of ten specifiedprotected voidroundTheIncrement(double powerOfTen)Rounds the scale increment up by the power of ten specified in the properties.voidsetMaxValue(double maxValue)voidsetMinValue(double minValue)voidsetNumberOfScaleItems(int numberOfScaleItems)voidsetRoundingPowerOfTen(int powerOfTen)Sets the exponent power of ten to round values to.java.lang.StringtoString()
-
-
-
Method Detail
-
computeIncrement
protected abstract void computeIncrement()
Computes the scale increment.
-
computeScaleValues
public final void computeScaleValues()
Drives the computation of the axis increment and related values taking into account the user specified rounding criteria. So if you specify to round to the nearest 100 and give an increment of 2.5, the increment will become 100.
-
setMinValue
public final void setMinValue(double minValue)
-
getMinValue
public final double getMinValue()
-
setMaxValue
public final void setMaxValue(double maxValue)
-
getMaxValue
public final double getMaxValue()
-
getIncrement
public final double getIncrement()
-
getNumberOfScaleItems
public int getNumberOfScaleItems()
-
setNumberOfScaleItems
public void setNumberOfScaleItems(int numberOfScaleItems)
-
setRoundingPowerOfTen
public final void setRoundingPowerOfTen(int powerOfTen)
Sets the exponent power of ten to round values to.- Parameters:
powerOfTen- exponent of ten to round to: 1=10, 2=100, -2=.01
-
getRoundingPowerOfTen
public final int getRoundingPowerOfTen()
-
round
protected double round(double value, double powerOfTen)Rounds the passed value by the power of ten specified- Parameters:
value- the value to roundpowerOfTen- the product of 10 times the rounding property.- Returns:
- double the rounded result
-
roundTheIncrement
protected void roundTheIncrement(double powerOfTen)
Rounds the scale increment up by the power of ten specified in the properties.- Parameters:
powerOfTen- the value of 10 times the rounding property.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- Returns:
-
-