Revision 11547 branches/v10/extensions/extAnnotations/src/com/iver/cit/gvsig/fmap/layers/Annotation_Layer.java
Annotation_Layer.java | ||
---|---|---|
1 | 1 |
package com.iver.cit.gvsig.fmap.layers; |
2 | 2 |
|
3 | 3 |
import java.awt.Color; |
4 |
import java.awt.Component; |
|
5 | 4 |
import java.awt.Font; |
6 | 5 |
import java.awt.Graphics2D; |
6 |
import java.awt.Shape; |
|
7 |
import java.awt.font.FontRenderContext; |
|
8 |
import java.awt.font.GlyphVector; |
|
9 |
import java.awt.geom.AffineTransform; |
|
7 | 10 |
import java.awt.geom.Point2D; |
8 | 11 |
import java.awt.geom.Rectangle2D; |
9 | 12 |
import java.awt.image.BufferedImage; |
10 | 13 |
import java.io.IOException; |
11 |
import java.util.ArrayList; |
|
12 | 14 |
|
13 | 15 |
import javax.print.attribute.PrintRequestAttributeSet; |
14 |
import javax.swing.JOptionPane; |
|
15 | 16 |
|
16 | 17 |
import org.cresques.cts.ICoordTrans; |
17 | 18 |
import org.cresques.cts.IProjection; |
18 | 19 |
|
19 | 20 |
import com.hardcode.driverManager.DriverLoadException; |
20 | 21 |
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException; |
21 |
import com.hardcode.gdbms.engine.values.NullValue; |
|
22 |
import com.hardcode.gdbms.engine.values.NumericValue; |
|
23 |
import com.hardcode.gdbms.engine.values.StringValue; |
|
24 | 22 |
import com.hardcode.gdbms.engine.values.Value; |
25 | 23 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
26 |
import com.iver.andami.PluginServices; |
|
27 | 24 |
import com.iver.cit.gvsig.fmap.DriverException; |
28 | 25 |
import com.iver.cit.gvsig.fmap.ViewPort; |
26 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
|
27 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
29 | 28 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
30 | 29 |
import com.iver.cit.gvsig.fmap.core.ISymbol; |
30 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
31 | 31 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
32 |
import com.iver.cit.gvsig.fmap.core.v02.FLabel; |
|
33 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
|
34 | 32 |
import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
35 | 33 |
import com.iver.cit.gvsig.fmap.drivers.BoundedShapes; |
36 |
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
|
37 | 34 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
38 | 35 |
import com.iver.cit.gvsig.fmap.edition.Annotation_EditableAdapter; |
39 | 36 |
import com.iver.cit.gvsig.fmap.edition.EditionEvent; |
... | ... | |
80 | 77 |
*/ |
81 | 78 |
public void setMapping(Annotation_Mapping mapping) { |
82 | 79 |
this.mapping = mapping; |
83 |
aLegend=new Annotation_Legend(this);
|
|
80 |
aLegend=new Annotation_Legend(); |
|
84 | 81 |
// try { |
85 | 82 |
setLegend(); |
86 | 83 |
// createLabels(); |
... | ... | |
813 | 810 |
strategy=null; |
814 | 811 |
System.gc(); |
815 | 812 |
} |
813 |
public IGeometry getTextWrappingGeometry(float height, String description, |
|
814 |
double rotation, int numReg) throws DriverIOException { |
|
815 |
ReadableVectorial adapter = getSource(); |
|
816 |
// adapter.start(); |
|
817 |
ICoordTrans ct = getCoordTrans(); |
|
818 |
IGeometry geom = adapter.getShape(numReg); |
|
819 |
boolean bMustClone = false; |
|
820 |
if (geom == null) { |
|
821 |
return null; |
|
822 |
} |
|
823 |
if (ct != null) { |
|
824 |
if (bMustClone) |
|
825 |
geom = geom.cloneGeometry(); |
|
826 |
geom.reProject(ct); |
|
827 |
} |
|
828 |
// FLabel[] lbls = geom.createLabels(0, true); |
|
829 |
FPoint2D p = ((FPoint2D) geom.getInternalShape()); |
|
830 |
// assuming FShape is a point with the starting position of the text |
|
831 |
// Font font = symbol.getFont(); |
|
832 |
double h = height; |
|
833 |
if (isInPixels()) |
|
834 |
h=getMapContext().getViewPort().toMapDistance( |
|
835 |
(int) (height)); |
|
836 |
// else |
|
837 |
// h=h*FConstant.FONT_HEIGHT_SCALE_FACTOR; |
|
816 | 838 |
|
839 |
Font font = new Font("Arial", 0, |
|
840 |
(int) (h* FConstant.FONT_HEIGHT_SCALE_FACTOR)); |
|
841 |
FontRenderContext frc = new FontRenderContext(new AffineTransform(), |
|
842 |
false, true);// g.getFontRenderContext(); |
|
843 |
GlyphVector gv = font.createGlyphVector(frc, description); |
|
844 |
|
|
845 |
/* p.transform(affineTransform); */ |
|
846 |
Shape shape = gv.getOutline((float) p.getX(), (float) (p.getY() + h)); |
|
847 |
|
|
848 |
IGeometry geomResult = ShapeFactory.createPolygon2D(new GeneralPathX( |
|
849 |
shape.getBounds2D())); |
|
850 |
// IGeometry geomResult2 = ShapeFactory.createPolygon2D(new GeneralPathX( |
|
851 |
// shape.getBounds2D())); |
|
852 |
// geomResult2.transform(layer.getMapContext().getViewPort().getAffineTransform()); |
|
853 |
// Rectangle r = geomResult2.getBounds(); |
|
854 |
if (rotation != 0) { |
|
855 |
geomResult.transform(AffineTransform.getRotateInstance(rotation, p |
|
856 |
.getX(), p.getY())); |
|
857 |
} |
|
858 |
// adapter.stop(); |
|
859 |
// geomResult.transform(layer.getMapContext().getViewPort().getAffineTransform()); |
|
860 |
return geomResult; |
|
861 |
} |
|
817 | 862 |
} |
Also available in: Unified diff