Example usage for org.jfree.chart.axis TickUnit getSize

List of usage examples for org.jfree.chart.axis TickUnit getSize

Introduction

In this page you can find the example usage for org.jfree.chart.axis TickUnit getSize.

Prototype

public double getSize() 

Source Link

Document

Returns the size of the tick unit.

Usage

From source file:lucee.runtime.chart.TicketUnitImpl.java

/**
 * Constructor of the class//  w  ww . j av  a 2s . co m
 * @param unit
 */
public TicketUnitImpl(int labelFormat, TickUnit unit) {
    this(labelFormat, unit.getSize());
}

From source file:lucee.runtime.chart.TickUnitWrap.java

public TickUnitWrap(TickUnit tickUnit, int labelFormat) {
    super(tickUnit.getSize());
    this.tickUnit = tickUnit;
    this.labelFormat = labelFormat;
}

From source file:edu.jhuapl.graphs.jfreechart.utils.CustomLabelNumberAxis.java

@Override
protected List<Tick> refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) {
    List<Tick> result = new ArrayList<Tick>();
    Font tickLabelFont = getTickLabelFont();
    g2.setFont(tickLabelFont);//from  w ww . j  av a2 s. co m

    if (isAutoTickUnitSelection()) {
        selectAutoTickUnit(g2, dataArea, edge);
    }

    TickUnit tu = getTickUnit();
    double size = tu.getSize();
    int count = this.tickCount != null ? this.tickCount : calculateVisibleTickCount();
    double lowestTickValue = this.lowestTickValue != null ? this.lowestTickValue
            : calculateLowestVisibleTickValue();

    if (count <= ValueAxis.MAXIMUM_TICK_COUNT) {
        int minorTickSpaces = getMinorTickCount();

        if (minorTickSpaces <= 0) {
            minorTickSpaces = tu.getMinorTickCount();
        }

        for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++) {
            double minorTickValue = lowestTickValue - size * minorTick / minorTickSpaces;

            if (getRange().contains(minorTickValue)) {
                result.add(new NumberTick(TickType.MINOR, minorTickValue, "", TextAnchor.TOP_CENTER,
                        TextAnchor.CENTER, 0.0));
            }
        }

        for (int i = 0; i < count; i++) {
            double currentTickValue = lowestTickValue + (i * size);
            String tickLabel = tickValueToLabelMapping.get(currentTickValue);

            if (tickLabel == null) {
                NumberFormat formatter = getNumberFormatOverride();

                if (formatter != null) {
                    tickLabel = formatter.format(currentTickValue);
                } else {
                    tickLabel = getTickUnit().valueToString(currentTickValue);
                }
            }

            TextAnchor anchor = null;
            TextAnchor rotationAnchor = null;
            double angle = 0.0;

            if (isVerticalTickLabels()) {
                anchor = TextAnchor.CENTER_RIGHT;
                rotationAnchor = TextAnchor.CENTER_RIGHT;

                if (edge == RectangleEdge.TOP) {
                    angle = Math.PI / 2.0;
                } else {
                    angle = -Math.PI / 2.0;
                }
            } else {
                if (edge == RectangleEdge.TOP) {
                    anchor = TextAnchor.BOTTOM_CENTER;
                    rotationAnchor = TextAnchor.BOTTOM_CENTER;
                } else {
                    anchor = TextAnchor.TOP_CENTER;
                    rotationAnchor = TextAnchor.TOP_CENTER;
                }
            }

            Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle);
            result.add(tick);
            double nextTickValue = lowestTickValue + ((i + 1) * size);

            for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++) {
                double minorTickValue = currentTickValue
                        + (nextTickValue - currentTickValue) * minorTick / minorTickSpaces;

                if (getRange().contains(minorTickValue)) {
                    result.add(new NumberTick(TickType.MINOR, minorTickValue, "", TextAnchor.TOP_CENTER,
                            TextAnchor.CENTER, 0.0));
                }
            }
        }
    }

    return result;
}

From source file:edu.jhuapl.graphs.jfreechart.utils.CustomLabelNumberAxis.java

@Override
protected List<Tick> refreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) {
    List<Tick> result = new ArrayList<Tick>();
    Font tickLabelFont = getTickLabelFont();
    g2.setFont(tickLabelFont);//from w ww.  j a  va  2s.  co m

    if (isAutoTickUnitSelection()) {
        selectAutoTickUnit(g2, dataArea, edge);
    }

    TickUnit tu = getTickUnit();
    double size = tu.getSize();
    int count = this.tickCount != null ? this.tickCount : calculateVisibleTickCount();
    double lowestTickValue = this.lowestTickValue != null ? this.lowestTickValue
            : calculateLowestVisibleTickValue();

    if (count <= ValueAxis.MAXIMUM_TICK_COUNT) {
        int minorTickSpaces = getMinorTickCount();

        if (minorTickSpaces <= 0) {
            minorTickSpaces = tu.getMinorTickCount();
        }

        for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++) {
            double minorTickValue = lowestTickValue - size * minorTick / minorTickSpaces;

            if (getRange().contains(minorTickValue)) {
                result.add(new NumberTick(TickType.MINOR, minorTickValue, "", TextAnchor.TOP_CENTER,
                        TextAnchor.CENTER, 0.0));
            }
        }

        for (int i = 0; i < count; i++) {
            double currentTickValue = lowestTickValue + (i * size);
            String tickLabel = tickValueToLabelMapping.get(currentTickValue);

            if (tickLabel == null) {
                NumberFormat formatter = getNumberFormatOverride();

                if (formatter != null) {
                    tickLabel = formatter.format(currentTickValue);
                } else {
                    tickLabel = getTickUnit().valueToString(currentTickValue);
                }
            }

            TextAnchor anchor = null;
            TextAnchor rotationAnchor = null;
            double angle = 0.0;

            if (isVerticalTickLabels()) {
                if (edge == RectangleEdge.LEFT) {
                    anchor = TextAnchor.BOTTOM_CENTER;
                    rotationAnchor = TextAnchor.BOTTOM_CENTER;
                    angle = -Math.PI / 2.0;
                } else {
                    anchor = TextAnchor.BOTTOM_CENTER;
                    rotationAnchor = TextAnchor.BOTTOM_CENTER;
                    angle = Math.PI / 2.0;
                }
            } else {
                if (edge == RectangleEdge.LEFT) {
                    anchor = TextAnchor.CENTER_RIGHT;
                    rotationAnchor = TextAnchor.CENTER_RIGHT;
                } else {
                    anchor = TextAnchor.CENTER_LEFT;
                    rotationAnchor = TextAnchor.CENTER_LEFT;
                }
            }

            Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle);
            result.add(tick);
            double nextTickValue = lowestTickValue + ((i + 1) * size);

            for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++) {
                double minorTickValue = currentTickValue
                        + (nextTickValue - currentTickValue) * minorTick / minorTickSpaces;

                if (getRange().contains(minorTickValue)) {
                    result.add(new NumberTick(TickType.MINOR, minorTickValue, "", TextAnchor.TOP_CENTER,
                            TextAnchor.CENTER, 0.0));
                }
            }
        }
    }

    return result;
}