Example usage for org.jfree.chart.axis DateTick getDate

List of usage examples for org.jfree.chart.axis DateTick getDate

Introduction

In this page you can find the example usage for org.jfree.chart.axis DateTick getDate.

Prototype

public Date getDate() 

Source Link

Document

Returns the date.

Usage

From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.DashDateAxis.java

/**
 * @see org.jfree.chart.axis.DateAxis#refreshTicksHorizontal(java.awt.Graphics2D, java.awt.geom.Rectangle2D,
 *      org.jfree.ui.RectangleEdge)/*  ww  w.  j  a  va 2 s  .  c om*/
 */

protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) {

    if (getDateTickLabelAngle() == 0.0) {
        return super.refreshTicksHorizontal(g2, dataArea, edge);
    } else {
        setVerticalTickLabels(true);
        List ticks = super.refreshTicksHorizontal(g2, dataArea, edge);
        List ret = new ArrayList();

        for (int i = 0; i < ticks.size(); i++) {
            Object tick = ticks.get(i);
            if (tick instanceof DateTick) {
                DateTick dateTick = (DateTick) tick;
                ret.add(new DateTick(dateTick.getDate(), dateTick.getText(), dateTick.getTextAnchor(),
                        dateTick.getRotationAnchor(), getDateTickLabelAngle()));
            } else {
                ret.add(tick);
            }
        }
        return ret;
    }
}

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

@SuppressWarnings("unchecked")
@Override/*  w w  w  .  j  av  a 2  s.c  o  m*/
protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) {
    double rotationAngleInRad = Math.toRadians(tickLabelAngle);
    //Template types are specified here for additional type safety.
    List<Tick> ticks = (List<Tick>) super.refreshTicksHorizontal(g2, dataArea, edge);
    List<Tick> ret = new ArrayList<Tick>();
    for (Tick tick : ticks) {
        if (tick instanceof DateTick) {
            DateTick dateTick = (DateTick) tick;

            //The anchor used depends on the label angle, as follows:
            TextAnchor textAnchor, rotationAnchor;

            double modRadians = rotationAngleInRad % (2 * Math.PI);
            //Handle case where user provided a negative angle value.
            if (modRadians < 0) {
                modRadians += 2 * Math.PI;
            }

            //For angles between 0-180 degrees:
            if (modRadians <= Math.PI) {
                textAnchor = TextAnchor.CENTER_LEFT;
                rotationAnchor = TextAnchor.CENTER_LEFT;
            }
            //For angles between 180-360 degrees:
            else {
                textAnchor = TextAnchor.CENTER_RIGHT;
                rotationAnchor = TextAnchor.CENTER_RIGHT;
            }
            ret.add(new DateTick(dateTick.getDate(), dateTick.getText(), textAnchor, rotationAnchor,
                    rotationAngleInRad));
        } else {
            ret.add(tick);
        }
    }

    return ret;
}