Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthProcessor.java @ 8884:7a8c12706834
Work on SINFO-FlowDepth
author | gernotbelger |
---|---|
date | Tue, 13 Feb 2018 14:53:23 +0100 |
parents | 7bbfb24e6eec |
children | cc86b0f9b3c3 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthProcessor.java Fri Feb 09 18:07:22 2018 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthProcessor.java Tue Feb 13 14:53:23 2018 +0100 @@ -1,6 +1,6 @@ /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde - * Software engineering by - * Björnsen Beratende Ingenieure GmbH + * Software engineering by + * Björnsen Beratende Ingenieure GmbH * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt * * This file is Free Software under the GNU AGPL (>=v3) @@ -10,96 +10,41 @@ package org.dive4elements.river.artifacts.sinfo.flowdepth; -import java.util.Map; +import java.util.HashSet; +import java.util.Set; -import org.apache.log4j.Logger; -import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; -import org.dive4elements.artifacts.CallContext; -import org.dive4elements.river.exports.DiagramGenerator; -import org.dive4elements.river.exports.StyledSeriesBuilder; -import org.dive4elements.river.exports.process.DefaultProcessor; -import org.dive4elements.river.jfree.StyledXYSeries; -import org.dive4elements.river.themes.ThemeDocument; +public final class FlowDepthProcessor extends AbstractSInfoProcessor { -public final class FlowDepthProcessor extends DefaultProcessor { - - /* Theme name, usually defined in 'FacetTypes', but that is soooo bad dependencies... */ + /* Theme name, usually defined in 'FacetTypes', but that is soooo bad dependencies... */ + // REMARK: these mustend with 'filtered' so extra handling happens in chart: point are always recalculated, because data + // changes depending on zoom state static String FACET_FLOW_DEPTH_FILTERED = "sinfo_flow_depth.filtered"; - private final static Logger log = Logger.getLogger(FlowDepthProcessor.class); + static String FACET_FLOW_DEPTH_TKH_FILTERED = "sinfo_flow_depth.tkh.filtered"; + + private static final Set<String> HANDLED_FACET_TYPES = new HashSet<>(); + + static { + HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_FILTERED); + HANDLED_FACET_TYPES.add(FACET_FLOW_DEPTH_TKH_FILTERED); + } private static final String I18N_AXIS_LABEL = "sinfo.chart.flow_depth.section.yaxis.label"; - private String yAxisLabel; - - @Override - public void doOut( - final DiagramGenerator generator, - final ArtifactAndFacet bundle, - final ThemeDocument theme, - final boolean visible) { - - final CallContext context = generator.getCallContext(); - final Map<String, String> metaData = bundle.getFacet().getMetaData(); - - final StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme); - series.putMetaData(metaData, bundle.getArtifact(), context); - yAxisLabel = metaData.get("Y"); - - final String facetName = bundle.getFacetName(); - final FlowDepthCalculationResult data = (FlowDepthCalculationResult) bundle.getData(context); - if (data == null) { - // Check has been here before so we keep it for security reasons - // this should never happen though. - log.error("Data is null for facet: " + facetName); - return; - } - - final double [][] points = generatePoints(data); - - StyledSeriesBuilder.addPoints(series, points, true); - generator.addAxisSeries(series, axisName, visible); + public FlowDepthProcessor() { + super(I18N_AXIS_LABEL, HANDLED_FACET_TYPES); } - private static double[][] generatePoints(final FlowDepthCalculationResult data) { - - // FIXME - return data.getFlowDepthPoints(); + // FIXME: do filtering + @Override + protected double[][] generatePoints(final FlowDepthCalculationResult data, final String facetName) { -// if (facetName.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL) || -// facetName.equals(FacetTypes.FLOW_VELOCITY_TOTALCHANNEL_FILTERED)) { -// FlowVelocityData fData = (FlowVelocityData) data; -// points = fData.getTotalChannelPoints(); -// } else if (facetName.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL) || -// facetName.equals(FacetTypes.FLOW_VELOCITY_MAINCHANNEL_FILTERED)) { -// FlowVelocityData fData = (FlowVelocityData) data; -// points = fData.getMainChannelPoints(); // I hate facets! -// } else if (facetName.equals(FacetTypes.FLOW_VELOCITY_MEASUREMENT)) { -// FastFlowVelocityMeasurementValue fData = -// (FastFlowVelocityMeasurementValue) data; -// points = new double[][] {{fData.getStation()},{fData.getV()}}; -// } else { -// log.error("Unknown facet name: " + facetName); -// return; -// } - } + if (FACET_FLOW_DEPTH_FILTERED.contentEquals(facetName)) + return data.getFlowDepthPoints(); - @Override - public boolean canHandle(String facettype) { - return FACET_FLOW_DEPTH_FILTERED.equals(facettype); - } + if (FACET_FLOW_DEPTH_TKH_FILTERED.contentEquals(facetName)) + return data.getFlowDepthTkhPoints(); - @Override - public String getAxisLabel(DiagramGenerator generator) { - if (yAxisLabel != null && !yAxisLabel.isEmpty()) { - // REMARK/UNINTENDED: yAxisLabel may also be a resolved message (side-effect of StyledXYSeries#putMetadata), - // and cannot be resolved, so we need to give the resolved value as default - // In other implementations (i.e. FlowVelocityProcessor), an explicit (German) default label is given here, probably - // the English version will also show German (CHECK) - return generator.msg(yAxisLabel, yAxisLabel); - } - return generator.msg( - I18N_AXIS_LABEL, - "MISSING"); + return super.generatePoints(data, facetName); } } \ No newline at end of file