Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixDerivedCurveGenerator.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixDerivedCurveGenerator.java@bd047b71ab37 |
children | 4897a58c8746 |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.exports.fixings; | |
2 | |
3 import org.apache.log4j.Logger; | |
4 import org.w3c.dom.Document; | |
5 | |
6 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; | |
7 import org.dive4elements.river.artifacts.model.FacetTypes; | |
8 import org.dive4elements.river.artifacts.model.fixings.FixDerivateFacet; | |
9 import org.dive4elements.river.artifacts.model.fixings.FixFunction; | |
10 import org.dive4elements.river.artifacts.resources.Resources; | |
11 import org.dive4elements.river.exports.ChartGenerator; | |
12 import org.dive4elements.river.jfree.JFreeUtil; | |
13 import org.dive4elements.river.jfree.StyledXYSeries; | |
14 | |
15 /** | |
16 * Generator for fixation derived function curve. | |
17 * | |
18 * @author <a href="mailto:christian.lins@intevation.de">Christian Lins</a> | |
19 */ | |
20 public class FixDerivedCurveGenerator | |
21 extends FixChartGenerator | |
22 implements FacetTypes | |
23 { | |
24 /** Private logger. */ | |
25 private static Logger logger = | |
26 Logger.getLogger(FixDerivedCurveGenerator.class); | |
27 | |
28 public static final String I18N_CHART_TITLE = | |
29 "chart.fixings.derivedcurve.title"; | |
30 | |
31 public static final String I18N_CHART_SUBTITLE = | |
32 "chart.fixings.derivedcurve.subtitle"; | |
33 | |
34 public static final String I18N_XAXIS_LABEL = | |
35 "chart.fixings.derivedcurve.xaxis.label"; | |
36 | |
37 public static final String I18N_YAXIS_LABEL = | |
38 "chart.fixings.derivedcurve.yaxis.label"; | |
39 | |
40 public static final String I18N_CHART_TITLE_DEFAULT = | |
41 "Ableitungskurve"; | |
42 | |
43 public static final String I18N_XAXIS_LABEL_DEFAULT = | |
44 "Q [m\u00B3/s]"; | |
45 | |
46 public static final String I18N_YAXIS_LABEL_DEFAULT = | |
47 "W [NN + m]"; | |
48 | |
49 public static enum YAXIS { | |
50 W(0), | |
51 Q(1); | |
52 public int idx; | |
53 private YAXIS(int c) { | |
54 idx = c; | |
55 } | |
56 } | |
57 | |
58 | |
59 @Override | |
60 public void doOut(ArtifactAndFacet aaf, Document doc, boolean visible) { | |
61 logger.debug("doOut"); | |
62 | |
63 if (FacetTypes.IS.MANUALPOINTS(aaf.getFacetName())) { | |
64 doPoints(aaf.getData(context), | |
65 aaf, | |
66 doc, visible, YAXIS.W.idx); | |
67 } | |
68 else { | |
69 FixDerivateFacet facet = (FixDerivateFacet)aaf.getFacet(); | |
70 FixFunction func = (FixFunction)facet.getData( | |
71 aaf.getArtifact(), context); | |
72 | |
73 if (func == null) { | |
74 logger.warn("doOut: Facet does not contain FixFunction"); | |
75 return; | |
76 } | |
77 | |
78 double maxQ = func.getMaxQ(); | |
79 | |
80 if (maxQ > 0) { | |
81 StyledXYSeries series = JFreeUtil.sampleFunction2D( | |
82 func.getFunction(), | |
83 doc, | |
84 aaf.getFacetDescription(), | |
85 500, // number of samples | |
86 0.0 , // start | |
87 maxQ); // end | |
88 addAxisSeries(series, 0, visible); | |
89 } | |
90 } | |
91 } | |
92 | |
93 | |
94 @Override | |
95 protected String getDefaultChartTitle() { | |
96 return msg(I18N_CHART_TITLE, I18N_CHART_TITLE_DEFAULT); | |
97 } | |
98 | |
99 | |
100 @Override | |
101 protected String getChartTitle() { | |
102 return Resources.format( | |
103 context.getMeta(), | |
104 I18N_CHART_TITLE, | |
105 I18N_CHART_TITLE_DEFAULT, | |
106 context.getContextValue(CURRENT_KM)); | |
107 } | |
108 | |
109 | |
110 @Override | |
111 protected String getDefaultXAxisLabel() { | |
112 return msg(I18N_XAXIS_LABEL, I18N_XAXIS_LABEL_DEFAULT); | |
113 } | |
114 | |
115 | |
116 @Override | |
117 protected String getDefaultYAxisLabel(int pos) { | |
118 return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT); | |
119 } | |
120 | |
121 | |
122 @Override | |
123 protected ChartGenerator.YAxisWalker getYAxisWalker() { | |
124 return new YAxisWalker() { | |
125 @Override | |
126 public int length() { | |
127 return YAXIS.values().length; | |
128 } | |
129 | |
130 @Override | |
131 public String getId(int idx) { | |
132 YAXIS[] yaxes = YAXIS.values(); | |
133 return yaxes[idx].toString(); | |
134 } | |
135 }; | |
136 } | |
137 } | |
138 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |