Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java @ 412:046bd86ae41d
Improved the OutGenerator interface to set a master artifact for the out generation.
flys-artifacts/trunk@1874 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 10 May 2011 10:26:26 +0000 |
parents | fc3ac59c3c8b |
children | bab867fb37e8 |
line wrap: on
line source
package de.intevation.flys.exports; import java.io.IOException; import java.io.OutputStream; import org.apache.log4j.Logger; import org.w3c.dom.Document; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; import de.intevation.flys.model.River; import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.resources.Resources; /** * The base class for chart creation. It should provide some basic things that * equal in all chart types. * * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public abstract class ChartGenerator implements OutGenerator { private static Logger logger = Logger.getLogger(ChartGenerator.class); /** The document of the incoming out() request.*/ protected Document request; /** The output stream where the data should be written to.*/ protected OutputStream out; /** The CallContext object.*/ protected CallContext context; /** The artifact that is used to decorate the chart with meta information.*/ protected Artifact master; public void init(Document request, OutputStream out, CallContext context) { logger.debug("ChartGenerator.init"); this.request = request; this.out = out; this.context = context; } public void setMasterArtifact(Artifact master) { this.master = master; } protected String msg(String key, String def) { return Resources.getMsg(context.getMeta(), key, def); } protected String msg(String key, String def, Object[] args) { return Resources.getMsg(context.getMeta(), key, def, args); } protected String getRiverName() { FLYSArtifact flys = (FLYSArtifact) master; River river = flys.getRiver(); return river != null ? river.getName() : ""; } protected double[] getRange() { FLYSArtifact flys = (FLYSArtifact) master; return flys.getDistance(); } public abstract void doOut(Artifact artifact, String facet, Document attr); public abstract void generate() throws IOException; } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :