Mercurial > mxd2map
annotate src/java/de/intevation/mxd/reader/MultiLayerFillSymbolReader.java @ 242:bb25c7a4553e
Refactored outline handling for polygons.
author | raimund renkert <raimund.renkert@intevation.de> |
---|---|
date | Tue, 09 Aug 2011 13:50:45 +0200 |
parents | 0bde090506f9 |
children | df4e0946ef02 |
rev | line source |
---|---|
68
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.mxd.reader; |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
2 |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
3 import org.apache.log4j.Logger; |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
4 |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
5 import com.esri.arcgis.display.ISymbol; |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
6 import com.esri.arcgis.display.IFillSymbol; |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
7 import com.esri.arcgis.display.MultiLayerFillSymbol; |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
8 |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
9 import org.w3c.dom.Element; |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
11 /** |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 * Reads multi layer line symbol information. |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 * |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
14 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
686a88eb531d
Added multi layer fill 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:
75
diff
changeset
|
16 public class MultiLayerFillSymbolReader |
83932f18dddc
All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
75
diff
changeset
|
17 extends AbstractSymbolReader { |
68
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
18 |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
19 /** |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
20 * The logger. |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 */ |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
22 private static final Logger logger = |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
23 Logger.getLogger(MultiLayerFillSymbolReader.class); |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
24 |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 /** |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
26 * Private member. |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
27 */ |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 private MultiLayerFillSymbol symbol; |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
29 |
181 | 30 /** |
31 * Constructor with symbol. | |
32 * | |
33 * @param symbol The symbol used to display polygons. | |
34 */ | |
68
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
35 public MultiLayerFillSymbolReader(ISymbol symbol) |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
36 throws Exception { |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
37 logger.debug("contructor()"); |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
38 if(symbol instanceof MultiLayerFillSymbol) { |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
39 this.symbol = (MultiLayerFillSymbol)symbol; |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
40 } |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
41 else { |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
42 throw new Exception("Not a MultiLayerFillSymbol!"); |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
43 } |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
44 } |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 |
181 | 46 /** |
47 * Constructor with symbol. | |
48 * | |
49 * @param symbol The symbol used to display polygons. | |
50 */ | |
68
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
51 public MultiLayerFillSymbolReader(IFillSymbol symbol) |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 throws Exception { |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
53 logger.debug("contructor()"); |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
54 if(symbol instanceof MultiLayerFillSymbol) { |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
55 this.symbol = (MultiLayerFillSymbol)symbol; |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
56 } |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
57 else { |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 throw new Exception("Not a MultiLayerFillSymbol!"); |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
59 } |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
60 } |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
61 |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
62 /** |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
63 * Reads the symbol attributes. |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
64 * |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
65 * @return The XML node. |
686a88eb531d
Added multi layer fill 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:
83
diff
changeset
|
67 public Element read() { |
68
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
68 logger.debug("read()"); |
115
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
69 try { |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
70 for(int i = 0; i < symbol.getLayerCount(); i++) { |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
71 ISymbol sym = (ISymbol)symbol.getLayer(i); |
68
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
72 |
115
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
73 FillSymbolReader fsr = new FillSymbolReader(); |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
74 if(fsr.canRead(sym)) { |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
75 fsr.setSymbol(sym); |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
76 fsr.setParent(parent); |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
77 fsr.setUtil(util); |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
78 fsr.read(); |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
79 } |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
80 else { |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
81 logger.debug("The type of " + sym.getClass().toString() + |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
82 " is not implemented!"); |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
83 } |
68
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
84 } |
115
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
85 } |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
86 catch(Exception e) { |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
87 logger.error( |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
88 "Could not read the symbol " + |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
89 symbol.getClass().toString()); |
68
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
90 } |
80
83932f18dddc
All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
75
diff
changeset
|
91 return parent; |
68
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
92 } |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
93 } |
686a88eb531d
Added multi layer fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
94 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |