Example usage for org.jfree.text TextBlock TextBlock

List of usage examples for org.jfree.text TextBlock TextBlock

Introduction

In this page you can find the example usage for org.jfree.text TextBlock TextBlock.

Prototype

public TextBlock() 

Source Link

Document

Creates a new empty text block.

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;
    }/*w  ww .j  av a  2  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//ww w  . j a  v a 2 s.  com
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;
}