Mercurial > mxd2map
annotate src/java/de/intevation/mxd/writer/LabelStyleWriter.java @ 320:9289b7c1b4ce
Minor style fix
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 20 Sep 2012 13:01:33 +0200 |
parents | 5a2b5bc066eb |
children | b6c0fbae16dc |
rev | line source |
---|---|
317
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
1 /* |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
2 * Copyright (c) 2012 by Intevation GmbH, Germany <info@intevation.de> |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
3 * |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
4 * This file is part of MXD2map. |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
5 * |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
6 * This program is free software under the LGPL (>=v2.1) |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
7 * Read the file LICENCE.txt coming with the software for details |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
8 * or visit http://www.gnu.org/licenses/ if it does not exist. |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
9 * |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
10 * MXD2map has been developed on behalf of the |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
11 * Bundesamt fuer Seeschifffahrt und Hydrographie (BSH) in Hamburg |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
12 * by Intevation GmbH. |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
13 * |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
14 * Authors: |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
15 * Raimund Renkert <raimund.renkert@intevation.de> |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
16 * Bjoern Schilberg <bjoern.schilberg@intevation.de> |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
17 * Stephan Holl <stephan.holl@intevation.de> |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
18 */ |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
19 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
20 package de.intevation.mxd.writer; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
21 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
22 import java.awt.Color; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
23 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
24 import org.apache.log4j.Logger; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
25 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
26 import org.w3c.dom.Element; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
27 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
28 import edu.umn.gis.mapscript.mapObj; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
29 import edu.umn.gis.mapscript.classObj; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
30 import edu.umn.gis.mapscript.styleObj; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
31 import edu.umn.gis.mapscript.colorObj; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
32 import edu.umn.gis.mapscript.labelObj; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
33 import edu.umn.gis.mapscript.symbolSetObj; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
34 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
35 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
36 /** |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
37 * The interface to the mapfile writer. |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
38 * |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
39 * @author <a href="mailto:aheinecke@intevation.de">Andre Heinecke</a> |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
40 */ |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
41 public class LabelStyleWriter { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
42 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
43 /** |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
44 * The Logger. |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
45 */ |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
46 private static final Logger logger = Logger.getLogger(LabelStyleWriter.class); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
47 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
48 /** |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
49 * Private member. |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
50 */ |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
51 private mapObj map; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
52 private classObj cl; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
53 private styleObj style; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
54 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
55 /** |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
56 * Contructor with map object and class object. |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
57 * |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
58 * @param map The map object. |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
59 * @param cl The class object containing the style. |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
60 */ |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
61 public LabelStyleWriter(mapObj map, classObj cl) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
62 this.map = map; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
63 this.cl = cl; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
64 this.style = new styleObj(cl); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
65 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
66 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
67 /** |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
68 * Write the content. |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
69 * |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
70 * @param symbolElement DOM element containing style attributes. |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
71 */ |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
72 public boolean write(Element symbolElement) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
73 logger.debug("write(Element)"); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
74 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
75 style.setGeomTransform("labelpoly"); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
76 cl.getLabel().insertStyle(style, -1); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
77 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
78 symbolSetObj symbolSet = map.getSymbolset(); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
79 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
80 if (symbolElement.hasAttribute("angle")) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
81 try { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
82 style.setAngle( |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
83 Double.parseDouble(symbolElement.getAttribute("angle"))); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
84 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
85 catch(NumberFormatException nfe) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
86 logger.warn("Error setting angle."); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
87 style.setAngle(0.0); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
88 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
89 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
90 if(symbolElement.hasAttribute("angleBinding")) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
91 style.setBinding(2, |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
92 symbolElement.getAttribute("angleBinding")); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
93 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
94 if (symbolElement.hasAttribute("bg_color")) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
95 // Background color takes precedence over the color as |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
96 // background color can be archived by geomtransform |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
97 String c = symbolElement.getAttribute("bg_color"); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
98 Color col = Color.decode(c); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
99 colorObj color = new colorObj( |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
100 col.getRed(), |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
101 col.getGreen(), |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
102 col.getBlue(), |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
103 -4); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
104 style.setColor(color); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
105 } else if(symbolElement.hasAttribute("color")) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
106 String c = symbolElement.getAttribute("color"); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
107 Color col = Color.decode(c); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
108 colorObj color = new colorObj( |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
109 col.getRed(), |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
110 col.getGreen(), |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
111 col.getBlue(), |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
112 -4); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
113 style.setColor(color); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
114 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
115 if (symbolElement.hasAttribute ("size")) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
116 try { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
117 style.setSize(Double.parseDouble( |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
118 symbolElement.getAttribute("size"))); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
119 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
120 catch(NumberFormatException nfe) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
121 logger.warn("Error setting size. Setting to deafult: 1."); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
122 style.setSize(1); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
123 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
124 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
125 if(symbolElement.hasAttribute("outline_color")) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
126 Color oCol = Color.decode( |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
127 symbolElement.getAttribute("outline_color")); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
128 colorObj outlineColor = new colorObj( |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
129 oCol.getRed(), |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
130 oCol.getGreen(), |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
131 oCol.getBlue(), |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
132 -4); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
133 style.setOutlinecolor(outlineColor); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
134 try { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
135 style.setOutlinewidth(Double.parseDouble( |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
136 symbolElement.getAttribute("outline_size"))); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
137 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
138 catch(NumberFormatException nfe) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
139 logger.warn("Error setting outline width."); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
140 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
141 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
142 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
143 if (symbolElement.hasAttribute("x_offset")) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
144 try { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
145 double val = |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
146 Double.parseDouble(symbolElement.getAttribute("x_offset")); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
147 double r = Math.round(val); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
148 style.setOffsetx(r); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
149 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
150 catch (NumberFormatException nfe) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
151 logger.warn("Error setting the symbol x-offset"); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
152 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
153 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
154 if (symbolElement.hasAttribute("y_offset")) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
155 try { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
156 double val = |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
157 Double.parseDouble(symbolElement.getAttribute("y_offset")); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
158 double r = Math.round(val); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
159 //In ArcGIS positive y offset values move the symbol upwards, |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
160 //in Mapserver positive values move downwards. |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
161 r = -r; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
162 style.setOffsety(r); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
163 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
164 catch (NumberFormatException nfe) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
165 logger.warn("Error setting the symbol y-offset."); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
166 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
167 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
168 String symType = symbolElement.getAttribute("style"); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
169 if(symType.equals("point") || |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
170 symType.equals("arrow") || |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
171 symType.equals("char") || |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
172 symType.equals("picture")) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
173 SymbolWriter sw = new SymbolWriter(this.map, this.cl); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
174 sw.write(symbolElement); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
175 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
176 else { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
177 return false; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
178 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
179 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
180 String name = symbolElement.getAttribute("name"); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
181 style.setSymbolByName(map, name); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
182 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
183 return true; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
184 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
185 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
186 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |