annotate src/java/de/intevation/mxd/reader/LineFillSymbolReader.java @ 97:18e4f143896b

Added polygon writer.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 06 Jun 2011 17:24:43 +0200
parents 59e06c405a9a
children fb93f20478cc
rev   line source
76
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
1 package de.intevation.mxd.reader;
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
2
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
3 import java.awt.Color;
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
4
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
6
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
7 import com.esri.arcgis.display.ISymbol;
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
8 import com.esri.arcgis.display.IFillSymbol;
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9 import com.esri.arcgis.display.ILineSymbol;
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10 import com.esri.arcgis.display.LineFillSymbol;
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 import com.esri.arcgis.display.IRgbColor;
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12 import com.esri.arcgis.display.RgbColor;
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 import org.w3c.dom.Element;
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16 /**
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17 * Reads marker line symbol information.
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18 *
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
20 */
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21 public class LineFillSymbolReader
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
22 extends AbstractSymbolReader{
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
23
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24 /**
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
25 * The logger.
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
26 */
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
27 private static final Logger logger =
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28 Logger.getLogger(LineFillSymbolReader.class);
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
29
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
30 /**
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
31 * Private member.
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
32 */
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
33 private LineFillSymbol symbol;
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
34
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
35 public LineFillSymbolReader(ISymbol symbol)
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
36 throws Exception {
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
37 logger.debug("contructor()");
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
38 if(symbol instanceof LineFillSymbol) {
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
39 this.symbol = (LineFillSymbol)symbol;
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 }
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 else {
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42 throw new Exception("Not a LineFillSymbol!");
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
43 }
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44 }
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
45
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
46
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
47 public LineFillSymbolReader(IFillSymbol symbol)
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
48 throws Exception {
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
49 logger.debug("contructor()");
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
50 if(symbol instanceof LineFillSymbol) {
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
51 this.symbol = (LineFillSymbol)symbol;
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
52 }
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
53 else {
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
54 throw new Exception("Not a LineFillSymbol!");
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
55 }
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
56 }
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
57
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
58 /**
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
59 * Reads the symbol attributes.
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
60 *
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
61 * @return The XML node.
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
62 */
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
63 public Element read()
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
64 throws Exception {
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
65 logger.debug("read()");
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
66
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
67 Element symbolElement = util.addSymbol(parent);
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
68
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69 symbolElement.setAttribute("name", symbol.getNameString());
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
70 symbolElement.setAttribute("style", "fill");
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
71 symbolElement.setAttribute(
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
72 "offset",
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
73 String.valueOf(symbol.getOffset()));
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
74 symbolElement.setAttribute(
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
75 "separation",
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
76 String.valueOf(symbol.getSeparation()));
97
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents: 83
diff changeset
77 symbolElement.setAttribute("angle", String.valueOf(symbol.getAngle()));
76
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
78
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
79 if(symbol.getColor() instanceof IRgbColor) {
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
80 IRgbColor color = (IRgbColor)symbol.getColor();
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
81 Color c = new Color (
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
82 color.getRed(),
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
83 color.getGreen(),
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
84 color.getBlue());
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
85 symbolElement.setAttribute("color", String.valueOf(c.getRGB()));
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
86 symbolElement.setAttribute("transparency",
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
87 String.valueOf(color.getTransparency()));
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
88 }
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
89 else {
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
90 RgbColor col = new RgbColor();
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
91 col.setRGB(symbol.getColor().getRGB());
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
92 Color c = new Color (
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
93 col.getRed(),
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
94 col.getGreen(),
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
95 col.getBlue());
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
96 symbolElement.setAttribute("color", String.valueOf(c.getRGB()));
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
97 symbolElement.setAttribute("transparency",
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
98 String.valueOf(col.getTransparency()));
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
99 }
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
100
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
101 ILineSymbol ols = symbol.getOutline();
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
102 LineSymbolReader olsr = new LineSymbolReader();
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
103 if(olsr.canRead(ols)) {
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
104 olsr.setSymbol(ols);
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
105 olsr.setUtil(util);
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
106 olsr.setParent(symbolElement);
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
107 olsr.read();
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
108 }
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
109 else {
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
110 logger.debug("The type of " + ols.getClass().toString() +
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
111 " is not implemented!");
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
112 }
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
113 ILineSymbol ls = symbol.getLineSymbol();
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
114 LineSymbolReader lsr = new LineSymbolReader();
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
115 if(lsr.canRead(ls)) {
97
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents: 83
diff changeset
116 symbolElement.setAttribute("hatch", "1");
76
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
117 lsr.setSymbol(ls);
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
118 lsr.setUtil(util);
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
119 lsr.setParent(symbolElement);
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
120 lsr.read();
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
121 }
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
122 else {
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
123 logger.debug("The type of " + ls.getClass().toString() +
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
124 " is not implemented!");
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
125 }
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
126 return parent;
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
127 }
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
128 }
3087c89a5bb8 Added line fill symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
129 // 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)