comparison flys-artifacts/src/main/java/de/intevation/flys/themes/ThemeAccess.java @ 3464:0b9b2a0c4e64

Point labels can have a background color now. flys-artifacts/trunk@5132 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Thu, 26 Jul 2012 10:02:07 +0000
parents f062b5a90e26
children
comparison
equal deleted inserted replaced
3463:7198f04e4221 3464:0b9b2a0c4e64
1 package de.intevation.flys.themes; 1 package de.intevation.flys.themes;
2 2
3 import de.intevation.flys.jfree.StableXYDifferenceRenderer;
4 import de.intevation.flys.utils.ThemeUtil; 3 import de.intevation.flys.utils.ThemeUtil;
5 4
6 import java.awt.Color; 5 import java.awt.Color;
7 import java.awt.Font; 6 import java.awt.Font;
8 7
9 import org.jfree.chart.annotations.XYTextAnnotation;
10 import org.w3c.dom.Document; 8 import org.w3c.dom.Document;
11 9
12 10
13 /** Undocumented. */
14 public class ThemeAccess 11 public class ThemeAccess
15 { 12 {
16 protected Document theme; 13 protected Document theme;
17 14
18 protected Integer lineWidth; 15 protected Integer lineWidth;
88 } 85 }
89 } 86 }
90 return textBackground; 87 return textBackground;
91 } 88 }
92 89
93 public boolean parseShowTextBackground() { 90 public boolean parseLabelShowBackground() {
94 if (showTextBackground == null) { 91 if (showTextBackground == null) {
95 showTextBackground = ThemeUtil.parseShowTextBackground(theme); 92 showTextBackground = ThemeUtil.parseLabelShowBackground(theme);
96 } 93 }
97 return showTextBackground; 94 return showTextBackground;
98 } 95 }
99 96
100 97
113 110
114 public LineStyle parseLineStyle() { 111 public LineStyle parseLineStyle() {
115 return new LineStyle(parseLineColorField(), Integer.valueOf(parseLineWidth())); 112 return new LineStyle(parseLineColorField(), Integer.valueOf(parseLineWidth()));
116 } 113 }
117 114
118 public static class PointStyle {
119 // TODO tbd
120 }
121
122 public static class LineStyle {
123 protected Color lineColor;
124 protected int lineWidth;
125
126 public LineStyle(Color color, int width) {
127 this.lineColor = color;
128 this.lineWidth = width;
129 }
130
131 public int getWidth() {
132 return lineWidth;
133 }
134
135 public Color getColor() {
136 return lineColor;
137 }
138 }
139
140
141 public TextStyle parseTextStyle() { 115 public TextStyle parseTextStyle() {
142 return new TextStyle( 116 return new TextStyle(
143 parseTextColor(), 117 parseTextColor(),
144 parseTextFont(), 118 parseTextFont(),
145 parseTextBackground(), 119 parseTextBackground(),
146 parseShowTextBackground(), 120 parseLabelShowBackground(),
147 !parseTextOrientation().equals("horizontal")); 121 !parseTextOrientation().equals("horizontal"));
148 }
149
150
151 public static class TextStyle {
152 protected Color textColor;
153 protected Font font;
154 protected Color bgColor;
155 protected boolean showBg;
156 protected boolean isVertical;
157
158 public TextStyle(Color fgColor, Font font, Color bgColor,
159 boolean showBg, boolean isVertical
160 ) {
161 this.textColor = fgColor;
162 this.font = font;
163 this.bgColor = bgColor;
164 this.showBg = showBg;
165 this.isVertical = isVertical;
166 }
167
168 public void apply(XYTextAnnotation ta) {
169 ta.setPaint(textColor);
170 ta.setFont(font);
171 if (this.showBg) {
172 ta.setBackgroundPaint(bgColor);
173 }
174 if (this.isVertical) {
175 ta.setRotationAngle(270f*Math.PI/180f);
176 }
177 else {
178 ta.setRotationAngle(0);
179 }
180 }
181
182 public void apply(StableXYDifferenceRenderer renderer) {
183 renderer.setLabelColor(textColor);
184 renderer.setLabelFont(font);
185 if (this.showBg) {
186 renderer.setLabelBGColor(bgColor);
187 }
188 }
189 } 122 }
190 } 123 }
191 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 124 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org