comparison src/java/de/intevation/mxd/writer/FillStyleWriter.java @ 251:6b80e46b8f38

Added picture symbol support to the converter.
author raimund renkert <raimund.renkert@intevation.de>
date Fri, 12 Aug 2011 16:08:57 +0200
parents df4e0946ef02
children 2cb2f26d0d54
comparison
equal deleted inserted replaced
250:d10fd4de02aa 251:6b80e46b8f38
75 * Write the content. 75 * Write the content.
76 * 76 *
77 * @param symbolElement DOM element containing style attributes. 77 * @param symbolElement DOM element containing style attributes.
78 */ 78 */
79 public boolean write(Element symbolElement) { 79 public boolean write(Element symbolElement) {
80 logger.debug("write()Element"); 80 logger.debug("write(Element)");
81 symbolSetObj symbolSet = map.getSymbolset(); 81 symbolSetObj symbolSet = map.getSymbolset();
82 82
83 if(symbolElement.hasChildNodes()) { 83 if(symbolElement.hasChildNodes()) {
84 NodeList symbols = symbolElement.getChildNodes(); 84 NodeList symbols = symbolElement.getChildNodes();
85 for (int i = 0; i < symbols.getLength(); i++) { 85 for (int i = 0; i < symbols.getLength(); i++) {
86 Element nextSym = (Element)symbols.item(i); 86 Element nextSym = (Element)symbols.item(i);
87 String type = nextSym.getAttribute("type"); 87 String type = nextSym.getAttribute("type");
88
89 if(((symbols.getLength() > 1 && i == 0) || 88 if(((symbols.getLength() > 1 && i == 0) ||
90 (symbols.getLength() == 1 && 89 (symbols.getLength() == 1 &&
91 !symbolElement.hasAttribute("hatch"))) && 90 !symbolElement.hasAttribute("hatch"))) &&
92 type.equals("line")) { 91 type.equals("line")) {
93 if(symbolElement.hasAttribute("color")) { 92 if(symbolElement.hasAttribute("color")) {
99 oCol.getBlue(), 98 oCol.getBlue(),
100 -4); 99 -4);
101 } 100 }
102 writeOutline(nextSym); 101 writeOutline(nextSym);
103 if (symbols.getLength() == 1) { 102 if (symbols.getLength() == 1) {
104 writeSimple(symbolElement); 103 String stype = symbolElement.getAttribute("style");
105 } 104 if(stype.equals("picture")) {
106 try { 105 double gap = 0;
107 SymbolWriter sw = new SymbolWriter(this.map, this.cl); 106 if(symbolElement.hasAttribute("xseparation")) {
108 sw.saveSymbolSet(symbolSet); 107 try {
109 } 108 gap = Double.parseDouble(
110 catch(Exception e) { 109 symbolElement.getAttribute("xseparation"));
111 logger.warn("Could not save symbol set."); 110 }
111 catch(NumberFormatException nfe) {
112 gap = 0;
113 }
114 }
115
116 try {
117 SymbolWriter sw =
118 new SymbolWriter(this.map, this.cl);
119 sw.write(symbolElement);
120 sw.saveSymbolSet(symbolSet);
121 }
122 catch(Exception e) {
123 logger.warn("Could not save symbol set.");
124 }
125 writeMarker(symbolElement, gap);
126 }
127 else {
128 writeSimple(symbolElement);
129 try {
130 SymbolWriter sw =
131 new SymbolWriter(this.map, this.cl);
132 sw.saveSymbolSet(symbolSet);
133 }
134 catch(Exception e) {
135 logger.warn("Could not save symbol set.");
136 }
137 }
112 } 138 }
113 } 139 }
114 else if(nextSym.getTagName().equals("symbol") && 140 else if(nextSym.getTagName().equals("symbol") &&
115 !symbolElement.hasAttribute("hatch") || 141 !symbolElement.hasAttribute("hatch") ||
116 (i == 1 && type.equals("marker"))) { 142 (i == 1 && type.equals("marker"))) {
146 } 172 }
147 } 173 }
148 else { 174 else {
149 writeSimple(symbolElement); 175 writeSimple(symbolElement);
150 try { 176 try {
151 SymbolWriter sw = new SymbolWriter(this.map, this.cl); 177 SymbolWriter sw =
178 new SymbolWriter(this.map, this.cl);
152 sw.saveSymbolSet(symbolSet); 179 sw.saveSymbolSet(symbolSet);
153 } 180 }
154 catch(Exception e) { 181 catch(Exception e) {
155 logger.warn("Could not save symbol set."); 182 logger.warn("Could not save symbol set.");
156 } 183 }
316 */ 343 */
317 private void writeMarker(Element symbolElement, double gap) { 344 private void writeMarker(Element symbolElement, double gap) {
318 logger.debug("writeMarker()"); 345 logger.debug("writeMarker()");
319 String name = symbolElement.getAttribute("name"); 346 String name = symbolElement.getAttribute("name");
320 String type = symbolElement.getAttribute("type"); 347 String type = symbolElement.getAttribute("type");
348 String stype = symbolElement.getAttribute("style");
321 if (symbolElement.hasAttribute("angle")) { 349 if (symbolElement.hasAttribute("angle")) {
322 try { 350 try {
323 style.setAngle( 351 style.setAngle(
324 Double.parseDouble(symbolElement.getAttribute("angle"))); 352 Double.parseDouble(symbolElement.getAttribute("angle")));
325 } 353 }
414 vals = new double[] {5.0, 3.0, 1.0, 3.0, 1.0, 4.0, 0, 0, 0, 0}; 442 vals = new double[] {5.0, 3.0, 1.0, 3.0, 1.0, 4.0, 0, 0, 0, 0};
415 style.setPattern(vals); 443 style.setPattern(vals);
416 } 444 }
417 } 445 }
418 } 446 }
447 if(stype.equals("picture")) {
448 style.setSymbolByName(map, name);
449 }
419 } 450 }
420 451
421 /** 452 /**
422 * Write simple fill attributes. 453 * Write simple fill attributes.
423 * 454 *
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)