1 41 42 package org.jfree.chart.axis; 43 44 import java.text.DecimalFormat ; 45 46 51 public class StandardTickUnitSource implements TickUnitSource { 52 53 54 private static final double LOG_10_VALUE = Math.log(10.0); 55 56 63 public TickUnit getLargerTickUnit(TickUnit unit) { 64 double x = unit.getSize(); 65 double log = Math.log(x) / LOG_10_VALUE; 66 double higher = Math.ceil(log); 67 return new NumberTickUnit( 68 Math.pow(10, higher), new DecimalFormat ("0.0E0") 69 ); 70 } 71 72 80 public TickUnit getCeilingTickUnit(TickUnit unit) { 81 return getLargerTickUnit(unit); 82 } 83 84 92 public TickUnit getCeilingTickUnit(double size) { 93 double log = Math.log(size) / LOG_10_VALUE; 94 double higher = Math.ceil(log); 95 return new NumberTickUnit( 96 Math.pow(10, higher), new DecimalFormat ("0.0E0") 97 ); 98 } 99 100 } 101 | Popular Tags |