Mercurial > mxd2map
annotate src/java/de/intevation/mxd/reader/PictureLineSymbolReader.java @ 336:a46adb3697fa
Fix annoying typo. s/contructor/constructor
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 05 Nov 2012 16:28:36 +0100 |
parents | 2cb2f26d0d54 |
children |
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 |
64
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
20 package de.intevation.mxd.reader; |
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 import java.awt.Color; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
23 import java.awt.Image; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
24 |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 import org.apache.log4j.Logger; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
26 |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
27 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
|
28 import com.esri.arcgis.display.ILineSymbol; |
64
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
29 import com.esri.arcgis.display.PictureLineSymbol; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 import com.esri.arcgis.support.ms.stdole.Picture; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
31 import com.esri.arcgis.display.RgbColor; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
32 |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
33 import org.w3c.dom.Element; |
115
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
34 import java.io.IOException; |
251
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
35 import java.awt.image.BufferedImage; |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
36 import javax.imageio.ImageIO; |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
37 import java.io.ByteArrayOutputStream; |
64
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
38 |
251
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
39 import org.apache.commons.codec.binary.Base64; |
64
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 * Reads picture line symbol information. |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
42 * |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
43 * @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
|
44 */ |
80
83932f18dddc
All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
45 public class PictureLineSymbolReader |
83932f18dddc
All symbol reader now extend the abstract symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
46 extends AbstractSymbolReader { |
64
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 /** |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
49 * The logger. |
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 private static final Logger logger = |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 Logger.getLogger(SimpleLineSymbolReader.class); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
53 |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
54 /** |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
55 * Private member. |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
56 */ |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
57 private PictureLineSymbol symbol; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
59 public PictureLineSymbolReader(ISymbol symbol) |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
60 throws Exception { |
336
a46adb3697fa
Fix annoying typo. s/contructor/constructor
Andre Heinecke <aheinecke@intevation.de>
parents:
262
diff
changeset
|
61 logger.debug("constructor()"); |
64
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
62 if(symbol instanceof PictureLineSymbol) { |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
63 this.symbol = (PictureLineSymbol)symbol; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
64 } |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
65 else { |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
66 throw new Exception("Not a PictureLineSymbol!"); |
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 } |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
69 |
67
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
70 public PictureLineSymbolReader(ILineSymbol symbol) |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
71 throws Exception { |
336
a46adb3697fa
Fix annoying typo. s/contructor/constructor
Andre Heinecke <aheinecke@intevation.de>
parents:
262
diff
changeset
|
72 logger.debug("constructor()"); |
67
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
73 if(symbol instanceof PictureLineSymbol) { |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
74 this.symbol = (PictureLineSymbol)symbol; |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
75 } |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
76 else { |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
77 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
|
78 } |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
79 } |
5ed9e720b6cd
Read the hash symbol in the hash line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
64
diff
changeset
|
80 |
64
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 * Reads the symbol attributes. |
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 * @return The XML node. |
c73647bd71c0
Added picture line 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:
97
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. |
64
c73647bd71c0
Added picture line 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); |
64
c73647bd71c0
Added picture line 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:
97
diff
changeset
|
92 try { |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
93 symbolElement.setAttribute("name", symbol.getNameString()); |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
94 } |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
95 catch(IOException ioe) { |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
115
diff
changeset
|
96 logger.warn("Could not read name. Setting name to \"default\""); |
115
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
97 symbolElement.setAttribute("name", "default"); |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
98 } |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
99 |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
100 try { |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
101 symbolElement.setAttribute( |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
102 "offset", |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
103 String.valueOf(symbol.getOffset())); |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
104 } |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
105 catch(IOException ioe) { |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
115
diff
changeset
|
106 logger.warn("Could not read offset."); |
115
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
107 } |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
108 |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
109 try { |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
110 symbolElement.setAttribute( |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
111 "x_scale", |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
112 String.valueOf(symbol.getXScale())); |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
113 } |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
114 catch(IOException ioe) { |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
115
diff
changeset
|
115 logger.warn("Could not read x-scale."); |
115
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
116 } |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
117 |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
118 try { |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
119 symbolElement.setAttribute( |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
120 "y_scale", |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
121 String.valueOf(symbol.getYScale())); |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
122 } |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
123 catch(IOException ioe) { |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
115
diff
changeset
|
124 logger.warn("Could not read y-scale."); |
115
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
125 } |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
126 |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
127 try { |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
128 symbolElement.setAttribute( |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
129 "width", |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
130 String.valueOf(symbol.getWidth())); |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
131 } |
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
132 catch(IOException ioe) { |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
115
diff
changeset
|
133 logger.warn("Could not read width."); |
115
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
134 } |
251
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
135 |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
136 //Read the picture and convert to base64. |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
137 try { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
138 Picture p = symbol.getPicture(); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
139 Image i = p.toImage(); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
140 if(i instanceof BufferedImage) { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
141 BufferedImage bi = (BufferedImage)i; |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
142 ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
143 //Get byte array from image. |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
144 ImageIO.write(bi, "BMP", baos); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
145 Base64 encoder = new Base64(); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
146 //encode in a base64 string |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
147 String pict = encoder.encodeBase64String(baos.toByteArray()); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
148 symbolElement.setAttribute("picture", pict); |
115
fb93f20478cc
Improved exception handling for symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
149 |
251
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
150 //Get transparent color. |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
151 RgbColor c = new RgbColor(); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
152 c.setRGB(symbol.getBitmapTransparencyColor().getRGB()); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
153 Color transp = new Color ( |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
154 c.getRed(), |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
155 c.getGreen(), |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
156 c.getBlue()); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
157 symbolElement.setAttribute( |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
158 "transparent_color", |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
159 String.valueOf(transp.getRGB())); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
160 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
161 else { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
162 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
|
163 return null; |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
164 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
165 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
166 catch(IOException ioe) { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
167 logger.warn("Could not read picture."); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
168 } |
97
18e4f143896b
Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
84
diff
changeset
|
169 symbolElement.setAttribute("type", "line"); |
64
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
170 symbolElement.setAttribute("style", "picture"); |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
171 |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
172 return symbolElement; |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
173 } |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
174 } |
c73647bd71c0
Added picture line symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
175 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |