comparison src/java/de/intevation/mxd/writer/FillStyleWriter.java @ 150:7b1433d3b574

Handle outlines with width < 1 and transparent color.
author vc11884admin@VC11884.win.bsh.de
date Wed, 29 Jun 2011 19:29:14 +0200
parents b2c5a66022f1
children b1e4a871033e
comparison
equal deleted inserted replaced
149:07e2033dd60e 150:7b1433d3b574
32 Logger.getLogger(FillStyleWriter.class); 32 Logger.getLogger(FillStyleWriter.class);
33 33
34 private mapObj map; 34 private mapObj map;
35 private classObj cl; 35 private classObj cl;
36 private styleObj style; 36 private styleObj style;
37 private colorObj fill;
37 38
38 public FillStyleWriter (mapObj map, classObj cl) { 39 public FillStyleWriter (mapObj map, classObj cl) {
39 logger.debug("contructor(mapObj, classObj)"); 40 logger.debug("contructor(mapObj, classObj)");
40 this.map = map; 41 this.map = map;
41 this.cl = cl; 42 this.cl = cl;
57 58
58 if(((symbols.getLength() > 1 && i == 0) || 59 if(((symbols.getLength() > 1 && i == 0) ||
59 (symbols.getLength() == 1 && 60 (symbols.getLength() == 1 &&
60 !symbolElement.hasAttribute("hatch"))) && 61 !symbolElement.hasAttribute("hatch"))) &&
61 type.equals("line")) { 62 type.equals("line")) {
63 if(symbolElement.hasAttribute("color")) {
64 Color oCol = Color.decode(
65 symbolElement.getAttribute("color"));
66 fill = new colorObj(
67 oCol.getRed(),
68 oCol.getGreen(),
69 oCol.getBlue(),
70 -4);
71 }
62 writeOutline(nextSym); 72 writeOutline(nextSym);
63 if (symbols.getLength() == 1) { 73 if (symbols.getLength() == 1) {
64 writeSimple(symbolElement); 74 writeSimple(symbolElement);
65 } 75 }
66 } 76 }
129 */ 139 */
130 private void writeOutline(Element symbolElement) { 140 private void writeOutline(Element symbolElement) {
131 logger.debug("writeOutline()"); 141 logger.debug("writeOutline()");
132 //write transparent outline 142 //write transparent outline
133 colorObj color = new colorObj(-1, -1, -1, -4); 143 colorObj color = new colorObj(-1, -1, -1, -4);
144 double w = 0;
145 double transp = -1;
134 if(symbolElement.hasAttribute("width")) { 146 if(symbolElement.hasAttribute("width")) {
135 double w = 0;
136 try { 147 try {
137 w = Double.parseDouble(symbolElement.getAttribute("width")); 148 w = Double.parseDouble(symbolElement.getAttribute("width"));
138 } 149 transp = Double.parseDouble(
139 catch(NumberFormatException nfe) { 150 symbolElement.getAttribute("transparency"));
140 logger.warn("Error setting outline width."); 151 }
152 catch(NumberFormatException nfe) {
153 logger.warn("Error setting outline width or transparency.");
141 w = 0; 154 w = 0;
142 } 155 transp = -1;
143 if (w < 1.0) {
144 return;
145 } 156 }
146 } 157 }
147 //write new style for the outline 158 //write new style for the outline
148 //TODO write further attribute like pattern etc. 159 //TODO write further attribute like pattern etc.
149 Color oCol = Color.decode( 160 Color oCol = Color.decode(
150 symbolElement.getAttribute("color")); 161 symbolElement.getAttribute("color"));
151 162
152 styleObj outline = new styleObj (cl); 163 styleObj outline = new styleObj (cl);
153 164 if (w < 1.0 && transp > 0) {
154 colorObj outlinecolor = new colorObj( 165 symbolElement.setAttribute("width", "1");
155 oCol.getRed(), 166 outline.setOutlinecolor(fill);
156 oCol.getGreen(), 167 }
157 oCol.getBlue(), 168 else {
158 -4); 169 colorObj outlinecolor = new colorObj(
159 outline.setOutlinecolor(outlinecolor); 170 oCol.getRed(),
171 oCol.getGreen(),
172 oCol.getBlue(),
173 -4);
174 outline.setOutlinecolor(outlinecolor);
175 }
160 try { 176 try {
161 outline.setOutlinewidth(Double.parseDouble( 177 outline.setOutlinewidth(Double.parseDouble(
162 symbolElement.getAttribute("width"))); 178 symbolElement.getAttribute("width")));
163 } 179 }
164 catch(NumberFormatException nfe) { 180 catch(NumberFormatException nfe) {
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)