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

View differences:

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) {

Also available in: Unified diff