Revision 19091

View differences:

trunk/extensions/extSymbology/src/org/gvsig/symbology/fmap/symbols/SmartTextSymbol.java
102 102

  
103 103
import org.gvsig.symbology.fmap.labeling.ITextParser;
104 104

  
105
import com.hardcode.gdbms.engine.spatial.GeneralPath;
105 106
import com.iver.cit.gvsig.fmap.ViewPort;
107
import com.iver.cit.gvsig.fmap.core.FPolygon2D;
106 108
import com.iver.cit.gvsig.fmap.core.FShape;
109
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
107 110
import com.iver.cit.gvsig.fmap.core.IGeometry;
108 111
import com.iver.cit.gvsig.fmap.core.TextPath;
109 112
import com.iver.cit.gvsig.fmap.core.symbols.IFillSymbol;
......
122 125
 * @author   jaume dominguez faus - jaume.dominguez@iver.es
123 126
 */
124 127
public class SmartTextSymbol extends SimpleTextSymbol implements ITextSymbol {
125
	private static ITextParser parse = new ITextParser() {
126
		public boolean hasTags() {
127
			// TODO Implement it
128
			throw new Error("Not yet implemented!");
129

  
130
		}
131
		public String next() {
132
			// TODO Implement it
133
			throw new Error("Not yet implemented!");
134

  
135
		}
136
	};
137

  
128
	
138 129
	private char[] text;
139 130
//	Background: ITextBackground
140 131
//	Case
......
182 173
	public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp, Cancellable cancel) {
183 174
		if (!isShapeVisible()) return;
184 175
		g.setFont(getFont());
185

  
186
		g.setColor(Color.BLACK);
187
		if (textPath != null) {
188
			//AffineTransform at = (AffineTransform) g.getTransform().clone();
189
			for (int i = 0; (cancel==null || !cancel.isCanceled()) && i < text.length; i++) {
190
				double[] pos = textPath.nextPosForGlyph(i);
191
				g.translate((int) pos[0], (int) pos[1]);
192
				g.rotate(pos[2]);
193
				g.drawChars(new char[] {text[i]}, 0, 1, 0, 0);
194
				g.rotate(-pos[2]);
195
				g.translate(-(int) pos[0], -(int) pos[1]);
196
			}
197
		} else {
198
			super.draw(g, affineTransform, shp, cancel);
199
		}
200 176
	}
201 177

  
202 178
	public void setTextPath(TextPath textPath) {
......
226 202
	}
227 203

  
228 204
	public boolean isSuitableFor(IGeometry geom) {
229
		return true;
205
		return geom.getGeometryType() == FShape.LINE;
230 206
	}
231 207

  
232 208
	public void drawInsideRectangle(Graphics2D g, AffineTransform scaleInstance, Rectangle r) throws SymbolDrawingException {
233
		g.drawString("Not yet implemented", 0, r.height);
209
		// let's take the bottom segment of the rectangle as the line
210
		
211
		GeneralPathX gpx = new GeneralPathX();
212
		gpx.moveTo(r.getX(), r.getY());
213
		gpx.lineTo(r.getX()+r.getWidth(), r.getY());
214
		draw(g, scaleInstance, new FPolygon2D(gpx), null);
234 215
	}
