Mercurial > mxd2map
comparison src/java/de/intevation/mxd/reader/TextSymbolReader.java @ 317:5a2b5bc066eb
Implement Label Styles and Labels with background
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 20 Sep 2012 12:55:21 +0200 |
parents | 2cb2f26d0d54 |
children | a46adb3697fa |
comparison
equal
deleted
inserted
replaced
316:5e3a40a84539 | 317:5a2b5bc066eb |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011 by Intevation GmbH, Germany <info@intevation.de> | 2 * Copyright (c) 2012 by Intevation GmbH, Germany <info@intevation.de> |
3 * | 3 * |
4 * This file is part of MXD2map. | 4 * This file is part of MXD2map. |
5 * | 5 * |
6 * This program is free software under the LGPL (>=v2.1) | 6 * This program is free software under the LGPL (>=v2.1) |
7 * Read the file LICENCE.txt coming with the software for details | 7 * Read the file LICENCE.txt coming with the software for details |
13 * | 13 * |
14 * Authors: | 14 * Authors: |
15 * Raimund Renkert <raimund.renkert@intevation.de> | 15 * Raimund Renkert <raimund.renkert@intevation.de> |
16 * Bjoern Schilberg <bjoern.schilberg@intevation.de> | 16 * Bjoern Schilberg <bjoern.schilberg@intevation.de> |
17 * Stephan Holl <stephan.holl@intevation.de> | 17 * Stephan Holl <stephan.holl@intevation.de> |
18 * Andre Heinecke <aheinecke@intevation.de> | |
18 */ | 19 */ |
19 | 20 |
20 package de.intevation.mxd.reader; | 21 package de.intevation.mxd.reader; |
21 | 22 |
22 import java.awt.Color; | 23 import java.awt.Color; |
25 | 26 |
26 import com.esri.arcgis.display.ITextSymbol; | 27 import com.esri.arcgis.display.ITextSymbol; |
27 import com.esri.arcgis.display.TextSymbol; | 28 import com.esri.arcgis.display.TextSymbol; |
28 import com.esri.arcgis.display.IRgbColor; | 29 import com.esri.arcgis.display.IRgbColor; |
29 import com.esri.arcgis.display.RgbColor; | 30 import com.esri.arcgis.display.RgbColor; |
31 import com.esri.arcgis.display.LineCallout; | |
32 import com.esri.arcgis.display.ITextBackground; | |
33 import com.esri.arcgis.display.IColor; | |
30 import com.esri.arcgis.support.ms.stdole.Font; | 34 import com.esri.arcgis.support.ms.stdole.Font; |
31 | 35 |
32 import org.w3c.dom.Element; | 36 import org.w3c.dom.Element; |
33 import java.io.IOException; | 37 import java.io.IOException; |
34 | 38 |
117 symbolElement.setAttribute( | 121 symbolElement.setAttribute( |
118 "size", | 122 "size", |
119 String.valueOf(symbol.getSize())); | 123 String.valueOf(symbol.getSize())); |
120 } | 124 } |
121 catch(IOException ioe) { | 125 catch(IOException ioe) { |
122 logger.warn("Could not read size. Setting size to 1."); | 126 logger.warn("Could not read size. Setting size to 10."); |
123 symbolElement.setAttribute("size", "1"); | 127 symbolElement.setAttribute("size", "10"); |
124 } | 128 } |
125 | 129 |
126 try { | 130 try { |
127 symbolElement.setAttribute( | 131 symbolElement.setAttribute( |
128 "angle", | 132 "angle", |
156 catch(IOException ioe) { | 160 catch(IOException ioe) { |
157 logger.warn("Could not read font. Setting font to \"FreeSans\"."); | 161 logger.warn("Could not read font. Setting font to \"FreeSans\"."); |
158 symbolElement.setAttribute("font", "FreeSans"); | 162 symbolElement.setAttribute("font", "FreeSans"); |
159 } | 163 } |
160 symbolElement.setAttribute("type", "text"); | 164 symbolElement.setAttribute("type", "text"); |
165 | |
166 // Background | |
167 try { | |
168 ITextBackground background = symbol.getBackground(); | |
169 if (background != null) { | |
170 if (background instanceof LineCallout) { | |
171 LineCallout lc = (LineCallout)background; | |
172 IColor pcolor = lc.getBorder().getColor(); | |
173 if(pcolor instanceof IRgbColor) { | |
174 IRgbColor color = (IRgbColor)pcolor; | |
175 Color c = new Color ( | |
176 color.getRed(), | |
177 color.getGreen(), | |
178 color.getBlue()); | |
179 symbolElement.setAttribute("bg_color", String.valueOf(c.getRGB())); | |
180 symbolElement.setAttribute("bg_transparency", | |
181 String.valueOf(color.getTransparency())); | |
182 } | |
183 else { | |
184 RgbColor col = new RgbColor(); | |
185 col.setRGB(pcolor.getRGB()); | |
186 Color c = new Color ( | |
187 col.getRed(), | |
188 col.getGreen(), | |
189 col.getBlue()); | |
190 symbolElement.setAttribute("bg_color", String.valueOf(c.getRGB())); | |
191 symbolElement.setAttribute("bg_transparency", | |
192 String.valueOf(col.getTransparency())); | |
193 } | |
194 } else { | |
195 logger.warn("Unhandled background of class: " + | |
196 background.getClass().toString()); | |
197 } | |
198 } | |
199 } | |
200 catch(Exception e) { | |
201 logger.warn("Could not read backgroundcolor."); | |
202 } | |
203 | |
161 return symbolElement; | 204 return symbolElement; |
162 } | 205 } |
163 } | 206 } |
164 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 207 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |