comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java @ 9208:53cc5b496692

funcion replaced by interface
author gernotbelger
date Tue, 03 Jul 2018 11:16:51 +0200
parents 3dae6b78e1da
children 0fc9c82e744e
comparison
equal deleted inserted replaced
9207:559775e2f53c 9208:53cc5b496692
13 import java.util.ArrayList; 13 import java.util.ArrayList;
14 import java.util.Collection; 14 import java.util.Collection;
15 import java.util.Collections; 15 import java.util.Collections;
16 import java.util.List; 16 import java.util.List;
17 17
18 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
18 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; 19 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult;
19 import org.dive4elements.river.artifacts.common.AbstractExportContext; 20 import org.dive4elements.river.artifacts.common.AbstractExportContext;
20 import org.dive4elements.river.artifacts.common.ExportContextCSV; 21 import org.dive4elements.river.artifacts.common.ExportContextCSV;
21 import org.dive4elements.river.artifacts.common.ExportContextPDF; 22 import org.dive4elements.river.artifacts.common.ExportContextPDF;
22 import org.dive4elements.river.artifacts.common.GeneralResultType; 23 import org.dive4elements.river.artifacts.common.GeneralResultType;
24 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; 25 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource;
25 import org.dive4elements.river.artifacts.common.ResultRow; 26 import org.dive4elements.river.artifacts.common.ResultRow;
26 import org.dive4elements.river.artifacts.sinfo.common.SInfoI18NStrings; 27 import org.dive4elements.river.artifacts.sinfo.common.SInfoI18NStrings;
27 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; 28 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType;
28 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; 29 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo;
30 import org.dive4elements.river.exports.DiagramGenerator;
29 31
30 import gnu.trove.TDoubleArrayList; 32 import gnu.trove.TDoubleArrayList;
31 33
32 /** 34 /**
33 * Contains the result of a {@link FloodDurationCalculation}. 35 * Contains the result of a {@link FloodDurationCalculation}.
41 private final String[] mainvalueLabels; 43 private final String[] mainvalueLabels;
42 44
43 private final int waterlevelCount; 45 private final int waterlevelCount;
44 // private final WstInfo wstInfo; 46 // private final WstInfo wstInfo;
45 private final int maxWaterlevelPdf = 3; 47 private final int maxWaterlevelPdf = 3;
48
49 public interface ValueGetter {
50 abstract double getValue(DurationWaterlevel waterlevel);
51 }
46 52
47 private enum ExportMode { 53 private enum ExportMode {
48 pdf, csv 54 pdf, csv
49 } 55 }
50 56
270 276
271 if (this.mainvalueLabels != null && j < this.mainvalueLabels.length) 277 if (this.mainvalueLabels != null && j < this.mainvalueLabels.length)
272 return this.mainvalueLabels[j]; 278 return this.mainvalueLabels[j];
273 return ""; 279 return "";
274 } 280 }
281
282 public final double[][] getMainValueDurationPoints(final DiagramGenerator generator, final ArtifactAndFacet bundle,
283 // final Function<DurationWaterlevel, Double> valueGetter
284 final ValueGetter valuegetter, final int dataIndex) {
285
286 final TDoubleArrayList xPoints = new TDoubleArrayList(this.rows.size());
287 final TDoubleArrayList yPoints = new TDoubleArrayList(this.rows.size());
288
289 for (final ResultRow row : this.rows) {
290
291 final double station = row.getDoubleValue(GeneralResultType.station);
292
293 final List<DurationWaterlevel> waterlevels = (List<DurationWaterlevel>) row.getValue(SInfoResultType.customMultiRowColWaterlevel);
294 final DurationWaterlevel waterlevel = waterlevels.get(dataIndex);
295
296 final Double value = valuegetter.getValue(waterlevel);
297
298 xPoints.add(station);
299 yPoints.add(value);
300 }
301
302 return new double[][] { xPoints.toNativeArray(), yPoints.toNativeArray() };
303 }
275 } 304 }

http://dive4elements.wald.intevation.org