annotate src/java/de/intevation/mxd/reader/PictureFillSymbolReader.java @ 314:cd3cb1a7f35a

Workaround a bug in ArcGIS causing FieldNames of shape files that are 11 Characters long to be postfixed with their Type Identifier.
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 17 Sep 2012 17:02:15 +0200
parents 2cb2f26d0d54
children a46adb3697fa
rev   line source
251
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /*
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 * Copyright (c) 2011 by Intevation GmbH, Germany <info@intevation.de>
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 *
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 * This file is part of MXD2map.
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 *
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 * This program is free software under the LGPL (>=v2.1)
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 * Read the file LICENCE.txt coming with the software for details
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8 * or visit http://www.gnu.org/licenses/ if it does not exist.
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9 *
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10 * MXD2map has been developed on behalf of the
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 * Bundesamt fuer Seeschifffahrt und Hydrographie (BSH) in Hamburg
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 * by Intevation GmbH.
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 *
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 * Authors:
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 * Raimund Renkert <raimund.renkert@intevation.de>
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 * Bjoern Schilberg <bjoern.schilberg@intevation.de>
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 * Stephan Holl <stephan.holl@intevation.de>
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 */
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 package de.intevation.mxd.reader;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 import java.awt.Color;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 import java.awt.Image;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 import org.apache.log4j.Logger;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 import com.esri.arcgis.display.ISymbol;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 import com.esri.arcgis.display.ILineSymbol;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 import com.esri.arcgis.display.IFillSymbol;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 import com.esri.arcgis.display.PictureFillSymbol;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 import com.esri.arcgis.support.ms.stdole.Picture;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 import com.esri.arcgis.display.RgbColor;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 import org.w3c.dom.Element;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 import java.io.IOException;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 import java.awt.image.BufferedImage;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 import javax.imageio.ImageIO;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38 import java.io.ByteArrayOutputStream;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 import org.apache.commons.codec.binary.Base64;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 /**
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 * Reads picture fill symbol information.
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 *
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 */
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46 public class PictureFillSymbolReader
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 extends AbstractSymbolReader {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49 /**
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 * The logger.
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 */
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 private static final Logger logger =
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 Logger.getLogger(PictureFillSymbolReader.class);
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 /**
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 * Private member.
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 */
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 private PictureFillSymbol symbol;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 public PictureFillSymbolReader(ISymbol symbol)
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 throws Exception {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 logger.debug("contructor()");
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 if(symbol instanceof PictureFillSymbol) {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 this.symbol = (PictureFillSymbol)symbol;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 else {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 throw new Exception("Not a PictureFillSymbol!");
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 public PictureFillSymbolReader(IFillSymbol symbol)
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 throws Exception {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 logger.debug("contructor()");
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 if(symbol instanceof PictureFillSymbol) {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 this.symbol = (PictureFillSymbol)symbol;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 else {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 throw new Exception("Not a PictureFillSymbol!");
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82 /**
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 * Reads the symbol attributes.
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 *
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 * @return The XML node.
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 */
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 public Element read() {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88 logger.debug("read()");
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
89 Element symbolElement = util.addSymbol(parent);
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
90
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 try {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92 symbolElement.setAttribute("name", symbol.getNameString());
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
93 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
94 catch(IOException ioe) {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
95 logger.warn("Could not read name. Setting name to \"default\"");
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
96 symbolElement.setAttribute("name", "default");
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 try {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 symbolElement.setAttribute(
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101 "x_scale",
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102 String.valueOf(symbol.getXScale()));
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
103 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
104 catch(IOException ioe) {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
105 logger.warn("Could not read x-scale.");
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
106 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
107
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
108 try {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
109 symbolElement.setAttribute(
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
110 "y_scale",
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
111 String.valueOf(symbol.getYScale()));
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
112 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
113 catch(IOException ioe) {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
114 logger.warn("Could not read y-scale.");
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
115 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
116
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
117 try {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
118 symbolElement.setAttribute(
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
119 "xseparation",
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
120 String.valueOf(symbol.getXSeparation()));
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
121 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
122 catch(IOException ioe) {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
123 logger.warn("Could not read x-separation.");
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
124 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
125
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
126 try {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
127 symbolElement.setAttribute(
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
128 "yseparation",
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129 String.valueOf(symbol.getYSeparation()));
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 catch(IOException ioe) {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
132 logger.warn(
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
133 "Could not read y-separation.");
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
134 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
135
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
136 try {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
137 ILineSymbol ls = symbol.getOutline();
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
138 LineSymbolReader lsr = new LineSymbolReader();
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
139 if(lsr.canRead(ls)) {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
140 lsr.setSymbol(ls);
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
141 lsr.setUtil(util);
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
142 lsr.setParent(symbolElement);
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
143 lsr.read();
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
144 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
145 else {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
146 logger.debug("The type of " + ls.getClass().toString() +
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
147 " is not implemented!");
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
148 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
149 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
150 catch(Exception e) {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
151 logger.warn("Could not read outline.");
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
152 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
153
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
154 //Read the picture and convert to base64.
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
155 try {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
156 Picture p = symbol.getPicture();
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
157 Image i = p.toImage();
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
158 if(i instanceof BufferedImage) {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
159 BufferedImage bi = (BufferedImage)i;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
160 ByteArrayOutputStream baos = new ByteArrayOutputStream();
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
161 //Get byte array from image.
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
162 ImageIO.write(bi, "BMP", baos);
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
163 Base64 encoder = new Base64();
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
164 //encode in a base64 string
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
165 String pict = encoder.encodeBase64String(baos.toByteArray());
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
166 symbolElement.setAttribute("picture", pict);
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
167
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
168 //Get transparent color.
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
169 RgbColor c = new RgbColor();
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
170 c.setRGB(symbol.getBitmapTransparencyColor().getRGB());
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
171 Color transp = new Color (
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
172 c.getRed(),
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
173 c.getGreen(),
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
174 c.getBlue());
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
175 symbolElement.setAttribute(
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
176 "transparent_color",
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
177 String.valueOf(transp.getRGB()));
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
178 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
179 else {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
180 logger.warn("Could not read image symbol.");
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
181 return null;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
182 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
183 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
184 catch(IOException ioe) {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
185 logger.warn("Could not read picture.");
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
186 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
187 symbolElement.setAttribute("type", "fill");
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
188 symbolElement.setAttribute("style", "picture");
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
189
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
190 return symbolElement;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
191 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
192 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff changeset
193 // 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)