Mercurial > mxd2map
annotate src/java/de/intevation/mxd/reader/PictureFillSymbolReader.java @ 260:10e0aa283217
Updated documentation and added ant task for javadoc generation.
author | raimund renkert <raimund.renkert@intevation.de> |
---|---|
date | Tue, 16 Aug 2011 14:32:06 +0200 |
parents | 6b80e46b8f38 |
children | 2cb2f26d0d54 |
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.IRgbColor; |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 import com.esri.arcgis.display.RgbColor; |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 import org.w3c.dom.Element; |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 import java.io.IOException; |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 import java.awt.image.BufferedImage; |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 import java.awt.image.DataBufferByte; |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 import javax.imageio.ImageIO; |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 import java.io.ByteArrayOutputStream; |
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 import org.apache.commons.codec.binary.Base64; |
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 * Reads picture fill symbol information. |
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 * @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
|
47 */ |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 public class PictureFillSymbolReader |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 extends AbstractSymbolReader { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 |
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 * The logger. |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 */ |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 private static final Logger logger = |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 Logger.getLogger(PictureFillSymbolReader.class); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 |
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 member. |
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 private PictureFillSymbol symbol; |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 public PictureFillSymbolReader(ISymbol symbol) |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 throws Exception { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 logger.debug("contructor()"); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 if(symbol instanceof PictureFillSymbol) { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 this.symbol = (PictureFillSymbol)symbol; |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 else { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 throw new Exception("Not a PictureFillSymbol!"); |
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 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 public PictureFillSymbolReader(IFillSymbol symbol) |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 throws Exception { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 logger.debug("contructor()"); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 if(symbol instanceof PictureFillSymbol) { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 this.symbol = (PictureFillSymbol)symbol; |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
79 else { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
80 throw new Exception("Not a PictureFillSymbol!"); |
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 |
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 * Reads the symbol attributes. |
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 * @return The XML node. |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
88 */ |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
89 public Element read() { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
90 logger.debug("read()"); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
91 Element symbolElement = util.addSymbol(parent); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
92 |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
93 try { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
94 symbolElement.setAttribute("name", symbol.getNameString()); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
95 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
96 catch(IOException ioe) { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
97 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
|
98 symbolElement.setAttribute("name", "default"); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
100 |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
101 try { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
102 symbolElement.setAttribute( |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
103 "x_scale", |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
104 String.valueOf(symbol.getXScale())); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
105 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
106 catch(IOException ioe) { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 logger.warn("Could not read x-scale."); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
108 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
109 |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 try { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 symbolElement.setAttribute( |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
112 "y_scale", |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
113 String.valueOf(symbol.getYScale())); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
114 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
115 catch(IOException ioe) { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
116 logger.warn("Could not read y-scale."); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
117 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
118 |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
119 try { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
120 symbolElement.setAttribute( |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
121 "xseparation", |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
122 String.valueOf(symbol.getXSeparation())); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
123 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
124 catch(IOException ioe) { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
125 logger.warn("Could not read x-separation."); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
126 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
127 |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
128 try { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
129 symbolElement.setAttribute( |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
130 "yseparation", |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
131 String.valueOf(symbol.getYSeparation())); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
132 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
133 catch(IOException ioe) { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
134 logger.warn( |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
135 "Could not read y-separation."); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
136 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
137 |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
138 try { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
139 ILineSymbol ls = symbol.getOutline(); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
140 LineSymbolReader lsr = new LineSymbolReader(); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
141 if(lsr.canRead(ls)) { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
142 lsr.setSymbol(ls); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
143 lsr.setUtil(util); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
144 lsr.setParent(symbolElement); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
145 lsr.read(); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
146 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
147 else { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
148 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
|
149 " is not implemented!"); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
150 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
151 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
152 catch(Exception e) { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
153 logger.warn("Could not read outline."); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
154 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
155 |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
156 //Read the picture and convert to base64. |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
157 try { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
158 Picture p = symbol.getPicture(); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
159 Image i = p.toImage(); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
160 if(i instanceof BufferedImage) { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
161 BufferedImage bi = (BufferedImage)i; |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
162 ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
163 //Get byte array from image. |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
164 ImageIO.write(bi, "BMP", baos); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
165 Base64 encoder = new Base64(); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
166 //encode in a base64 string |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
167 String pict = encoder.encodeBase64String(baos.toByteArray()); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
168 symbolElement.setAttribute("picture", pict); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
169 |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
170 //Get transparent color. |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
171 RgbColor c = new RgbColor(); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
172 c.setRGB(symbol.getBitmapTransparencyColor().getRGB()); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
173 Color transp = new Color ( |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
174 c.getRed(), |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
175 c.getGreen(), |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
176 c.getBlue()); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
177 symbolElement.setAttribute( |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
178 "transparent_color", |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
179 String.valueOf(transp.getRGB())); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
180 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
181 else { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
182 logger.warn("Could not read image symbol."); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
183 return null; |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
184 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
185 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
186 catch(IOException ioe) { |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
187 logger.warn("Could not read picture."); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
188 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
189 symbolElement.setAttribute("type", "fill"); |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
190 symbolElement.setAttribute("style", "picture"); |
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 return symbolElement; |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
193 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
194 } |
6b80e46b8f38
Added picture symbol support to the converter.
raimund renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
195 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |