aheinecke@7145: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde aheinecke@7145: * Software engineering by Intevation GmbH aheinecke@7145: * aheinecke@7145: * This file is Free Software under the GNU AGPL (>=v3) aheinecke@7145: * and comes with ABSOLUTELY NO WARRANTY! Check out the aheinecke@7145: * documentation coming with Dive4Elements River for details. aheinecke@7145: */ aheinecke@7145: aheinecke@7145: package org.dive4elements.river.exports.process; aheinecke@7145: aheinecke@7145: import org.apache.log4j.Logger; rrenkert@7892: import java.util.Map; aheinecke@7689: aheinecke@7145: import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; aheinecke@7145: import org.dive4elements.artifacts.CallContext; aheinecke@7145: import org.dive4elements.river.artifacts.model.FacetTypes; aheinecke@7145: import org.dive4elements.river.exports.DiagramGenerator; aheinecke@7145: import org.dive4elements.river.exports.StyledSeriesBuilder; aheinecke@7145: import org.dive4elements.river.jfree.StyledXYSeries; aheinecke@7145: import org.dive4elements.river.themes.ThemeDocument; aheinecke@7145: aheinecke@7145: import org.dive4elements.river.artifacts.model.minfo.MorphologicWidth; aheinecke@7145: aheinecke@7145: public class BedWidthProcessor extends DefaultProcessor { aheinecke@7145: teichmann@8202: private final static Logger log = aheinecke@7145: Logger.getLogger(BedWidthProcessor.class); aheinecke@7145: aheinecke@7145: public static final String I18N_AXIS_LABEL_DEFAULT = aheinecke@7145: "Breite [m]"; aheinecke@7145: public static final String I18N_AXIS_LABEL = aheinecke@7145: "chart.beddifference.yaxis.label.morph"; aheinecke@7145: rrenkert@7892: protected String yAxisLabel; rrenkert@7981: tom@8695: public static final double GAP_WIDTH = 0.101; teichmann@7901: aheinecke@7145: @Override aheinecke@7145: public void doOut( aheinecke@7145: DiagramGenerator generator, aheinecke@7145: ArtifactAndFacet bundle, aheinecke@7145: ThemeDocument theme, aheinecke@7145: boolean visible) { gernotbelger@9123: CallContext context = generator.getContext(); rrenkert@7892: Map metaData = bundle.getFacet().getMetaData(); rrenkert@7892: StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), aheinecke@7145: theme); tom@8150: if (!metaData.isEmpty()) { tom@8150: series.putMetaData(metaData, bundle.getArtifact(), context); tom@8150: yAxisLabel = metaData.get("Y"); tom@8150: } aheinecke@7145: Object data = bundle.getData(context); aheinecke@7145: rrenkert@7985: if (data instanceof MorphologicWidth) { aheinecke@7145: MorphologicWidth bData = (MorphologicWidth) data; aheinecke@7145: StyledSeriesBuilder.addPoints(series, bData.getAsArray(), true); rrenkert@7985: } else if (data instanceof double[][]) { rrenkert@7985: double[][]values = (double[][]) data; tom@8699: StyledSeriesBuilder.addPoints(series, tom@8699: values, tom@8699: false, tom@8699: GAP_WIDTH); aheinecke@7148: } else { teichmann@8202: log.error("Unknown data for facet: " + bundle.getFacetName()); aheinecke@7145: } aheinecke@7145: aheinecke@7145: generator.addAxisSeries(series, axisName, visible); aheinecke@7145: } aheinecke@7145: aheinecke@7145: @Override aheinecke@7145: public boolean canHandle(String facettype) { tom@8433: return facettype.equals(FacetTypes.MORPHOLOGIC_WIDTH) || aheinecke@7689: facettype.equals(FacetTypes.BEDHEIGHT_SOUNDING_WIDTH); aheinecke@7145: } aheinecke@7145: aheinecke@7145: @Override aheinecke@7145: public String getAxisLabel(DiagramGenerator generator) { rrenkert@7892: if (yAxisLabel != null && !yAxisLabel.isEmpty()) { rrenkert@7892: return generator.msg(yAxisLabel, I18N_AXIS_LABEL_DEFAULT); rrenkert@7892: } aheinecke@7145: return generator.msg( aheinecke@7145: I18N_AXIS_LABEL, aheinecke@7145: I18N_AXIS_LABEL_DEFAULT); aheinecke@7145: } aheinecke@7145: }