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 Object

  Base 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 and Description
    --- | ---
    `protected double` | `increment`
    `private double` | `maxValue`
    `private double` | `minValue`
    `private int` | `numberOfScaleItems`
    `private int` | `roundingPowerOfTen`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ScaleCalculator()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract void` | `computeIncrement()` Computes the scale increment.
    `void` | `computeScaleValues()` Drives the computation of the axis increment and related values taking into account the user specified rounding criteria.
    `double` | `getIncrement()`
    `double` | `getMaxValue()`
    `double` | `getMinValue()`
    `int` | `getNumberOfScaleItems()`
    `int` | `getRoundingPowerOfTen()`
    `protected double` | `round(double value, double powerOfTen)` Rounds the passed value by the power of ten specified
    `protected void` | `roundTheIncrement(double powerOfTen)` Rounds the scale increment up by the power of ten specified in the properties.
    `void` | `setMaxValue(double maxValue)`
    `void` | `setMinValue(double minValue)`
    `void` | `setNumberOfScaleItems(int numberOfScaleItems)`
    `void` | `setRoundingPowerOfTen(int powerOfTen)` Sets the exponent power of ten to round values to.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### minValue

          private double minValue

    - #### maxValue

          private double maxValue

    - #### roundingPowerOfTen

          private int roundingPowerOfTen

    - #### numberOfScaleItems

          private int numberOfScaleItems

    - #### increment

          protected double increment

  - ### Constructor Detail

    - #### ScaleCalculator

          public ScaleCalculator()

  - ### 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 round
        `powerOfTen` - 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 String toString()

      Overrides:
        `toString` in class `Object`
      Returns: