view flys-artifacts/src/main/java/de/intevation/flys/exports/StyledSeriesBuilder.java @ 2581:afebbe9c2fce

Added a new Artifact for loading existing 'floodmaps' via datacage. flys-artifacts/trunk@4130 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 08 Mar 2012 13:44:51 +0000
parents 63f44b8b41a3
children 9e8459c2e7d4
line wrap: on
line source
package de.intevation.flys.exports;

import org.apache.log4j.Logger;

import org.jfree.data.xy.XYSeries;

import de.intevation.flys.artifacts.model.WKms; 
import de.intevation.flys.artifacts.model.WQKms; 

/**
 * Helper to create and modify StyledXYSeries.
 */
public class StyledSeriesBuilder {

    private static final Logger logger = Logger.getLogger
        (StyledSeriesBuilder.class);


    /**
     * Trivial, hidden constructor.
     */
    private StyledSeriesBuilder() {
    }


    /**
     * Add points to series.
     *
     * @param series Series to add points to.
     * @param points Points to add to series, points[0] to 1st dim, points[1]
     *               to 2nd dim.
     */
    public static void addPoints(XYSeries series, double[][] points) {
        if (points == null || points.length <= 1) {
            return;
        }
        double [] xPoints = points[0];
        double [] yPoints = points[1];
        for (int i = 0; i < xPoints.length; i++) {
            if (Double.isNaN(xPoints[i]) || Double.isNaN(yPoints[i])) {
                logger.warn ("Skipping NaN in StyledSeriesBuilder.");
                continue;
            }
            series.add(xPoints[i], yPoints[i], false);
        }
    }


    /**
     * Add points to series (km to 1st dim, w to 2nd dim).
     *
     * @param series Series to add points to.
     * @param points Points to add to series.
     */
    public static void addPoints(XYSeries series, WKms wkms) {
        if (wkms == null) {
            return;
        }

        int size = wkms.size();

        for (int i = 0; i < size; i++) {
            series.add(wkms.getKm(i), wkms.getW(i), false);
        }
    }


    /**
     * Add points to series (km to 1st dim, q to 2nd dim).
     *
     * @param series Series to add points to.
     * @param points Points to add to series.
     */
    public static void addPointsKmQ(XYSeries series, WQKms wqkms) {
        if (wqkms == null) {
            return;
        }

        int size = wqkms.size();

        for (int i = 0; i < size; i++) {
            series.add(wqkms.getKm(i), wqkms.getQ(i), false);
        }
    }


    /**
     * Add points to series (q to 1st dim, w to 2nd dim).
     *
     * @param series Series to add points to.
     * @param points Points to add to series.
     */
    public static void addPointsQW(XYSeries series, WQKms wqkms) {
        if (wqkms == null) {
            return;
        }

        int size = wqkms.size();

        for (int i = 0; i < size; i++) {
            series.add(wqkms.getQ(i), wqkms.getW(i));
        }
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org