annotate src/java/de/intevation/mxd/reader/PictureLineSymbolReader.java @ 77:04b6162c95df

Added sample for ESRIs PersonalGeodataBase
author Stephan Holl <stephan.holl@intevation.de>
date Thu, 26 May 2011 16:12:38 +0200
parents 5ed9e720b6cd
children 7eba97e8201b
rev   line source
64
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
1 package de.intevation.mxd.reader;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
2
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
3 import java.io.IOException;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
4
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
5 import java.awt.Color;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
6 import java.awt.Image;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
7
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
8 import org.apache.log4j.Logger;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10 import com.esri.arcgis.display.ISymbol;
67
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 64
diff changeset
11 import com.esri.arcgis.display.ILineSymbol;
64
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12 import com.esri.arcgis.display.PictureLineSymbol;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 import com.esri.arcgis.support.ms.stdole.Picture;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 import com.esri.arcgis.display.esriSimpleLineStyle;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15 import com.esri.arcgis.display.IRgbColor;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16 import com.esri.arcgis.display.RgbColor;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18 import org.w3c.dom.Element;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19 import de.intevation.mxd.utils.MapToXMLUtils;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
20
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21 /**
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
22 * Reads picture line symbol information.
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
23 *
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
25 */
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
26 public class PictureLineSymbolReader implements ISymbolReader{
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
27
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28 /**
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
29 * The logger.
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
30 */
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
31 private static final Logger logger =
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
32 Logger.getLogger(SimpleLineSymbolReader.class);
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
33
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
34 /**
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
35 * Private member.
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
36 */
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
37 private Element renderer;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
38 private PictureLineSymbol symbol;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
39 private MapToXMLUtils util;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42 public PictureLineSymbolReader(ISymbol symbol)
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
43 throws Exception {
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44 logger.debug("contructor()");
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
45 if(symbol instanceof PictureLineSymbol) {
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
46 this.symbol = (PictureLineSymbol)symbol;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
47 }
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
48 else {
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
49 throw new Exception("Not a PictureLineSymbol!");
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
50 }
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
51 }
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
52
67
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 64
diff changeset
53
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 64
diff changeset
54 public PictureLineSymbolReader(ILineSymbol symbol)
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 64
diff changeset
55 throws Exception {
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 64
diff changeset
56 logger.debug("contructor()");
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 64
diff changeset
57 if(symbol instanceof PictureLineSymbol) {
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 64
diff changeset
58 this.symbol = (PictureLineSymbol)symbol;
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 64
diff changeset
59 }
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 64
diff changeset
60 else {
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 64
diff changeset
61 throw new Exception("Not a PictureLineSymbol!");
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 64
diff changeset
62 }
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 64
diff changeset
63 }
5ed9e720b6cd Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 64
diff changeset
64
64
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
65 /**
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
66 * Setter for the parent XML element.
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
67 *
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
68 * @param parent The XML parent node.
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69 */
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
70 public void setParent(Element parent) {
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
71 this.renderer = parent;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
72 }
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
73
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
74 /**
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
75 * Setter for XML document helper.
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
76 *
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
77 * @param util The helper class for storing map information.
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
78 */
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
79 public void setUtil(MapToXMLUtils util) {
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
80 this.util = util;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
81 }
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
82
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
83 /**
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
84 * Reads the symbol attributes.
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
85 *
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
86 * @return The XML node.
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
87 */
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
88 public Element read()
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
89 throws IOException {
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
90 logger.debug("read()");
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
91 Element symbolElement;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
92 try {
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
93 symbolElement = util.addSymbol(renderer);
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
94 }
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
95 catch(Exception e) {
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
96 e.printStackTrace();
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
97 return null;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
98 }
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
99
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
100 symbolElement.setAttribute("name", symbol.getNameString());
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
101 symbolElement.setAttribute("style", "picture");
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
102 if(symbol.getColor() instanceof IRgbColor) {
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
103 IRgbColor color = (IRgbColor)symbol.getColor();
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
104 Color c = new Color (
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
105 color.getRed(),
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
106 color.getGreen(),
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
107 color.getBlue());
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
108 symbolElement.setAttribute("color", String.valueOf(c.getRGB()));
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
109 }
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
110 else {
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
111 RgbColor col = new RgbColor();
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
112 col.setRGB(symbol.getColor().getRGB());
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
113 Color c = new Color (
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
114 col.getRed(),
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
115 col.getGreen(),
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
116 col.getBlue());
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
117 symbolElement.setAttribute("color", String.valueOf(c.getRGB()));
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
118 }
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
119 symbolElement.setAttribute(
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
120 "offset",
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
121 String.valueOf(symbol.getOffset()));
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
122 symbolElement.setAttribute(
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
123 "x_scale",
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
124 String.valueOf(symbol.getXScale()));
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
125 symbolElement.setAttribute(
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
126 "y_scale",
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
127 String.valueOf(symbol.getYScale()));
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
128
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
129 symbolElement.setAttribute("width", String.valueOf(symbol.getWidth()));
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
130
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
131 Picture pic = symbol.getPicture();
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
132 Image im = pic.toImage();
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
133 //TODO Save the image.
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
134
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
135 return symbolElement;
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
136 }
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
137 }
c73647bd71c0 Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
138 // 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)