Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/AbstractFixGenerator.java @ 4377:512a3af69e18
Extract common generator method from FixLongitudinalSectionGenerator
The extracted methods and code can be reused for generating charts for bed
differences if fixanalysis data is loaded via the datacache.
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Fri, 02 Nov 2012 15:47:15 +0100 |
parents | |
children | 8f131a870c6f |
comparison
equal
deleted
inserted
replaced
4376:3c8964855270 | 4377:512a3af69e18 |
---|---|
1 package de.intevation.flys.exports.fixings; | |
2 | |
3 import org.apache.log4j.Logger; | |
4 import org.jfree.data.xy.XYSeries; | |
5 import org.jfree.data.xy.XYSeriesCollection; | |
6 import org.w3c.dom.Document; | |
7 | |
8 import de.intevation.artifactdatabase.state.ArtifactAndFacet; | |
9 import de.intevation.flys.artifacts.model.fixings.AnalysisPeriod; | |
10 import de.intevation.flys.artifacts.model.fixings.QWD; | |
11 import de.intevation.flys.jfree.StyledXYSeries; | |
12 import de.intevation.flys.utils.KMIndex; | |
13 | |
14 public abstract class AbstractFixGenerator extends FixChartGenerator { | |
15 | |
16 public static final String I18N_DW_YAXIS_LABEL_DEFAULT = | |
17 "delta W [cm]"; | |
18 | |
19 public static final String I18N_DW_YAXIS_LABEL = | |
20 "chart.fixings.longitudinalsection.yaxis.label"; | |
21 | |
22 private final static Logger logger = | |
23 Logger.getLogger(FixLongitudinalSectionGenerator.class); | |
24 | |
25 @SuppressWarnings("unchecked") | |
26 protected void doSectorAverageOut(ArtifactAndFacet aaf, Document doc, boolean visible, int idx) { | |
27 logger.debug("doSectorAverageOut" + aaf.getFacet().getIndex()); | |
28 | |
29 int index = aaf.getFacet().getIndex(); | |
30 int sectorNdx = index & 3; | |
31 | |
32 KMIndex<AnalysisPeriod> kms = | |
33 (KMIndex<AnalysisPeriod>)aaf.getData(context); | |
34 | |
35 if(kms == null) { | |
36 return; | |
37 } | |
38 | |
39 XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), doc); | |
40 | |
41 for (KMIndex.Entry<AnalysisPeriod> entry: kms) { | |
42 double km = entry.getKm(); | |
43 AnalysisPeriod ap = entry.getValue(); | |
44 QWD qwd = ap.getQSectorAverages()[sectorNdx]; | |
45 if (qwd == null) { | |
46 continue; | |
47 } | |
48 double deltaW = qwd.getDeltaW(); | |
49 series.add(km, deltaW); | |
50 } | |
51 | |
52 addAxisSeries(series, idx, visible); | |
53 | |
54 } | |
55 | |
56 @SuppressWarnings("unchecked") | |
57 protected void doAnalysisEventsOut(ArtifactAndFacet aaf, Document doc, boolean visible, int idx) { | |
58 logger.debug("doAnalysisEventsOut"); | |
59 | |
60 KMIndex<QWD> kms = | |
61 (KMIndex<QWD>)aaf.getData(context); | |
62 | |
63 if(kms == null) { | |
64 return; | |
65 } | |
66 | |
67 XYSeriesCollection col = new XYSeriesCollection(); | |
68 | |
69 StyledXYSeries series = new StyledXYSeries(aaf.getFacetDescription(), false, doc); | |
70 | |
71 for (KMIndex.Entry<QWD> entry: kms) { | |
72 double km = entry.getKm(); | |
73 QWD qwd = entry.getValue(); | |
74 | |
75 series.add(km, qwd.getDeltaW()); | |
76 } | |
77 col.addSeries(series); | |
78 | |
79 addAxisDataset(col, idx, visible); | |
80 } | |
81 | |
82 @SuppressWarnings("unchecked") | |
83 protected void doReferenceEventsOut(ArtifactAndFacet aaf, Document doc, boolean visible, int idx) { | |
84 logger.debug("doReferenceEventOut"); | |
85 | |
86 KMIndex<QWD> kms = | |
87 (KMIndex<QWD>)aaf.getData(context); | |
88 | |
89 if(kms == null) { | |
90 return; | |
91 } | |
92 | |
93 XYSeriesCollection col = new XYSeriesCollection(); | |
94 | |
95 StyledXYSeries series = new StyledXYSeries(aaf.getFacetDescription(), false, doc); | |
96 | |
97 for (KMIndex.Entry<QWD> entry: kms) { | |
98 double km = entry.getKm(); | |
99 QWD qwd = entry.getValue(); | |
100 | |
101 series.add(km, qwd.getDeltaW()); | |
102 } | |
103 col.addSeries(series); | |
104 | |
105 addAxisDataset(col, idx, visible); | |
106 } | |
107 | |
108 } |