Revision 11009
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/legend/gui/LabelingManager.java | ||
---|---|---|
82 | 82 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
83 | 83 |
import com.iver.cit.gvsig.fmap.core.FShape; |
84 | 84 |
import com.iver.cit.gvsig.fmap.core.ILabelable; |
85 |
import com.iver.cit.gvsig.fmap.core.styles.ILabelStyle; |
|
85 | 86 |
import com.iver.cit.gvsig.fmap.core.styles.IStyle; |
86 | 87 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
87 | 88 |
import com.iver.cit.gvsig.fmap.core.symbols.ITextSymbol; |
... | ... | |
880 | 881 |
clazz.getLabelStyle(), |
881 | 882 |
FShape.TEXT ); |
882 | 883 |
PluginServices.getMDIManager().addWindow(stySel); |
883 |
IStyle sty = (IStyle) stySel.getSelectedObject();
|
|
884 |
// if (sty != null)
|
|
885 |
// // gather the symbol and apply to the class
|
|
886 |
// clazz.setSymbol(sty);
|
|
884 |
ILabelStyle sty = (ILabelStyle) stySel.getSelectedObject();
|
|
885 |
if (sty != null) |
|
886 |
// gather the symbol and apply to the class |
|
887 |
clazz.setLabelStyle(sty);
|
|
887 | 888 |
} else if (c.equals(btnPlacement)) { |
888 | 889 |
|
889 | 890 |
try { |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/StyleSelector.java | ||
---|---|---|
185 | 185 |
protected void setStyle(Object selectedValue) { |
186 | 186 |
// TODO missing change SymbolPreviewer by a StylePrevier and apply it |
187 | 187 |
// the new style |
188 |
selectedElement = selectedValue; |
|
188 | 189 |
} |
189 | 190 |
|
190 | 191 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/LabelClass.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.2 2007-03-09 08:33:43 jaume |
|
46 |
* Revision 1.3 2007-04-02 16:34:56 jaume |
|
47 |
* Styled labeling (start commiting) |
|
48 |
* |
|
49 |
* Revision 1.2 2007/03/09 08:33:43 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.1.2.6 2007/02/15 16:23:44 jaume |
... | ... | |
68 | 71 |
*/ |
69 | 72 |
package com.iver.cit.gvsig.fmap.rendering.styling; |
70 | 73 |
|
74 |
import java.awt.Graphics; |
|
75 |
import java.awt.Graphics2D; |
|
76 |
import java.awt.Point; |
|
77 |
import java.awt.Rectangle; |
|
78 |
import java.awt.geom.AffineTransform; |
|
79 |
|
|
80 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
|
81 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
|
82 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
83 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
84 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
85 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
71 | 86 |
import com.iver.cit.gvsig.fmap.core.styles.ILabelStyle; |
72 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
73 | 87 |
import com.iver.cit.gvsig.fmap.core.symbols.ITextSymbol; |
74 | 88 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleTextSymbol; |
75 | 89 |
|
... | ... | |
132 | 146 |
public String toString() { |
133 | 147 |
return name; |
134 | 148 |
} |
149 |
|
|
150 |
public void drawInsideRectangle(Graphics2D graphics, Rectangle bounds, String[] texts) { |
|
151 |
bounds.y = bounds.y - bounds.height; |
|
152 |
if (labelStyle != null) { |
|
153 |
labelStyle.drawInsideRectangle(graphics, bounds); |
|
154 |
for (int i = 0; i < texts.length; i++) { |
|
155 |
getLabelSymbol().setText(texts[i]); |
|
156 |
getLabelSymbol().drawInsideRectangle(graphics, null, labelStyle.getTextBounds()[i]); |
|
157 |
} |
|
158 |
} else { |
|
159 |
getLabelSymbol().setText(texts[0]); |
|
160 |
getLabelSymbol().drawInsideRectangle(graphics, null, bounds); |
|
161 |
} |
|
162 |
} |
|
163 |
|
|
164 |
public FShape getShape(Graphics2D g, /*AffineTransform at,*/ IGeometry geom) { |
|
165 |
if (labelStyle == null) { |
|
166 |
// shape is defined by the symbol |
|
167 |
FShape shp = null; |
|
168 |
|
|
169 |
switch (geom.getGeometryType()) { |
|
170 |
case FShape.POINT: |
|
171 |
shp = new FPoint2D((Point) geom.getInternalShape()); |
|
172 |
break; |
|
173 |
case FShape.LINE: |
|
174 |
shp = new FPolyline2D(new GeneralPathX(geom.getInternalShape())); |
|
175 |
break; |
|
176 |
case FShape.POLYGON: |
|
177 |
shp = new FPolygon2D(new GeneralPathX(geom.getInternalShape())); |
|
178 |
break; |
|
179 |
} |
|
180 |
return getLabelSymbol().getTextWrappingShape(g, shp); |
|
181 |
} else { |
|
182 |
// shape is defined by the style |
|
183 |
// maybe this is incorrect but for the moment we'll go with it |
|
184 |
Rectangle bounds = labelStyle.getBounds(); |
|
185 |
return new FPolygon2D(new GeneralPathX(bounds)); |
|
186 |
} |
|
187 |
} |
|
135 | 188 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/AttrInTableLabeling.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.awt.Color; |
4 | 4 |
import java.awt.Graphics2D; |
5 |
import java.awt.geom.NoninvertibleTransformException; |
|
6 | 5 |
import java.awt.image.BufferedImage; |
7 | 6 |
import java.util.logging.Level; |
8 | 7 |
import java.util.logging.Logger; |
... | ... | |
12 | 11 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
13 | 12 |
import com.hardcode.gdbms.engine.values.NullValue; |
14 | 13 |
import com.hardcode.gdbms.engine.values.NumericValue; |
15 |
import com.hardcode.gdbms.engine.values.StringValue; |
|
16 | 14 |
import com.hardcode.gdbms.engine.values.Value; |
17 | 15 |
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException; |
18 | 16 |
import com.iver.cit.gvsig.exceptions.visitors.VisitorException; |
19 | 17 |
import com.iver.cit.gvsig.fmap.ViewPort; |
20 | 18 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
19 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
21 | 20 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
22 | 21 |
import com.iver.cit.gvsig.fmap.core.symbols.SimpleTextSymbol; |
23 | 22 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
... | ... | |
137 | 136 |
IGeometry geom = source.getShape(i); |
138 | 137 |
sym.setText(vv[idTextField].toString()); |
139 | 138 |
sym.setRotation(rotation); |
140 |
|
|
139 |
|
|
141 | 140 |
FLabel[] aux = geom.createLabels(0, true); |
141 |
g.setColor(Color.GREEN); |
|
142 | 142 |
for (int j = 0; j < aux.length; j++) { |
143 | 143 |
FPoint2D p = new FPoint2D(aux[j].getOrig()); |
144 |
FPoint2D p2 = (FPoint2D)p.cloneFShape(); |
|
145 |
p2.transform(viewPort.getAffineTransform()); |
|
146 |
FShape s = sym.getTextWrappingShape(g, p2); |
|
144 | 147 |
sym.draw(g, viewPort.getAffineTransform(), p); |
148 |
g.draw(s); |
|
149 |
|
|
150 |
|
|
145 | 151 |
} |
146 | 152 |
|
147 | 153 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/PolygonPlacementConstraints.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.2 2007-03-09 08:33:43 jaume |
|
46 |
* Revision 1.3 2007-04-02 16:34:56 jaume |
|
47 |
* Styled labeling (start commiting) |
|
48 |
* |
|
49 |
* Revision 1.2 2007/03/09 08:33:43 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.1.2.1 2007/02/21 07:34:08 jaume |
... | ... | |
61 | 64 |
|
62 | 65 |
public class PolygonPlacementConstraints extends AbstractPlacementConstraints { |
63 | 66 |
|
64 |
public FShape[] getLocationsFor(IGeometry geom, ITextSymbol label, |
|
65 |
MultiPolygon exclusionZone) { |
|
67 |
public FShape[] getLocationsFor(IGeometry geom, FShape labelShape, MultiPolygon exclusionZone) { |
|
66 | 68 |
// TODO Implement it |
67 | 69 |
throw new Error("Not yet implemented!"); |
68 | 70 |
|
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/LinePlacementConstraints.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.2 2007-03-09 08:33:43 jaume |
|
46 |
* Revision 1.3 2007-04-02 16:34:56 jaume |
|
47 |
* Styled labeling (start commiting) |
|
48 |
* |
|
49 |
* Revision 1.2 2007/03/09 08:33:43 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.1.2.1 2007/02/09 07:47:05 jaume |
... | ... | |
60 | 63 |
import com.iver.cit.gvsig.fmap.core.symbols.ITextSymbol; |
61 | 64 |
|
62 | 65 |
public class LinePlacementConstraints extends AbstractPlacementConstraints { |
63 |
|
|
64 |
public FShape[] getLocationsFor(IGeometry geom, ITextSymbol label, MultiPolygon exclusionZone) { |
|
66 |
public FShape[] getLocationsFor(IGeometry geom, FShape labelShape, MultiPolygon exclusionZone) { |
|
65 | 67 |
return new FShape[] { (FShape) geom.getInternalShape() }; |
66 | 68 |
} |
67 | 69 |
|
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/IPlacementConstraints.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.2 2007-03-09 08:33:43 jaume |
|
46 |
* Revision 1.3 2007-04-02 16:34:56 jaume |
|
47 |
* Styled labeling (start commiting) |
|
48 |
* |
|
49 |
* Revision 1.2 2007/03/09 08:33:43 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.1.2.2 2007/02/15 16:23:44 jaume |
... | ... | |
115 | 118 |
* @param MultiPolygon exclusionZone |
116 | 119 |
* @return FShape[], the FShapes where the label will be placed |
117 | 120 |
*/ |
118 |
public abstract FShape[] getLocationsFor(IGeometry geom, ITextSymbol label,
|
|
121 |
public abstract FShape[] getLocationsFor(IGeometry geom, FShape labelShape,
|
|
119 | 122 |
MultiPolygon exclusionZone); |
120 | 123 |
|
121 | 124 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/PointPlacementConstraints.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.2 2007-03-09 08:33:43 jaume |
|
46 |
* Revision 1.3 2007-04-02 16:34:56 jaume |
|
47 |
* Styled labeling (start commiting) |
|
48 |
* |
|
49 |
* Revision 1.2 2007/03/09 08:33:43 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.1.2.1 2007/02/21 07:34:08 jaume |
... | ... | |
53 | 56 |
*/ |
54 | 57 |
package com.iver.cit.gvsig.fmap.rendering.styling; |
55 | 58 |
|
59 |
import java.awt.geom.AffineTransform; |
|
60 |
|
|
56 | 61 |
import org.cresques.px.gml.MultiPolygon; |
57 | 62 |
|
63 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
|
58 | 64 |
import com.iver.cit.gvsig.fmap.core.FShape; |
59 | 65 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
60 |
import com.iver.cit.gvsig.fmap.core.symbols.ITextSymbol; |
|
61 | 66 |
|
62 | 67 |
public class PointPlacementConstraints extends AbstractPlacementConstraints { |
63 | 68 |
|
64 |
public FShape[] getLocationsFor(IGeometry geom, ITextSymbol label,
|
|
65 |
MultiPolygon exclusionZone) {
|
|
66 |
// TODO Implement it
|
|
67 |
throw new Error("Not yet implemented!");
|
|
68 |
|
|
69 |
public FShape[] getLocationsFor(IGeometry geom, FShape labelShape, MultiPolygon exclusionZone) {
|
|
70 |
FPoint2D p = (FPoint2D) geom.getInternalShape();
|
|
71 |
FShape myShape = labelShape.cloneFShape();
|
|
72 |
myShape.transform(AffineTransform.getTranslateInstance(p.getX(), p.getY()));
|
|
73 |
return new FShape[] { myShape }; |
|
69 | 74 |
} |
70 | 75 |
|
71 | 76 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/SimpleLabeling.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.3 2007-03-28 16:48:01 jaume |
|
46 |
* Revision 1.4 2007-04-02 16:34:56 jaume |
|
47 |
* Styled labeling (start commiting) |
|
48 |
* |
|
49 |
* Revision 1.3 2007/03/28 16:48:01 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.2 2007/03/26 14:40:38 jaume |
... | ... | |
163 | 166 |
ReadableVectorial rv = layer.getSource(); |
164 | 167 |
SelectableDataSource sds = rv.getRecordset(); |
165 | 168 |
|
166 |
ITextSymbol sym = lc.getLabelSymbol(); |
|
167 | 169 |
for(i=bs.nextSetBit(0); i>=0 && !cancel.isCanceled(); i=bs.nextSetBit(i+1)) { |
168 | 170 |
IGeometry geom; |
169 | 171 |
Integer index = new Integer(i); |
170 | 172 |
|
171 |
String text = getText(index, sds); |
|
172 |
sym.setText(text); |
|
173 |
String[] texts = getText(index, sds); |
|
174 |
geom = rv.getShape(i); |
|
175 |
FShape labelShape = lc.getShape(g, geom); |
|
176 |
if (labelShape != null) { |
|
177 |
FShape[] places = placementConstraints.getLocationsFor( |
|
178 |
geom, labelShape, |
|
179 |
null); |
|
173 | 180 |
|
174 |
geom = rv.getShape(i); |
|
175 |
FShape[] shp = placementConstraints.getLocationsFor(geom, sym, null); |
|
176 |
AffineTransform at = viewPort.getAffineTransform(); |
|
177 |
for (int j = 0; j < shp.length; j++) { |
|
178 |
sym.draw(g, at, shp[i]); |
|
181 |
for (int j = 0; j < places.length; j++) { |
|
182 |
places[j].transform(viewPort.getAffineTransform()); |
|
183 |
lc.drawInsideRectangle(g, places[j].getBounds(), texts); |
|
184 |
} |
|
179 | 185 |
} |
180 |
|
|
181 | 186 |
} |
182 | 187 |
} catch (ExpansionFileReadException e) { |
183 | 188 |
// TODO Auto-generated catch block |
... | ... | |
189 | 194 |
} |
190 | 195 |
} |
191 | 196 |
|
192 |
private String getText(Integer index, SelectableDataSource sds) throws ReadDriverException { |
|
197 |
private String[] getText(Integer index, SelectableDataSource sds) throws ReadDriverException {
|
|
193 | 198 |
String text = (String) texts.get(index); |
194 | 199 |
if (text == null) { |
195 | 200 |
String expr = method.getDefaultLabelClass().getLabelExpression(); |
... | ... | |
201 | 206 |
text = sds.getFieldValue(index.longValue(), sds.getFieldIndexByName(fieldName)).toString(); |
202 | 207 |
texts.put(index, text); |
203 | 208 |
} |
204 |
return text;
|
|
209 |
return new String[] { text };
|
|
205 | 210 |
} |
206 | 211 |
|
207 | 212 |
private TextPath getTreePath(Integer index, Graphics2D g, FShape shp, char[] text) { |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/styles/SVGStyle.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
1 | 41 |
package com.iver.cit.gvsig.fmap.core.styles; |
2 | 42 |
import java.awt.Graphics2D; |
3 | 43 |
import java.awt.Rectangle; |
... | ... | |
2 | 42 |
import java.awt.RenderingHints; |
43 |
import java.awt.geom.Rectangle2D; |
|
3 | 44 |
import java.io.File; |
... | ... | |
18 | 59 |
|
19 | 60 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
20 | 61 |
import com.iver.utiles.XMLEntity; |
21 |
|
|
62 |
/** |
|
63 |
* |
|
64 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
65 |
* |
|
66 |
*/ |
|
22 | 67 |
public class SVGStyle extends AbstractStyle { |
23 | 68 |
|
24 | 69 |
private GVTBuilder gvtBuilder = new GVTBuilder(); |
... | ... | |
45 | 90 |
ctx = new BridgeContext(userAgent, loader); |
46 | 91 |
renderer.setDoubleBuffered(true); |
47 | 92 |
} |
48 |
|
|
93 |
|
|
49 | 94 |
public void drawInsideRectangle(Graphics2D g, Rectangle r) { |
95 |
long t1, t2; |
|
50 | 96 |
Graphics2D g2 = (Graphics2D) g; |
51 | 97 |
RenderingHints renderingHints = new RenderingHints(defaultRenderingHints); |
52 | 98 |
g2.setRenderingHints(renderingHints); |
... | ... | |
87 | 133 |
renderer.setTree(gvtRoot); |
88 | 134 |
elt = ((SVGDocument)svgDoc).getRootElement(); |
89 | 135 |
} |
136 |
|
|
137 |
protected Rectangle getBounds() { |
|
138 |
Rectangle2D r = gvtRoot.getBounds(); |
|
139 |
return new Rectangle((int) r.getX(), |
|
140 |
(int) r.getY(), |
|
141 |
(int) r.getWidth(), |
|
142 |
(int) r.getHeight()); |
|
143 |
} |
|
144 |
|
|
90 | 145 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/styles/ILabelStyle.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.3 2007-03-29 16:02:01 jaume |
|
46 |
* Revision 1.4 2007-04-02 16:34:56 jaume |
|
47 |
* Styled labeling (start commiting) |
|
48 |
* |
|
49 |
* Revision 1.3 2007/03/29 16:02:01 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.2 2007/03/09 11:20:56 jaume |
... | ... | |
59 | 62 |
*/ |
60 | 63 |
package com.iver.cit.gvsig.fmap.core.styles; |
61 | 64 |
|
62 |
import java.awt.Graphics2D; |
|
63 |
import java.awt.Shape; |
|
64 |
import java.awt.geom.AffineTransform; |
|
65 |
import java.awt.geom.Point2D; |
|
65 |
import java.awt.Rectangle; |
|
66 | 66 |
|
67 | 67 |
/** |
68 | 68 |
* Defines the style that a Label symbol can contain which typically define |
... | ... | |
85 | 85 |
public void setTextFields(String[] texts); |
86 | 86 |
|
87 | 87 |
/** |
88 |
* Document me! |
|
89 |
* @return |
|
88 |
* Returns the text at the i-th field. |
|
89 |
* @param int i. |
|
90 |
* @return String |
|
90 | 91 |
*/ |
91 |
public void drawBackground(Graphics2D g, Shape shp);
|
|
92 |
public String getTextAt(int i);
|
|
92 | 93 |
|
93 | 94 |
/** |
94 |
* Returns an array of points whose length is getFieldCount()-1 or less
|
|
95 |
* with the points where start to draw the text.
|
|
95 |
* Return an array of rectangles defining the text boxes where text is
|
|
96 |
* placed.
|
|
96 | 97 |
* @return |
97 | 98 |
*/ |
98 |
public Point2D[] getTextPositions(AffineTransform at);
|
|
99 |
public Rectangle[] getTextBounds();
|
|
99 | 100 |
|
100 |
/** |
|
101 |
* Returns the text at the i-th field. |
|
102 |
* @param int i. |
|
103 |
* @return String |
|
104 |
*/ |
|
105 |
public String getTextAt(int i); |
|
101 |
public Rectangle getBounds(); |
|
106 | 102 |
|
107 | 103 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/styles/SimpleLabelStyle.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.4 2007-04-02 00:10:04 jaume |
|
46 |
* Revision 1.5 2007-04-02 16:34:56 jaume |
|
47 |
* Styled labeling (start commiting) |
|
48 |
* |
|
49 |
* Revision 1.4 2007/04/02 00:10:04 jaume |
|
47 | 50 |
* *** empty log message *** |
48 | 51 |
* |
49 | 52 |
* Revision 1.3 2007/03/29 16:02:01 jaume |
... | ... | |
64 | 67 |
|
65 | 68 |
import java.awt.Graphics2D; |
66 | 69 |
import java.awt.Rectangle; |
67 |
import java.awt.Shape; |
|
68 |
import java.awt.geom.AffineTransform; |
|
69 |
import java.awt.geom.Point2D; |
|
70 |
import java.awt.geom.Rectangle2D; |
|
70 | 71 |
|
71 | 72 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
72 |
import com.iver.cit.gvsig.fmap.core.symbols.PictureMarkerSymbol; |
|
73 | 73 |
import com.iver.utiles.XMLEntity; |
74 | 74 |
|
75 | 75 |
|
... | ... | |
97 | 97 |
return text; |
98 | 98 |
} |
99 | 99 |
|
100 |
public Point2D[] getTextPositions(AffineTransform at) { |
|
101 |
// TODO Implement it |
|
102 |
throw new Error("Not yet implemented!"); |
|
103 |
} |
|
104 |
|
|
105 | 100 |
public boolean isSuitableFor(ISymbol symbol) { |
106 | 101 |
return true; |
107 |
}
|
|
102 |
} |
|
108 | 103 |
|
109 | 104 |
public String getClassName() { |
110 | 105 |
return getClass().getName(); |
... | ... | |
124 | 119 |
text = xml.getStringProperty("text"); |
125 | 120 |
} |
126 | 121 |
|
127 |
public void drawBackground(Graphics2D g, Shape shp) {
|
|
128 |
// drawInsideRectangle(g, )
|
|
122 |
public Rectangle[] getTextBounds() {
|
|
123 |
return new Rectangle[] {new Rectangle(0,0,300,-60)};
|
|
129 | 124 |
} |
125 |
|
|
126 |
public void drawInsideRectangle(Graphics2D g, Rectangle r) { |
|
127 |
g.translate(r.getX(), r.getY()); |
|
128 |
super.drawInsideRectangle(g, r); |
|
129 |
g.translate(-r.getX(), -r.getY()); |
|
130 |
} |
|
131 |
|
|
132 |
public Rectangle getBounds() { |
|
133 |
return super.getBounds(); |
|
134 |
} |
|
130 | 135 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/ITextSymbol.java | ||
---|---|---|
61 | 61 |
* @param targetSymbolShape |
62 | 62 |
* @return |
63 | 63 |
*/ |
64 |
public abstract FShape getTextWrappingShape(Graphics2D g, AffineTransform affineTransform, FShape targetSymbolShape);
|
|
64 |
public abstract FShape getTextWrappingShape(Graphics2D g, /*AffineTransform affineTransform,*/ FShape targetSymbolShape);
|
|
65 | 65 |
|
66 | 66 |
} |
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/SimpleTextSymbol.java | ||
---|---|---|
59 | 59 |
Geometry geo = FConverter.java2d_to_jts(shp); |
60 | 60 |
|
61 | 61 |
if (geo == null) { |
62 |
return; |
|
62 |
// return;
|
|
63 | 63 |
} |
64 | 64 |
|
65 | 65 |
Point pJTS = geo.getCentroid(); |
... | ... | |
182 | 182 |
this.rotation = rotation; |
183 | 183 |
} |
184 | 184 |
|
185 |
public FShape getTextWrappingShape(Graphics2D g, AffineTransform affineTransform, FShape targetSymbolShape ) { |
|
185 |
/** |
|
186 |
* Returns an FShape which represents a rectangle containing the text in |
|
187 |
* <b>screen</b> units. |
|
188 |
*/ |
|
189 |
public FShape getTextWrappingShape(Graphics2D g, /*AffineTransform affineTransform,*/ FShape targetSymbolShape ) { |
|
186 | 190 |
// assuming FShape is a point with the starting position of the text |
187 | 191 |
Font font = getFont(); |
188 | 192 |
|
189 | 193 |
FontRenderContext frc = g.getFontRenderContext(); |
190 | 194 |
|
191 | 195 |
GlyphVector gv = font.createGlyphVector(frc, text); |
192 |
FPoint2D p = (FPoint2D) targetSymbolShape; |
|
193 |
p.transform(affineTransform); |
|
196 |
Point2D p = null; |
|
197 |
|
|
198 |
switch (targetSymbolShape.getShapeType()) { |
|
199 |
case FShape.POINT: |
|
200 |
FPoint2D fp=(FPoint2D) targetSymbolShape; |
|
201 |
p = new Point2D.Double(fp.getX(),fp.getY()); |
|
202 |
break; |
|
203 |
case FShape.LINE: |
|
204 |
PathLength pathLen = new PathLength(targetSymbolShape); |
|
205 |
|
|
206 |
// if (pathLen.lengthOfPath() < width / mT.getScaleX()) return; |
|
207 |
float midDistance = pathLen.lengthOfPath() / 2; |
|
208 |
p = pathLen.pointAtLength(midDistance); |
|
209 |
break; |
|
210 |
case FShape.POLYGON: |
|
211 |
Geometry geo = FConverter.java2d_to_jts(targetSymbolShape); |
|
212 |
|
|
213 |
if (geo == null) { |
|
214 |
return null; |
|
215 |
} |
|
216 |
|
|
217 |
Point pJTS = geo.getCentroid(); |
|
218 |
|
|
219 |
if (pJTS != null) { |
|
220 |
FShape pLabel = FConverter.jts_to_java2d(pJTS); |
|
221 |
p= new Point2D.Double(((FPoint2D) pLabel).getX(), |
|
222 |
((FPoint2D) pLabel).getY()); |
|
223 |
} |
|
224 |
break; |
|
225 |
} |
|
226 |
|
|
227 |
|
|
228 |
/*p.transform(affineTransform);*/ |
|
194 | 229 |
Shape shape = gv.getOutline((float) p.getX(), (float) p.getY()); |
195 | 230 |
|
196 | 231 |
FShape myFShape = new FPolygon2D(new GeneralPathX(shape.getBounds2D())); |
Also available in: Unified diff