Example usage for org.jfree.chart.axis CategoryTick getRotationAnchor

List of usage examples for org.jfree.chart.axis CategoryTick getRotationAnchor

Introduction

In this page you can find the example usage for org.jfree.chart.axis CategoryTick getRotationAnchor.

Prototype

public TextAnchor getRotationAnchor() 

Source Link

Document

Returns the text anchor that defines the point around which the label is rotated.

Usage

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   w  w  w  .  j  a v  a2 s.  c  o 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/*from   w  w  w . 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;
}