annotate src/java/de/intevation/mxd/reader/PictureMarkerSymbolReader.java @ 323:4051c39757db

Bump Version to 1.1
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 12 Oct 2012 16:26:30 +0200
parents 2cb2f26d0d54
children a46adb3697fa
rev   line source
243
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 135
diff changeset
1 /*
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 135
diff changeset
2 * Copyright (c) 2011 by Intevation GmbH, Germany <info@intevation.de>
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 135
diff changeset
3 *
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 135
diff changeset
4 * This file is part of MXD2map.
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 135
diff changeset
5 *
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 135
diff changeset
6 * This program is free software under the LGPL (>=v2.1)
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 135
diff changeset
7 * Read the file LICENCE.txt coming with the software for details
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 135
diff changeset
8 * or visit http://www.gnu.org/licenses/ if it does not exist.
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 135
diff changeset
9 *
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 135
diff changeset
10 * MXD2map has been developed on behalf of the
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 135
diff changeset
11 * Bundesamt fuer Seeschifffahrt und Hydrographie (BSH) in Hamburg
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 135
diff changeset
12 * by Intevation GmbH.
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 135
diff changeset
13 *
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 135
diff changeset
14 * Authors:
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 135
diff changeset
15 * Raimund Renkert <raimund.renkert@intevation.de>
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 135
diff changeset
16 * Bjoern Schilberg <bjoern.schilberg@intevation.de>
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 135
diff changeset
17 * Stephan Holl <stephan.holl@intevation.de>
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 135
diff changeset
18 */
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 135
diff changeset
19
58
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
20 package de.intevation.mxd.reader;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
22 import org.apache.log4j.Logger;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
23
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24 import com.esri.arcgis.display.ISymbol;
63
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
25 import com.esri.arcgis.display.IMarkerSymbol;
58
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
26 import com.esri.arcgis.display.PictureMarkerSymbol;
251
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
27 import com.esri.arcgis.support.ms.stdole.Picture;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
28 import com.esri.arcgis.display.RgbColor;
58
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
29
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
30 import org.w3c.dom.Element;
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
31 import java.io.IOException;
251
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
32 import java.awt.Image;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
33 import java.awt.image.BufferedImage;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
34 import javax.imageio.ImageIO;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
35 import java.io.ByteArrayOutputStream;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
36 import java.awt.Color;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
37
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
38 import org.apache.commons.codec.binary.Base64;
58
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
39
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 /**
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 * Reads picture marker symbol information.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42 *
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
43 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44 */
80
83932f18dddc All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 74
diff changeset
45 public class PictureMarkerSymbolReader
83932f18dddc All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 74
diff changeset
46 extends AbstractSymbolReader {
58
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
47
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
48 /**
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
49 * The logger.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
50 */
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
51 private static final Logger logger =
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
52 Logger.getLogger(PictureMarkerSymbolReader.class);
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
53
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
54 /**
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
55 * Private member.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
56 */
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
57 private PictureMarkerSymbol symbol;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
58
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
59 public PictureMarkerSymbolReader(ISymbol symbol)
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
60 throws Exception {
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
61 logger.debug("contructor()");
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
62 if(symbol instanceof PictureMarkerSymbol) {
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
63 this.symbol = (PictureMarkerSymbol)symbol;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
64 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
65 else {
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
66 throw new Exception("Not a PictureMarkerSymbol!");
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
67 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
68 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69
63
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
70 public PictureMarkerSymbolReader(IMarkerSymbol symbol)
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
71 throws Exception {
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
72 logger.debug("contructor()");
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
73 if(symbol instanceof PictureMarkerSymbol) {
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
74 this.symbol = (PictureMarkerSymbol)symbol;
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
75 }
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
76 else {
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
77 throw new Exception("Not a PictureMarkerSymbol!");
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
78 }
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
79 }
5c5ef5768893 Added MultiLayerLineSymbolReader.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
80
58
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
81 /**
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
82 * Reads the symbol attributes.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
83 *
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
84 * @return The XML node.
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
85 */
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
86 public Element read() {
84
2362609ffa66 Added TODOs for picture symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 83
diff changeset
87 //TODO Read the picture from mxd and write it as base64 string to the
2362609ffa66 Added TODOs for picture symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 83
diff changeset
88 // XML Element.
58
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
89 logger.debug("read()");
80
83932f18dddc All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 74
diff changeset
90 Element symbolElement = util.addSymbol(parent);
58
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
91
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
92 try {
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
93 symbolElement.setAttribute(
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
94 "angle",
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
95 String.valueOf(symbol.getAngle()));
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
96 }
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
97 catch(IOException ioe) {
135
a4ab239509f1 Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents: 115
diff changeset
98 logger.warn("Could not read angle.");
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
99 }
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
100
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
101 try {
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
102 symbolElement.setAttribute(
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
103 "size",
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
104 String.valueOf(symbol.getSize()));
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
105 }
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
106 catch (IOException ioe) {
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
107 logger.warn("Could not read size. Setting size to 1.");
135
a4ab239509f1 Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents: 115
diff changeset
108 symbolElement.setAttribute("size", "1");
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
109 }
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
110
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
111 try {
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
112 symbolElement.setAttribute(
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
113 "x_offset",
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
114 String.valueOf(symbol.getXOffset()));
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
115 }
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
116 catch(IOException ioe) {
135
a4ab239509f1 Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents: 115
diff changeset
117 logger.warn("Could not read x-offset.");
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
118 }
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
119
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
120 try {
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
121 symbolElement.setAttribute(
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
122 "y_offset",
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
123 String.valueOf(symbol.getYOffset()));
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
124 }
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
125 catch(IOException ioe) {
135
a4ab239509f1 Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents: 115
diff changeset
126 logger.warn("Could not read y-offset.");
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
127 }
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
128
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
129 try {
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
130 symbolElement.setAttribute(
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
131 "name",
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
132 symbol.getNameString());
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
133 }
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
134 catch(IOException ioe) {
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
135 logger.warn("Could not read name. Setting name to \"default\"");
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
136 symbolElement.setAttribute("name", "default");
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
137 }
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
138
251
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
139 //Read the picture and convert to base64.
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
140 try {
251
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
141 Picture p = symbol.getPicture();
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
142 Image i = p.toImage();
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
143 if(i instanceof BufferedImage) {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
144 BufferedImage bi = (BufferedImage)i;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
145 ByteArrayOutputStream baos = new ByteArrayOutputStream();
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
146 //Get byte array from image.
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
147 ImageIO.write(bi, "BMP", baos);
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
148 Base64 encoder = new Base64();
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
149 //encode in a base64 string
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
150 String pict = encoder.encodeBase64String(baos.toByteArray());
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
151 symbolElement.setAttribute("picture", pict);
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
152
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
153 //Get transparent color.
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
154 RgbColor c = new RgbColor();
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
155 c.setRGB(symbol.getBitmapTransparencyColor().getRGB());
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
156 Color transp = new Color (
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
157 c.getRed(),
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
158 c.getGreen(),
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
159 c.getBlue());
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
160 symbolElement.setAttribute(
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
161 "transparent_color",
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
162 String.valueOf(transp.getRGB()));
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
163 }
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
164 else {
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
165 logger.warn("Could not read image symbol.");
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
166 return null;
6b80e46b8f38 Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
167 }
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
168 }
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
169 catch(IOException ioe) {
135
a4ab239509f1 Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents: 115
diff changeset
170 logger.warn("Could not read picture.");
115
fb93f20478cc Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 89
diff changeset
171 }
58
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
172 symbolElement.setAttribute("style", "picture");
89
475ee3e4bc8b Added "type" as XML attribute to symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 84
diff changeset
173 symbolElement.setAttribute("type", "marker");
58
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
174 return symbolElement;
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
175 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
176 }
4e0464c620f0 Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
177 // 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)