Example usage for org.jfree.data.time DateRange getUpperDate

List of usage examples for org.jfree.data.time DateRange getUpperDate

Introduction

In this page you can find the example usage for org.jfree.data.time DateRange getUpperDate.

Prototype

public Date getUpperDate() 

Source Link

Document

Returns the upper (later) date for the range.

Usage

From source file:org.jfree.data.time.DateRangeTest.java

/**
 * Confirm that a DateRange is immutable.
 */// w w w.  j a v  a  2 s  .  c  o m
@Test
public void testImmutable() {
    Date d1 = new Date(10L);
    Date d2 = new Date(20L);
    DateRange r = new DateRange(d1, d2);
    d1.setTime(11L);
    assertEquals(new Date(10L), r.getLowerDate());
    r.getUpperDate().setTime(22L);
    assertEquals(new Date(20L), r.getUpperDate());
}

From source file:figs.treeVisualization.gui.PhyloDateAxis.java

/**
 * Translates the data value to the display coordinates (Java 2D User Space)
 * of the chart.// w  w  w.j av a  2 s.c  o m
 *
 * @param value  the date to be plotted.
 * @param area  the rectangle (in Java2D space) where the data is to be 
 *              plotted.
 * @param edge  the axis location.
 *
 * @return The coordinate corresponding to the supplied data value.
 * 
 * Original method is in <code>org.jfree.chart.axis.DateAxis</code>
 */
@Override
public double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge) {

    Timeline timeline = this.getTimeline();
    value = timeline.toTimelineValue((long) value);

    DateRange range = (DateRange) getRange();
    double axisMin = timeline.toTimelineValue(range.getLowerDate());
    double axisMax = timeline.toTimelineValue(range.getUpperDate());
    double result = 0.0;
    if (RectangleEdge.isTopOrBottom(edge)) {
        double minX = area.getX();
        double maxX = area.getMaxX();
        if (isInverted()) {
            result = maxX + ((value - axisMin) / (axisMax - axisMin)) * (minX - maxX);
        } else {
            result = minX + ((value - axisMin) / (axisMax - axisMin)) * (maxX - minX);
        }
    } else if (RectangleEdge.isLeftOrRight(edge)) {
        //double minY = area.getMinY();
        //double maxY = area.getMaxY();
        double minY = area.getY();
        double maxY = area.getHeight();
        if (isInverted()) {
            result = minY + (((value - axisMin) / (axisMax - axisMin)) * (maxY - minY));
        } else {
            result = maxY - (((value - axisMin) / (axisMax - axisMin)) * (maxY - minY));
        }
    }
    return result;

}