Revision 10994 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/SimpleTextSymbol.java
SimpleTextSymbol.java | ||
---|---|---|
5 | 5 |
import java.awt.Graphics2D; |
6 | 6 |
import java.awt.Rectangle; |
7 | 7 |
import java.awt.Shape; |
8 |
import java.awt.font.FontRenderContext; |
|
9 |
import java.awt.font.GlyphVector; |
|
8 | 10 |
import java.awt.geom.AffineTransform; |
9 | 11 |
import java.awt.geom.Point2D; |
10 | 12 |
|
... | ... | |
12 | 14 |
|
13 | 15 |
import org.apache.batik.ext.awt.geom.PathLength; |
14 | 16 |
|
17 |
import sun.reflect.ReflectionFactory.GetReflectionFactoryAction; |
|
18 |
|
|
15 | 19 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
16 | 20 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
21 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
|
22 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
17 | 23 |
import com.iver.cit.gvsig.fmap.core.FShape; |
24 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
18 | 25 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
19 | 26 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
20 | 27 |
import com.iver.utiles.StringUtilities; |
... | ... | |
32 | 39 |
if (!isShapeVisible()) return; |
33 | 40 |
|
34 | 41 |
Point2D p = null; |
42 |
double rot=0; |
|
35 | 43 |
shp.transform(affineTransform); |
36 |
double rot=0; |
|
37 | 44 |
switch (shp.getShapeType()) { |
38 | 45 |
case FShape.POINT: |
39 | 46 |
FPoint2D fp=(FPoint2D) shp; |
... | ... | |
175 | 182 |
this.rotation = rotation; |
176 | 183 |
} |
177 | 184 |
|
178 |
public FShape getTextShape(Graphics2D g, FShape targetSymbolShape ) {
|
|
179 |
// TODO Implement it
|
|
180 |
throw new Error("Not yet implemented!");
|
|
185 |
public FShape getTextWrappingShape(Graphics2D g, AffineTransform affineTransform, FShape targetSymbolShape ) {
|
|
186 |
// assuming FShape is a point with the starting position of the text
|
|
187 |
Font font = getFont();
|
|
181 | 188 |
|
189 |
FontRenderContext frc = g.getFontRenderContext(); |
|
190 |
|
|
191 |
GlyphVector gv = font.createGlyphVector(frc, text); |
|
192 |
FPoint2D p = (FPoint2D) targetSymbolShape; |
|
193 |
p.transform(affineTransform); |
|
194 |
Shape shape = gv.getOutline((float) p.getX(), (float) p.getY()); |
|
195 |
|
|
196 |
FShape myFShape = new FPolygon2D(new GeneralPathX(shape.getBounds2D())); |
|
197 |
if (rotation != 0) { |
|
198 |
myFShape.transform(AffineTransform.getRotateInstance(rotation, p.getX(), p.getY())); |
|
199 |
} |
|
200 |
return myFShape; |
|
182 | 201 |
} |
183 | 202 |
|
184 | 203 |
} |
Also available in: Unified diff