Mercurial > mxd2map
annotate src/java/de/intevation/mxd/reader/MultiLayerLineSymbolReader.java @ 115:fb93f20478cc
Improved exception handling for symbol reader.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 15 Jun 2011 16:48:42 +0200 |
parents | 59e06c405a9a |
children | 0bde090506f9 |
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 org.apache.log4j.Logger; |
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 com.esri.arcgis.display.ISymbol; |
67
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
66
diff
changeset
|
6 import com.esri.arcgis.display.ILineSymbol; |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
7 import com.esri.arcgis.display.MultiLayerLineSymbol; |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
8 |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
9 import org.w3c.dom.Element; |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
11 /** |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 * Reads multi layer line symbol information. |
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 * @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
|
15 */ |
80
83932f18dddc
All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
16 public class MultiLayerLineSymbolReader |
83932f18dddc
All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
17 extends AbstractSymbolReader { |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
18 |
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 * The logger. |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 */ |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
22 private static final Logger logger = |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
23 Logger.getLogger(MultiLayerLineSymbolReader.class); |
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 * Private member. |
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 MultiLayerLineSymbol symbol; |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
29 |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 public MultiLayerLineSymbolReader(ISymbol symbol) |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
31 throws Exception { |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
32 logger.debug("contructor()"); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
33 if(symbol instanceof MultiLayerLineSymbol) { |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
34 this.symbol = (MultiLayerLineSymbol)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 else { |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
37 throw new Exception("Not a MultiLayerLineSymbol!"); |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
38 } |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
39 } |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
40 |
67
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
66
diff
changeset
|
41 public MultiLayerLineSymbolReader(ILineSymbol symbol) |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
66
diff
changeset
|
42 throws Exception { |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
66
diff
changeset
|
43 logger.debug("contructor()"); |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
66
diff
changeset
|
44 if(symbol instanceof MultiLayerLineSymbol) { |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
66
diff
changeset
|
45 this.symbol = (MultiLayerLineSymbol)symbol; |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
66
diff
changeset
|
46 } |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
66
diff
changeset
|
47 else { |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
66
diff
changeset
|
48 throw new Exception("Not a MultiLayerLineSymbol!"); |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
66
diff
changeset
|
49 } |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
66
diff
changeset
|
50 } |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
66
diff
changeset
|
51 |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 /** |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
53 * Reads the symbol attributes. |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
54 * |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
55 * @return The XML node. |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
56 */ |
115
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
57 public Element read() { |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 logger.debug("read()"); |
115
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
59 try { |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
60 for(int i = 0; i < symbol.getLayerCount(); i++) { |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
61 ISymbol sym = (ISymbol)symbol.getLayer(i); |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
62 ISymbolReader sreader = new LineSymbolReader(sym); |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
63 sreader.setParent(parent); |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
64 sreader.setUtil(util); |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
65 sreader.read(); |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
66 } |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
67 } |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
68 catch(Exception e) { |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
69 logger.error( |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
70 "Could not read the symbol " + |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
71 symbol.getClass().toString()); |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
72 } |
80
83932f18dddc
All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
73 return parent; |
61
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
74 } |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
75 } |
e00deee347a5
Added first line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
76 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |