Revision 36429
tags/tmp_build/libraries/libArcIMS/.cvsignore | ||
---|---|---|
1 |
bin |
|
2 |
doc |
|
3 |
javadoc.xml |
|
4 |
test |
|
0 | 5 |
tags/tmp_build/libraries/libArcIMS/build.xml | ||
---|---|---|
1 |
<project name="RemoteClient" default="dist" basedir="."> |
|
2 |
<description> Genera el jar con RemoteClient y sus dependencias </description> |
|
3 |
<!-- set global properties for this build --> |
|
4 |
<property name="src" location="src"/> |
|
5 |
<property name="build" location="bin"/> |
|
6 |
<property name="dist" location="dist"/> |
|
7 |
<property name="lib" location="lib"/> |
|
8 |
<property name="jar" value="remote-clients-arcims"/> |
|
9 |
<property name="targetDir" location="."/> |
|
10 |
<property name="targetDir2" location="../extArcims/lib"/> |
|
11 |
<property name="fmap" location="../libFMap"/> |
|
12 |
<property name="andami" location="../_fwAndami"/> |
|
13 |
|
|
14 |
<!-- to move the lib directly to andami without having to run extArcims build.xml--> |
|
15 |
<property name="extensionDir" location="${andami}/gvSIG/extensiones"/> |
|
16 |
<property name="mainplugin" value="com.iver.cit.gvsig"/> |
|
17 |
<property name="targetDir3" location="${extensionDir}/${mainplugin}/lib"/> |
|
18 |
|
|
19 |
<import file="../binaries/ant/utilities.xml"/> |
|
20 |
|
|
21 |
<target name="init"> |
|
22 |
<!-- Create the build directory structure used by compile --> |
|
23 |
<mkdir dir="${build}"/> |
|
24 |
<mkdir dir="${dist}"/> |
|
25 |
|
|
26 |
</target> |
|
27 |
|
|
28 |
<target name="compile" depends="init" description="compile the source"> |
|
29 |
<!-- Compile the Java code from ${src} to ${bin} --> |
|
30 |
<loadEclipseClasspath project="${basedir}"/> |
|
31 |
<gvSIG-javac |
|
32 |
classpath="${eclipseClasspath}"/> |
|
33 |
</target> |
|
34 |
|
|
35 |
<target name="batch-build" |
|
36 |
description="compile the sources, create the jar file" |
|
37 |
depends="compile,create-jar,copy-files"> |
|
38 |
</target> |
|
39 |
|
|
40 |
<target name="dist" depends="init,create-jar,copy-files" description="generate the distribution"> |
|
41 |
|
|
42 |
<!-- <move todir="${targetDir}/"> |
|
43 |
<fileset dir="${dist}" includes="**/**"/> |
|
44 |
</move>--> |
|
45 |
</target> |
|
46 |
|
|
47 |
<target name="copy-files"> |
|
48 |
<!-- Put everything in ${build} into the cms-${DSTAMP}.jar file --> |
|
49 |
|
|
50 |
<copy todir="${targetDir3}"> |
|
51 |
<fileset dir="${dist}" includes="${jar}.jar"/> |
|
52 |
</copy> |
|
53 |
|
|
54 |
<move todir="${targetDir2}/"> |
|
55 |
<fileset dir="${dist}" includes="**/**"/> |
|
56 |
</move> |
|
57 |
<copy todir="${targetDir2}/"> |
|
58 |
<fileset dir="${lib}" includes="*.jar"/> |
|
59 |
</copy> |
|
60 |
|
|
61 |
</target> |
|
62 |
|
|
63 |
<target name="create-jar" |
|
64 |
description="Creates the library jars"> |
|
65 |
<jar jarfile="${dist}/${jar}.jar" basedir="${build}"/> |
|
66 |
<jar jarfile="${dist}/${jar}.jar" basedir="." includes="images/*.gif" |
|
67 |
update="true"/> |
|
68 |
|
|
69 |
</target> |
|
70 |
|
|
71 |
|
|
72 |
<target name="clean" description="clean up"> |
|
73 |
<!-- Delete the ${build} and ${dist} directory trees --> |
|
74 |
<delete includeemptydirs="true" failonerror="no"> |
|
75 |
<fileset dir="${build}" includes="**/*"/> |
|
76 |
</delete> |
|
77 |
<delete includeemptydirs="true" failonerror="no"> |
|
78 |
<fileset dir="${dist}" includes="**/*"/> |
|
79 |
</delete> |
|
80 |
</target> |
|
81 |
</project> |
|
82 |
|
|
83 |
|
|
0 | 84 |
tags/tmp_build/libraries/libArcIMS/.classpath | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<classpath> |
|
3 |
<classpathentry kind="src" path="src"/> |
|
4 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
|
5 |
<classpathentry combineaccessrules="false" kind="src" path="/libRemoteServices"/> |
|
6 |
<classpathentry kind="lib" path="/libFMap/lib/gdbms-0.8-SNAPSHOT.jar"/> |
|
7 |
<classpathentry combineaccessrules="false" kind="src" path="/libFMap"/> |
|
8 |
<classpathentry combineaccessrules="false" kind="src" path="/appgvSIG"/> |
|
9 |
<classpathentry combineaccessrules="false" kind="src" path="/_fwAndami"/> |
|
10 |
<classpathentry kind="var" path="JUNIT_HOME/junit.jar"/> |
|
11 |
<classpathentry kind="lib" path="/libFMap/lib/org.cresques.cts.jar"/> |
|
12 |
<classpathentry kind="lib" path="/libRemoteServices/lib/kxml2.jar"/> |
|
13 |
<classpathentry kind="lib" path="/_fwAndami/lib/iver-utiles.jar" sourcepath="/libIverUtiles"/> |
|
14 |
<classpathentry combineaccessrules="false" kind="src" path="/libExceptions"/> |
|
15 |
<classpathentry combineaccessrules="false" kind="src" path="/extSymbology"/> |
|
16 |
<classpathentry kind="lib" path="/_fwAndami/lib/log4j-1.2.14.jar"/> |
|
17 |
<classpathentry kind="output" path="bin"/> |
|
18 |
</classpath> |
|
0 | 19 |
tags/tmp_build/libraries/libArcIMS/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>libArcIMS</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
<buildCommand> |
|
9 |
<name>org.eclipse.jdt.core.javabuilder</name> |
|
10 |
<arguments> |
|
11 |
</arguments> |
|
12 |
</buildCommand> |
|
13 |
</buildSpec> |
|
14 |
<natures> |
|
15 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
16 |
</natures> |
|
17 |
</projectDescription> |
|
0 | 18 |
tags/tmp_build/libraries/libArcIMS/lib/.cvsignore | ||
---|---|---|
1 |
remote-clients.jar |
|
0 | 2 |
tags/tmp_build/libraries/libArcIMS/src/org/gvsig/remoteClient/arcims/ArcImsStyle.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL |
|
34 |
* Conde Salvatierra de ?lava , 34-10 |
|
35 |
* 46004 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963 510 612 |
|
39 |
* +34 963 510 968 |
|
40 |
* gis@prodevelop.es |
|
41 |
* http://www.prodevelop.es |
|
42 |
*/ |
|
43 |
|
|
44 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
45 |
* |
|
46 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana. |
|
47 |
* |
|
48 |
* This program is free software; you can redistribute it and/or |
|
49 |
* modify it under the terms of the GNU General Public License |
|
50 |
* as published by the Free Software Foundation; either version 2 |
|
51 |
* of the License, or (at your option) any later version. |
|
52 |
* |
|
53 |
* This program is distributed in the hope that it will be useful, |
|
54 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
55 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
56 |
* GNU General Public License for more details. |
|
57 |
* |
|
58 |
* You should have received a copy of the GNU General Public License |
|
59 |
* along with this program; if not, write to the Free Software |
|
60 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
61 |
* |
|
62 |
* For more information, contact: |
|
63 |
* |
|
64 |
* Generalitat Valenciana |
|
65 |
* Conselleria d'Infraestructures i Transport |
|
66 |
* Av. Blasco Ib??ez, 50 |
|
67 |
* 46010 VALENCIA |
|
68 |
* SPAIN |
|
69 |
* |
|
70 |
* +34 963862235 |
|
71 |
* gvsig@gva.es |
|
72 |
* www.gvsig.gva.es |
|
73 |
* |
|
74 |
* or |
|
75 |
* |
|
76 |
* Prodevelop Integraci?n de Tecnolog?as SL |
|
77 |
* Conde Salvatierra de ?lava , 34-10 |
|
78 |
* 46004 Valencia |
|
79 |
* Spain |
|
80 |
* |
|
81 |
* +34 963 510 612 |
|
82 |
* +34 963 510 968 |
|
83 |
* gis@prodevelop.es |
|
84 |
* http://www.prodevelop.es |
|
85 |
*/ |
|
86 |
package org.gvsig.remoteClient.arcims; |
|
87 |
|
|
88 |
import org.gvsig.remoteClient.utils.CapabilitiesTags; |
|
89 |
|
|
90 |
import org.kxml2.io.KXmlParser; |
|
91 |
|
|
92 |
import org.xmlpull.v1.XmlPullParserException; |
|
93 |
|
|
94 |
import java.io.IOException; |
|
95 |
|
|
96 |
|
|
97 |
/** |
|
98 |
* <p>Defines a style. Theme that describes the appeareance of certain layer.</p> |
|
99 |
* |
|
100 |
*/ |
|
101 |
public abstract class ArcImsStyle { |
|
102 |
/** |
|
103 |
* style name, defined in the ArcIms capabilities |
|
104 |
*/ |
|
105 |
private String name; |
|
106 |
|
|
107 |
/** |
|
108 |
* style title, defined in the ArcIms capabilities |
|
109 |
*/ |
|
110 |
private String title; |
|
111 |
|
|
112 |
/** |
|
113 |
* style abstract, defined in the ArcIms capabilities |
|
114 |
*/ |
|
115 |
private String styleAbstract; |
|
116 |
private LegendURL legendURL; |
|
117 |
|
|
118 |
/** |
|
119 |
* <p>Parses the STYLE tag in the ArcIms capabilities, filling the ArcImsStyle object |
|
120 |
* loading the data in memory to be easily accesed</p> |
|
121 |
* |
|
122 |
*/ |
|
123 |
public abstract void parse(KXmlParser parser) |
|
124 |
throws IOException, XmlPullParserException; |
|
125 |
|
|
126 |
/** |
|
127 |
* Parses the legendURL tag. |
|
128 |
* @param parser |
|
129 |
* @throws IOException |
|
130 |
* @throws XmlPullParserException |
|
131 |
*/ |
|
132 |
protected void parseLegendURL(KXmlParser parser) |
|
133 |
throws IOException, XmlPullParserException { |
|
134 |
int currentTag; |
|
135 |
boolean end = false; |
|
136 |
|
|
137 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.LEGENDURL); |
|
138 |
currentTag = parser.nextTag(); |
|
139 |
|
|
140 |
String value = new String(); |
|
141 |
LegendURL legend = new LegendURL(); |
|
142 |
|
|
143 |
//First of all set whether the layer is Queryable reading the attribute. |
|
144 |
value = parser.getAttributeValue("", CapabilitiesTags.WIDTH); |
|
145 |
|
|
146 |
if (value != null) { |
|
147 |
legend.width = Integer.parseInt(value); |
|
148 |
} |
|
149 |
|
|
150 |
value = parser.getAttributeValue("", CapabilitiesTags.HEIGHT); |
|
151 |
|
|
152 |
if (value != null) { |
|
153 |
legend.height = Integer.parseInt(value); |
|
154 |
} |
|
155 |
|
|
156 |
while (!end) { |
|
157 |
switch (currentTag) { |
|
158 |
case KXmlParser.START_TAG: |
|
159 |
|
|
160 |
if (parser.getName().compareTo(CapabilitiesTags.FORMAT) == 0) { |
|
161 |
legend.format = parser.nextText(); |
|
162 |
} else if (parser.getName() |
|
163 |
.compareTo(CapabilitiesTags.ONLINERESOURCE) == 0) { |
|
164 |
value = parser.getAttributeValue("", |
|
165 |
CapabilitiesTags.XLINK_TYPE); |
|
166 |
|
|
167 |
if (value != null) { |
|
168 |
legend.onlineResource_type = value; |
|
169 |
} |
|
170 |
|
|
171 |
value = parser.getAttributeValue("", |
|
172 |
CapabilitiesTags.XLINK_HREF); |
|
173 |
|
|
174 |
if (value != null) { |
|
175 |
legend.onlineResource_href = value; |
|
176 |
} |
|
177 |
} |
|
178 |
|
|
179 |
break; |
|
180 |
|
|
181 |
case KXmlParser.END_TAG: |
|
182 |
|
|
183 |
if (parser.getName().compareTo(CapabilitiesTags.LEGENDURL) == 0) { |
|
184 |
end = true; |
|
185 |
} |
|
186 |
|
|
187 |
break; |
|
188 |
|
|
189 |
case KXmlParser.TEXT: |
|
190 |
break; |
|
191 |
} |
|
192 |
|
|
193 |
if (!end) { |
|
194 |
currentTag = parser.next(); |
|
195 |
} |
|
196 |
} |
|
197 |
|
|
198 |
parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.LEGENDURL); |
|
199 |
} |
|
200 |
|
|
201 |
/** |
|
202 |
* gets the LegendURL OnlineResource type |
|
203 |
*/ |
|
204 |
public String getLegendURLOnlineResourceType() { |
|
205 |
if (legendURL != null) { |
|
206 |
return legendURL.onlineResource_type; |
|
207 |
} else { |
|
208 |
return null; |
|
209 |
} |
|
210 |
} |
|
211 |
|
|
212 |
/** |
|
213 |
* gets the LegendURL OnlineResource href |
|
214 |
*/ |
|
215 |
public String getLegendURLOnlineResourceHRef() { |
|
216 |
if (legendURL != null) { |
|
217 |
return legendURL.onlineResource_href; |
|
218 |
} else { |
|
219 |
return null; |
|
220 |
} |
|
221 |
} |
|
222 |
|
|
223 |
public String getLegendURLFormat() { |
|
224 |
if (legendURL != null) { |
|
225 |
return legendURL.format; |
|
226 |
} else { |
|
227 |
return null; |
|
228 |
} |
|
229 |
} |
|
230 |
|
|
231 |
public int getLegendURLWidth() { |
|
232 |
if (legendURL != null) { |
|
233 |
return legendURL.width; |
|
234 |
} |
|
235 |
|
|
236 |
return 0; |
|
237 |
} |
|
238 |
|
|
239 |
public int getLegendURLHeight() { |
|
240 |
if (legendURL != null) { |
|
241 |
return legendURL.height; |
|
242 |
} |
|
243 |
|
|
244 |
return 0; |
|
245 |
} |
|
246 |
|
|
247 |
/** |
|
248 |
* sets LegendURL |
|
249 |
*/ |
|
250 |
protected void setLegendURL(LegendURL legendURL) { |
|
251 |
this.legendURL = legendURL; |
|
252 |
} |
|
253 |
|
|
254 |
/** |
|
255 |
* <p>gets the style name</p> |
|
256 |
* |
|
257 |
* @return style name |
|
258 |
*/ |
|
259 |
public String getName() { |
|
260 |
return name; |
|
261 |
} |
|
262 |
|
|
263 |
/** |
|
264 |
* <p>sets the style name.</p> |
|
265 |
* |
|
266 |
* @param _name |
|
267 |
*/ |
|
268 |
public void setName(String _name) { |
|
269 |
name = _name; |
|
270 |
} |
|
271 |
|
|
272 |
/** |
|
273 |
* <p>gets the style title</p> |
|
274 |
* |
|
275 |
* |
|
276 |
* @return style title |
|
277 |
*/ |
|
278 |
public String getTitle() { |
|
279 |
return title; |
|
280 |
} |
|
281 |
|
|
282 |
/** |
|
283 |
* <p>Sets style title</p> |
|
284 |
* |
|
285 |
* |
|
286 |
* @param _title |
|
287 |
*/ |
|
288 |
public void setTitle(String _title) { |
|
289 |
title = _title.trim(); |
|
290 |
} |
|
291 |
|
|
292 |
/** |
|
293 |
* <p>gets style abstract</p> |
|
294 |
* |
|
295 |
* |
|
296 |
* @return style abstract |
|
297 |
*/ |
|
298 |
public String getAbstract() { |
|
299 |
return styleAbstract; |
|
300 |
} |
|
301 |
|
|
302 |
/** |
|
303 |
* <p>sets style abstract</p> |
|
304 |
* |
|
305 |
* |
|
306 |
* @param aabstract style abstract |
|
307 |
*/ |
|
308 |
public void setAbstract(String aabstract) { |
|
309 |
styleAbstract = aabstract; |
|
310 |
} |
|
311 |
|
|
312 |
/** |
|
313 |
* <p>Inner class describing the Legend URL defined for styles in the specifications in ArcIms</p> |
|
314 |
* |
|
315 |
*/ |
|
316 |
protected class LegendURL { |
|
317 |
public int width; |
|
318 |
public int height; |
|
319 |
public String format; |
|
320 |
public String onlineResource_type; |
|
321 |
public String onlineResource_href; |
|
322 |
|
|
323 |
public LegendURL() { |
|
324 |
width = 0; |
|
325 |
height = 0; |
|
326 |
format = new String(); |
|
327 |
onlineResource_type = new String(); |
|
328 |
onlineResource_href = new String(); |
|
329 |
} |
|
330 |
} |
|
331 |
} |
|
0 | 332 |
tags/tmp_build/libraries/libArcIMS/src/org/gvsig/remoteClient/arcims/exceptions/ArcImsException.java | ||
---|---|---|
1 |
package org.gvsig.remoteClient.arcims.exceptions; |
|
2 |
|
|
3 |
/** |
|
4 |
* ArcIms specific exception, @see Exception |
|
5 |
*/ |
|
6 |
public class ArcImsException extends Exception |
|
7 |
{ |
|
8 |
static final long serialVersionUID = 0; |
|
9 |
|
|
10 |
private String arcims_message = null; |
|
11 |
|
|
12 |
/** |
|
13 |
* |
|
14 |
*/ |
|
15 |
public ArcImsException() { |
|
16 |
super(); |
|
17 |
} |
|
18 |
|
|
19 |
/** |
|
20 |
* Creates an ArcimsException |
|
21 |
* |
|
22 |
* @param message |
|
23 |
*/ |
|
24 |
public ArcImsException(String message) { |
|
25 |
super(message); |
|
26 |
} |
|
27 |
|
|
28 |
/** |
|
29 |
* Creates an ArcimsException |
|
30 |
* |
|
31 |
* @param message |
|
32 |
* @param cause |
|
33 |
*/ |
|
34 |
public ArcImsException(String message, Throwable cause) { |
|
35 |
super(message, cause); |
|
36 |
} |
|
37 |
|
|
38 |
/** |
|
39 |
* Creates an ArcimsException |
|
40 |
* |
|
41 |
* @param cause |
|
42 |
*/ |
|
43 |
public ArcImsException(Throwable cause) { |
|
44 |
super(cause); |
|
45 |
} |
|
46 |
|
|
47 |
public String getArcImsMessage() |
|
48 |
{ |
|
49 |
if (arcims_message == null) |
|
50 |
return ""; |
|
51 |
else |
|
52 |
return arcims_message; |
|
53 |
} |
|
54 |
|
|
55 |
public void setArcImsMessage(String mes) |
|
56 |
{ |
|
57 |
arcims_message = mes; |
|
58 |
} |
|
59 |
} |
|
0 | 60 |
tags/tmp_build/libraries/libArcIMS/src/org/gvsig/remoteClient/arcims/ArcImsVectStatus.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL |
|
34 |
* Conde Salvatierra de ?lava , 34-10 |
|
35 |
* 46004 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963 510 612 |
|
39 |
* +34 963 510 968 |
|
40 |
* gis@prodevelop.es |
|
41 |
* http://www.prodevelop.es |
|
42 |
*/ |
|
43 |
|
|
44 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
45 |
* |
|
46 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana. |
|
47 |
* |
|
48 |
* This program is free software; you can redistribute it and/or |
|
49 |
* modify it under the terms of the GNU General Public License |
|
50 |
* as published by the Free Software Foundation; either version 2 |
|
51 |
* of the License, or (at your option) any later version. |
|
52 |
* |
|
53 |
* This program is distributed in the hope that it will be useful, |
|
54 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
55 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
56 |
* GNU General Public License for more details. |
|
57 |
* |
|
58 |
* You should have received a copy of the GNU General Public License |
|
59 |
* along with this program; if not, write to the Free Software |
|
60 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
61 |
* |
|
62 |
* For more information, contact: |
|
63 |
* |
|
64 |
* Generalitat Valenciana |
|
65 |
* Conselleria d'Infraestructures i Transport |
|
66 |
* Av. Blasco Ib??ez, 50 |
|
67 |
* 46010 VALENCIA |
|
68 |
* SPAIN |
|
69 |
* |
|
70 |
* +34 963862235 |
|
71 |
* gvsig@gva.es |
|
72 |
* www.gvsig.gva.es |
|
73 |
* |
|
74 |
* or |
|
75 |
* |
|
76 |
* Prodevelop Integraci?n de Tecnolog?as SL |
|
77 |
* Conde Salvatierra de ?lava , 34-10 |
|
78 |
* 46004 Valencia |
|
79 |
* Spain |
|
80 |
* |
|
81 |
* +34 963 510 612 |
|
82 |
* +34 963 510 968 |
|
83 |
* gis@prodevelop.es |
|
84 |
* http://www.prodevelop.es |
|
85 |
*/ |
|
86 |
|
|
87 |
/** |
|
88 |
* |
|
89 |
*/ |
|
90 |
package org.gvsig.remoteClient.arcims; |
|
91 |
|
|
92 |
|
|
93 |
/** |
|
94 |
* Extended class to implement specific vectorial state information |
|
95 |
* @author jsanz |
|
96 |
* |
|
97 |
*/ |
|
98 |
public class ArcImsVectStatus extends ArcImsStatus { |
|
99 |
private String where; |
|
100 |
private String[] subfields; |
|
101 |
|
|
102 |
/** |
|
103 |
* |
|
104 |
*/ |
|
105 |
public ArcImsVectStatus() { |
|
106 |
super(); |
|
107 |
where = ""; |
|
108 |
subfields = new String[1]; |
|
109 |
subfields[0] = "#ALL#"; |
|
110 |
} |
|
111 |
|
|
112 |
public Object clone() { |
|
113 |
ArcImsVectStatus avs = new ArcImsVectStatus(); |
|
114 |
avs = (ArcImsVectStatus) super.clone(); |
|
115 |
avs.setWhere(this.getWhere()); |
|
116 |
avs.setSubfields(this.getSubfields()); |
|
117 |
|
|
118 |
return avs; |
|
119 |
} |
|
120 |
|
|
121 |
/** |
|
122 |
* @return Returns the where. |
|
123 |
*/ |
|
124 |
public String getWhere() { |
|
125 |
return where; |
|
126 |
} |
|
127 |
|
|
128 |
/** |
|
129 |
* @param where The where to set. |
|
130 |
*/ |
|
131 |
public void setWhere(String where) { |
|
132 |
this.where = where; |
|
133 |
} |
|
134 |
|
|
135 |
/** |
|
136 |
* @return Returns the subfields. |
|
137 |
*/ |
|
138 |
public String[] getSubfields() { |
|
139 |
return subfields; |
|
140 |
} |
|
141 |
|
|
142 |
/** |
|
143 |
* @param subfields The subfields to set. |
|
144 |
*/ |
|
145 |
public void setSubfields(String[] subfields) { |
|
146 |
if (subfields == null) { |
|
147 |
subfields = new String[1]; |
|
148 |
subfields[0] = "#ALL#"; |
|
149 |
} |
|
150 |
|
|
151 |
this.subfields = subfields; |
|
152 |
} |
|
153 |
} |
|
0 | 154 |
tags/tmp_build/libraries/libArcIMS/src/org/gvsig/remoteClient/arcims/styling/symbols/ArcImsFSymbolFactory.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2006 Prodevelop and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* Prodevelop Integraci?n de Tecnolog?as SL |
|
34 |
* Conde Salvatierra de ?lava , 34-10 |
|
35 |
* 46004 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963 510 612 |
|
39 |
* +34 963 510 968 |
|
40 |
* gis@prodevelop.es |
|
41 |
* http://www.prodevelop.es |
|
42 |
*/ |
|
43 |
|
|
44 |
/** |
|
45 |
* |
|
46 |
*/ |
|
47 |
package org.gvsig.remoteClient.arcims.styling.symbols; |
|
48 |
|
|
49 |
import com.iver.cit.gvsig.fmap.MapContext; |
|
50 |
import com.iver.cit.gvsig.fmap.core.styles.ILineStyle; |
|
51 |
import com.iver.cit.gvsig.fmap.core.styles.SimpleLineStyle; |
|
52 |
import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol; |
|
53 |
import com.iver.cit.gvsig.fmap.core.symbols.IMarkerSymbol; |
|
54 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
55 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol; |
|
56 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleLineSymbol; |
|
57 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleMarkerSymbol; |
|
58 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleTextSymbol; |
|
59 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
|
60 |
|
|
61 |
import com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D; |
|
62 |
|
|
63 |
import com.iver.utiles.ImageFilter; |
|
64 |
|
|
65 |
import org.apache.log4j.Logger; |
|
66 |
|
|
67 |
import org.gvsig.remoteClient.arcims.utils.ArcImsDownloadUtils; |
|
68 |
import org.gvsig.symbology.fmap.symbols.GradientFillSymbol; |
|
69 |
import org.gvsig.symbology.fmap.symbols.PictureFillSymbol; |
|
70 |
import org.gvsig.symbology.fmap.symbols.PictureMarkerSymbol; |
|
71 |
|
|
72 |
import java.awt.BasicStroke; |
|
73 |
import java.awt.Color; |
|
74 |
import java.awt.Font; |
|
75 |
import java.awt.GradientPaint; |
|
76 |
import java.awt.Graphics2D; |
|
77 |
import java.awt.Paint; |
|
78 |
import java.awt.Rectangle; |
|
79 |
import java.awt.TexturePaint; |
|
80 |
import java.awt.geom.Rectangle2D; |
|
81 |
import java.awt.image.BufferedImage; |
|
82 |
|
|
83 |
import java.io.File; |
|
84 |
import java.io.IOException; |
|
85 |
|
|
86 |
import java.net.ConnectException; |
|
87 |
import java.net.MalformedURLException; |
|
88 |
import java.net.URI; |
|
89 |
import java.net.URL; |
|
90 |
import java.net.UnknownHostException; |
|
91 |
|
|
92 |
import java.util.ArrayList; |
|
93 |
|
|
94 |
import javax.swing.ImageIcon; |
|
95 |
|
|
96 |
|
|
97 |
/** |
|
98 |
* Factory class to produce FSymbol's from ArcIMS Symbol defintions |
|
99 |
* @author jsanz |
|
100 |
* |
|
101 |
*/ |
|
102 |
public class ArcImsFSymbolFactory { |
|
103 |
private static Logger logger = Logger.getLogger(ArcImsFSymbolFactory.class.getName()); |
|
104 |
public static char ds = '.'; |
|
105 |
private static ArrayList initialColors = new ArrayList(); |
|
106 |
|
|
107 |
static { |
|
108 |
initialColors.add(new Color(179, 226, 205)); |
|
109 |
initialColors.add(new Color(253, 205, 172)); |
|
110 |
initialColors.add(new Color(203, 213, 232)); |
|
111 |
initialColors.add(new Color(230, 245, 201)); |
|
112 |
initialColors.add(new Color(141, 211, 199)); |
|
113 |
initialColors.add(new Color(255, 255, 179)); |
|
114 |
initialColors.add(new Color(190, 186, 218)); |
|
115 |
initialColors.add(new Color(251, 128, 114)); |
|
116 |
initialColors.add(new Color(128, 177, 211)); |
|
117 |
} |
|
118 |
|
|
119 |
//This code is copy&paste from com.iver.cit.gvsig.fmap.core.v02.FSymbolFactory; |
|
120 |
static int w; |
|
121 |
|
|
122 |
//This code is copy&paste from com.iver.cit.gvsig.fmap.core.v02.FSymbolFactory; |
|
123 |
static int h; |
|
124 |
|
|
125 |
/** |
|
126 |
* Returns a point FSymbol |
|
127 |
* @param simb |
|
128 |
* @return |
|
129 |
*/ |
|
130 |
protected static ISymbol getFSymbol(ArcImsSimpleMarkerSymbol simb) { |
|
131 |
Color mcolor = SymbolUtils.getColor(simb.getColor(), 1); |
|
132 |
int pointWidth = Integer.parseInt(simb.getWidth()); |
|
133 |
int pointStyle = getPointType(simb.getType()); |
|
134 |
|
|
135 |
SimpleMarkerSymbol mSimb = new SimpleMarkerSymbol(); |
|
136 |
|
|
137 |
mSimb.setColor(mcolor); |
|
138 |
mSimb.setSize(pointWidth); |
|
139 |
mSimb.setStyle(SimpleMarkerSymbol.CIRCLE_STYLE); |
|
140 |
logger.info("Getting ArcIMS simple point symbol"); |
|
141 |
|
|
142 |
return mSimb; |
|
143 |
} |
|
144 |
|
|
145 |
/** |
|
146 |
* Returns a point ISymbol with a remote image |
|
147 |
* @param symb |
|
148 |
* @return |
|
149 |
*/ |
|
150 |
protected static ISymbol getFSymbol(RasterMarkerSymbol symb) { |
|
151 |
String surl = symb.getUrl(); |
|
152 |
|
|
153 |
// Get the icon size |
|
154 |
float size = 0; |
|
155 |
|
|
156 |
if (symb.getSize() != null) { |
|
157 |
String[] tams = symb.getSize().split(","); |
|
158 |
int ntams = tams.length; |
|
159 |
|
|
160 |
if (ntams != 0) { |
|
161 |
for (int i = 0; i < ntams; i++) |
|
162 |
size += Float.parseFloat(tams[i]); // Sums different sizes |
|
163 |
|
|
164 |
size = size / ntams; // Get the mean |
|
165 |
} |
|
166 |
} else { |
|
167 |
size = 15; // Default size |
|
168 |
} |
|
169 |
|
|
170 |
// Get the icon file |
|
171 |
File img = getIconFile(surl); |
|
172 |
|
|
173 |
// If is an image, we build the symbol |
|
174 |
ImageFilter filter = new ImageFilter(); |
|
175 |
|
|
176 |
if (filter.accept(img)) { |
|
177 |
|
|
178 |
URL theUri; |
|
179 |
PictureMarkerSymbol mSimb = null; |
|
180 |
try { |
|
181 |
theUri = img.toURI().toURL(); |
|
182 |
mSimb = new PictureMarkerSymbol(); |
|
183 |
mSimb.setImage(theUri); |
|
184 |
} catch (Exception e) { |
|
185 |
logger.error("While getting image symbol: " + e.getMessage()); |
|
186 |
return getDefaultFSymbol(FConstant.SYMBOL_TYPE_POINT); |
|
187 |
} |
|
188 |
|
|
189 |
mSimb.setSize((int) size); |
|
190 |
logger.info("Getting ArcIMS raster marker point symbol"); |
|
191 |
return mSimb; |
|
192 |
} else { |
|
193 |
logger.info("Getting random point symbol"); |
|
194 |
return getDefaultFSymbol(FConstant.SYMBOL_TYPE_POINT); |
|
195 |
} |
|
196 |
} |
|
197 |
|
|
198 |
/** |
|
199 |
* Returns a line FSymbol |
|
200 |
* @param simb |
|
201 |
* @return |
|
202 |
*/ |
|
203 |
protected static SimpleLineSymbol getFSymbol(ArcImsSimpleLineSymbol simb) { |
|
204 |
String sTrans = simb.getTransparency(); |
|
205 |
|
|
206 |
if (ds != '.') { |
|
207 |
sTrans = sTrans.replace(ds, '.'); |
|
208 |
} |
|
209 |
|
|
210 |
float trans = Float.parseFloat(sTrans); |
|
211 |
|
|
212 |
Color mcolor = SymbolUtils.getColor(simb.getColor(), trans); |
|
213 |
int lineWidth = Integer.parseInt(simb.getWidth()); |
|
214 |
int intCapType = getCapType(simb.getCaptype()); |
|
215 |
int intJoin = getJoinType(simb.getJointype()); |
|
216 |
String linePattern = getLinePattern(simb.getType()); |
|
217 |
|
|
218 |
// BasicStroke bStroke = new BasicStroke(lineWidth, intCapType, intJoin, |
|
219 |
// 1.0f, FSymbol.toArray(linePattern, lineWidth), 0); |
|
220 |
|
|
221 |
SimpleLineSymbol theSymbol = new SimpleLineSymbol(); |
|
222 |
|
|
223 |
theSymbol.setLineColor(mcolor); |
|
224 |
SimpleLineStyle linestyle = new SimpleLineStyle( |
|
225 |
Float.parseFloat(simb.getWidth()), |
|
226 |
intCapType, intJoin, 1.0f, ArcImsSimpleLineSymbol.toArray(linePattern, lineWidth), 0); |
|
227 |
theSymbol.setLineStyle(linestyle); |
|
228 |
|
|
229 |
logger.info("Getting ArcIMS simple line symbol"); |
|
230 |
return theSymbol; |
|
231 |
} |
|
232 |
|
|
233 |
/** |
|
234 |
* The hasline symbol seems as a railroad, as gvSIG doesn't supports |
|
235 |
* railroad symbols, this method will return a simple line with the |
|
236 |
* same color and width |
|
237 |
* @param symbol |
|
238 |
* @return |
|
239 |
*/ |
|
240 |
protected static ISymbol getFSymbol(HashLineSymbol symbol) { |
|
241 |
ArcImsSimpleLineSymbol line = new ArcImsSimpleLineSymbol(); |
|
242 |
line.setColor(symbol.getColor()); |
|
243 |
line.setWidth(symbol.getLinethickness()); |
|
244 |
line.setType(SymbolUtils.LINE_TYPE_SOLID); |
|
245 |
|
|
246 |
logger.info("Getting ArcIMS hashline as a simple line symbol"); |
|
247 |
|
|
248 |
return line.getFSymbol(); |
|
249 |
} |
|
250 |
|
|
251 |
/** |
|
252 |
* Returns a polygon ISymbol with proper fill |
|
253 |
* @param simb |
|
254 |
* @return |
|
255 |
*/ |
|
256 |
protected static ISymbol getFSymbol(ArcImsSimplePolygonSymbol simb) { |
|
257 |
String sTrans = simb.getFilltransparency(); |
|
258 |
|
|
259 |
if (ds != '.') { |
|
260 |
sTrans = sTrans.replace(ds, '.'); |
|
261 |
} |
|
262 |
|
|
263 |
float trans = Float.parseFloat(sTrans); |
|
264 |
|
|
265 |
Color fColor = SymbolUtils.getColor(simb.getFillcolor(), trans); |
|
266 |
SimpleFillSymbol mSimb = new SimpleFillSymbol(); |
|
267 |
|
|
268 |
mSimb.setFillColor(fColor); |
|
269 |
|
|
270 |
//Set the type of fill |
|
271 |
int type = getFillStyle(simb.getFilltype()); |
|
272 |
|
|
273 |
switch (type) { |
|
274 |
case FConstant.SYMBOL_STYLE_FILL_GRAYFILL: |
|
275 |
mSimb.setFillColor(getGray(fColor)); |
|
276 |
|
|
277 |
break; |
|
278 |
|
|
279 |
case FConstant.SYMBOL_STYLE_FILL_LIGHTGRAYFILL: |
|
280 |
mSimb.setFillColor(getLightGray(fColor)); |
|
281 |
|
|
282 |
break; |
|
283 |
|
|
284 |
case FConstant.SYMBOL_STYLE_FILL_DARKGRAYFILL: |
|
285 |
mSimb.setFillColor(getDarkGray(fColor)); |
|
286 |
|
|
287 |
break; |
|
288 |
|
|
289 |
default: |
|
290 |
|
|
291 |
mSimb.setFillColor(fColor); |
|
292 |
// Paint fill = createPatternFill(type, fColor); |
|
293 |
// mSimb.setFill(fill); |
|
294 |
} |
|
295 |
|
|
296 |
if (simb.isHasBoundary()) { |
|
297 |
|
|
298 |
SimpleLineSymbol sls = getFSymbol(simb.getBoundary()); |
|
299 |
mSimb.setOutline(sls); |
|
300 |
} |
|
301 |
|
|
302 |
logger.info("Getting ArcIMS simple polygon symbol"); |
|
303 |
|
|
304 |
return mSimb; |
|
305 |
} |
|
306 |
|
|
307 |
/** |
|
308 |
* A this time, this symbol will be promoted into a genery polygon symbol |
|
309 |
* with the intermediate color between start and finish color and an outline |
|
310 |
* "darker" color |
|
311 |
* @param simb |
|
312 |
* @return |
|
313 |
*/ |
|
314 |
protected static ISymbol getFSymbol(ArcImsGradientFillSymbol simb) { |
|
315 |
String sTrans = simb.getTransparency(); |
|
316 |
|
|
317 |
if (ds != '.') { |
|
318 |
sTrans = sTrans.replace(ds, '.'); |
|
319 |
} |
|
320 |
|
|
321 |
float trans = Float.parseFloat(sTrans); |
|
322 |
|
|
323 |
Color startColor = SymbolUtils.getColor(simb.getStartcolor(), trans); |
|
324 |
Color finishColor = SymbolUtils.getColor(simb.getFinishcolor(), trans); |
|
325 |
Color avgColor = mixColors(startColor, finishColor); |
|
326 |
|
|
327 |
GradientFillSymbol gfs = new GradientFillSymbol(); |
|
328 |
Color[] start_end = new Color[2]; |
|
329 |
start_end[0] = startColor; |
|
330 |
start_end[1] = finishColor; |
|
331 |
|
|
332 |
SimpleLineSymbol sls = new SimpleLineSymbol(); |
|
333 |
sls.setLineColor(avgColor); |
|
334 |
|
|
335 |
gfs.setOutline(sls); |
|
336 |
gfs.setGradientColor(start_end); |
|
337 |
|
|
338 |
//Until gvSIG supports gradients, this code is useless |
|
339 |
/* |
|
340 |
int type = getFillStyle(simb.getType()); |
|
341 |
|
|
342 |
Point2D startP2D = null; |
|
343 |
Point2D finishP2D = null; |
|
344 |
|
|
345 |
double ratio = 150; |
|
346 |
|
|
347 |
switch (type) { |
|
348 |
case FConstant.SYMBOL_STYLE_FILL_UPWARD_DIAGONAL: |
|
349 |
startP2D = new Point2D.Double(0.0*ratio,0.0*ratio); |
|
350 |
finishP2D = new Point2D.Double(1.0*ratio,1.0*ratio); |
|
351 |
break; |
|
352 |
case FConstant.SYMBOL_STYLE_FILL_DOWNWARD_DIAGONAL: |
|
353 |
startP2D = new Point2D.Double(0.0*ratio,1.0*ratio); |
|
354 |
finishP2D = new Point2D.Double(1.0*ratio,0.0*ratio); |
|
355 |
break; |
|
356 |
case FConstant.SYMBOL_STYLE_FILL_VERTICAL: |
|
357 |
startP2D = new Point2D.Double(0.5*ratio,0.0*ratio); |
|
358 |
finishP2D = new Point2D.Double(0.5*ratio,1.0*ratio); |
|
359 |
break; |
|
360 |
case FConstant.SYMBOL_STYLE_FILL_HORIZONTAL: |
|
361 |
startP2D = new Point2D.Double(0.0*ratio,0.5*ratio); |
|
362 |
finishP2D = new Point2D.Double(1.0*ratio,0.5*ratio); |
|
363 |
break; |
|
364 |
} |
|
365 |
|
|
366 |
//Set the paint |
|
367 |
mSimb.setFill((Paint) new GradientPaint(startP2D,startColor,finishP2D,finishColor)); |
|
368 |
//Remove the outline |
|
369 |
mSimb.setOutlined(false); |
|
370 |
*/ |
|
371 |
logger.info("Getting ArcIMS gradient fill..."); |
|
372 |
|
|
373 |
return gfs; |
|
374 |
} |
|
375 |
|
|
376 |
protected static ISymbol getFSymbol(RasterFillSymbol simb) { |
|
377 |
//Get the icon file |
|
378 |
String surl = simb.getUrl(); |
|
379 |
File img = getIconFile(surl); |
|
380 |
|
|
381 |
//Get the transparency |
|
382 |
String sTrans = simb.getTransparency(); |
|
383 |
|
|
384 |
if (ds != '.') { |
|
385 |
sTrans = sTrans.replace(ds, '.'); |
|
386 |
} |
|
387 |
|
|
388 |
float trans = Float.parseFloat(sTrans); |
|
389 |
Color fColor = new Color(1.0f, 1.0f, 1.0f, trans); |
|
390 |
|
|
391 |
PictureFillSymbol pfs = new PictureFillSymbol(); |
|
392 |
// If is an image, we build the paint |
|
393 |
ImageFilter filter = new ImageFilter(); |
|
394 |
|
|
395 |
if (filter.accept(img)) { |
|
396 |
//Creates the BufferedImage object |
|
397 |
BufferedImage bi; |
|
398 |
ImageIcon icon = new ImageIcon(img.getAbsolutePath()); |
|
399 |
int w = icon.getIconWidth(); |
|
400 |
int h = icon.getIconHeight(); |
|
401 |
bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); |
|
402 |
|
|
403 |
// Draw the image in the BufferedImage object |
|
404 |
Graphics2D big = createG2(fColor, bi); |
|
405 |
big.drawImage(icon.getImage(), 0, 0, null); |
|
406 |
|
|
407 |
Rectangle2D rProv = new Rectangle(); |
|
408 |
rProv.setFrame(0, 0, w, h); |
|
409 |
|
|
410 |
try { |
|
411 |
pfs.setImage(img.toURI().toURL()); |
|
412 |
} catch (Exception e) { |
|
413 |
logger.error(""); |
|
414 |
return getDefaultFSymbol(FConstant.SYMBOL_TYPE_FILL); |
|
415 |
} |
|
416 |
pfs.setHasOutline(false); |
|
417 |
} |
|
418 |
|
|
419 |
logger.info("Getting ArcIMS raster fill symbol"); |
|
420 |
return pfs; |
|
421 |
} |
|
422 |
|
|
423 |
public static ISymbol getDefaultFSymbol(int type) { |
|
424 |
|
|
425 |
int rndcol = initialColors.size(); |
|
426 |
rndcol = (int) (System.currentTimeMillis() % rndcol); |
|
427 |
Color incolor = (Color) initialColors.get(rndcol); |
|
428 |
Color outcolor = incolor.darker().darker(); |
|
429 |
|
|
430 |
ISymbol resp = null; |
|
431 |
switch (type) { |
|
432 |
|
|
433 |
case FConstant.SYMBOL_TYPE_FILL: |
|
434 |
SimpleFillSymbol sfs = new SimpleFillSymbol(); |
|
435 |
sfs.setFillColor(incolor); |
|
436 |
SimpleLineSymbol sls = new SimpleLineSymbol(); |
|
437 |
sls.setLineColor(outcolor); |
|
438 |
sfs.setOutline(sls); |
|
439 |
resp = sfs; |
|
440 |
break; |
|
441 |
case FConstant.SYMBOL_TYPE_LINE: |
|
442 |
SimpleLineSymbol sls2 = new SimpleLineSymbol(); |
|
443 |
sls2.setLineColor(outcolor); |
|
444 |
resp = sls2; |
|
445 |
break; |
|
446 |
case FConstant.SYMBOL_TYPE_POINT: |
|
447 |
SimpleMarkerSymbol sms = new SimpleMarkerSymbol(); |
|
448 |
sms.setStyle(SimpleMarkerSymbol.CIRCLE_STYLE); |
|
449 |
sms.setSize(5); |
|
450 |
resp = sms; |
|
451 |
break; |
|
452 |
default: |
|
453 |
resp = (new SimpleFillSymbol()).getSymbolForSelection(); |
|
454 |
break; |
|
455 |
} |
|
456 |
// TODO Auto-generated method stub |
|
457 |
return resp; |
|
458 |
} |
|
459 |
|
|
460 |
/** |
|
461 |
* Return a Font Symbol |
|
462 |
* @param symbol |
|
463 |
* @return |
|
464 |
*/ |
|
465 |
protected static ISymbol getFSymbol(TextSymbol symb) { |
|
466 |
|
|
467 |
SimpleTextSymbol mSimb = new SimpleTextSymbol(); |
|
468 |
|
|
469 |
String font = symb.getFont(); |
|
470 |
int fontSize = Integer.parseInt(symb.getFontSize()); |
|
471 |
Color fontColor = SymbolUtils.getColor(symb.getFontColor(), 1); |
|
472 |
int fontStyle = SymbolUtils.getFontStyle(symb.getFontStyle()); |
|
473 |
|
|
474 |
mSimb.setFont(new Font(font, fontStyle, fontSize)); |
|
475 |
mSimb.setTextColor(fontColor); |
|
476 |
mSimb.setFontSize(fontSize); |
|
477 |
|
|
478 |
logger.info( |
|
479 |
"Getting ArcIMS TextSymbol..."); |
|
480 |
|
|
481 |
return mSimb; |
|
482 |
} |
|
483 |
|
|
484 |
/** |
|
485 |
* @param symbol |
|
486 |
* @return |
|
487 |
*/ |
|
488 |
protected static ISymbol getFSymbol(TextMarkerSymbol symbol) { |
|
489 |
logger.info("Getting ArcIMS TextSymbol as a random point symbol"); |
|
490 |
|
|
491 |
return getDefaultFSymbol(FConstant.SYMBOL_TYPE_POINT); |
|
492 |
} |
|
493 |
|
|
494 |
protected static ISymbol getFSymbol(TrueTypeMarkerSymbol symbol) { |
|
495 |
logger.info("Getting ArcIMS TextSymbol as a random point symbol"); |
|
496 |
|
|
497 |
return getDefaultFSymbol(FConstant.SYMBOL_TYPE_POINT); |
|
498 |
} |
|
499 |
|
|
500 |
/** |
|
501 |
* This method will return a null value as |
|
502 |
* this kind of symbol cannot be promoted to other |
|
503 |
* supported symbol |
|
504 |
* @param symbol |
|
505 |
* @return null |
|
506 |
*/ |
|
507 |
protected static ISymbol getFSymbol(ChartSymbol symbol) { |
|
508 |
return null; |
|
509 |
} |
|
510 |
|
|
511 |
|
|
512 |
|
|
513 |
/* |
|
514 |
* Supporting private methods |
|
515 |
*/ |
|
516 |
|
|
517 |
/** |
|
518 |
* Gets the correct constant for a ArcIMS point type |
|
519 |
* @param type |
|
520 |
* @return |
|
521 |
*/ |
|
522 |
private static int getPointType(String type) { |
|
523 |
//Default symbol, as gvsig doesn't paints stars |
|
524 |
int mtype = FConstant.SYMBOL_STYLE_MARKER_CIRCLE; |
|
525 |
|
|
526 |
if (type.equals(SymbolUtils.POINT_TYPE_CIRCLE)) { |
|
527 |
mtype = FConstant.SYMBOL_STYLE_MARKER_CIRCLE; |
|
528 |
} else if (type.equals(SymbolUtils.POINT_TYPE_CROSS)) { |
|
529 |
mtype = FConstant.SYMBOL_STYLE_MARKER_CROSS; |
|
530 |
} else if (type.equals(SymbolUtils.POINT_TYPE_SQUARE)) { |
|
531 |
mtype = FConstant.SYMBOL_STYLE_MARKER_SQUARE; |
|
532 |
} else if (type.equals(SymbolUtils.POINT_TYPE_TRIANGLE)) { |
|
533 |
mtype = FConstant.SYMBOL_STYLE_MARKER_TRIANGLE; |
|
534 |
} |
|
535 |
|
|
536 |
return mtype; |
|
537 |
} |
|
538 |
|
|
539 |
/** |
|
540 |
* Method to translate from ArcIMS type to a string of values that will be parsed |
|
541 |
* @return a correct string for the line type definition as "1,3" for dots |
|
542 |
*/ |
|
543 |
private static String getLinePattern(String type) { |
|
544 |
return (String) SymbolUtils.LINE_TYPES.get(type); |
|
545 |
} |
|
546 |
|
|
547 |
/** |
|
548 |
* Translates ArcIMS line end style into BasicStroke line end constants |
|
549 |
* @see java.awt.BasicStroke#getEndCap() |
|
550 |
* @param captype |
|
551 |
* @return |
|
552 |
*/ |
|
553 |
private static int getCapType(String captype) { |
|
554 |
int resp = BasicStroke.CAP_BUTT; |
|
555 |
|
|
556 |
if (captype.equals(SymbolUtils.CAP_TYPE_BUTT)) { |
|
557 |
resp = BasicStroke.CAP_BUTT; |
|
558 |
} else if (captype.equals(SymbolUtils.CAP_TYPE_ROUND)) { |
|
559 |
resp = BasicStroke.CAP_ROUND; |
|
560 |
} else if (captype.equals(SymbolUtils.CAP_TYPE_SQUARE)) { |
|
561 |
resp = BasicStroke.CAP_SQUARE; |
|
562 |
} |
|
563 |
|
|
564 |
return resp; |
|
565 |
} |
|
566 |
|
|
567 |
/** |
|
568 |
* Translate ArcIMS joining line types into BasicStroke join line constants |
|
569 |
* @see java.awt.BasicStroke#getLineJoin() |
|
570 |
* @param jointype |
|
571 |
* @return |
|
572 |
*/ |
|
573 |
private static int getJoinType(String jointype) { |
|
574 |
int resp = BasicStroke.CAP_BUTT; |
|
575 |
|
|
576 |
if (jointype.equals(SymbolUtils.JOIN_TYPE_ROUND)) { |
|
577 |
resp = BasicStroke.JOIN_ROUND; |
|
578 |
} else if (jointype.equals(SymbolUtils.JOIN_TYPE_MITER)) { |
|
579 |
resp = BasicStroke.JOIN_MITER; |
|
580 |
} else if (jointype.equals(SymbolUtils.JOIN_TYPE_BEVEL)) { |
|
581 |
resp = BasicStroke.JOIN_BEVEL; |
|
582 |
} |
|
583 |
|
|
584 |
return resp; |
|
585 |
} |
|
586 |
|
|
587 |
/** |
|
588 |
* Gets a valid FConstant integer to translate an ArcIMS fill style |
|
589 |
* @param filltype |
|
590 |
* @return |
|
591 |
*/ |
|
592 |
private static int getFillStyle(String filltype) { |
|
593 |
int style = FConstant.SYMBOL_STYLE_FILL_SOLID; |
|
594 |
|
|
595 |
if (filltype.equals(SymbolUtils.FILL_TYPE_SOLID)) { |
|
596 |
style = FConstant.SYMBOL_STYLE_FILL_SOLID; |
|
597 |
} else if (filltype.equals(SymbolUtils.FILL_TYPE_BDIAG)) { |
|
598 |
style = FConstant.SYMBOL_STYLE_FILL_UPWARD_DIAGONAL; |
|
599 |
} else if (filltype.equals(SymbolUtils.FILL_TYPE_FDIAG)) { |
|
600 |
style = FConstant.SYMBOL_STYLE_FILL_DOWNWARD_DIAGONAL; |
|
601 |
} else if (filltype.equals(SymbolUtils.FILL_TYPE_CROSS)) { |
|
602 |
style = FConstant.SYMBOL_STYLE_FILL_CROSS; |
|
603 |
} else if (filltype.equals(SymbolUtils.FILL_TYPE_DIAGC)) { |
|
604 |
style = FConstant.SYMBOL_STYLE_FILL_CROSS_DIAGONAL; |
|
605 |
} else if (filltype.equals(SymbolUtils.FILL_TYPE_HORIZ)) { |
|
606 |
style = FConstant.SYMBOL_STYLE_FILL_HORIZONTAL; |
|
607 |
} else if (filltype.equals(SymbolUtils.FILL_TYPE_VERT)) { |
|
608 |
style = FConstant.SYMBOL_STYLE_FILL_VERTICAL; |
|
609 |
} else if (filltype.equals(SymbolUtils.FILL_TYPE_GRAYFILL)) { |
|
610 |
style = FConstant.SYMBOL_STYLE_FILL_GRAYFILL; |
|
611 |
} else if (filltype.equals(SymbolUtils.FILL_TYPE_LIGHTGRAYFILL)) { |
|
612 |
style = FConstant.SYMBOL_STYLE_FILL_LIGHTGRAYFILL; |
|
613 |
} else if (filltype.equals(SymbolUtils.FILL_TYPE_DARKGRAYFILL)) { |
|
614 |
style = FConstant.SYMBOL_STYLE_FILL_DARKGRAYFILL; |
|
615 |
} |
|
616 |
|
|
617 |
return style; |
|
618 |
} |
|
619 |
|
|
620 |
/** |
|
621 |
* @see com.iver.cit.gvsig.fmap.core.v02.FSymbolFactory |
|
622 |
* @param cRef |
|
623 |
* @param bi |
|
624 |
* @return |
|
625 |
*/ |
|
626 |
static private Graphics2D createG2(Color cRef, BufferedImage bi) { |
|
627 |
Graphics2D big = bi.createGraphics(); |
|
628 |
Color color = new Color(0, 0, 0, 0); |
|
629 |
big.setBackground(color); |
|
630 |
big.clearRect(0, 0, w, h); |
|
631 |
big.setColor(new Color(cRef.getRed(), cRef.getGreen(), cRef.getBlue(), |
|
632 |
cRef.getAlpha())); |
|
633 |
big.setStroke(new BasicStroke()); |
|
634 |
|
|
635 |
return big; |
|
636 |
} |
|
637 |
|
|
638 |
/** |
|
639 |
* @see com.iver.cit.gvsig.fmap.core.v02.FSymbolFactory |
|
640 |
* @param style |
|
641 |
* @param cRef |
|
642 |
* @return |
|
643 |
*/ |
|
644 |
private static Paint createPatternFill(int style, Color cRef) { |
|
645 |
w = 7; |
|
646 |
h = 7; |
|
647 |
|
|
648 |
BufferedImage bi = null; |
|
649 |
Graphics2D big = null; |
|
650 |
|
|
651 |
Rectangle2D rProv = new Rectangle(); |
|
652 |
rProv.setFrame(0, 0, w, h); |
|
653 |
|
|
654 |
Paint resulPatternFill = null; |
|
655 |
bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); |
|
656 |
big = createG2(cRef, bi); |
|
657 |
|
|
658 |
switch (style) { |
|
659 |
case FConstant.SYMBOL_STYLE_FILL_SOLID: |
|
660 |
return null; |
|
661 |
|
|
662 |
case FConstant.SYMBOL_STYLE_FILL_TRANSPARENT: |
|
663 |
return null; |
|
664 |
|
|
665 |
case FConstant.SYMBOL_STYLE_FILL_UPWARD_DIAGONAL: |
|
666 |
big.drawLine(0, 0, w, h); |
|
667 |
|
|
668 |
break; |
|
669 |
|
|
670 |
case FConstant.SYMBOL_STYLE_FILL_CROSS: |
|
671 |
big.drawLine(w / 2, 0, w / 2, h); |
|
672 |
big.drawLine(0, h / 2, w, h / 2); |
|
673 |
|
|
674 |
break; |
|
675 |
|
|
676 |
case FConstant.SYMBOL_STYLE_FILL_CROSS_DIAGONAL: |
|
677 |
big.drawLine(0, 0, w, h); |
|
678 |
big.drawLine(0, h, w, 0); |
|
679 |
|
|
680 |
break; |
|
681 |
|
|
682 |
case FConstant.SYMBOL_STYLE_FILL_VERTICAL: |
|
683 |
big.drawLine(w / 2, 0, w / 2, h); |
|
684 |
|
|
685 |
break; |
|
686 |
|
|
687 |
case FConstant.SYMBOL_STYLE_FILL_HORIZONTAL: |
|
688 |
big.drawLine(0, h / 2, w, h / 2); |
|
689 |
|
|
690 |
break; |
|
691 |
|
|
692 |
case FConstant.SYMBOL_STYLE_FILL_DOWNWARD_DIAGONAL: |
|
693 |
big.drawLine(0, h, w, 0); |
|
694 |
|
|
695 |
break; |
|
696 |
} |
|
697 |
|
|
698 |
resulPatternFill = new TexturePaint(bi, rProv); |
|
699 |
|
|
700 |
return resulPatternFill; |
|
701 |
} |
|
702 |
|
|
703 |
/** |
|
704 |
* Gets the hue of a color and returns the color |
|
705 |
* with 75% of saturation and 50% of brightness |
|
706 |
* @param cRef |
|
707 |
* @return |
|
708 |
*/ |
|
709 |
private static Color getGray(Color cRef) { |
|
710 |
float[] hsbvals = new float[3]; |
|
711 |
Color.RGBtoHSB(cRef.getRed(), cRef.getGreen(), cRef.getBlue(), hsbvals); |
|
712 |
|
|
713 |
return new Color(Color.HSBtoRGB(hsbvals[0], 0.75f, 0.5f)); |
|
714 |
} |
|
715 |
|
|
716 |
/** |
|
717 |
* Gets the hue of a color and returns the color |
|
718 |
* with 75% of saturation and 25% of brightness |
|
719 |
* @param cRef |
Also available in: Unified diff