annotate src/java/de/intevation/mxd/reader/TextSymbolReader.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 5a2b5bc066eb
children a46adb3697fa
rev   line source
243
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
1 /*
317
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
2 * Copyright (c) 2012 by Intevation GmbH, Germany <info@intevation.de>
243
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
3 *
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
4 * This file is part of MXD2map.
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
5 *
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
6 * This program is free software under the LGPL (>=v2.1)
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
7 * Read the file LICENCE.txt coming with the software for details
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
8 * or visit http://www.gnu.org/licenses/ if it does not exist.
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
9 *
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
10 * MXD2map has been developed on behalf of the
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
11 * Bundesamt fuer Seeschifffahrt und Hydrographie (BSH) in Hamburg
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
12 * by Intevation GmbH.
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
13 *
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
14 * Authors:
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
15 * Raimund Renkert <raimund.renkert@intevation.de>
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
16 * Bjoern Schilberg <bjoern.schilberg@intevation.de>
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
17 * Stephan Holl <stephan.holl@intevation.de>
317
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
18 * Andre Heinecke <aheinecke@intevation.de>
243
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
19 */
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
20
179
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 package de.intevation.mxd.reader;
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 import java.awt.Color;
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 import org.apache.log4j.Logger;
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 import com.esri.arcgis.display.ITextSymbol;
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 import com.esri.arcgis.display.TextSymbol;
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 import com.esri.arcgis.display.IRgbColor;
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 import com.esri.arcgis.display.RgbColor;
317
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
31 import com.esri.arcgis.display.LineCallout;
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
32 import com.esri.arcgis.display.ITextBackground;
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
33 import com.esri.arcgis.display.IColor;
179
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 import com.esri.arcgis.support.ms.stdole.Font;
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 import org.w3c.dom.Element;
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 import java.io.IOException;
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39 /**
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 * Reads text symbol information.
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 *
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 */
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 public class TextSymbolReader
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 extends AbstractSymbolReader {
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 /**
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 * The logger.
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49 */
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 private static final Logger logger =
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 Logger.getLogger(TextSymbolReader.class);
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 /**
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 * Private member.
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 */
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 private TextSymbol symbol;
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57
181
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
58 /**
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
59 * Constructor with text symbol.
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
60 *
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
61 * @param symbol The symbol used to write text.
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 180
diff changeset
62 */
179
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 public TextSymbolReader(ITextSymbol symbol)
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 throws Exception {
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 logger.debug("contructor()");
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 if(symbol instanceof TextSymbol) {
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 this.symbol = (TextSymbol)symbol;
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 }
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 else {
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 throw new Exception("Not a TextSymbol!");
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 }
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 }
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 /**
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 * Reads the symbol attributes.
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 *
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 * @return The XML node.
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 */
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 public Element read() {
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 logger.debug("read()");
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81 Element symbolElement = util.addSymbol(parent);
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 try {
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 symbolElement.setAttribute("name", symbol.getNameString());
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 }
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 catch(IOException ioe) {
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 logger.warn("Could not read name. Setting name to \"default\".");
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88 symbolElement.setAttribute("name", "default");
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
89 }
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
90
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 symbolElement.setAttribute("style", "text");
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
93 try {
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
94 if(symbol.getColor() instanceof IRgbColor) {
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
95 IRgbColor color = (IRgbColor)symbol.getColor();
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
96 Color c = new Color (
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97 color.getRed(),
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 color.getGreen(),
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 color.getBlue());
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 symbolElement.setAttribute("color", String.valueOf(c.getRGB()));
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101 symbolElement.setAttribute("transparency",
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102 String.valueOf(color.getTransparency()));
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
103 }
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
104 else {
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
105 RgbColor col = new RgbColor();
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
106 col.setRGB(symbol.getColor().getRGB());
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
107 Color c = new Color (
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
108 col.getRed(),
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
109 col.getGreen(),
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
110 col.getBlue());
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
111 symbolElement.setAttribute("color", String.valueOf(c.getRGB()));
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
112 symbolElement.setAttribute("transparency",
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
113 String.valueOf(col.getTransparency()));
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
114 }
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
115 }
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
116 catch(IOException ioe) {
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
117 logger.warn("Could not read color.");
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
118 }
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
119
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
120 try {
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
121 symbolElement.setAttribute(
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
122 "size",
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
123 String.valueOf(symbol.getSize()));
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
124 }
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
125 catch(IOException ioe) {
317
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
126 logger.warn("Could not read size. Setting size to 10.");
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
127 symbolElement.setAttribute("size", "10");
179
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
128 }
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130 try {
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 symbolElement.setAttribute(
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
132 "angle",
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
133 String.valueOf(symbol.getAngle()));
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
134 }
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
135 catch(IOException ioe) {
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
136 logger.warn("Could not read angle.");
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
137 }
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
138
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
139 try {
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
140 symbolElement.setAttribute(
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
141 "offset",
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
142 symbol.getXOffset() + "," + symbol.getYOffset());
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
143 }
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
144 catch(IOException ioe) {
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
145 logger.warn("Could not read offset.");
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
146 }
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
147
180
f4eb506499f5 Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents: 179
diff changeset
148 try {
179
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
149 Font f = symbol.getFont();
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
150 symbolElement.setAttribute("font", f.getName());
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
151 symbolElement.setAttribute("char_set", String.valueOf(f.getCharset()));
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
152 symbolElement.setAttribute("bold", String.valueOf(f.getBold()));
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
153 symbolElement.setAttribute("italic", String.valueOf(f.getItalic()));
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
154 symbolElement.setAttribute("font_size", String.valueOf(f.getSize()));
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
155 symbolElement.setAttribute(
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
156 "strike_through",
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
157 String.valueOf(f.getStrikethrough()));
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
158 symbolElement.setAttribute("weight", String.valueOf(f.getWeight()));
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
159 }
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
160 catch(IOException ioe) {
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
161 logger.warn("Could not read font. Setting font to \"FreeSans\".");
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
162 symbolElement.setAttribute("font", "FreeSans");
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
163 }
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
164 symbolElement.setAttribute("type", "text");
317
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
165
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
166 // Background
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
167 try {
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
168 ITextBackground background = symbol.getBackground();
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
169 if (background != null) {
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
170 if (background instanceof LineCallout) {
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
171 LineCallout lc = (LineCallout)background;
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
172 IColor pcolor = lc.getBorder().getColor();
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
173 if(pcolor instanceof IRgbColor) {
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
174 IRgbColor color = (IRgbColor)pcolor;
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
175 Color c = new Color (
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
176 color.getRed(),
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
177 color.getGreen(),
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
178 color.getBlue());
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
179 symbolElement.setAttribute("bg_color", String.valueOf(c.getRGB()));
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
180 symbolElement.setAttribute("bg_transparency",
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
181 String.valueOf(color.getTransparency()));
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
182 }
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
183 else {
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
184 RgbColor col = new RgbColor();
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
185 col.setRGB(pcolor.getRGB());
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
186 Color c = new Color (
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
187 col.getRed(),
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
188 col.getGreen(),
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
189 col.getBlue());
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
190 symbolElement.setAttribute("bg_color", String.valueOf(c.getRGB()));
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
191 symbolElement.setAttribute("bg_transparency",
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
192 String.valueOf(col.getTransparency()));
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
193 }
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
194 } else {
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
195 logger.warn("Unhandled background of class: " +
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
196 background.getClass().toString());
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
197 }
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
198 }
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
199 }
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
200 catch(Exception e) {
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
201 logger.warn("Could not read backgroundcolor.");
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
202 }
5a2b5bc066eb Implement Label Styles and Labels with background
Andre Heinecke <aheinecke@intevation.de>
parents: 262
diff changeset
203
179
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
204 return symbolElement;
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
205 }
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
206 }
f3a91cd7440b Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
207 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)