comparison flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java @ 2047:0318fa6f0844

Make use of first attributes specified in the ChartSettings. NOTE: work is still in progress. flys-artifacts/trunk@3535 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 23 Dec 2011 08:57:25 +0000
parents a7c437c9547e
children 49b7c2b1a6a7
comparison
equal deleted inserted replaced
2046:2ae0627f956e 2047:0318fa6f0844
76 protected CallContext context; 76 protected CallContext context;
77 77
78 /** The artifact that is used to decorate the chart with meta information.*/ 78 /** The artifact that is used to decorate the chart with meta information.*/
79 protected Artifact master; 79 protected Artifact master;
80 80
81 /** The settings that should be used during output creation.*/
82 protected Settings settings;
83
81 84
82 public void init(Document request, OutputStream out, CallContext context) { 85 public void init(Document request, OutputStream out, CallContext context) {
83 logger.debug("ChartGenerator.init"); 86 logger.debug("ChartGenerator.init");
84 87
85 this.request = request; 88 this.request = request;
88 } 91 }
89 92
90 93
91 public void setMasterArtifact(Artifact master) { 94 public void setMasterArtifact(Artifact master) {
92 this.master = master; 95 this.master = master;
96 }
97
98
99 @Override
100 public void setSettings(Settings settings) {
101 this.settings = settings;
102 }
103
104
105 /**
106 * Returns the chart title provided by <i>settings</i>.
107 *
108 * @param settings A ChartSettings object.
109 *
110 * @return the title provided by <i>settings</i> or null if no
111 * <i>ChartSection</i> is provided by <i>settings</i>.
112 *
113 * @throws NullPointerException if <i>settings</i> is null.
114 */
115 public String getChartTitle(ChartSettings settings) {
116 ChartSection cs = settings.getChartSection();
117 return cs != null ? cs.getTitle() : null;
118 }
119
120
121 /**
122 * Returns the chart subtitle provided by <i>settings</i>.
123 *
124 * @param settings A ChartSettings object.
125 *
126 * @return the subtitle provided by <i>settings</i> or null if no
127 * <i>ChartSection</i> is provided by <i>settings</i>.
128 *
129 * @throws NullPointerException if <i>settings</i> is null.
130 */
131 public String getChartSubtitle(ChartSettings settings) {
132 ChartSection cs = settings.getChartSection();
133 return cs != null ? cs.getSubtitle() : null;
134 }
135
136
137 /**
138 * Returns a boolean object that determines if the chart grid should be
139 * visible or not. This information needs to be provided by <i>settings</i>,
140 * otherweise the default is true.
141 *
142 * @param settings A ChartSettings object.
143 *
144 * @return true, if the chart grid should be visible otherwise false.
145 *
146 * @throws NullPointerException if <i>settings</i> is null.
147 */
148 public boolean isGridVisible(ChartSettings settings) {
149 ChartSection cs = settings.getChartSection();
150 Boolean displayGrid = cs.getDisplayGrid();
151
152 return displayGrid != null ? displayGrid : true;
153 }
154
155
156 /**
157 * Returns a boolean object that determines if the chart legend should be
158 * visible or not. This information needs to be provided by <i>settings</i>,
159 * otherwise the default is true.
160 *
161 * @param settings A ChartSettings object.
162 *
163 * @return true, if the chart legend should be visible otherwise false.
164 *
165 * @throws NullPointerException if <i>settings</i> is null.
166 */
167 public boolean isLegendVisible(ChartSettings settings) {
168 LegendSection ls = settings.getLegendSection();
169 Boolean displayLegend = ls.getVisibility();
170
171 return displayLegend != null ? displayLegend : true;
172 }
173
174
175 /**
176 * Returns the legend font size specified in <i>settings</i> or null if no
177 * <i>LegendSection</i> is provided by <i>settings</i>.
178 *
179 * @param settings A ChartSettings object.
180 *
181 * @return the legend font size or null.
182 *
183 * @throws NullPointerException if <i>settings</i> is null.
184 */
185 public Integer getLegendFontSize(ChartSettings settings) {
186 LegendSection ls = settings.getLegendSection();
187 return ls != null ? ls.getFontSize() : null;
93 } 188 }
94 189
95 190
96 protected Locale getLocale() { 191 protected Locale getLocale() {
97 CallMeta meta = context.getMeta(); 192 CallMeta meta = context.getMeta();
293 * Returns an instance of <i>EmptySettings</i> currently! 388 * Returns an instance of <i>EmptySettings</i> currently!
294 * 389 *
295 * @return an instance of <i>EmptySettings</i>. 390 * @return an instance of <i>EmptySettings</i>.
296 */ 391 */
297 public Settings getSettings() { 392 public Settings getSettings() {
298 return new EmptySettings(); 393 return settings != null ? settings : new EmptySettings();
394 }
395
396
397 /**
398 * Returns the <i>settings</i> as <i>ChartSettings</i>.
399 *
400 * @return the <i>settings</i> as <i>ChartSettings</i> or null, if
401 * <i>settings</i> is not an instance of <i>ChartSettings</i>.
402 */
403 public ChartSettings getChartSettings() {
404 if (settings instanceof ChartSettings) {
405 return (ChartSettings) settings;
406 }
407
408 return null;
299 } 409 }
300 } 410 }
301 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 411 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org