view flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixChartGenerator.java @ 4282:8b4988815974

Added marker for Ws and Qs in Historical Discharge WQ charts. Therefore, the XYChartGenerator got two new methods addDomainMarker(Marker, boolean) and addValueMarker(Marker, boolean). The boolean parameters determine, if the marker should be visible or not. This is analogous to addAxisSeries(XYSeries, int, boolean).
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 29 Oct 2012 05:59:27 +0100
parents b81f328da582
children dd8a63002fb8
line wrap: on
line source
package de.intevation.flys.exports.fixings;

import de.intevation.artifacts.ArtifactNamespaceContext;
import de.intevation.artifacts.CallContext;
import de.intevation.artifacts.common.utils.XMLUtils;
import de.intevation.flys.exports.XYChartGenerator;

import java.io.OutputStream;

import org.apache.log4j.Logger;
import org.w3c.dom.Document;

/**
 * Base class for FixChartGenerator.
 */
public abstract class FixChartGenerator
extends XYChartGenerator
{
    /** Private logger. */
    private static Logger logger = Logger.getLogger(FixChartGenerator.class);

    public static final Double INVALID_KM = Double.valueOf(-1d);
    public static final String CURRENT_KM = "currentKm";
    public static final String XPATH_CHART_CURRENTKM =
        "/art:action/art:attributes/art:currentKm/@art:km";

    @Override
    public void init(Document request, OutputStream out, CallContext context) {
        super.init(request, out, context);

        Double currentKm = getCurrentKmFromRequest(request);

        if (logger.isDebugEnabled()) {
            logger.debug("currentKm = " + currentKm);
        }

        context.putContextValue(CURRENT_KM, currentKm);
    }

    public static final Double getCurrentKmFromRequest(Document request) {

        String km = XMLUtils.xpathString(
            request,
            XPATH_CHART_CURRENTKM,
            ArtifactNamespaceContext.INSTANCE);

        if (km == null) {
            return INVALID_KM;
        }

        try {
            return Double.valueOf(km);
        }
        catch (NumberFormatException nfe) {
            return INVALID_KM;
        }
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org