Mercurial > dive4elements > river
changeset 4536:ce4ff444f215
Implement a BedheightProcessor to generate charts from bed height data
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Thu, 15 Nov 2012 16:21:21 +0100 |
parents | b838d16c629e |
children | d337c67b6845 |
files | flys-artifacts/src/main/java/de/intevation/flys/exports/process/BedheightProcessor.java |
diffstat | 1 files changed, 77 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/process/BedheightProcessor.java Thu Nov 15 16:21:21 2012 +0100 @@ -0,0 +1,77 @@ +package de.intevation.flys.exports.process; + +import java.util.List; + +import javax.swing.text.html.HTMLDocument.HTMLReader.IsindexAction; + +import org.apache.log4j.Logger; +import org.jfree.data.xy.XYSeries; +import org.w3c.dom.Document; + +import de.intevation.artifactdatabase.state.ArtifactAndFacet; +import de.intevation.artifacts.CallContext; +import de.intevation.flys.artifacts.model.minfo.BedHeightSingle; +import de.intevation.flys.exports.XYChartGenerator; +import de.intevation.flys.jfree.StyledXYSeries; +import de.intevation.flys.model.BedHeightSingleValue; + +public class BedheightProcessor implements Processor { + + private final static Logger logger = + Logger.getLogger(BedheightProcessor.class); + + private final static String BEDHEIGHT = "bedheight"; + + @Override + public void doOut(XYChartGenerator generator, ArtifactAndFacet aandf, + Document theme, boolean visible, int index) { + CallContext context = generator.getCallContext(); + Object data = aandf.getData(context); + if (data instanceof BedHeightSingle) { + doBedheightSingleOut(generator, aandf, theme, index, visible, + (BedHeightSingle)data); + } + else if (data instanceof List<?>) { + doBedheightSingeValuesOut(generator, aandf, theme, index, visible, + (List<BedHeightSingleValue>)data); + } + logger.error("Can't process " + data.getClass().getName() + " objects"); + } + + private void doBedheightSingeValuesOut(XYChartGenerator generator, + ArtifactAndFacet aandf, Document theme, int index, boolean visible, + List<BedHeightSingleValue> data) { + logger.debug("doBedheightSingleOut"); + + XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), + theme); + for(BedHeightSingleValue bvalue: data) { + series.add(bvalue.getStation(), bvalue.getSoundingWidth()); + } + generator.addAxisSeries(series, index, visible); + } + + @Override + public boolean canHandle(String facettype) { + return BEDHEIGHT.equals(facettype); + } + + public void doBedheightSingleOut(XYChartGenerator generator, + ArtifactAndFacet aandf, Document theme, int index, boolean visible, + BedHeightSingle data) { + double[] width = data.getMorphWidths(); + double[] stations = data.getStations().toNativeArray(); + + logger.debug("doBedheightSingleOut"); + + XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), + theme); + + for (int i = 0; i < width.length; i++) { + series.add(stations[i], width[i], false); + } + + generator.addAxisSeries(series, index, visible); + } + +}