comparison artifacts/src/main/java/org/dive4elements/river/exports/process/BedHeightSoundingProcessor.java @ 7388:c4a03db67198

BedHeightSoundingProcessor: refactored to avoid drifting behavior when using old/new style diagram generators.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 17 Oct 2013 10:50:04 +0200
parents b6595716f5f0
children 2c3031b6a831
comparison
equal deleted inserted replaced
7387:cfac25ad6b3e 7388:c4a03db67198
38 public void doOut( 38 public void doOut(
39 DiagramGenerator generator, 39 DiagramGenerator generator,
40 ArtifactAndFacet bundle, 40 ArtifactAndFacet bundle,
41 ThemeDocument theme, 41 ThemeDocument theme,
42 boolean visible) { 42 boolean visible) {
43 CallContext context = generator.getCallContext(); 43 XYSeries series = prepareSeries(bundle, theme, generator.getCallContext());
44 generator.addAxisSeries(series, axisName, visible);
45 }
46
47 @Override
48 public void doOut(
49 XYChartGenerator generator,
50 ArtifactAndFacet bundle,
51 ThemeDocument theme,
52 boolean visible,
53 int index
54 ) {
55 XYSeries series = prepareSeries(bundle, theme, generator.getCallContext());
56 generator.addAxisSeries(series, index, visible);
57 }
58
59 /** Prepare an series, independent of axis. */
60 private XYSeries prepareSeries(ArtifactAndFacet bundle,
61 ThemeDocument theme, CallContext context) {
44 Object data = bundle.getData(context); 62 Object data = bundle.getData(context);
45 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), 63 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
46 theme); 64 theme);
47 if (data instanceof BedHeightSingle) { 65 if (data instanceof BedHeightSingle) {
48 BedHeightSingle bData = (BedHeightSingle)data; 66 BedHeightSingle bData = (BedHeightSingle)data;
61 79
62 for(BedHeightSingleValue bvalue: bData) { 80 for(BedHeightSingleValue bvalue: bData) {
63 series.add(bvalue.getStation(), bvalue.getSoundingWidth()); 81 series.add(bvalue.getStation(), bvalue.getSoundingWidth());
64 } 82 }
65 } 83 }
66 generator.addAxisSeries(series, axisName, visible); 84 return series;
67 } 85 }
68 86
69 @Override
70 public void doOut(
71 XYChartGenerator generator,
72 ArtifactAndFacet bundle,
73 ThemeDocument theme,
74 boolean visible,
75 int index
76 ) {
77 CallContext context = generator.getCallContext();
78 Object data = bundle.getData(context);
79 XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
80 theme);
81 if (data instanceof BedHeightSingle) {
82 BedHeightSingle bData = (BedHeightSingle)data;
83 double[] width = bData.getMorphWidths();
84 double[] stations = bData.getStations().toNativeArray();
85
86 logger.debug("doBedheightSingleOut");
87
88 for (int i = 0; i < width.length; i++) {
89 series.add(stations[i], width[i], false);
90 }
91 } else if (data instanceof List<?>) {
92 List<BedHeightSingleValue> bData = (List<BedHeightSingleValue>)data;
93
94 logger.debug("doBedheightSingleValueOut");
95
96 for(BedHeightSingleValue bvalue: bData) {
97 series.add(bvalue.getStation(), bvalue.getSoundingWidth());
98 }
99 }
100 generator.addAxisSeries(series, index, visible);
101 }
102 87
103 @Override 88 @Override
104 public boolean canHandle(String facettype) { 89 public boolean canHandle(String facettype) {
105 return BEDHEIGHT.equals(facettype); 90 return BEDHEIGHT.equals(facettype);
106 } 91 }

http://dive4elements.wald.intevation.org