235 216

  
236 217
	public void setPrintingProperties(PrintRequestAttributeSet printProperties) {
trunk/extensions/extSymbology/src/org/gvsig/symbology/fmap/symbols/PictureFillSymbol.java
86 86
	
87 87
	private IMarkerFillPropertiesStyle markerFillProperties = new SimpleMarkerFillPropertiesStyle();
88 88
	private String imagePath;
89
//	private BufferedImage img;
90 89
	private BackgroundFileStyle bgImage;
91 90

  
92 91
	
93
	
94 92
	public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp, Cancellable cancel) {
95 93
		Color fillColor = getFillColor();
96 94
		if (fillColor != null) {
......
99 97
		}
100 98
		
101 99
		g.setClip(shp);
102
//		try{
103
			if (xScale<=0 &&  yScale<=0)
104
				return;
105 100

  
106
//			BufferedImage img = getImg();
107
			BackgroundFileStyle bg =  bgImage ;
101
		if (xScale<=0 &&  yScale<=0)
102
			return;
108 103

  
109
			final double imageWidth  = bg.getBounds().getWidth()  * xScale;
110
			final double imageHeight = bg.getBounds().getWidth() * yScale;
104
		BackgroundFileStyle bg =  bgImage ;
111 105

  
112
			if (imageWidth==0 || imageHeight==0) return;
106
		final double imageWidth  = bg.getBounds().getWidth()  * xScale;
107
		final double imageHeight = bg.getBounds().getWidth() * yScale;
113 108

  
114
			Rectangle rProv = new Rectangle();
115
			rProv.setFrame(0, 0, imageWidth, imageHeight);
116
			Paint resulPatternFill = null;
109
		if (imageWidth==0 || imageHeight==0) return;
117 110

  
118
			Graphics2D gAux;// = img.createGraphics();
111
		Rectangle rProv = new Rectangle();
112
		rProv.setFrame(0, 0, imageWidth, imageHeight);
113
		Paint resulPatternFill = null;
119 114

  
120
			double xSeparation = markerFillProperties.getXSeparation(); 
121
			double ySeparation = markerFillProperties.getYSeparation(); 
122
			double xOffset = markerFillProperties.getXOffset();
123
			double yOffset = markerFillProperties.getYOffset();
115
		Graphics2D gAux;// = img.createGraphics();
124 116

  
125
			rProv.setRect(0, 0,
126
					rProv.getWidth() + xSeparation,
127
					rProv.getHeight() + ySeparation);
117
		double xSeparation = markerFillProperties.getXSeparation(); 
118
		double ySeparation = markerFillProperties.getYSeparation(); 
119
		double xOffset = markerFillProperties.getXOffset();
120
		double yOffset = markerFillProperties.getYOffset();
128 121

  
129
			BufferedImage bi = new BufferedImage(rProv.width, rProv.height, BufferedImage.TYPE_INT_ARGB);
130
			gAux = bi.createGraphics();
131
			AffineTransform tx = AffineTransform.getScaleInstance(xScale, yScale);
132
			tx.translate(xSeparation*0.5, ySeparation*0.5);
133
			tx.rotate(angle, rProv.getWidth(), rProv.getHeight());
134
			gAux.setTransform(tx);
135
			bg.drawInsideRectangle(gAux, rProv);
136
//			gAux.drawImage(img, tx, null);
122
		rProv.setRect(0, 0,
123
				rProv.getWidth() + xSeparation,
124
				rProv.getHeight() + ySeparation);
137 125

  
138
			resulPatternFill = new TexturePaint(bi,rProv);
139
			g.translate(xOffset, yOffset);
140
			g.setPaint(resulPatternFill);
141
			g.fill(shp);
142
			g.translate(-xOffset, -yOffset);
126
		BufferedImage bi = new BufferedImage(rProv.width, rProv.height, BufferedImage.TYPE_INT_ARGB);
127
		gAux = bi.createGraphics();
128
		AffineTransform tx = AffineTransform.getScaleInstance(xScale, yScale);
129
		tx.translate(xSeparation*0.5, ySeparation*0.5);
130
		tx.rotate(angle, rProv.getWidth(), rProv.getHeight());
131
		gAux.setTransform(tx);
132
		bg.drawInsideRectangle(gAux, rProv);
143 133

  
144
//		} catch (IOException e) {
145
//			Logger.getLogger(this.getClass()).error(Messages.getString("failed_to_read_image_file"), e);
146
//		}
134
		resulPatternFill = new TexturePaint(bi,rProv);
135
		g.translate(xOffset, yOffset);
136
		g.setPaint(resulPatternFill);
137
		g.fill(shp);
138
		g.translate(-xOffset, -yOffset);
147 139

  
140

  
148 141
		g.setClip(null);
149 142
		if (getOutline()!=null) {
150 143
			getOutline().draw(g, affineTransform, shp, cancel);
151 144
		}
152 145
	}
146

  
153 147
	/**
154
	 * Gets the path of the picture that is used to fill the polygon
155
	 * @return img,BufferedImage
156
	 * @throws IOException
157
	 */
158
//	private BufferedImage getImg() throws IOException {
159
//		
160
//		if (img == null) {
161
//			if (imagePath == null) 
162
//				throw new IOException("No filename");
163
//				
164
//			img = ImageIO.read(new File(imagePath));
165
//		}
166
//		return img;
167
//	}
168
	/**
169 148
	 * Defines the file from where the picture to fill the polygon is taken.
170 149
	 * @param imageFile
171 150
	 * @throws IOException
trunk/extensions/extSymbology/src/org/gvsig/symbology/fmap/symbols/PictureLineSymbol.java
81 81
//	transient private BufferedImage selImg;
82 82
	transient private PictureLineSymbol selectionSym;
83 83
	private String selImagePath;
84
	private double width, csWidth;
84
	private double width;
85 85
	private String imagePath;
86 86
	private boolean selected;
87 87
	private double xScale = 1, csXScale = xScale;
......
145 145

  
146 146
	public void setLineWidth(double width) {
147 147
		this.width = width;
148
		this.csWidth = width;
148
		getLineStyle().setLineWidth((float) width);
149 149
	}
150 150

  
151 151
	public double getLineWidth() {
......
164 164
	}
165 165
	
166 166
	public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp, Cancellable cancel) {
167
		float csWidth = getLineStyle().getLineWidth();
167 168
		g.setClip(new BasicStroke((float) csWidth, BasicStroke.CAP_ROUND,BasicStroke.CAP_ROUND).createStrokedShape(shp));
168 169
		BackgroundFileStyle bg = (!selected) ? bgImage : bgSelImage ;
169 170

  
......
356 357
	
357 358
	@Override
358 359
	public void setCartographicSize(double cartographicSize, FShape shp) {
359
		csWidth = cartographicSize;
360
		double scale = csWidth/width;
360
		getLineStyle().setLineWidth((float) cartographicSize);
361
		double scale = cartographicSize/width;
361 362
		csXScale = xScale * scale;
362 363
		csYScale = yScale * scale;
363 364
	}
trunk/extensions/extSymbology/src/org/gvsig/symbology/gui/layerproperties/PlacementProperties.java
818 818
			GeneralLabelingStrategy labeling2 = new GeneralLabelingStrategy();
819 819
			DefaultLabelingMethod method = new DefaultLabelingMethod();
820 820
			LabelClass lc = method.getDefaultLabelClass();
821
			lc.setLabelExpression("[TEXT];");
821
			lc.setLabelExpression("[TEXT];");  // <- TODO puede que se decida quitar el punto y coma del evaluador de expresiones
822 822
			lc.getTextSymbol().setFontSize(16);
823 823
			
824 824
			labeling1.setLabelingMethod(method);

Also available in: Unified diff