aheinecke@7153: /* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde aheinecke@7153: * Software engineering by Intevation GmbH aheinecke@7153: * aheinecke@7153: * This file is Free Software under the GNU AGPL (>=v3) aheinecke@7153: * and comes with ABSOLUTELY NO WARRANTY! Check out the aheinecke@7153: * documentation coming with Dive4Elements River for details. aheinecke@7153: */ aheinecke@7153: aheinecke@7153: package org.dive4elements.river.exports.process; aheinecke@7153: aheinecke@7153: import java.util.Set; aheinecke@7153: aheinecke@7153: import org.apache.log4j.Logger; aheinecke@7153: import org.jfree.data.xy.XYSeries; aheinecke@7153: import org.dive4elements.river.artifacts.D4EArtifact; aheinecke@7153: aheinecke@7153: import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; aheinecke@7153: import org.dive4elements.artifacts.CallContext; aheinecke@7153: import org.dive4elements.river.artifacts.access.SedimentLoadAccess; aheinecke@7153: import org.dive4elements.river.artifacts.model.FacetTypes; aheinecke@7153: import org.dive4elements.river.exports.DiagramGenerator; aheinecke@7153: import org.dive4elements.river.exports.StyledSeriesBuilder; aheinecke@7153: import org.dive4elements.river.jfree.StyledXYSeries; aheinecke@7153: import org.dive4elements.river.themes.ThemeDocument; aheinecke@7153: aheinecke@7153: import org.dive4elements.river.artifacts.model.minfo.SedimentLoad; aheinecke@7153: import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFraction; aheinecke@7153: felix@7503: public class SedimentLoadTAProcessor extends DefaultProcessor { aheinecke@7153: aheinecke@7153: private final static Logger logger = felix@7503: Logger.getLogger(SedimentLoadTAProcessor.class); aheinecke@7153: felix@7503: public static final String I18N_YAXIS_LABEL = aheinecke@7153: "chart.sedimentload.ls.yaxis.label.tpera"; felix@7503: public static final String I18N_YAXIS_LABEL_DEFAULT = "[t/a]"; aheinecke@7153: aheinecke@7153: @Override aheinecke@7153: public void doOut( aheinecke@7153: DiagramGenerator generator, aheinecke@7153: ArtifactAndFacet bundle, aheinecke@7153: ThemeDocument theme, aheinecke@7153: boolean visible) { felix@7189: logger.debug("doOut " + bundle.getFacetName()); aheinecke@7153: CallContext context = generator.getCallContext(); aheinecke@7153: XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), aheinecke@7153: theme); aheinecke@7153: Object data = bundle.getData(context); aheinecke@7153: String facetName = bundle.getFacetName(); aheinecke@7153: double [][] points; aheinecke@7153: felix@7503: if (FacetTypes.IS.SEDIMENT_LOAD_TA(facetName)) { aheinecke@7153: points = (double[][]) data; aheinecke@7153: } else if (FacetTypes.IS.SEDIMENT_LOAD_UNKNOWN(facetName)) { aheinecke@7153: SedimentLoad load = (SedimentLoad) data; aheinecke@7153: Set kms = load.getKms(); aheinecke@7153: points = new double[2][kms.size()]; aheinecke@7153: int counter = 0; aheinecke@7153: for (Double km: kms) { aheinecke@7153: SedimentLoadFraction fraction = load.getFraction(km); aheinecke@7153: points[0][counter] = km; aheinecke@7153: points[1][counter] = fraction.getUnknown(); aheinecke@7153: counter++; aheinecke@7153: } aheinecke@7153: } else { aheinecke@7153: logger.error("Unknown facet name: " + facetName); aheinecke@7153: return; aheinecke@7153: } felix@7503: aheinecke@7153: StyledSeriesBuilder.addPoints(series, points, true); aheinecke@7153: aheinecke@7153: generator.addAxisSeries(series, axisName, visible); aheinecke@7153: } aheinecke@7153: aheinecke@7153: @Override aheinecke@7153: public boolean canHandle(String facettype) { felix@7503: return FacetTypes.IS.SEDIMENT_LOAD_TA(facettype) || felix@7503: FacetTypes.SEDIMENT_LOAD_TA_UNKNOWN.equals(facettype); aheinecke@7153: } aheinecke@7153: aheinecke@7153: @Override aheinecke@7153: public String getAxisLabel(DiagramGenerator generator) { felix@7503: return generator.msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); aheinecke@7153: } aheinecke@7153: }