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 Details

    • minValue

      private double minValue
    • maxValue

      private double maxValue
    • roundingPowerOfTen

      private int roundingPowerOfTen
    • numberOfScaleItems

      private int numberOfScaleItems
    • increment

      protected double increment
  • Constructor Details

    • ScaleCalculator

      public ScaleCalculator()
  • Method Details

    • 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: