annotate src/java/de/intevation/mxd/reader/SimpleLineSymbolReader.java @ 174:707f13cfba74

Improved the commandline arguments and save the mapfile in the correct directory.
author raimund.renkert@intevation.de
date Wed, 06 Jul 2011 18:38:40 +0200
parents 7b1433d3b574
children f4eb506499f5
rev   line source
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
1 package de.intevation.mxd.reader;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
2
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
3 import java.awt.Color;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
4
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
6
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
7 import com.esri.arcgis.display.ISymbol;
67
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
8 import com.esri.arcgis.display.ILineSymbol;
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9 import com.esri.arcgis.display.SimpleLineSymbol;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10 import com.esri.arcgis.display.esriSimpleLineStyle;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 import com.esri.arcgis.display.IRgbColor;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12 import com.esri.arcgis.display.RgbColor;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 import org.w3c.dom.Element;
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
15 import java.io.IOException;
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17 /**
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18 * Reads simple line symbol information.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19 *
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
20 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21 */
80
83932f18dddc All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 74
diff changeset
22 public class SimpleLineSymbolReader
83932f18dddc All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 74
diff changeset
23 extends AbstractSymbolReader {
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
25 /**
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
26 * The logger.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
27 */
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28 private static final Logger logger =
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
29 Logger.getLogger(SimpleLineSymbolReader.class);
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
30
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
31 /**
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
32 * Private member.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
33 */
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
34 private SimpleLineSymbol symbol;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
35
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
36 public SimpleLineSymbolReader(ISymbol symbol)
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
37 throws Exception {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
38 logger.debug("contructor()");
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
39 if(symbol instanceof SimpleLineSymbol) {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 this.symbol = (SimpleLineSymbol)symbol;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42 else {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
43 throw new Exception("Not a SimpleLineSymbol!");
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
45 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
46
67
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
47 public SimpleLineSymbolReader(ILineSymbol symbol)
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
48 throws Exception {
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
49 logger.debug("contructor()");
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
50 if(symbol instanceof SimpleLineSymbol) {
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
51 this.symbol = (SimpleLineSymbol)symbol;
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
52 }
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
53 else {
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
54 throw new Exception("Not a SimpleLineSymbol!");
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
55 }
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
56 }
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 62
diff changeset
57
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
58 /**
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
59 * Reads the symbol attributes.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
60 *
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
61 * @return The XML node.
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
62 */
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
63 public Element read() {
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
64 logger.debug("read()");
80
83932f18dddc All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 74
diff changeset
65 Element symbolElement = util.addSymbol(parent);
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
66
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
67 try {
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
68 symbolElement.setAttribute("name", symbol.getNameString());
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69 }
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
70 catch(IOException ioe) {
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
71 logger.warn("Could not read name. Setting name to \"default\"");
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
72 symbolElement.setAttribute("name", "default");
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
73 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
74
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
75 try {
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
76 if(symbol.getColor() instanceof IRgbColor) {
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
77 IRgbColor color = (IRgbColor)symbol.getColor();
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
78 Color c = new Color (
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
79 color.getRed(),
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
80 color.getGreen(),
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
81 color.getBlue());
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
82 symbolElement.setAttribute("color", String.valueOf(c.getRGB()));
150
7b1433d3b574 Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents: 135
diff changeset
83 symbolElement.setAttribute(
7b1433d3b574 Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents: 135
diff changeset
84 "transparency",
7b1433d3b574 Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents: 135
diff changeset
85 String.valueOf(c.getTransparency()));
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
86 }
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
87 else {
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
88 RgbColor col = new RgbColor();
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
89 col.setRGB(symbol.getColor().getRGB());
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
90 Color c = new Color (
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
91 col.getRed(),
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
92 col.getGreen(),
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
93 col.getBlue());
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
94 symbolElement.setAttribute("color", String.valueOf(c.getRGB()));
150
7b1433d3b574 Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents: 135
diff changeset
95 symbolElement.setAttribute(
7b1433d3b574 Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents: 135
diff changeset
96 "transparency",
7b1433d3b574 Handle outlines with width < 1 and transparent color.
vc11884admin@VC11884.win.bsh.de
parents: 135
diff changeset
97 String.valueOf(c.getTransparency()));
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
98 }
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
99 }
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
100 catch(IOException ioe) {
135
a4ab239509f1 Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents: 115
diff changeset
101 logger.warn("Could not read color.");
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
102 }
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
103
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
104 try {
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
105 symbolElement.setAttribute("width", String.valueOf(symbol.getWidth()));
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
106 }
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
107 catch(IOException ioe) {
135
a4ab239509f1 Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents: 115
diff changeset
108 logger.warn("Could not read width.");
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
109 }
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
110
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
111 int style;
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
112 try {
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
113 style = symbol.getStyle();
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
114 }
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
115 catch(IOException ioe) {
135
a4ab239509f1 Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents: 115
diff changeset
116 logger.warn("Could not read line style.");
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
117 style = -1;
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
118 }
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
119 switch(style) {
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
120 case esriSimpleLineStyle.esriSLSSolid:
62
e468cf8701ea Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 61
diff changeset
121 symbolElement.setAttribute("linestyle", "solid"); break;
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
122 case esriSimpleLineStyle.esriSLSDash:
62
e468cf8701ea Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 61
diff changeset
123 symbolElement.setAttribute("linestyle", "dash"); break;
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
124 case esriSimpleLineStyle.esriSLSDot:
62
e468cf8701ea Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 61
diff changeset
125 symbolElement.setAttribute("linestyle", "dot"); break;
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
126 case esriSimpleLineStyle.esriSLSDashDot:
62
e468cf8701ea Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 61
diff changeset
127 symbolElement.setAttribute("linestyle", "dashdot"); break;
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
128 case esriSimpleLineStyle.esriSLSDashDotDot:
62
e468cf8701ea Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 61
diff changeset
129 symbolElement.setAttribute("linestyle", "dashdotdot"); break;
135
a4ab239509f1 Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents: 115
diff changeset
130 default: break;
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
131 }
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
132
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
133 symbolElement.setAttribute("type", "line");
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
134 symbolElement.setAttribute("style", "simple");
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
135
61
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
136 return symbolElement;
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
137 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
138 }
e00deee347a5 Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
139 // 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)