comparison src/java/de/intevation/mxd/reader/SimpleFillSymbolReader.java @ 68:686a88eb531d

Added multi layer fill symbol reader.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 26 May 2011 12:30:07 +0200
parents ef7ca23c4233
children b41fcf268827
comparison
equal deleted inserted replaced
67:5ed9e720b6cd 68:686a88eb531d
1 package de.intevation.mxd.reader; 1 package de.intevation.mxd.reader;
2 2
3 import java.io.IOException; 3 import java.io.IOException;
4 import java.awt.Color;
4 5
5 import org.apache.log4j.Logger; 6 import org.apache.log4j.Logger;
6 7
7 import com.esri.arcgis.display.ISymbol; 8 import com.esri.arcgis.display.ISymbol;
9 import com.esri.arcgis.display.ILineSymbol;
8 import com.esri.arcgis.display.SimpleFillSymbol; 10 import com.esri.arcgis.display.SimpleFillSymbol;
9 import com.esri.arcgis.display.esriSimpleMarkerStyle; 11 import com.esri.arcgis.display.MultiLayerLineSymbol;
12 import com.esri.arcgis.display.SimpleLineSymbol;
13 import com.esri.arcgis.display.MarkerLineSymbol;
14 import com.esri.arcgis.display.PictureLineSymbol;
15 import com.esri.arcgis.display.CartographicLineSymbol;
16 import com.esri.arcgis.display.HashLineSymbol;
17 import com.esri.arcgis.display.MultiLayerFillSymbol;
18 import com.esri.arcgis.display.esriSimpleFillStyle;
10 import com.esri.arcgis.display.IRgbColor; 19 import com.esri.arcgis.display.IRgbColor;
11 import com.esri.arcgis.display.RgbColor; 20 import com.esri.arcgis.display.RgbColor;
12 21
13 import org.w3c.dom.Element; 22 import org.w3c.dom.Element;
14 23
80 e.printStackTrace(); 89 e.printStackTrace();
81 return null; 90 return null;
82 } 91 }
83 92
84 symbolElement.setAttribute("name", symbol.getNameString()); 93 symbolElement.setAttribute("name", symbol.getNameString());
85 if(symbol.getStyle() == esriSimpleMarkerStyle.esriSMSCircle) { 94 symbolElement.setAttribute("style", "fill");
86 symbolElement.setAttribute("style", "point"); 95 int style = symbol.getStyle();
96 switch(style) {
97 case esriSimpleFillStyle.esriSFSCross:
98 symbolElement.setAttribute("fillstyle", "cross"); break;
99 case esriSimpleFillStyle.esriSFSSolid:
100 symbolElement.setAttribute("fillstyle", "solid"); break;
101 case esriSimpleFillStyle.esriSFSVertical:
102 symbolElement.setAttribute("fillstyle", "vertical"); break;
103 case esriSimpleFillStyle.esriSFSHorizontal:
104 symbolElement.setAttribute("fillstyle", "horizontal"); break;
105 case esriSimpleFillStyle.esriSFSForwardDiagonal:
106 symbolElement.setAttribute("fillstyle", "fwdiagonal"); break;
107 case esriSimpleFillStyle.esriSFSBackwardDiagonal:
108 symbolElement.setAttribute("fillstyle", "bwdiagonal"); break;
109 case esriSimpleFillStyle.esriSFSDiagonalCross:
110 symbolElement.setAttribute("fillstyle", "diagonalcross");
111 break;
112 default: symbolElement.setAttribute("fillstyle", "empty");
87 } 113 }
88 114
89 if(symbol.getColor() instanceof IRgbColor) { 115 if(symbol.getColor() instanceof IRgbColor) {
90 IRgbColor color = (IRgbColor)symbol.getColor(); 116 IRgbColor color = (IRgbColor)symbol.getColor();
91 symbolElement.setAttribute("color", "(" + color.getRed() + 117 Color c = new Color (
92 "," + color.getGreen() + 118 color.getRed(),
93 "," + color.getBlue() + ")"); 119 color.getGreen(),
120 color.getBlue());
121 symbolElement.setAttribute("color", String.valueOf(c.getRGB()));
94 symbolElement.setAttribute("transparency", 122 symbolElement.setAttribute("transparency",
95 String.valueOf(color.getTransparency())); 123 String.valueOf(color.getTransparency()));
96 } 124 }
97 else { 125 else {
98 RgbColor col = new RgbColor(); 126 RgbColor col = new RgbColor();
99 col.setRGB(symbol.getColor().getRGB()); 127 col.setRGB(symbol.getColor().getRGB());
100 symbolElement.setAttribute("color", "(" + col.getRed() + 128 Color c = new Color (
101 "," + col.getGreen() + 129 col.getRed(),
102 "," + col.getBlue() + ")"); 130 col.getGreen(),
131 col.getBlue());
132 symbolElement.setAttribute("color", String.valueOf(c.getRGB()));
103 symbolElement.setAttribute("transparency", 133 symbolElement.setAttribute("transparency",
104 String.valueOf(col.getTransparency())); 134 String.valueOf(col.getTransparency()));
105 } 135 }
106 //TODO read further attributes. 136
137 try {
138 ILineSymbol ls = symbol.getOutline();
139 if(ls instanceof MultiLayerLineSymbol) {
140 ISymbolReader sreader = new MultiLayerLineSymbolReader(ls);
141 sreader.setParent(symbolElement);
142 sreader.setUtil(util);
143 sreader.read();
144 }
145 else if(ls instanceof SimpleLineSymbol) {
146 ISymbolReader sreader = new SimpleLineSymbolReader(ls);
147 sreader.setParent(symbolElement);
148 sreader.setUtil(util);
149 sreader.read();
150 }
151 else if(ls instanceof MarkerLineSymbol) {
152 ISymbolReader sreader = new MarkerLineSymbolReader(ls);
153 sreader.setParent(symbolElement);
154 sreader.setUtil(util);
155 sreader.read();
156 }
157 else if(ls instanceof PictureLineSymbol) {
158 ISymbolReader sreader = new PictureLineSymbolReader(ls);
159 sreader.setParent(symbolElement);
160 sreader.setUtil(util);
161 sreader.read();
162 }
163 else if(ls instanceof CartographicLineSymbol) {
164 ISymbolReader sreader = new CartoLineSymbolReader(ls);
165 sreader.setParent(symbolElement);
166 sreader.setUtil(util);
167 sreader.read();
168 }
169 else if(ls instanceof HashLineSymbol) {
170 ISymbolReader sreader = new HashLineSymbolReader(ls);
171 sreader.setParent(symbolElement);
172 sreader.setUtil(util);
173 sreader.read();
174 }
175 else {
176 logger.debug("The type of " + ls.getClass().toString() +
177 " is not implemented!");
178 System.out.println(
179 "No known instance: " + ls.getClass().toString());
180 }
181 }
182 catch(Exception e) {
183 e.printStackTrace();
184 }
185
107 return symbolElement; 186 return symbolElement;
108 } 187 }
109 } 188 }
110 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 189 // 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)