Revision 9524 branches/piloto3d/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/v02/FSymbol.java

View differences:

FSymbol.java
53 53
import java.awt.Image;
54 54
import java.awt.Paint;
55 55
import java.awt.Rectangle;
56
import java.awt.Shape;
56 57
import java.awt.Stroke;
58
import java.awt.geom.AffineTransform;
57 59
import java.awt.image.BufferedImage;
58 60
import java.awt.image.ImageObserver;
59 61
import java.net.MalformedURLException;
60 62
import java.net.URI;
61 63
import java.net.URISyntaxException;
62 64
import java.util.StringTokenizer;
65

  
66
import javax.print.attribute.PrintRequestAttributeSet;
67
import javax.print.attribute.standard.PrintQuality;
63 68
import javax.swing.ImageIcon;
64 69

  
65 70
import com.iver.cit.gvsig.fmap.core.FShape;
71
import com.iver.cit.gvsig.fmap.core.IGeometry;
66 72
import com.iver.cit.gvsig.fmap.core.ISLDCompatible;
73
import com.iver.cit.gvsig.fmap.core.ISymbol;
67 74
import com.iver.cit.gvsig.fmap.core.SLDTags;
68 75
import com.iver.cit.gvsig.fmap.core.SLDUtils;
69 76
import com.iver.cit.gvsig.fmap.rendering.XmlBuilder;
......
77 84
 *
78 85
 * @author Vicente Caballero Navarro
79 86
 */
80
public class FSymbol implements ISLDCompatible{
87
public class FSymbol implements ISymbol, ISLDCompatible{
81 88
	private static BufferedImage img = new BufferedImage(1, 1,
82 89
			BufferedImage.TYPE_INT_ARGB);
83 90
	private static Rectangle rect = new Rectangle(0, 0, 1, 1);
......
124 131
	private String m_Descrip;
125 132
	public Color m_BackColor;
126 133
	public Paint m_BackFill;
134
	private PrintRequestAttributeSet properties;
135
	private int resolutionPrinting=300;
127 136

  
128 137
    /**
129 138
     * Converts the comma-delimited string into a List of trimmed strings.
......
206 215
				// setStyle(FConstant.SYMBOL_STYLE_MARKER_SQUARE);
207 216
				setSize(5); //pixels
208 217
				break;
209
				
218

  
210 219
			case FConstant.SYMBOL_TYPE_TEXT:
211 220
				setStroke(new BasicStroke());
212 221
				setStyle(FConstant.SYMBOL_STYLE_TEXT_NORMAL);
......
364 373
				// setStyle(FConstant.SYMBOL_STYLE_MARKER_SQUARE);
365 374
				setSize(5); //pixels
366 375
				break;
367
				
376

  
368 377
			case FConstant.SYMBOL_TYPE_TEXT:
369 378
				setStroke(new BasicStroke());
370 379
				setStyle(FConstant.SYMBOL_STYLE_TEXT_NORMAL);
......
393 402
	 *
394 403
	 * @return rgb del s?mbolo.
395 404
	 */
396
	public int getRgb() {
405
	public int getOnePointRgb() {
397 406
		return rgb;
398 407
	}
399 408

  
......
1079 1088
				xmlBuilder.openTag(SLDTags.POINTSYMBOLIZER);
1080 1089
				xmlBuilder.openTag(SLDTags.GRAPHIC);
1081 1090
				xmlBuilder.openTag(SLDTags.MARK);
1082
			
1091

  
1083 1092
				if (this.getStyle() == FConstant.SYMBOL_STYLE_MARKER_CIRCLE ){
1084 1093
					xmlBuilder.writeTag(SLDTags.WELLKNOWNNAME,"circle");
1085 1094
				}else if (this.getStyle() == FConstant.SYMBOL_STYLE_MARKER_SQUARE ){
......
1089 1098
				}else if (this.getStyle() == FConstant.SYMBOL_STYLE_MARKER_CROSS ){
1090 1099
					xmlBuilder.writeTag(SLDTags.WELLKNOWNNAME,"cross");
1091 1100
				}
1092
				
1101

  
1093 1102
				if(this.m_Color != null){
1094 1103
					xmlBuilder.openTag(SLDTags.FILL);
1095 1104
					xmlBuilder.writeTag(SLDTags.CSSPARAMETER,
......
1128 1137
					if (getStroke() != null) {
1129 1138
						xmlBuilder.writeTag(SLDTags.CSSPARAMETER
1130 1139
								,Float.toString(((BasicStroke) getStroke()).getLineWidth())
1131
								,SLDTags.NAME,SLDTags.STROKE_WIDTH_ATTR);						
1140
								,SLDTags.NAME,SLDTags.STROKE_WIDTH_ATTR);
1132 1141
					}
1133 1142
					//TODO: Add to the SLD all the line styles
1134
//					if (this.getStyle() ==  FConstant.SYMBOL_STYLE_LINE_DASH  					
1143
//					if (this.getStyle() ==  FConstant.SYMBOL_STYLE_LINE_DASH
1135 1144
//				    <CssParameter name="stroke">#FFFF00</CssParameter>
1136 1145
//				    <CssParameter name="stroke-opacity">1.0</CssParameter>
1137 1146
//				    <CssParameter name="stroke-width">6.0</CssParameter>
1138 1147
//				    <CssParameter name="stroke-dasharray">1</CssParameter>
1139
					
1148

  
1140 1149
					xmlBuilder.closeTag();
1141 1150
				}
1142 1151
				xmlBuilder.closeTag();
......
1164 1173
								,SLDTags.NAME,SLDTags.STROKE_WIDTH_ATTR);
1165 1174
					}
1166 1175
					xmlBuilder.closeTag();
1167
				}				
