Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/process/BedheightProcessor.java @ 7091:c7d8adb91576 generator-refactoring
Simplify code to prepare DiagramGenerator signature
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 23 Sep 2013 10:22:52 +0200 |
parents | 253d80af5b7f |
children | cdae0ff8960b |
comparison
equal
deleted
inserted
replaced
7090:9a37d6dce2c7 | 7091:c7d8adb91576 |
---|---|
36 boolean visible, | 36 boolean visible, |
37 int index | 37 int index |
38 ) { | 38 ) { |
39 CallContext context = generator.getCallContext(); | 39 CallContext context = generator.getCallContext(); |
40 Object data = bundle.getData(context); | 40 Object data = bundle.getData(context); |
41 if (data instanceof BedHeightSingle) { | |
42 doBedheightSingleOut(generator, bundle, theme, index, visible, | |
43 (BedHeightSingle)data); | |
44 } | |
45 else if (data instanceof List<?>) { | |
46 doBedheightSingeValuesOut(generator, bundle, theme, index, visible, | |
47 (List<BedHeightSingleValue>)data); | |
48 } | |
49 logger.error("Can't process " + data.getClass().getName() + " objects"); | |
50 } | |
51 | |
52 private void doBedheightSingeValuesOut(XYChartGenerator generator, | |
53 ArtifactAndFacet bundle, ThemeDocument theme, int index, boolean visible, | |
54 List<BedHeightSingleValue> data) { | |
55 logger.debug("doBedheightSingeValuesOut"); | |
56 | |
57 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), | 41 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), |
58 theme); | 42 theme); |
59 for(BedHeightSingleValue bvalue: data) { | 43 if (data instanceof BedHeightSingle) { |
60 series.add(bvalue.getStation(), bvalue.getSoundingWidth()); | 44 BedHeightSingle bData = (BedHeightSingle)data; |
45 double[] width = bData.getMorphWidths(); | |
46 double[] stations = bData.getStations().toNativeArray(); | |
47 | |
48 logger.debug("doBedheightSingleOut"); | |
49 | |
50 for (int i = 0; i < width.length; i++) { | |
51 series.add(stations[i], width[i], false); | |
52 } | |
53 } else if (data instanceof List<?>) { | |
54 List<BedHeightSingleValue> bData = (List<BedHeightSingleValue>)data; | |
55 | |
56 logger.debug("doBedheightSingleValueOut"); | |
57 | |
58 for(BedHeightSingleValue bvalue: bData) { | |
59 series.add(bvalue.getStation(), bvalue.getSoundingWidth()); | |
60 } | |
61 } | 61 } |
62 generator.addAxisSeries(series, index, visible); | 62 generator.addAxisSeries(series, index, visible); |
63 } | 63 } |
64 | 64 |
65 @Override | 65 @Override |
66 public boolean canHandle(String facettype) { | 66 public boolean canHandle(String facettype) { |
67 return BEDHEIGHT.equals(facettype); | 67 return BEDHEIGHT.equals(facettype); |
68 } | 68 } |
69 | |
70 public void doBedheightSingleOut(XYChartGenerator generator, | |
71 ArtifactAndFacet bundle, ThemeDocument theme, int index, boolean visible, | |
72 BedHeightSingle data) { | |
73 double[] width = data.getMorphWidths(); | |
74 double[] stations = data.getStations().toNativeArray(); | |
75 | |
76 logger.debug("doBedheightSingleOut"); | |
77 | |
78 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), | |
79 theme); | |
80 | |
81 for (int i = 0; i < width.length; i++) { | |
82 series.add(stations[i], width[i], false); | |
83 } | |
84 | |
85 generator.addAxisSeries(series, index, visible); | |
86 } | |
87 } | 69 } |