view gnv-artifacts/src/main/java/de/intevation/gnv/state/MinMaxState.java @ 364:2413273f1c13

Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly. gnv-artifacts/trunk@439 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 16 Dec 2009 11:58:44 +0000
parents e964a3d8f7bc
children b7bb66440cc8
line wrap: on
line source
/**
 *
 */
package de.intevation.gnv.state;

import java.util.ArrayList;
import java.util.Collection;

import org.apache.log4j.Logger;

import de.intevation.gnv.geobackend.base.Result;
import de.intevation.gnv.state.describedata.DefaultMinMaxDescribeData;
import de.intevation.gnv.state.describedata.DescribeData;

/**
 * @author Tim Englich <tim.englich@intevation.de>
 * 
 */
public class MinMaxState extends StateBase {

    /**
     * The UID of this Class
     */
    private static final long serialVersionUID = -3525903792105187408L;
    /**
     * the logger, used to log exceptions and additonaly information
     */
    private static Logger log = Logger.getLogger(MinMaxState.class);

    /**
     * Constructor
     */
    public MinMaxState() {
        super();
    }

    /**
     * @see de.intevation.gnv.state.StateBase#purifyResult(java.util.Collection,
     *      java.lang.String)
     */
    @Override
    protected void purifyResult(Collection<Result> result, String uuid) {
        log.debug("MinMaxState.purifyResult");
        Collection<Object> describeData = this.getDescibeData(uuid);
        if (describeData == null) {
            describeData = new ArrayList<Object>();
        }
        if (result != null && result.size() == 1) {
            
            Result value = result.iterator().next();
            DescribeData values = new DefaultMinMaxDescribeData(this.dataName, 
                                                               value.getObject("MIN"), 
                                                               value.getObject("MAX"));
            log.debug(values.toString());
            describeData.add(values);
        } else {
            log.warn("Result cannot be handled as MinMax Resultset");
        }
        this.setDescibeData(uuid, describeData);
    }

}

http://dive4elements.wald.intevation.org