1 package hudson.util; 2 3 import org.jfree.chart.axis.CategoryAxis; 4 import org.jfree.ui.RectangleEdge; 5 6 import java.awt.geom.Rectangle2D ; 7 8 12 public final class ShiftedCategoryAxis extends CategoryAxis { 13 public ShiftedCategoryAxis(String label) { 14 super(label); 15 } 16 17 protected double calculateCategorySize(int categoryCount, Rectangle2D area, RectangleEdge edge) { 18 return super.calculateCategorySize(categoryCount-1, area, edge); 21 } 22 23 public double getCategoryEnd(int category, int categoryCount, Rectangle2D area, RectangleEdge edge) { 24 return super.getCategoryStart(category, categoryCount, area, edge) 25 + calculateCategorySize(categoryCount, area, edge) / 2; 26 } 27 28 public double getCategoryMiddle(int category, int categoryCount, Rectangle2D area, RectangleEdge edge) { 29 return super.getCategoryStart(category, categoryCount, area, edge); 30 } 31 32 public double getCategoryStart(int category, int categoryCount, Rectangle2D area, RectangleEdge edge) { 33 return super.getCategoryStart(category, categoryCount, area, edge) 34 - calculateCategorySize(categoryCount, area, edge) / 2; 35 } 36 } 37 | Popular Tags |