teichmann@5863: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5863: * Software engineering by Intevation GmbH teichmann@5863: * teichmann@5994: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5863: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5994: * documentation coming with Dive4Elements River for details. teichmann@5863: */ teichmann@5863: teichmann@5831: package org.dive4elements.river.exports.minfo; raimund@3898: raimund@3898: import org.apache.log4j.Logger; raimund@3898: teichmann@5831: import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; teichmann@5831: import org.dive4elements.artifactdatabase.state.Facet; teichmann@5831: import org.dive4elements.river.artifacts.model.FacetTypes; teichmann@5831: import org.dive4elements.river.artifacts.model.minfo.BedDifferencesResult; felix@6567: import org.dive4elements.river.exports.process.BedDiffHeightYearProcessor; teichmann@5831: import org.dive4elements.river.exports.process.KMIndexProcessor; teichmann@5831: import org.dive4elements.river.exports.process.Processor; teichmann@5864: import org.dive4elements.river.jfree.RiverAnnotation; teichmann@6905: import org.dive4elements.river.themes.ThemeDocument; raimund@3898: raimund@3898: raimund@3898: public class BedDiffHeightYearGenerator felix@6551: extends BedDiffBaseGenerator raimund@3898: implements FacetTypes raimund@3898: { raimund@3898: public enum YAXIS { bjoern@4378: D(0), dW(1); raimund@3898: raimund@3898: protected int idx; raimund@3898: raimund@3898: private YAXIS(int c) { raimund@3898: idx = c; raimund@3898: } raimund@3898: } raimund@3898: raimund@3898: /** The logger that is used in this generator. */ raimund@3898: private static Logger logger = Logger.getLogger(BedDiffHeightYearGenerator.class); raimund@3898: raimund@3898: public static final String I18N_CHART_TITLE = "chart.beddifference.height.title"; tom@6639: public static final String I18N_XAXIS_LABEL = "chart.beddifference.height.xaxis.label"; raimund@3898: public static final String I18N_YAXIS_LABEL = "chart.beddifference.height.yaxis.label"; raimund@3898: raimund@3898: public static final String I18N_CHART_TITLE_DEFAULT = "Sohlenhöhen Differenz"; tom@6639: public static final String I18N_XAXIS_LABEL_DEFAULT = "Fluss-Km"; raimund@3898: public static final String I18N_YAXIS_LABEL_DEFAULT = "delta S [cm / Jahr]"; bjoern@4446: public static final String I18N_DW_YAXIS_LABEL_DEFAULT = bjoern@4446: "delta W [cm]"; bjoern@4446: public static final String I18N_DW_YAXIS_LABEL = bjoern@4446: "chart.fixings.longitudinalsection.yaxis.label"; raimund@3898: raimund@3898: @Override raimund@3898: protected YAxisWalker getYAxisWalker() { raimund@3898: return new YAxisWalker() { raimund@3898: raimund@3898: @Override raimund@3898: public int length() { raimund@3898: return YAXIS.values().length; raimund@3898: } raimund@3898: raimund@3898: @Override raimund@3898: public String getId(int idx) { raimund@3898: YAXIS[] yaxes = YAXIS.values(); raimund@3898: return yaxes[idx].toString(); raimund@3898: } raimund@3898: }; raimund@3898: } raimund@3898: raimund@3898: @Override teichmann@6905: public void doOut(ArtifactAndFacet bundle, ThemeDocument attr, boolean visible) { raimund@3898: String name = bundle.getFacetName(); raimund@3898: raimund@3898: logger.debug("doOut: " + name); raimund@3898: raimund@3898: if (name == null) { raimund@3898: logger.error("No facet name for doOut(). No output generated!"); raimund@3898: return; raimund@3898: } raimund@3898: raimund@3898: Facet facet = bundle.getFacet(); raimund@3898: raimund@3898: if (facet == null) { raimund@3898: return; raimund@3898: } raimund@3898: aheinecke@6051: if (bundle.getData(context) instanceof BedDifferencesResult) { felix@6549: setContextBounds(bundle); rrenkert@4638: } felix@6549: bjoern@4446: Processor processor = new KMIndexProcessor(); felix@6567: Processor bdyProcessor = new BedDiffHeightYearProcessor(); felix@6566: if (name.equals(LONGITUDINAL_ANNOTATION)) { raimund@3898: doAnnotations( teichmann@5864: (RiverAnnotation) bundle.getData(context), raimund@3898: bundle, raimund@3898: attr, raimund@3898: visible); raimund@3898: } bjoern@4446: else if (processor.canHandle(name)) { bjoern@4446: processor.doOut(this, bundle, attr, visible, YAXIS.dW.idx); bjoern@4446: } felix@6566: else if (bdyProcessor.canHandle(name)) { felix@6566: bdyProcessor.doOut(this, bundle, attr, visible, YAXIS.D.idx); felix@6566: } bjoern@4446: else { bjoern@4446: logger.warn("Unknown facet name " + name); bjoern@4446: } raimund@3898: } raimund@3898: felix@6549: raimund@3898: @Override raimund@3898: protected String getDefaultChartTitle() { raimund@3898: return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); raimund@3898: } raimund@3898: raimund@3898: @Override raimund@3898: protected String getDefaultXAxisLabel() { felix@6123: return msg(I18N_XAXIS_LABEL, felix@6123: I18N_XAXIS_LABEL_DEFAULT, felix@6123: new Object[] { getRiverName() }); raimund@3898: } raimund@3898: raimund@3898: @Override raimund@3898: protected String getDefaultYAxisLabel(int pos) { bjoern@4378: if (pos == YAXIS.D.idx) { bjoern@4378: return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); bjoern@4378: } bjoern@4378: else if (pos == YAXIS.dW.idx) { bjoern@4378: return msg(I18N_DW_YAXIS_LABEL, I18N_DW_YAXIS_LABEL_DEFAULT); bjoern@4378: } bjoern@4378: return "default"; raimund@3898: } raimund@3898: }