1176
				}
1168 1177
//				TODO: Fill opacity and other graphic features
1169 1178
				xmlBuilder.closeTag();
1170 1179
				break;
......
1221 1230
		this.imgObserver = imgObserver;
1222 1231
	}
1223 1232

  
1233
	public ISymbol getSymbolForSelection() {
1234
		return FSymbol.getSymbolForSelection(this);
1235
	}
1236

  
1237
	public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp) {
1238
		if (properties==null)
1239
			FGraphicUtilities.DrawShape(g, affineTransform, shp, this);
1240
		else {
1241
			int strokeValue=0;
1242
				BasicStroke stroke=(BasicStroke)this.getStroke();
1243
				if (stroke != null || stroke.getLineWidth()!=0) {
1244
					strokeValue=(int)stroke.getLineWidth();
1245
					double d=strokeValue*resolutionPrinting/72;
1246
					this.setStroke(new BasicStroke((int)d,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
1247
				}
1248
			FGraphicUtilities.DrawShape(g, affineTransform, shp, this);
1249
			this.setStroke(new BasicStroke(strokeValue));
1250

  
1251
		}
1252
	}
1253

  
1254
	/* (non-Javadoc)
1255
	 * @see com.iver.cit.gvsig.fmap.core.ISymbol#getPixExtentPlus(java.awt.Graphics2D, java.awt.geom.AffineTransform, java.awt.Shape)
1256
	 */
1257
	public int getPixExtentPlus(Graphics2D g, AffineTransform affineTransform, Shape shp) {
1258
		// TODO Auto-generated method stub
1259
		// Por ahora cero, pero habr? que revisar esto.
1260
		return 0;
1261
	}
1262

  
1263
	public boolean isSuitableFor(IGeometry geom) {
1264
		return true;
1265
	}
1266

  
1267
	public void drawInsideRectangle(Graphics2D g2, AffineTransform scaleInstance, Rectangle r) {
1268
		FGraphicUtilities.DrawSymbol(g2, scaleInstance, r, this);
1269
	}
1270

  
1271
	public String getClassName() {
1272
		// TODO Auto-generated method stub
1273
		return null;
1274
	}
1275

  
1276
	public void setXMLEntity(XMLEntity xml) {
1277
		// TODO Auto-generated method stub
1278

  
1279
	}
1280

  
1281
	public void setPrintingProperties(PrintRequestAttributeSet properties) {
1282
		this.properties=properties;
1283
		if (properties!=null){
1284
		PrintQuality resolution=(PrintQuality)properties.get(PrintQuality.class);
1285
			if (resolution.equals(PrintQuality.NORMAL)){
1286
				resolutionPrinting=300;
1287
			}else if (resolution.equals(PrintQuality.HIGH)){
1288
				resolutionPrinting=600;
1289
			}else if (resolution.equals(PrintQuality.DRAFT)){
1290
				resolutionPrinting=72;
1291
			}
1292
		}
1293
	}
1294

  
1224 1295
}

Also available in: Unified diff