view flys-artifacts/src/main/java/de/intevation/flys/jfree/TimeBounds.java @ 2395:cd4fb19ab892

Some API changes in ChartGenerator and XYChartGenerator for fetching user specified zoom values. flys-artifacts/trunk@4021 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 10 Feb 2012 08:56:19 +0000
parents d0e7afb3696b
children c38063bf99da
line wrap: on
line source
package de.intevation.flys.jfree;

import java.util.Date;


import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.axis.ValueAxis;


/**
 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
 */
public class TimeBounds implements Bounds {

    protected long lower;
    protected long upper;


    public TimeBounds(long lower, long upper) {
        this.lower = lower;
        this.upper = upper;
    }


    @Override
    public Number getLower() {
        return Long.valueOf(lower);
    }


    @Override
    public Number getUpper() {
        return Long.valueOf(upper);
    }


    @Override
    public void applyBounds(ValueAxis axis) {
        DateAxis dateAxis = (DateAxis) axis;

        dateAxis.setMinimumDate(new Date(lower));
        dateAxis.setMaximumDate(new Date(upper));
    }


    @Override
    public Bounds combine(Bounds bounds) {
        if (bounds == null) {
            return this;
        }

        TimeBounds other = (TimeBounds) bounds;

        long otherLower = other.getLower().longValue();
        long otherUpper = other.getUpper().longValue();

        return new TimeBounds(
            otherLower < lower ? otherLower : lower,
            otherUpper > upper ? otherUpper : upper);
    }


    @Override
    public String toString() {
        return "TimeBounds=[" + lower + " ; " + upper + "]";
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org