Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixChartGenerator.java @ 3200:099f18a4e227
Only dates as point labels
flys-artifacts/trunk@4817 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Wed, 27 Jun 2012 16:12:32 +0000 |
parents | 960307cf2adc |
children | 06ae0258269b |
line wrap: on
line source
package de.intevation.flys.exports.fixings; import org.w3c.dom.Element; import org.w3c.dom.Document; import org.apache.log4j.Logger; import java.io.OutputStream; import javax.xml.xpath.XPathConstants; import de.intevation.artifacts.ArtifactNamespaceContext; import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.artifacts.CallContext; import de.intevation.flys.exports.XYChartGenerator; public abstract class FixChartGenerator extends XYChartGenerator { private static Logger logger = Logger.getLogger(FixChartGenerator.class); public static final String XPATH_CHART_CURRENTKM = "/art:action/art:attributes/art:currentKm"; @Override public void init(Document request, OutputStream out, CallContext context) { super.init(request, out, context); logger.debug("currentKm = " + new Double(getCurrentKmFromRequest())); context.putContextValue("currentKm", new Double(getCurrentKmFromRequest())); } public double getCurrentKmFromRequest() { Element km = (Element)XMLUtils.xpath( request, XPATH_CHART_CURRENTKM, XPathConstants.NODE, ArtifactNamespaceContext.INSTANCE); if (km == null) { return -1d; } String uri = ArtifactNamespaceContext.NAMESPACE_URI; String currentKm = km.getAttributeNS(uri, "km"); try { double d = Double.valueOf(currentKm).doubleValue(); return d; } catch(NumberFormatException nfe) { return -1d; } } }