Revision 18877
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/avl2sld/AVL2SLD.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig.fmap.rendering.avl2sld; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.FileWriter; |
|
5 |
|
|
6 |
import org.deegree.graphics.sld.StyledLayerDescriptor; |
|
7 |
import org.deegree.xml.Marshallable; |
|
8 |
|
|
9 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
10 |
|
|
11 |
public class AVL2SLD { |
|
12 |
public static File avl2sld(File avlFile,File sldFile,int type) { |
|
13 |
try { |
|
14 |
// avlFile = new File(txtPath.getText()); |
|
15 |
|
|
16 |
|
|
17 |
// int option = 0; |
|
18 |
|
|
19 |
// if (sldFile.exists()) { |
|
20 |
// option = JOptionPane.showConfirmDialog((Component) PluginServices.getMainFrame(), |
|
21 |
// PluginServices.getText(this, |
|
22 |
// "fichero_ya_existe_seguro_desea_guardarlo")); |
|
23 |
// } |
|
24 |
|
|
25 |
// if (option != 0) { |
|
26 |
// return false; |
|
27 |
// } |
|
28 |
|
|
29 |
System.out.println("processing: " + avlFile.getName()); |
|
30 |
|
|
31 |
int pos = avlFile.getAbsolutePath().lastIndexOf('.'); |
|
32 |
String file = avlFile.getAbsolutePath().substring(0, pos); |
|
33 |
AVL2SLD avl2sld=new AVL2SLD(); |
|
34 |
MyAVL2SLD avl = avl2sld.new MyAVL2SLD(file, |
|
35 |
avlFile.getParentFile().getAbsolutePath()); |
|
36 |
avl.setGeometryType(type); |
|
37 |
avl.read(); |
|
38 |
|
|
39 |
StyledLayerDescriptor sld = avl.getStyledLayerDescriptor(); |
|
40 |
|
|
41 |
// String sldText = sldFile.getA(); |
|
42 |
// |
|
43 |
// if (!(sldText.toUpperCase().endsWith(".SLD") || |
|
44 |
// sldText.toUpperCase().endsWith(".XML"))) { |
|
45 |
// sldText = sldText.concat(".sld"); |
|
46 |
// } |
|
47 |
|
|
48 |
FileWriter fos = new FileWriter(sldFile); |
|
49 |
fos.write(((Marshallable) sld).exportAsXML()); |
|
50 |
fos.close(); |
|
51 |
return sldFile; |
|
52 |
} catch (Exception e) { |
|
53 |
// JOptionPane.showMessageDialog((Component) PluginServices.getMainFrame(), |
|
54 |
// PluginServices.getText(this, "tipo_de_shape_incorrecto")); |
|
55 |
// |
|
56 |
// return false; |
|
57 |
} |
|
58 |
return null; |
|
59 |
} |
|
60 |
public class MyAVL2SLD extends org.deegree_impl.tools.shape.AVL2SLD { |
|
61 |
private int type = FShape.POINT; |
|
62 |
|
|
63 |
public MyAVL2SLD(String arg0, String arg1) { |
|
64 |
super(arg0, arg1); |
|
65 |
} |
|
66 |
|
|
67 |
public int getGeometryType() { |
|
68 |
return type; |
|
69 |
} |
|
70 |
|
|
71 |
public void setGeometryType(int type2) { |
|
72 |
type = type2; |
|
73 |
} |
|
74 |
} |
|
75 |
} |
Also available in: Unified diff