Class TickFactory


  • public class TickFactory
    extends java.lang.Object
    Tick factory produces the different axis ticks. When specifying a format and given the screen size parameters and range it will return a list of Ticks
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  TickFactory.TickFormatting
      tick formatting modes
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static boolean compare​(boolean isGreaterThan, double a, double b)  
      private void createFormatString​(int precision, boolean useExponent)  
      private int determineNumLogTicks​(double min, double max, int maxTicks, boolean allowMinMaxOver)  
      private double determineNumTicks​(double min, double max, int maxTicks, boolean allowMinMaxOver)  
      private static java.math.BigDecimal divide​(java.math.BigDecimal dividend, int divisor)  
      java.util.List<Tick> generateIndexBasedTicks​(double min, double max, int maxTicks)
      Generate a list of ticks that span range given by min and max.
      java.util.List<Tick> generateLogTicks​(double min, double max, int maxTicks, boolean allowMinMaxOver, boolean tight)  
      java.util.List<Tick> generateTicks​(double min, double max, int maxTicks, boolean allowMinMaxOver, boolean tight)
      Generate a list of ticks that span range given by min and max.
      private java.lang.String getTickString​(double value)  
      private boolean inRange​(double x, double min, double max)  
      private boolean inRangeLog​(double x, double min, double max)  
      private static int log10​(java.math.BigDecimal x)  
      protected static java.math.BigDecimal nicenum​(java.math.BigDecimal x, boolean round)  
      protected static double roundDown​(java.math.BigDecimal numerator, java.math.BigDecimal denominator)
      Round numerator down to multiples of denominators
      protected static double roundUp​(java.math.BigDecimal numerator, java.math.BigDecimal denominator)
      Round numerator up to multiples of denominators
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EPSILON

        private static final java.math.BigDecimal EPSILON
      • DIGITS_UPPER_LIMIT

        private static final int DIGITS_UPPER_LIMIT
        limit for number of digits to display left of decimal point
        See Also:
        Constant Field Values
      • DIGITS_LOWER_LIMIT

        private static final int DIGITS_LOWER_LIMIT
        limit for number of zeros to display right of decimal point
        See Also:
        Constant Field Values
      • ROUND_FRACTION

        private static final double ROUND_FRACTION
        fraction of denominator to round to
        See Also:
        Constant Field Values
      • BREL_ERROR

        private static final java.math.BigDecimal BREL_ERROR
      • REL_ERROR

        private static final double REL_ERROR
      • graphMin

        private double graphMin
      • graphMax

        private double graphMax
      • tickFormat

        private java.lang.String tickFormat
      • numberOfIntervals

        private int numberOfIntervals
      • isReversed

        private boolean isReversed
      • INDEX_FORMAT

        private static final java.text.DecimalFormat INDEX_FORMAT
    • Method Detail

      • getTickString

        private java.lang.String getTickString​(double value)
      • createFormatString

        private void createFormatString​(int precision,
                                        boolean useExponent)
      • roundDown

        protected static double roundDown​(java.math.BigDecimal numerator,
                                          java.math.BigDecimal denominator)
        Round numerator down to multiples of denominators
        Parameters:
        numerator -
        denominator -
        Returns:
        rounded down value
      • roundUp

        protected static double roundUp​(java.math.BigDecimal numerator,
                                        java.math.BigDecimal denominator)
        Round numerator up to multiples of denominators
        Parameters:
        numerator -
        denominator -
        Returns:
        rounded up value
      • log10

        private static int log10​(java.math.BigDecimal x)
        Parameters:
        x -
        Returns:
        floor of log 10
      • divide

        private static java.math.BigDecimal divide​(java.math.BigDecimal dividend,
                                                   int divisor)
      • nicenum

        protected static java.math.BigDecimal nicenum​(java.math.BigDecimal x,
                                                      boolean round)
        Parameters:
        x -
        round - if true, then round else take ceiling
        Returns:
        a nice number
      • determineNumTicks

        private double determineNumTicks​(double min,
                                         double max,
                                         int maxTicks,
                                         boolean allowMinMaxOver)
      • inRange

        private boolean inRange​(double x,
                                double min,
                                double max)
      • generateTicks

        public java.util.List<Tick> generateTicks​(double min,
                                                  double max,
                                                  int maxTicks,
                                                  boolean allowMinMaxOver,
                                                  boolean tight)
        Generate a list of ticks that span range given by min and max. The maximum number of ticks is exceed by one in the case where the range straddles zero.
        Parameters:
        min -
        max -
        maxTicks -
        allowMinMaxOver - allow min/maximum overwrite
        tight - if true then remove ticks outside range
        Returns:
        a list of the ticks for the axis
      • compare

        private static boolean compare​(boolean isGreaterThan,
                                       double a,
                                       double b)
      • generateIndexBasedTicks

        public java.util.List<Tick> generateIndexBasedTicks​(double min,
                                                            double max,
                                                            int maxTicks)
        Generate a list of ticks that span range given by min and max.
        Parameters:
        min -
        max -
        maxTicks -
        Returns:
        a list of the ticks for the axis
      • determineNumLogTicks

        private int determineNumLogTicks​(double min,
                                         double max,
                                         int maxTicks,
                                         boolean allowMinMaxOver)
      • inRangeLog

        private boolean inRangeLog​(double x,
                                   double min,
                                   double max)
      • generateLogTicks

        public java.util.List<Tick> generateLogTicks​(double min,
                                                     double max,
                                                     int maxTicks,
                                                     boolean allowMinMaxOver,
                                                     boolean tight)
        Parameters:
        min - (must be >0)
        max - (must be >0)
        maxTicks -
        allowMinMaxOver - allow min/maximum overwrite
        tight - if true then remove ticks outside range
        Returns:
        a list of the ticks for the axis