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.process; bjoern@4536: bjoern@4536: import java.util.List; bjoern@4536: bjoern@4536: import org.apache.log4j.Logger; bjoern@4536: import org.jfree.data.xy.XYSeries; bjoern@4536: teichmann@5831: import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; teichmann@5831: import org.dive4elements.artifacts.CallContext; teichmann@5831: import org.dive4elements.river.artifacts.model.minfo.BedHeightSingle; teichmann@5831: import org.dive4elements.river.exports.XYChartGenerator; aheinecke@7093: import org.dive4elements.river.exports.DiagramGenerator; teichmann@5831: import org.dive4elements.river.jfree.StyledXYSeries; teichmann@5831: import org.dive4elements.river.model.BedHeightSingleValue; teichmann@6905: import org.dive4elements.river.themes.ThemeDocument; bjoern@4536: aheinecke@7128: public class BedWidthProcessor extends DefaultProcessor { bjoern@4536: bjoern@4536: private final static Logger logger = aheinecke@7128: Logger.getLogger(BedWidthProcessor.class); bjoern@4536: bjoern@4536: private final static String BEDHEIGHT = "bedheight"; bjoern@4536: aheinecke@7127: public static final String I18N_AXIS_LABEL_DEFAULT aheinecke@7127: = "Gepeilte Breite [m]"; aheinecke@7127: public static final String I18N_AXIS_LABEL = aheinecke@7127: "chart.bedheight_middle.sounding.yaxis.label"; aheinecke@7127: bjoern@4536: @Override teichmann@4551: public void doOut( aheinecke@7093: DiagramGenerator generator, aheinecke@7093: ArtifactAndFacet bundle, aheinecke@7093: ThemeDocument theme, aheinecke@7093: boolean visible) { aheinecke@7093: CallContext context = generator.getCallContext(); aheinecke@7093: Object data = bundle.getData(context); aheinecke@7093: XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), aheinecke@7093: theme); aheinecke@7093: if (data instanceof BedHeightSingle) { aheinecke@7093: BedHeightSingle bData = (BedHeightSingle)data; aheinecke@7093: double[] width = bData.getMorphWidths(); aheinecke@7093: double[] stations = bData.getStations().toNativeArray(); aheinecke@7093: aheinecke@7093: logger.debug("doBedheightSingleOut"); aheinecke@7093: aheinecke@7093: for (int i = 0; i < width.length; i++) { aheinecke@7093: series.add(stations[i], width[i], false); aheinecke@7093: } aheinecke@7093: } else if (data instanceof List) { aheinecke@7093: List bData = (List)data; aheinecke@7093: aheinecke@7093: logger.debug("doBedheightSingleValueOut"); aheinecke@7093: aheinecke@7093: for(BedHeightSingleValue bvalue: bData) { aheinecke@7093: series.add(bvalue.getStation(), bvalue.getSoundingWidth()); aheinecke@7093: } aheinecke@7093: } aheinecke@7093: generator.addAxisSeries(series, axisName, visible); aheinecke@7093: } aheinecke@7093: aheinecke@7093: @Override aheinecke@7093: public void doOut( teichmann@4551: XYChartGenerator generator, aheinecke@7075: ArtifactAndFacet bundle, teichmann@6905: ThemeDocument theme, teichmann@4551: boolean visible, teichmann@4551: int index teichmann@4551: ) { bjoern@4536: CallContext context = generator.getCallContext(); aheinecke@7075: Object data = bundle.getData(context); aheinecke@7075: XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), bjoern@4536: theme); aheinecke@7091: if (data instanceof BedHeightSingle) { aheinecke@7091: BedHeightSingle bData = (BedHeightSingle)data; aheinecke@7091: double[] width = bData.getMorphWidths(); aheinecke@7091: double[] stations = bData.getStations().toNativeArray(); aheinecke@7091: aheinecke@7091: logger.debug("doBedheightSingleOut"); aheinecke@7091: aheinecke@7091: for (int i = 0; i < width.length; i++) { aheinecke@7091: series.add(stations[i], width[i], false); aheinecke@7091: } aheinecke@7091: } else if (data instanceof List) { aheinecke@7091: List bData = (List)data; aheinecke@7091: aheinecke@7091: logger.debug("doBedheightSingleValueOut"); aheinecke@7091: aheinecke@7091: for(BedHeightSingleValue bvalue: bData) { aheinecke@7091: series.add(bvalue.getStation(), bvalue.getSoundingWidth()); aheinecke@7091: } bjoern@4536: } bjoern@4536: generator.addAxisSeries(series, index, visible); bjoern@4536: } bjoern@4536: bjoern@4536: @Override bjoern@4536: public boolean canHandle(String facettype) { bjoern@4536: return BEDHEIGHT.equals(facettype); bjoern@4536: } aheinecke@7127: aheinecke@7127: @Override aheinecke@7127: public String getAxisLabel(DiagramGenerator generator) { aheinecke@7127: return generator.msg( aheinecke@7127: I18N_AXIS_LABEL, aheinecke@7127: I18N_AXIS_LABEL_DEFAULT); aheinecke@7127: } bjoern@4536: }