Mercurial > dive4elements > river
changeset 7214:8817bb81cf27
Initial commit of sediment density processor.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 30 Sep 2013 17:40:42 +0200 |
parents | c453f7ecf479 |
children | 9cd3ff139601 |
files | artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentDensityProcessor.java |
diffstat | 1 files changed, 73 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentDensityProcessor.java Mon Sep 30 17:40:42 2013 +0200 @@ -0,0 +1,73 @@ +/* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.exports.process; + +import org.apache.log4j.Logger; +import org.jfree.data.xy.XYSeries; + +import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; +import org.dive4elements.artifacts.CallContext; + +import org.dive4elements.river.artifacts.model.FacetTypes; +import org.dive4elements.river.artifacts.model.minfo.SedimentDensity; + +import org.dive4elements.river.exports.DiagramGenerator; +import org.dive4elements.river.exports.StyledSeriesBuilder; +import org.dive4elements.river.jfree.StyledXYSeries; +import org.dive4elements.river.themes.ThemeDocument; + + +/** Process Sediment Density data. */ +public class SedimentDensityProcessor extends DefaultProcessor { + + /** Private logger. */ + private final static Logger logger = + Logger.getLogger(SedimentDensityProcessor.class); + + public static final String I18N_AXIS_LABEL_DEFAULT = + "Sedimentdichte [t/m^3]"; + public static final String I18N_AXIS_LABEL = + "chart.yaxis.label.sedimentdensity"; + + @Override + public void doOut( + DiagramGenerator generator, + ArtifactAndFacet bundle, + ThemeDocument theme, + boolean visible) { + CallContext context = generator.getCallContext(); + XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), + theme); + Object data = bundle.getData(context); + String facetName = bundle.getFacetName(); + double [][] points; + + if (facetName.equals(FacetTypes.SEDIMENT_DENSITY)) { + points =((SedimentDensity) data).getDensities(2006); + } else { + logger.error("Unknown facet name: " + facetName); + return; + } + StyledSeriesBuilder.addPoints(series, points, true); + + generator.addAxisSeries(series, axisName, visible); + } + + @Override + public boolean canHandle(String facettype) { + return facettype.equals(FacetTypes.SEDIMENT_DENSITY); + } + + @Override + public String getAxisLabel(DiagramGenerator generator) { + return generator.msg( + I18N_AXIS_LABEL, + I18N_AXIS_LABEL_DEFAULT); + } +}