@Test public void testCalculateTickSpacingHuge() { assertEquals( 5e10, StableTicksAxis.calculateTickSpacing( 23e10, 5 ), 0.0001e10 ); }
public static double calculateTickSpacing( double delta, int maxTicks ) { if ( delta == 0.0 ) return 0.0; if ( delta <= 0.0 ) throw new IllegalArgumentException( "delta must be positive" ); if ( maxTicks < 1 ) throw new IllegalArgumentException( "must be at least one tick" ); int factor = (int) Math.log10( delta ); int divider = 0; double numTicks = delta / ( dividers[divider] * Math.pow( 10, factor ) ); if ( numTicks < maxTicks ) { while ( numTicks < maxTicks ) { --divider; if ( divider < 0 ) { --factor; divider = dividers.length - 1; } numTicks = delta / ( dividers[divider] * Math.pow( 10, factor ) ); } if ( numTicks != maxTicks ) { ++divider; if ( divider >= dividers.length ) { ++factor; divider = 0; } } } else { while ( numTicks > maxTicks ) { ++divider; if ( divider >= dividers.length ) { ++factor; divider = 0; } numTicks = delta / ( dividers[divider] * Math.pow( 10, factor ) ); } } return dividers[divider] * Math.pow( 10, factor ); }
StableTicksAxis extends ValueAxis<Number> { public static double calculateTickSpacing( double delta, int maxTicks ) { if ( delta == 0.0 ) return 0.0; if ( delta <= 0.0 ) throw new IllegalArgumentException( "delta must be positive" ); if ( maxTicks < 1 ) throw new IllegalArgumentException( "must be at least one tick" ); int factor = (int) Math.log10( delta ); int divider = 0; double numTicks = delta / ( dividers[divider] * Math.pow( 10, factor ) ); if ( numTicks < maxTicks ) { while ( numTicks < maxTicks ) { --divider; if ( divider < 0 ) { --factor; divider = dividers.length - 1; } numTicks = delta / ( dividers[divider] * Math.pow( 10, factor ) ); } if ( numTicks != maxTicks ) { ++divider; if ( divider >= dividers.length ) { ++factor; divider = 0; } } } else { while ( numTicks > maxTicks ) { ++divider; if ( divider >= dividers.length ) { ++factor; divider = 0; } numTicks = delta / ( dividers[divider] * Math.pow( 10, factor ) ); } } return dividers[divider] * Math.pow( 10, factor ); } }
StableTicksAxis extends ValueAxis<Number> { public static double calculateTickSpacing( double delta, int maxTicks ) { if ( delta == 0.0 ) return 0.0; if ( delta <= 0.0 ) throw new IllegalArgumentException( "delta must be positive" ); if ( maxTicks < 1 ) throw new IllegalArgumentException( "must be at least one tick" ); int factor = (int) Math.log10( delta ); int divider = 0; double numTicks = delta / ( dividers[divider] * Math.pow( 10, factor ) ); if ( numTicks < maxTicks ) { while ( numTicks < maxTicks ) { --divider; if ( divider < 0 ) { --factor; divider = dividers.length - 1; } numTicks = delta / ( dividers[divider] * Math.pow( 10, factor ) ); } if ( numTicks != maxTicks ) { ++divider; if ( divider >= dividers.length ) { ++factor; divider = 0; } } } else { while ( numTicks > maxTicks ) { ++divider; if ( divider >= dividers.length ) { ++factor; divider = 0; } numTicks = delta / ( dividers[divider] * Math.pow( 10, factor ) ); } } return dividers[divider] * Math.pow( 10, factor ); } StableTicksAxis();  StableTicksAxis( double lowerBound, double upperBound ); }
StableTicksAxis extends ValueAxis<Number> { public static double calculateTickSpacing( double delta, int maxTicks ) { if ( delta == 0.0 ) return 0.0; if ( delta <= 0.0 ) throw new IllegalArgumentException( "delta must be positive" ); if ( maxTicks < 1 ) throw new IllegalArgumentException( "must be at least one tick" ); int factor = (int) Math.log10( delta ); int divider = 0; double numTicks = delta / ( dividers[divider] * Math.pow( 10, factor ) ); if ( numTicks < maxTicks ) { while ( numTicks < maxTicks ) { --divider; if ( divider < 0 ) { --factor; divider = dividers.length - 1; } numTicks = delta / ( dividers[divider] * Math.pow( 10, factor ) ); } if ( numTicks != maxTicks ) { ++divider; if ( divider >= dividers.length ) { ++factor; divider = 0; } } } else { while ( numTicks > maxTicks ) { ++divider; if ( divider >= dividers.length ) { ++factor; divider = 0; } numTicks = delta / ( dividers[divider] * Math.pow( 10, factor ) ); } } return dividers[divider] * Math.pow( 10, factor ); } StableTicksAxis();  StableTicksAxis( double lowerBound, double upperBound ); AxisTickFormatter getAxisTickFormatter(); void setAxisTickFormatter( AxisTickFormatter axisTickFormatter ); double getAutoRangePadding(); DoubleProperty autoRangePaddingProperty(); void setAutoRangePadding( double autoRangePadding ); boolean isForceZeroInRange(); BooleanProperty forceZeroInRangeProperty(); void setForceZeroInRange( boolean forceZeroInRange ); static double calculateTickSpacing( double delta, int maxTicks ); }
StableTicksAxis extends ValueAxis<Number> { public static double calculateTickSpacing( double delta, int maxTicks ) { if ( delta == 0.0 ) return 0.0; if ( delta <= 0.0 ) throw new IllegalArgumentException( "delta must be positive" ); if ( maxTicks < 1 ) throw new IllegalArgumentException( "must be at least one tick" ); int factor = (int) Math.log10( delta ); int divider = 0; double numTicks = delta / ( dividers[divider] * Math.pow( 10, factor ) ); if ( numTicks < maxTicks ) { while ( numTicks < maxTicks ) { --divider; if ( divider < 0 ) { --factor; divider = dividers.length - 1; } numTicks = delta / ( dividers[divider] * Math.pow( 10, factor ) ); } if ( numTicks != maxTicks ) { ++divider; if ( divider >= dividers.length ) { ++factor; divider = 0; } } } else { while ( numTicks > maxTicks ) { ++divider; if ( divider >= dividers.length ) { ++factor; divider = 0; } numTicks = delta / ( dividers[divider] * Math.pow( 10, factor ) ); } } return dividers[divider] * Math.pow( 10, factor ); } StableTicksAxis();  StableTicksAxis( double lowerBound, double upperBound ); AxisTickFormatter getAxisTickFormatter(); void setAxisTickFormatter( AxisTickFormatter axisTickFormatter ); double getAutoRangePadding(); DoubleProperty autoRangePaddingProperty(); void setAutoRangePadding( double autoRangePadding ); boolean isForceZeroInRange(); BooleanProperty forceZeroInRangeProperty(); void setForceZeroInRange( boolean forceZeroInRange ); static double calculateTickSpacing( double delta, int maxTicks );  }