Mercurial > mxd2map
annotate src/java/de/intevation/mxd/writer/LabelStyleWriter.java @ 331:10939bda0aaa
* contrib/installer/example/example/epsg/epsg:
Add Gauss Kruger zone 2, Germany Zone 2, Germany Zone 3
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 22 Oct 2012 17:38:01 +0200 |
parents | b6c0fbae16dc |
children | da60e3ac2b5d |
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 cl.getLabel().insertStyle(style, -1); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
76 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
77 symbolSetObj symbolSet = map.getSymbolset(); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
78 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
79 if (symbolElement.hasAttribute("angle")) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
80 try { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
81 style.setAngle( |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
82 Double.parseDouble(symbolElement.getAttribute("angle"))); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
83 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
84 catch(NumberFormatException nfe) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
85 logger.warn("Error setting angle."); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
86 style.setAngle(0.0); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
87 } |
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 if(symbolElement.hasAttribute("angleBinding")) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
90 style.setBinding(2, |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
91 symbolElement.getAttribute("angleBinding")); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
92 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
93 if (symbolElement.hasAttribute("bg_color")) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
94 // Background color takes precedence over the color as |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
95 // background color can be archived by geomtransform |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
96 String c = symbolElement.getAttribute("bg_color"); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
97 Color col = Color.decode(c); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
98 colorObj color = new colorObj( |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
99 col.getRed(), |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
100 col.getGreen(), |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
101 col.getBlue(), |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
102 -4); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
103 style.setColor(color); |
321
b6c0fbae16dc
Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
317
diff
changeset
|
104 style.setGeomTransform("labelpoly"); |
317
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
105 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
106 if (symbolElement.hasAttribute ("size")) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
107 try { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
108 style.setSize(Double.parseDouble( |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
109 symbolElement.getAttribute("size"))); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
110 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
111 catch(NumberFormatException nfe) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
112 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
|
113 style.setSize(1); |
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 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
116 if(symbolElement.hasAttribute("outline_color")) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
117 Color oCol = Color.decode( |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
118 symbolElement.getAttribute("outline_color")); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
119 colorObj outlineColor = new colorObj( |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
120 oCol.getRed(), |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
121 oCol.getGreen(), |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
122 oCol.getBlue(), |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
123 -4); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
124 style.setOutlinecolor(outlineColor); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
125 try { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
126 style.setOutlinewidth(Double.parseDouble( |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
127 symbolElement.getAttribute("outline_size"))); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
128 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
129 catch(NumberFormatException nfe) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
130 logger.warn("Error setting outline width."); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
131 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
132 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
133 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
134 if (symbolElement.hasAttribute("x_offset")) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
135 try { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
136 double val = |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
137 Double.parseDouble(symbolElement.getAttribute("x_offset")); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
138 double r = Math.round(val); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
139 style.setOffsetx(r); |
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 catch (NumberFormatException nfe) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
142 logger.warn("Error setting the symbol x-offset"); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
143 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
144 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
145 if (symbolElement.hasAttribute("y_offset")) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
146 try { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
147 double val = |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
148 Double.parseDouble(symbolElement.getAttribute("y_offset")); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
149 double r = Math.round(val); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
150 //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
|
151 //in Mapserver positive values move downwards. |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
152 r = -r; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
153 style.setOffsety(r); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
154 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
155 catch (NumberFormatException nfe) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
156 logger.warn("Error setting the symbol y-offset."); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
157 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
158 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
159 String symType = symbolElement.getAttribute("style"); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
160 if(symType.equals("point") || |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
161 symType.equals("arrow") || |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
162 symType.equals("char") || |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
163 symType.equals("picture")) { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
164 SymbolWriter sw = new SymbolWriter(this.map, this.cl); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
165 sw.write(symbolElement); |
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 else { |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
168 return false; |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
169 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
170 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
171 String name = symbolElement.getAttribute("name"); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
172 style.setSymbolByName(map, name); |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
173 |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
174 return true; |
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 } |
5a2b5bc066eb
Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents:
diff
changeset
|
177 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |