List of usage examples for org.jfree.chart.axis CategoryTick getLabelAnchor
public TextBlockAnchor getLabelAnchor()
From source file:dk.sdu.mmmi.featureous.views.codecharacterization.SparselyLabeledCategoryAxis.java
@Override @SuppressWarnings("unchecked") public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { List<CategoryTick> standardTicks = super.refreshTicks(g2, state, dataArea, edge); if (standardTicks.isEmpty()) { return standardTicks; }/*from ww w. j a v a 2 s . co m*/ int tickEvery = standardTicks.size() / labeledTicks; if (tickEvery < 1) { return standardTicks; } //Replace a few labels with blank ones List<CategoryTick> fixedTicks = new ArrayList<CategoryTick>(standardTicks.size()); //Skip the first tick so your 45degree labels don't fall of the edge CategoryTick tick = standardTicks.get(0); fixedTicks.add(new CategoryTick(tick.getCategory(), new TextBlock(), tick.getLabelAnchor(), tick.getRotationAnchor(), tick.getAngle())); for (int i = 1; i < standardTicks.size(); i++) { tick = standardTicks.get(i); if (i % tickEvery == 0) { fixedTicks.add(tick); } else { fixedTicks.add(new CategoryTick(tick.getCategory(), new TextBlock(), tick.getLabelAnchor(), tick.getRotationAnchor(), tick.getAngle())); } } return fixedTicks; }
From source file:edu.jhuapl.graphs.jfreechart.utils.SparselyLabeledCategoryAxis.java
@SuppressWarnings("unchecked") @Override/* w ww. j a v a 2 s.c o m*/ public List<CategoryTick> refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { List<CategoryTick> standardTicks = super.refreshTicks(g2, state, dataArea, edge); if (standardTicks.isEmpty()) { return standardTicks; } int tickEvery = standardTicks.size() / (maxLabeledTicks == 0 ? 1 : maxLabeledTicks); if (tickEvery < 1) { return standardTicks; } // replace some labels with blank ones List<CategoryTick> fixedTicks = new ArrayList<CategoryTick>(standardTicks.size()); for (int i = 0; i < standardTicks.size(); i++) { CategoryTick tick = standardTicks.get(i); if (i % tickEvery == 0) { fixedTicks.add(tick); } else { fixedTicks.add(new CategoryTick(tick.getCategory(), new TextBlock(), tick.getLabelAnchor(), tick.getRotationAnchor(), tick.getAngle())); } } return fixedTicks; }