1 package de.laures.cewolf.cpp; 2 3 import java.util.Map ; 4 5 import org.jfree.chart.JFreeChart; 6 import org.jfree.chart.axis.CategoryAxis; 7 import org.jfree.chart.axis.CategoryLabelPositions; 8 import org.jfree.chart.plot.CategoryPlot; 9 import org.jfree.data.category.CategoryDataset; 10 11 import de.laures.cewolf.ChartPostProcessor; 12 13 30 31 public class RotatedAxisLabels implements ChartPostProcessor { 32 33 public void processChart(Object chart, Map params) { 34 CategoryPlot plot = (CategoryPlot) ((JFreeChart) chart).getPlot(); 35 36 CategoryAxis axis = plot.getDomainAxis(); 37 38 Number rotateThreshold = (Number ) params.get("rotate_at"); 39 Number skipThreshold = (Number ) params.get("skip_at"); 40 Number removeThreshold = (Number ) params.get("remove_at"); 41 42 CategoryDataset dataset = plot.getDataset(); 43 int iCategoryCount = dataset.getRowCount(); 44 45 if (rotateThreshold != null) 46 { 47 if (iCategoryCount >= rotateThreshold.intValue()) 48 { 49 axis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); 50 } 51 else 52 { 53 axis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD); 54 } 55 56 } 57 58 if (skipThreshold != null) 59 { 60 } 63 64 if (removeThreshold != null) 65 { 66 axis.setTickLabelsVisible(iCategoryCount < removeThreshold.intValue()); 67 } 68 } 69 70 } 71 | Popular Tags |