58 |
58 |
import java.net.MalformedURLException;
|
59 |
59 |
import java.net.URI;
|
60 |
60 |
import java.net.URISyntaxException;
|
61 |
|
import java.util.ArrayList;
|
62 |
|
import java.util.List;
|
63 |
61 |
import java.util.StringTokenizer;
|
64 |
62 |
|
65 |
63 |
import javax.swing.ImageIcon;
|
66 |
64 |
|
|
65 |
import com.iver.cit.gvsig.fmap.core.FPoint2D;
|
|
66 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D;
|
|
67 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D;
|
67 |
68 |
import com.iver.cit.gvsig.fmap.core.FShape;
|
|
69 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
|
|
70 |
import com.iver.cit.gvsig.fmap.core.ISLDCompatible;
|
|
71 |
import com.iver.cit.gvsig.fmap.core.SLDTags;
|
68 |
72 |
import com.iver.utiles.StringUtilities;
|
69 |
73 |
import com.iver.utiles.XMLEntity;
|
70 |
74 |
|
... | ... | |
75 |
79 |
*
|
76 |
80 |
* @author Vicente Caballero Navarro
|
77 |
81 |
*/
|
78 |
|
public class FSymbol {
|
|
82 |
public class FSymbol implements ISLDCompatible {
|
79 |
83 |
private static BufferedImage img = new BufferedImage(1, 1,
|
80 |
84 |
BufferedImage.TYPE_INT_ARGB);
|
81 |
85 |
private static Rectangle rect = new Rectangle(0, 0, 1, 1);
|
... | ... | |
998 |
1002 |
|
999 |
1003 |
}
|
1000 |
1004 |
|
|
1005 |
//methods to be ISLDCompatible
|
|
1006 |
|
|
1007 |
/**
|
|
1008 |
* converts FSymbol to an SLD
|
|
1009 |
*/
|
|
1010 |
public String toSLD ()
|
|
1011 |
{
|
|
1012 |
StringBuffer sld = new StringBuffer();
|
|
1013 |
try
|
|
1014 |
{
|
|
1015 |
switch (this.getSymbolType())
|
|
1016 |
{
|
|
1017 |
|
|
1018 |
case FConstant.SYMBOL_TYPE_POINT:
|
|
1019 |
// Para no tener que clonarlo si viene en unidades de mapa
|
|
1020 |
boolean bAux2 = this.isSizeInPixels();
|
|
1021 |
int alturaMetros = this.getSize(); // Nota: Cambiar m_Size a float
|
|
1022 |
|
|
1023 |
if (!bAux2) {
|
|
1024 |
this.setSizeInPixels(true);
|
|
1025 |
this.setSize(8); // tama?o fijo
|
|
1026 |
}
|
|
1027 |
if (this.getFont() != null) {
|
|
1028 |
// Para no tener que clonarlo si viene en unidades de mapa
|
|
1029 |
boolean bAux = this.isFontSizeInPixels();
|
|
1030 |
this.setFontSizeInPixels(true);
|
|
1031 |
}
|
|
1032 |
|
|
1033 |
break;
|
|
1034 |
|
|
1035 |
case FConstant.SYMBOL_TYPE_LINE:
|
|
1036 |
sld.append(SLDTags.OT_LINESYMBOLIZER);
|
|
1037 |
// <Geometry>
|
|
1038 |
// <ogc:PropertyName>centerline</ogc:PropertyName>
|
|
1039 |
// </Geometry>
|
|
1040 |
// <Stroke>
|
|
1041 |
// <CssParameter name="stroke">#0000ff</CssParameter>
|
|
1042 |
// <CssParameter name="stroke-width">2</CssParameter>
|
|
1043 |
// </Stroke>
|
|
1044 |
sld.append(SLDTags.CT_LINESYMBOLIZER);
|
|
1045 |
break;
|
|
1046 |
|
|
1047 |
case FConstant.SYMBOL_TYPE_FILL:
|
|
1048 |
//FGraphicUtilities.DrawShape(g2, mT, shp, symbol);
|
|
1049 |
break;
|
|
1050 |
|
|
1051 |
case FShape.MULTI:
|
|
1052 |
//FGraphicUtilities.DrawShape(g2, mT, shp, symbol);
|
|
1053 |
//FGraphicUtilities.DrawShape(g2, mT, shp, symbol);
|
|
1054 |
// Punto:
|
|
1055 |
// Para no tener que clonarlo si viene en unidades de mapa
|
|
1056 |
//bAux2 = symbol.isSizeInPixels();
|
|
1057 |
//alturaMetros = symbol.getSize(); // Nota: Cambiar m_Size a float
|
|
1058 |
// if (!bAux2) {
|
|
1059 |
// this.setSizeInPixels(true);
|
|
1060 |
// this.setSize(4); // tama?o fijo
|
|
1061 |
// }
|
|
1062 |
// FGraphicUtilities.DrawShape(g2, mT, shp, this);
|
|
1063 |
|
|
1064 |
// if (!bAux2) {
|
|
1065 |
// this.setSize(alturaMetros);
|
|
1066 |
// this.setSizeInPixels(bAux2);
|
|
1067 |
// }
|
|
1068 |
|
|
1069 |
if (this.getFont() != null) {
|
|
1070 |
// Para no tener que clonarlo si viene en unidades de mapa
|
|
1071 |
boolean bAux = this.isFontSizeInPixels();
|
|
1072 |
this.setFontSizeInPixels(true);
|
|
1073 |
//FGraphicUtilities.DrawLabel(g2, mT, shp, symbol,new FLabel("Abcd"));
|
|
1074 |
this.setFontSizeInPixels(bAux);
|
|
1075 |
}
|
|
1076 |
|
|
1077 |
break;
|
|
1078 |
}
|
|
1079 |
|
|
1080 |
|
|
1081 |
|
|
1082 |
|
|
1083 |
return sld.toString();
|
|
1084 |
}
|
|
1085 |
catch(Exception e)
|
|
1086 |
{
|
|
1087 |
e.printStackTrace();
|
|
1088 |
return null;
|
|
1089 |
}
|
|
1090 |
}
|
|
1091 |
|
|
1092 |
/**
|
|
1093 |
* creates an FSymbol from an SLD
|
|
1094 |
*
|
|
1095 |
*/
|
|
1096 |
public String fromSLD (String sld)
|
|
1097 |
{
|
|
1098 |
//TODO: This function can be implemented later...
|
|
1099 |
StringBuffer sb = new StringBuffer();
|
|
1100 |
try
|
|
1101 |
{
|
|
1102 |
|
|
1103 |
return sb.toString();
|
|
1104 |
}
|
|
1105 |
catch(Exception e)
|
|
1106 |
{
|
|
1107 |
e.printStackTrace();
|
|
1108 |
return null;
|
|
1109 |
}
|
|
1110 |
}
|
|
1111 |
|
1001 |
1112 |
}
|