Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 1754:8e6615ad60b8
Added some simple caching for themes. Only used in sticky annotations by now.
flys-artifacts/trunk@3057 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 21 Oct 2011 15:19:49 +0000 |
parents | 6cdc7a77d3d4 |
children | 41ba2276d785 |
comparison
equal
deleted
inserted
replaced
1753:741ba9e34c7d | 1754:8e6615ad60b8 |
---|---|
34 | 34 |
35 import org.jfree.ui.RectangleInsets; | 35 import org.jfree.ui.RectangleInsets; |
36 | 36 |
37 import de.intevation.flys.exports.ChartExportHelper; | 37 import de.intevation.flys.exports.ChartExportHelper; |
38 import de.intevation.flys.jfree.FLYSAnnotation; | 38 import de.intevation.flys.jfree.FLYSAnnotation; |
39 import de.intevation.flys.utils.ThemeUtil; | |
40 import de.intevation.flys.jfree.StickyAxisAnnotation; | 39 import de.intevation.flys.jfree.StickyAxisAnnotation; |
41 | 40 |
41 import de.intevation.flys.utils.ThemeAccess; | |
42 | 42 |
43 /** | 43 /** |
44 * An abstract base class for creating XY charts. | 44 * An abstract base class for creating XY charts. |
45 * | 45 * |
46 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 46 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
444 XYItemRenderer renderer = plot.getRenderer(idx); | 444 XYItemRenderer renderer = plot.getRenderer(idx); |
445 | 445 |
446 for (FLYSAnnotation fa: annotations) { | 446 for (FLYSAnnotation fa: annotations) { |
447 Document theme = fa.getTheme(); | 447 Document theme = fa.getTheme(); |
448 | 448 |
449 Color color = theme != null | 449 ThemeAccess themeAccess = new ThemeAccess(theme); |
450 ? ThemeUtil.parseLineColorField(theme) | 450 |
451 : null; | 451 Color color = themeAccess.parseLineColorField(); |
452 | 452 int lineWidth = themeAccess.parseLineWidth(); |
453 if (color == null) { | |
454 color = Color.black; | |
455 } | |
456 | |
457 int lineWidth = theme != null | |
458 ? ThemeUtil.parseLineWidth(theme) | |
459 : 1; | |
460 | 453 |
461 lic.add(new LegendItem(fa.getLabel(), color)); | 454 lic.add(new LegendItem(fa.getLabel(), color)); |
462 | 455 |
463 for (XYTextAnnotation ta: fa.getAnnotations()) { | 456 for (XYTextAnnotation ta: fa.getAnnotations()) { |
464 if(ta instanceof StickyAxisAnnotation) { | 457 if(ta instanceof StickyAxisAnnotation) { |
465 StickyAxisAnnotation sta = (StickyAxisAnnotation)ta; | 458 StickyAxisAnnotation sta = (StickyAxisAnnotation)ta; |
466 sta.applyTheme(theme); | 459 sta.applyTheme(themeAccess); |
467 renderer.addAnnotation(sta); | 460 renderer.addAnnotation(sta); |
468 } | 461 } |
469 else { | 462 else { |
470 ta.setPaint(color); | 463 ta.setPaint(color); |
471 ta.setOutlineStroke(new BasicStroke((float) lineWidth)); | 464 ta.setOutlineStroke(new BasicStroke((float) lineWidth)); |