Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/exports/ChartInfoGenerator.java @ 1106:e9f66d63bdd0
Write user defined barriers into a shapefile that is placed in the Artifact's directory.
flys-artifacts/trunk@2609 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 30 Aug 2011 11:09:54 +0000 |
parents | 45cd58a2a2bb |
children | bdb05dc9b763 |
line wrap: on
line source
package de.intevation.flys.exports; import java.awt.Transparency; import java.io.IOException; import java.io.OutputStream; import org.w3c.dom.Document; import org.apache.log4j.Logger; import org.jfree.chart.ChartRenderingInfo; import org.jfree.chart.JFreeChart; import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; import de.intevation.artifactdatabase.state.Facet; import de.intevation.artifacts.common.utils.XMLUtils; /** * An OutGenerator that generates meta information for charts. A concrete * ChartInfoGenerator need to instantiate a concrete ChartGenerator and dispatch * the methods to that instance. The only thing this ChartInfoGenerator needs * to, is to overrite the generate() method which doesn't write the chart image * to the OutputStream but a Document that contains some meta information of the * created chart. * * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public abstract class ChartInfoGenerator implements OutGenerator { /** The logger used in this generator.*/ private static Logger logger = Logger.getLogger(ChartInfoGenerator.class); /** The OutGenerator that creates the charts.*/ protected XYChartGenerator generator; protected OutputStream out; public ChartInfoGenerator(XYChartGenerator generator) { this.generator = generator; } /** * Dispatches the operation to the instantiated generator. * * @param request * @param out * @param context */ public void init(Document request, OutputStream out, CallContext context) { this.out = out; generator.init(request, out, context); } /** * Dispatches the operation to the instantiated generator. * * @param master */ public void setMasterArtifact(Artifact master) { generator.setMasterArtifact(master); } /** * Dispatches the operation to the instantiated generator. * * @param artifacts * @param facet * @param attr */ public void doOut(Artifact artifact, Facet facet, Document attr) { generator.doOut(artifact, facet, attr); } /** * This method generates the chart using a concrete ChartGenerator but * doesn't write the chart itself to the OutputStream but a Document that * contains meta information of the created chart. */ @Override public void generate() throws IOException { logger.debug("ChartInfoGenerator.generate"); JFreeChart chart = generator.generateChart(); int[] size = generator.getSize(); ChartRenderingInfo info = new ChartRenderingInfo(); chart.createBufferedImage(size[0], size[1], Transparency.BITMASK, info); InfoGeneratorHelper helper = new InfoGeneratorHelper(generator); Document doc = helper.createInfoDocument(chart, info); XMLUtils.toStream(doc, out); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :