annotate src/java/de/intevation/mxd/reader/HashLineSymbolReader.java @ 83:59e06c405a9a

Removed needless imports.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 27 May 2011 14:09:10 +0200
parents 4d6fae53956a
children 18e4f143896b
rev   line source
66
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
1 package de.intevation.mxd.reader;
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
2
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
3 import java.awt.Color;
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
4
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
6
6bfebb7eb1df Added hash 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: 66
diff changeset
8 import com.esri.arcgis.display.ILineSymbol;
66
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9 import com.esri.arcgis.display.HashLineSymbol;
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10 import com.esri.arcgis.display.IRgbColor;
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 import com.esri.arcgis.display.RgbColor;
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 import com.esri.arcgis.display.esriLineCapStyle;
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 import com.esri.arcgis.display.esriLineJoinStyle;
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16 import org.w3c.dom.Element;
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18 /**
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19 * Reads cartoline symbol information.
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
20 *
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
22 */
80
83932f18dddc All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 74
diff changeset
23 public class HashLineSymbolReader
83932f18dddc All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 74
diff changeset
24 extends AbstractSymbolReader {
66
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
25
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
26 /**
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
27 * The logger.
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28 */
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
29 private static final Logger logger =
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
30 Logger.getLogger(HashLineSymbolReader.class);
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
31
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
32 /**
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
33 * Private member.
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
34 */
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
35 private HashLineSymbol symbol;
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
36
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
37 public HashLineSymbolReader(ISymbol symbol)
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
38 throws Exception {
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
39 logger.debug("contructor()");
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 if(symbol instanceof HashLineSymbol) {
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 this.symbol = (HashLineSymbol)symbol;
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42 }
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
43 else {
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44 throw new Exception("Not a HashLineSymbol!");
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
45 }
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
46 }
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
47
67
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 66
diff changeset
48 public HashLineSymbolReader(ILineSymbol symbol)
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 66
diff changeset
49 throws Exception {
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 66
diff changeset
50 logger.debug("contructor()");
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 66
diff changeset
51 if(symbol instanceof HashLineSymbol) {
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 66
diff changeset
52 this.symbol = (HashLineSymbol)symbol;
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 66
diff changeset
53 }
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 66
diff changeset
54 else {
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 66
diff changeset
55 throw new Exception("Not a HashLineSymbol!");
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 66
diff changeset
56 }
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 66
diff changeset
57 }
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 66
diff changeset
58
66
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
59 /**
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
60 * Reads the symbol attributes.
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
61 *
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
62 * @return The XML node.
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
63 */
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
64 public Element read()
82
4d6fae53956a Use the wrapper to read hash line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 80
diff changeset
65 throws Exception {
66
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
66 logger.debug("read()");
80
83932f18dddc All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 74
diff changeset
67 Element symbolElement = util.addSymbol(parent);
66
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
68
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69 symbolElement.setAttribute("name", symbol.getNameString());
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
70 symbolElement.setAttribute("style", "line");
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
71 if(symbol.getColor() instanceof IRgbColor) {
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
72 IRgbColor color = (IRgbColor)symbol.getColor();
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
73 Color c = new Color (
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
74 color.getRed(),
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
75 color.getGreen(),
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
76 color.getBlue());
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
77 symbolElement.setAttribute("color", String.valueOf(c.getRGB()));
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
78 }
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
79 else {
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
80 RgbColor col = new RgbColor();
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
81 col.setRGB(symbol.getColor().getRGB());
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
82 Color c = new Color (
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
83 col.getRed(),
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
84 col.getGreen(),
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
85 col.getBlue());
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
86 symbolElement.setAttribute("color", String.valueOf(c.getRGB()));
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
87 }
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
88 int cap = symbol.getCap();
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
89 String capStyle = "butt";
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
90 switch(cap) {
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
91 case esriLineCapStyle.esriLCSRound: capStyle = "round"; break;
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
92 case esriLineCapStyle.esriLCSSquare: capStyle = "square"; break;
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
93 default: break;
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
94 }
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
95 int join = symbol.getJoin();
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
96 String joinStyle = "bevel";
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
97 switch(join) {
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
98 case esriLineJoinStyle.esriLJSRound: joinStyle = "round"; break;
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
99 case esriLineJoinStyle.esriLJSMitre: joinStyle = "miter"; break;
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
100 default: break;
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
101 }
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
102 symbolElement.setAttribute("cap", capStyle);
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
103 symbolElement.setAttribute("join", joinStyle);
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
104 symbolElement.setAttribute(
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
105 "linestart",
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
106 String.valueOf(symbol.getLineStartOffset()));
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
107 symbolElement.setAttribute(
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
108 "miterlimit",
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
109 String.valueOf(symbol.getMiterLimit()));
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
110 symbolElement.setAttribute(
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
111 "offset",
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
112 String.valueOf(symbol.getOffset()));
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
113 symbolElement.setAttribute("width", String.valueOf(symbol.getWidth()));
67
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 66
diff changeset
114 ILineSymbol ls = symbol.getHashSymbol();
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 66
diff changeset
115 readHashSymbol(ls, symbolElement);
66
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
116
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
117 //TODO Read further HashLine specific attributes:
67
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 66
diff changeset
118 // LineDecoration, Template.
66
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
119
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
120 return symbolElement;
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
121 }
67
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 66
diff changeset
122
82
4d6fae53956a Use the wrapper to read hash line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 80
diff changeset
123 private void readHashSymbol(ILineSymbol ls, Element parent)
4d6fae53956a Use the wrapper to read hash line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 80
diff changeset
124 throws Exception {
4d6fae53956a Use the wrapper to read hash line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 80
diff changeset
125 LineSymbolReader lsr = new LineSymbolReader ();
4d6fae53956a Use the wrapper to read hash line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 80
diff changeset
126 if (lsr.canRead(ls)) {
4d6fae53956a Use the wrapper to read hash line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 80
diff changeset
127 lsr.setSymbol(ls);
4d6fae53956a Use the wrapper to read hash line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 80
diff changeset
128 lsr.setParent(parent);
4d6fae53956a Use the wrapper to read hash line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 80
diff changeset
129 lsr.setUtil(util);
4d6fae53956a Use the wrapper to read hash line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 80
diff changeset
130 lsr.read();
67
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 66
diff changeset
131 }
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 66
diff changeset
132 }
66
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
133 }
6bfebb7eb1df Added hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
134 // 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)