comparison artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator.java @ 6905:1b35b2ddfc28

Artifacts: Introduce ThemeDocument & make stuff compileable again. THIS BREAKS THE SYSTEM! TODO: Move ThemeUtils into ThemeDocument.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 22 Aug 2013 23:31:38 +0200
parents a38640f273ae
children 7a9cbb3a3d5a
comparison
equal deleted inserted replaced
6904:d710bd3df387 6905:1b35b2ddfc28
31 import org.dive4elements.river.jfree.StyledAreaSeriesCollection; 31 import org.dive4elements.river.jfree.StyledAreaSeriesCollection;
32 import org.dive4elements.river.jfree.StyledSeries; 32 import org.dive4elements.river.jfree.StyledSeries;
33 import org.dive4elements.river.model.River; 33 import org.dive4elements.river.model.River;
34 import org.dive4elements.river.themes.LineStyle; 34 import org.dive4elements.river.themes.LineStyle;
35 import org.dive4elements.river.themes.TextStyle; 35 import org.dive4elements.river.themes.TextStyle;
36 import org.dive4elements.river.themes.ThemeAccess; 36 import org.dive4elements.river.themes.ThemeDocument;
37 import org.dive4elements.river.utils.RiverUtils; 37 import org.dive4elements.river.utils.RiverUtils;
38 import org.dive4elements.river.utils.ThemeUtil;
39 38
40 import java.awt.BasicStroke; 39 import java.awt.BasicStroke;
41 import java.awt.Color; 40 import java.awt.Color;
42 import java.awt.Font; 41 import java.awt.Font;
43 import java.awt.Paint; 42 import java.awt.Paint;
196 StickyAxisAnnotation annotation, 195 StickyAxisAnnotation annotation,
197 XYPlot plot, 196 XYPlot plot,
198 ChartArea area, 197 ChartArea area,
199 LineStyle lineStyle, 198 LineStyle lineStyle,
200 TextStyle textStyle, 199 TextStyle textStyle,
201 Document theme 200 ThemeDocument theme
202 ) { 201 ) {
203 // OPTIMIZE pre-calculate area-related values 202 // OPTIMIZE pre-calculate area-related values
204 final float TEXT_OFF = 0.03f; 203 final float TEXT_OFF = 0.03f;
205 204
206 XYLineAnnotation lineAnnotation = null; 205 XYLineAnnotation lineAnnotation = null;
247 textAnnotation.setTextAnchor(TextAnchor.CENTER_RIGHT); 246 textAnnotation.setTextAnchor(TextAnchor.CENTER_RIGHT);
248 lineAnnotation = createRightStickAnnotation( 247 lineAnnotation = createRightStickAnnotation(
249 area2, annotation.getPos(), lineStyle); 248 area2, annotation.getPos(), lineStyle);
250 if (!Float.isNaN(annotation.getHitPoint()) && theme != null) { 249 if (!Float.isNaN(annotation.getHitPoint()) && theme != null) {
251 // New line annotation to hit curve. 250 // New line annotation to hit curve.
252 if (ThemeUtil.parseShowVerticalLine(theme)) { 251 if (theme.parseShowVerticalLine()) {
253 XYLineAnnotation hitLineAnnotation = 252 XYLineAnnotation hitLineAnnotation =
254 createStickyLineAnnotation( 253 createStickyLineAnnotation(
255 StickyAxisAnnotation.SimpleAxis.X_AXIS, 254 StickyAxisAnnotation.SimpleAxis.X_AXIS,
256 annotation.getHitPoint(), annotation.getPos(),// annotation.getHitPoint(), 255 annotation.getHitPoint(), annotation.getPos(),// annotation.getHitPoint(),
257 area2, lineStyle); 256 area2, lineStyle);
258 plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation, 257 plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation,
259 org.jfree.ui.Layer.BACKGROUND); 258 org.jfree.ui.Layer.BACKGROUND);
260 } 259 }
261 if (ThemeUtil.parseShowHorizontalLine(theme)) { 260 if (theme.parseShowHorizontalLine()) {
262 XYLineAnnotation lineBackAnnotation = 261 XYLineAnnotation lineBackAnnotation =
263 createStickyLineAnnotation( 262 createStickyLineAnnotation(
264 StickyAxisAnnotation.SimpleAxis.Y_AXIS2, 263 StickyAxisAnnotation.SimpleAxis.Y_AXIS2,
265 annotation.getPos(), annotation.getHitPoint(), 264 annotation.getPos(), annotation.getHitPoint(),
266 area2, lineStyle); 265 area2, lineStyle);
275 textAnnotation.setRotationAnchor(TextAnchor.CENTER_LEFT); 274 textAnnotation.setRotationAnchor(TextAnchor.CENTER_LEFT);
276 textAnnotation.setTextAnchor(TextAnchor.CENTER_LEFT); 275 textAnnotation.setTextAnchor(TextAnchor.CENTER_LEFT);
277 lineAnnotation = createLeftStickAnnotation(area, annotation.getPos(), lineStyle); 276 lineAnnotation = createLeftStickAnnotation(area, annotation.getPos(), lineStyle);
278 if (!Float.isNaN(annotation.getHitPoint()) && theme != null) { 277 if (!Float.isNaN(annotation.getHitPoint()) && theme != null) {
279 // New line annotation to hit curve. 278 // New line annotation to hit curve.
280 if (ThemeUtil.parseShowHorizontalLine(theme)) { 279 if (theme.parseShowHorizontalLine()) {
281 XYLineAnnotation hitLineAnnotation = 280 XYLineAnnotation hitLineAnnotation =
282 createStickyLineAnnotation( 281 createStickyLineAnnotation(
283 StickyAxisAnnotation.SimpleAxis.Y_AXIS, 282 StickyAxisAnnotation.SimpleAxis.Y_AXIS,
284 annotation.getPos(), annotation.getHitPoint(), 283 annotation.getPos(), annotation.getHitPoint(),
285 area, lineStyle); 284 area, lineStyle);
286 plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation, 285 plot.getRenderer(rendererIndex).addAnnotation(hitLineAnnotation,
287 org.jfree.ui.Layer.BACKGROUND); 286 org.jfree.ui.Layer.BACKGROUND);
288 } 287 }
289 if (ThemeUtil.parseShowVerticalLine(theme)) { 288 if (theme.parseShowVerticalLine()) {
290 XYLineAnnotation lineBackAnnotation = 289 XYLineAnnotation lineBackAnnotation =
291 createStickyLineAnnotation( 290 createStickyLineAnnotation(
292 StickyAxisAnnotation.SimpleAxis.X_AXIS, 291 StickyAxisAnnotation.SimpleAxis.X_AXIS,
293 annotation.getHitPoint(), annotation.getPos(), 292 annotation.getHitPoint(), annotation.getPos(),
294 area, lineStyle); 293 area, lineStyle);
450 449
451 // Walk over all Annotation sets. 450 // Walk over all Annotation sets.
452 for (RiverAnnotation fa: annotations) { 451 for (RiverAnnotation fa: annotations) {
453 452
454 // Access text styling, if any. 453 // Access text styling, if any.
455 Document theme = fa.getTheme(); 454 ThemeDocument theme = fa.getTheme();
456 TextStyle textStyle = null; 455 TextStyle textStyle = null;
457 LineStyle lineStyle = null; 456 LineStyle lineStyle = null;
458 457
459 // Get Themeing information and add legend item. 458 // Get Themeing information and add legend item.
460 if (theme != null) { 459 if (theme != null) {
461 ThemeAccess themeAccess = new ThemeAccess(theme); 460 textStyle = theme.parseTextStyle();
462 textStyle = themeAccess.parseTextStyle(); 461 lineStyle = theme.parseComplexLineStyle();
463 lineStyle = themeAccess.parseLineStyle();
464 if (fa.getLabel() != null) { 462 if (fa.getLabel() != null) {
465 LegendItemCollection lic = new LegendItemCollection(); 463 LegendItemCollection lic = new LegendItemCollection();
466 LegendItemCollection old = plot.getFixedLegendItems(); 464 LegendItemCollection old = plot.getFixedLegendItems();
467 lic.add(createLegendItem(theme, fa.getLabel())); 465 lic.add(createLegendItem(theme, fa.getLabel()));
468 // (Re-)Add prior legend entries. 466 // (Re-)Add prior legend entries.
507 /** For every outable (i.e. facets), this function is 505 /** For every outable (i.e. facets), this function is
508 * called and handles the data accordingly. */ 506 * called and handles the data accordingly. */
509 @Override 507 @Override
510 public abstract void doOut( 508 public abstract void doOut(
511 ArtifactAndFacet bundle, 509 ArtifactAndFacet bundle,
512 Document attr, 510 ThemeDocument attr,
513 boolean visible); 511 boolean visible);
514 512
515 513
516 protected abstract YAxisWalker getYAxisWalker(); 514 protected abstract YAxisWalker getYAxisWalker();
517 515
620 * @param visible The visibility of the annotations. 618 * @param visible The visibility of the annotations.
621 */ 619 */
622 public void doAnnotations( 620 public void doAnnotations(
623 RiverAnnotation annotations, 621 RiverAnnotation annotations,
624 ArtifactAndFacet aandf, 622 ArtifactAndFacet aandf,
625 Document theme, 623 ThemeDocument theme,
626 boolean visible 624 boolean visible
627 ){ 625 ){
628 logger.debug("doAnnotations"); 626 logger.debug("doAnnotations");
629 627
630 // Add all annotations to our annotation pool. 628 // Add all annotations to our annotation pool.
1832 * @param theme The theme of the chart line. 1830 * @param theme The theme of the chart line.
1833 * @param name The displayed name of the item. 1831 * @param name The displayed name of the item.
1834 * 1832 *
1835 * @return a new LegendItem instance. 1833 * @return a new LegendItem instance.
1836 */ 1834 */
1837 public LegendItem createLegendItem(Document theme, String name) { 1835 public LegendItem createLegendItem(ThemeDocument theme, String name) {
1838 // OPTIMIZE Pass font, parsed Theme items. 1836 // OPTIMIZE Pass font, parsed Theme items.
1839 ThemeAccess themeAccess = new ThemeAccess(theme); 1837
1840 1838 Color color = theme.parseComplexLineColorField();
1841 Color color = themeAccess.parseLineColorField();
1842 LegendItem legendItem = new LegendItem(name, color); 1839 LegendItem legendItem = new LegendItem(name, color);
1843 1840
1844 legendItem.setLabelFont(createLegendLabelFont()); 1841 legendItem.setLabelFont(createLegendLabelFont());
1845 return legendItem; 1842 return legendItem;
1846 } 1843 }

http://dive4elements.wald.intevation.org