Revision 11743 branches/v10/extensions/extAnnotations/src/com/iver/cit/gvsig/fmap/operation/strategies/Annotation_Strategy.java
Annotation_Strategy.java | ||
---|---|---|
1 |
|
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
|
|
1 | 43 |
package com.iver.cit.gvsig.fmap.operation.strategies; |
2 | 44 |
|
3 | 45 |
import java.awt.Color; |
... | ... | |
43 | 85 |
import com.vividsolutions.jts.geom.Geometry; |
44 | 86 |
import com.vividsolutions.jts.geom.IntersectionMatrix; |
45 | 87 |
|
88 |
|
|
46 | 89 |
/** |
47 | 90 |
* Esta clase se encargar? de dibujar de la forma m?s eficiente los temas de |
48 | 91 |
* anotaciones. |
49 |
*
|
|
92 |
* |
|
50 | 93 |
* @author Vicente Caballero Navarro |
51 | 94 |
*/ |
52 | 95 |
public class Annotation_Strategy extends DefaultStrategy { |
53 |
private FSymbol symbolPoint = new FSymbol(FShape.POINT, Color.black); |
|
96 |
private FSymbol symbolPoint = new FSymbol(FShape.POINT, Color.black); |
|
97 |
private Annotation_Layer capa; |
|
54 | 98 |
|
55 |
private Annotation_Layer capa; |
|
99 |
/** |
|
100 |
* Crea un nuevo AnotationStrategy. |
|
101 |
* |
|
102 |
* @param layer |
|
103 |
*/ |
|
104 |
public Annotation_Strategy(FLayer layer) { |
|
105 |
super(layer); |
|
106 |
capa = (Annotation_Layer) getCapa(); |
|
107 |
symbolPoint.setSize(5); |
|
108 |
} |
|
56 | 109 |
|
57 |
/** |
|
58 |
* Crea un nuevo AnotationStrategy. |
|
59 |
* |
|
60 |
* @param layer |
|
61 |
*/ |
|
62 |
public Annotation_Strategy(FLayer layer) { |
|
63 |
super(layer); |
|
64 |
capa = (Annotation_Layer) getCapa(); |
|
65 |
symbolPoint.setSize(5); |
|
66 |
} |
|
110 |
// /** |
|
111 |
// * @see |
|
112 |
// com.iver.cit.gvsig.fmap.operations.LayerOperations#draw(java.awt.image.BufferedImage, |
|
113 |
// * java.awt.Graphics2D, ISymbol) |
|
114 |
// */ |
|
115 |
// public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
|
116 |
// Cancellable cancel) throws DriverException { |
|
117 |
// Annotation_Legend l = (Annotation_Legend) capa.getLegend(); |
|
118 |
// FSymbol sym = (FSymbol) l.getDefaultSymbol(); |
|
119 |
// |
|
120 |
// Rectangle2D elExtent = viewPort.getAdjustedExtent(); |
|
121 |
// List lstIndexes=null; |
|
122 |
// |
|
123 |
// try { |
|
124 |
// int sc; |
|
125 |
// ReadableVectorial source = capa.getSource(); |
|
126 |
// sc=source.getShapeCount(); |
|
127 |
// |
|
128 |
// SelectableDataSource recordSet = source.getRecordset(); |
|
129 |
// FBitSet bitSet=recordSet.getSelection(); |
|
130 |
// // If area of needed extent is less than fullExtent / 4, |
|
131 |
// // it will be worthy to use SpatialIndex. |
|
132 |
// // Otherwhise, we will not use it. |
|
133 |
// boolean bUseSpatialIndex = false; |
|
134 |
// if(capa.getISpatialIndex() != null) |
|
135 |
// { |
|
136 |
// if(isSpatialIndexNecessary(elExtent)){ |
|
137 |
// lstIndexes = capa.getISpatialIndex().query(elExtent); |
|
138 |
// sc = lstIndexes.size(); |
|
139 |
// System.out.println("LISTA DEL SPATIALINDEX.SIZE = " + sc); |
|
140 |
// bUseSpatialIndex = true; |
|
141 |
// }//if |
|
142 |
// }//if |
|
143 |
// FontMetrics metrics = g.getFontMetrics(); |
|
144 |
// Annotation_Mapping mapping = ((Annotation_Layer) capa) |
|
145 |
// .getMapping(); |
|
146 |
// int idHeightField = mapping.getColumnHeight(); |
|
147 |
// int idFontName = mapping.getColumnTypeFont(); |
|
148 |
// int idFontStyle = mapping.getColumnStyleFont(); |
|
149 |
// int idRotationField = mapping.getColumnRotate(); |
|
150 |
// int idFontColor = mapping.getColumnColor(); |
|
151 |
// int idTextField = mapping.getColumnText(); |
|
152 |
// |
|
153 |
// double rotation = 0D; |
|
154 |
// double size = sym.getFont().getSize(); |
|
155 |
// sym.setFontSizeInPixels(((Annotation_Layer)capa).isInPixels()); |
|
156 |
// String fontName = "Dialog"; |
|
157 |
// int fontStyle = sym.getFont().getStyle(); |
|
158 |
// int fontColor = sym.getFontColor().getRGB(); |
|
159 |
// SpatialCache cache = capa.getSpatialCache(); |
|
160 |
// cache.clearAll(); |
|
161 |
// int numOriginal; |
|
162 |
// for (int numReg = 0; numReg < sc; numReg++) { |
|
163 |
// if (cancel.isCanceled()){ |
|
164 |
// break; |
|
165 |
// } |
|
166 |
// if (bUseSpatialIndex){ |
|
167 |
// Integer idRec = (Integer) lstIndexes.get(numReg); |
|
168 |
// numOriginal = idRec.intValue(); |
|
169 |
// }else{ |
|
170 |
// numOriginal = numReg; |
|
171 |
// } |
|
172 |
// Value[] vv = recordSet.getRow(numOriginal); |
|
173 |
// if (idHeightField != -1) { |
|
174 |
// // text size is defined in the table |
|
175 |
// try { |
|
176 |
// size = ((NumericValue) vv[idHeightField]).doubleValue() |
|
177 |
// * FConstant.FONT_HEIGHT_SCALE_FACTOR; |
|
178 |
// } catch (ClassCastException ccEx) { |
|
179 |
// if (!NullValue.class.equals(vv[idHeightField] |
|
180 |
// .getClass())) { |
|
181 |
// // throw new ReadDriverException("Unknown", ccEx); |
|
182 |
// } |
|
183 |
// // a null value |
|
184 |
// // Logger.getAnonymousLogger(). |
|
185 |
// // warning("Null text height value for text |
|
186 |
// // '"+vv[idTextField].toString()+"'"); |
|
187 |
// continue; |
|
188 |
// } |
|
189 |
// } else { |
|
190 |
// // otherwise will use the size in the symbol |
|
191 |
// |
|
192 |
// } |
|
193 |
// |
|
194 |
// // size = CartographicSupportToolkit. |
|
195 |
// // toScreenUnitYAxis(size, |
|
196 |
// // unit, |
|
197 |
// // viewPort |
|
198 |
// // ); |
|
199 |
// |
|
200 |
// // if (size <= 3) { |
|
201 |
// // // label is too small to be readable, will be skipped |
|
202 |
// // // this speeds up the rendering in wider zooms |
|
203 |
// // continue; |
|
204 |
// // } |
|
205 |
// |
|
206 |
// |
|
207 |
// if (idFontName != -1) { |
|
208 |
// fontName = ((StringValue) vv[idFontName]).toString(); |
|
209 |
// } |
|
210 |
// |
|
211 |
// |
|
212 |
// if (idFontStyle != -1) { |
|
213 |
// fontStyle = ((NumericValue) vv[idFontStyle]).intValue(); |
|
214 |
// } |
|
215 |
// |
|
216 |
// |
|
217 |
// |
|
218 |
// if (idRotationField != -1) { |
|
219 |
// // text rotation is defined in the table |
|
220 |
// rotation = ((NumericValue) vv[idRotationField]) |
|
221 |
// .doubleValue(); |
|
222 |
// } |
|
223 |
// |
|
224 |
// |
|
225 |
// if (idFontColor != -1) { |
|
226 |
// // text rotation is defined in the table |
|
227 |
// fontColor = ((NumericValue) vv[idFontColor]).intValue(); |
|
228 |
// sym.setFontColor(new Color(fontColor)); |
|
229 |
// } |
|
230 |
// |
|
231 |
// if (bitSet.get(numOriginal)){ |
|
232 |
// sym = (FSymbol)sym.getSymbolForSelection(); |
|
233 |
// } |
|
234 |
// IGeometry geom = source.getShape(numOriginal); |
|
235 |
// |
|
236 |
// sym.setFont(new Font(fontName, fontStyle, (int) size)); |
|
237 |
// |
|
238 |
// |
|
239 |
// // sym.setDescription(vv[idTextField].toString()); |
|
240 |
// // sym.setRotation((int) rotation); |
|
241 |
// FLabel[] aux = geom.createLabels(0, true); |
|
242 |
// aux[0].setHeight(size); |
|
243 |
// aux[0].setRotation((int) rotation); |
|
244 |
// aux[0].setString(vv[idTextField].toString()); |
|
245 |
// symbolPoint.draw((Graphics2D)g,viewPort.getAffineTransform(),new |
|
246 |
// FPoint2D(viewPort.fromMapPoint(aux[0].getOrig()))); |
|
247 |
// FGraphicUtilities.DrawAnnotation(g, viewPort |
|
248 |
// .getAffineTransform(), sym, aux[0], metrics, false); |
|
249 |
// } |
|
250 |
// |
|
251 |
// // System.out.println("..................Fin del dibujado |
|
252 |
// .............."); |
|
253 |
// } catch (DriverIOException e) { |
|
254 |
// e.printStackTrace(); |
|
255 |
// } catch (DriverException e) { |
|
256 |
// // TODO Auto-generated catch block |
|
257 |
// e.printStackTrace(); |
|
258 |
// } |
|
259 |
// heightDefault=-1; |
|
260 |
// } |
|
261 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
|
262 |
Cancellable cancel) { |
|
263 |
// Copia draw AttrInTableLabeling |
|
264 |
Annotation_Legend l = (Annotation_Legend) capa.getLegend(); |
|
265 |
FSymbol sym = (FSymbol) l.getDefaultSymbol(); |
|
67 | 266 |
|
68 |
// /** |
|
69 |
// * @see |
|
70 |
// com.iver.cit.gvsig.fmap.operations.LayerOperations#draw(java.awt.image.BufferedImage, |
|
71 |
// * java.awt.Graphics2D, ISymbol) |
|
72 |
// */ |
|
73 |
// public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
|
74 |
// Cancellable cancel) throws DriverException { |
|
75 |
// Annotation_Legend l = (Annotation_Legend) capa.getLegend(); |
|
76 |
// FSymbol sym = (FSymbol) l.getDefaultSymbol(); |
|
77 |
// |
|
78 |
// Rectangle2D elExtent = viewPort.getAdjustedExtent(); |
|
79 |
// List lstIndexes=null; |
|
80 |
// |
|
81 |
// try { |
|
82 |
// int sc; |
|
83 |
// ReadableVectorial source = capa.getSource(); |
|
84 |
// sc=source.getShapeCount(); |
|
85 |
// |
|
86 |
// SelectableDataSource recordSet = source.getRecordset(); |
|
87 |
// FBitSet bitSet=recordSet.getSelection(); |
|
88 |
// // If area of needed extent is less than fullExtent / 4, |
|
89 |
// // it will be worthy to use SpatialIndex. |
|
90 |
// // Otherwhise, we will not use it. |
|
91 |
// boolean bUseSpatialIndex = false; |
|
92 |
// if(capa.getISpatialIndex() != null) |
|
93 |
// { |
|
94 |
// if(isSpatialIndexNecessary(elExtent)){ |
|
95 |
// lstIndexes = capa.getISpatialIndex().query(elExtent); |
|
96 |
// sc = lstIndexes.size(); |
|
97 |
// System.out.println("LISTA DEL SPATIALINDEX.SIZE = " + sc); |
|
98 |
// bUseSpatialIndex = true; |
|
99 |
// }//if |
|
100 |
// }//if |
|
101 |
// FontMetrics metrics = g.getFontMetrics(); |
|
102 |
// Annotation_Mapping mapping = ((Annotation_Layer) capa) |
|
103 |
// .getMapping(); |
|
104 |
// int idHeightField = mapping.getColumnHeight(); |
|
105 |
// int idFontName = mapping.getColumnTypeFont(); |
|
106 |
// int idFontStyle = mapping.getColumnStyleFont(); |
|
107 |
// int idRotationField = mapping.getColumnRotate(); |
|
108 |
// int idFontColor = mapping.getColumnColor(); |
|
109 |
// int idTextField = mapping.getColumnText(); |
|
110 |
// |
|
111 |
// double rotation = 0D; |
|
112 |
// double size = sym.getFont().getSize(); |
|
113 |
// sym.setFontSizeInPixels(((Annotation_Layer)capa).isInPixels()); |
|
114 |
// String fontName = "Dialog"; |
|
115 |
// int fontStyle = sym.getFont().getStyle(); |
|
116 |
// int fontColor = sym.getFontColor().getRGB(); |
|
117 |
// SpatialCache cache = capa.getSpatialCache(); |
|
118 |
// cache.clearAll(); |
|
119 |
// int numOriginal; |
|
120 |
// for (int numReg = 0; numReg < sc; numReg++) { |
|
121 |
// if (cancel.isCanceled()){ |
|
122 |
// break; |
|
123 |
// } |
|
124 |
// if (bUseSpatialIndex){ |
|
125 |
// Integer idRec = (Integer) lstIndexes.get(numReg); |
|
126 |
// numOriginal = idRec.intValue(); |
|
127 |
// }else{ |
|
128 |
// numOriginal = numReg; |
|
129 |
// } |
|
130 |
// Value[] vv = recordSet.getRow(numOriginal); |
|
131 |
// if (idHeightField != -1) { |
|
132 |
// // text size is defined in the table |
|
133 |
// try { |
|
134 |
// size = ((NumericValue) vv[idHeightField]).doubleValue() |
|
135 |
// * FConstant.FONT_HEIGHT_SCALE_FACTOR; |
|
136 |
// } catch (ClassCastException ccEx) { |
|
137 |
// if (!NullValue.class.equals(vv[idHeightField] |
|
138 |
// .getClass())) { |
|
139 |
// // throw new ReadDriverException("Unknown", ccEx); |
|
140 |
// } |
|
141 |
// // a null value |
|
142 |
// // Logger.getAnonymousLogger(). |
|
143 |
// // warning("Null text height value for text |
|
144 |
// // '"+vv[idTextField].toString()+"'"); |
|
145 |
// continue; |
|
146 |
// } |
|
147 |
// } else { |
|
148 |
// // otherwise will use the size in the symbol |
|
149 |
// |
|
150 |
// } |
|
151 |
// |
|
152 |
// // size = CartographicSupportToolkit. |
|
153 |
// // toScreenUnitYAxis(size, |
|
154 |
// // unit, |
|
155 |
// // viewPort |
|
156 |
// // ); |
|
157 |
// |
|
158 |
// // if (size <= 3) { |
|
159 |
// // // label is too small to be readable, will be skipped |
|
160 |
// // // this speeds up the rendering in wider zooms |
|
161 |
// // continue; |
|
162 |
// // } |
|
163 |
// |
|
164 |
// |
|
165 |
// if (idFontName != -1) { |
|
166 |
// fontName = ((StringValue) vv[idFontName]).toString(); |
|
167 |
// } |
|
168 |
// |
|
169 |
// |
|
170 |
// if (idFontStyle != -1) { |
|
171 |
// fontStyle = ((NumericValue) vv[idFontStyle]).intValue(); |
|
172 |
// } |
|
173 |
// |
|
174 |
// |
|
175 |
// |
|
176 |
// if (idRotationField != -1) { |
|
177 |
// // text rotation is defined in the table |
|
178 |
// rotation = ((NumericValue) vv[idRotationField]) |
|
179 |
// .doubleValue(); |
|
180 |
// } |
|
181 |
// |
|
182 |
// |
|
183 |
// if (idFontColor != -1) { |
|
184 |
// // text rotation is defined in the table |
|
185 |
// fontColor = ((NumericValue) vv[idFontColor]).intValue(); |
|
186 |
// sym.setFontColor(new Color(fontColor)); |
|
187 |
// } |
|
188 |
// |
|
189 |
// if (bitSet.get(numOriginal)){ |
|
190 |
// sym = (FSymbol)sym.getSymbolForSelection(); |
|
191 |
// } |
|
192 |
// IGeometry geom = source.getShape(numOriginal); |
|
193 |
// |
|
194 |
// sym.setFont(new Font(fontName, fontStyle, (int) size)); |
|
195 |
// |
|
196 |
// |
|
197 |
// // sym.setDescription(vv[idTextField].toString()); |
|
198 |
// // sym.setRotation((int) rotation); |
|
199 |
// FLabel[] aux = geom.createLabels(0, true); |
|
200 |
// aux[0].setHeight(size); |
|
201 |
// aux[0].setRotation((int) rotation); |
|
202 |
// aux[0].setString(vv[idTextField].toString()); |
|
203 |
// symbolPoint.draw((Graphics2D)g,viewPort.getAffineTransform(),new |
|
204 |
// FPoint2D(viewPort.fromMapPoint(aux[0].getOrig()))); |
|
205 |
// FGraphicUtilities.DrawAnnotation(g, viewPort |
|
206 |
// .getAffineTransform(), sym, aux[0], metrics, false); |
|
207 |
// } |
|
208 |
// |
|
209 |
// // System.out.println("..................Fin del dibujado |
|
210 |
// .............."); |
|
211 |
// } catch (DriverIOException e) { |
|
212 |
// e.printStackTrace(); |
|
213 |
// } catch (DriverException e) { |
|
214 |
// // TODO Auto-generated catch block |
|
215 |
// e.printStackTrace(); |
|
216 |
// } |
|
217 |
// heightDefault=-1; |
|
218 |
// } |
|
267 |
try { |
|
268 |
ReadableVectorial source = capa.getSource(); |
|
219 | 269 |
|
220 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
|
221 |
Cancellable cancel) { |
|
222 |
// Copia draw AttrInTableLabeling |
|
223 |
Annotation_Legend l = (Annotation_Legend) capa.getLegend(); |
|
224 |
FSymbol sym = (FSymbol) l.getDefaultSymbol(); |
|
225 |
try { |
|
226 |
ReadableVectorial source = capa.getSource(); |
|
227 |
// limit the labeling to the visible extent |
|
228 |
FBitSet bs = capa.queryByRect(viewPort.getAdjustedExtent()); |
|
270 |
// limit the labeling to the visible extent |
|
271 |
FBitSet bs = capa.queryByRect(viewPort.getAdjustedExtent()); |
|
229 | 272 |
|
230 |
SelectableDataSource recordSet = source.getRecordset(); |
|
231 |
FBitSet bitSet = recordSet.getSelection(); |
|
232 |
FontMetrics metrics = g.getFontMetrics(); |
|
233 |
Annotation_Mapping mapping = ((Annotation_Layer) capa) |
|
234 |
.getAnnotatonMapping(); |
|
235 |
int idHeightField = mapping.getColumnHeight(); |
|
236 |
int idFontName = mapping.getColumnTypeFont(); |
|
237 |
int idFontStyle = mapping.getColumnStyleFont(); |
|
238 |
int idRotationField = mapping.getColumnRotate(); |
|
239 |
int idFontColor = mapping.getColumnColor(); |
|
240 |
int idTextField = mapping.getColumnText(); |
|
273 |
SelectableDataSource recordSet = source.getRecordset(); |
|
274 |
FBitSet bitSet = recordSet.getSelection(); |
|
275 |
FontMetrics metrics = g.getFontMetrics(); |
|
276 |
Annotation_Mapping mapping = ((Annotation_Layer) capa).getAnnotatonMapping(); |
|
277 |
int idHeightField = mapping.getColumnHeight(); |
|
278 |
int idFontName = mapping.getColumnTypeFont(); |
|
279 |
int idFontStyle = mapping.getColumnStyleFont(); |
|
280 |
int idRotationField = mapping.getColumnRotate(); |
|
281 |
int idFontColor = mapping.getColumnColor(); |
|
282 |
int idTextField = mapping.getColumnText(); |
|
241 | 283 |
|
242 |
double rotation = 0D; |
|
243 |
double size = sym.getFont().getSize(); |
|
244 |
sym.setFontSizeInPixels(((Annotation_Layer) capa).isInPixels()); |
|
245 |
String fontName = "Dialog"; |
|
246 |
int fontStyle = sym.getFont().getStyle(); |
|
247 |
int fontColor = sym.getFontColor().getRGB(); |
|
248 |
for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) { |
|
249 |
if (cancel.isCanceled()) { |
|
250 |
break; |
|
251 |
} |
|
252 |
Value[] vv = recordSet.getRow(i); |
|
253 |
if (idHeightField != -1) { |
|
254 |
// text size is defined in the table |
|
255 |
try { |
|
256 |
size = ((NumericValue) vv[idHeightField]).doubleValue() |
|
257 |
* FConstant.FONT_HEIGHT_SCALE_FACTOR; |
|
258 |
} catch (ClassCastException ccEx) { |
|
259 |
if (!NullValue.class.equals(vv[idHeightField] |
|
260 |
.getClass())) { |
|
261 |
// throw new ReadDriverException("Unknown", ccEx); |
|
262 |
} |
|
263 |
// a null value |
|
264 |
// Logger.getAnonymousLogger(). |
|
265 |
// warning("Null text height value for text |
|
266 |
// '"+vv[idTextField].toString()+"'"); |
|
267 |
continue; |
|
268 |
} |
|
269 |
} else { |
|
270 |
// otherwise will use the size in the symbol |
|
284 |
double rotation = 0D; |
|
285 |
double size = sym.getFont().getSize(); |
|
271 | 286 |
|
272 |
} |
|
287 |
// sym.setFontSizeInPixels(((Annotation_Layer) capa).isInPixels()); |
|
288 |
String fontName = "Dialog"; |
|
289 |
int fontStyle = sym.getFont().getStyle(); |
|
290 |
int fontColor = sym.getFontColor().getRGB(); |
|
273 | 291 |
|
274 |
// size = CartographicSupportToolkit. |
|
275 |
// toScreenUnitYAxis(size, |
|
276 |
// unit, |
|
277 |
// viewPort |
|
278 |
// ); |
|
292 |
for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) { |
|
293 |
if (cancel.isCanceled()) { |
|
294 |
break; |
|
295 |
} |
|
279 | 296 |
|
280 |
// if (size <= 3) { |
|
281 |
// // label is too small to be readable, will be skipped |
|
282 |
// // this speeds up the rendering in wider zooms |
|
283 |
// continue; |
|
284 |
// } |
|
297 |
Value[] vv = recordSet.getRow(i); |
|
285 | 298 |
|
286 |
if (idFontName != -1) { |
|
287 |
fontName = ((StringValue) vv[idFontName]).toString(); |
|
288 |
} |
|
299 |
if (idHeightField != -1) { |
|
300 |
// text size is defined in the table |
|
301 |
try { |
|
302 |
size = ((NumericValue) vv[idHeightField]).doubleValue() * FConstant.FONT_HEIGHT_SCALE_FACTOR; |
|
303 |
} catch (ClassCastException ccEx) { |
|
304 |
if (!NullValue.class.equals( |
|
305 |
vv[idHeightField].getClass())) { |
|
306 |
// throw new ReadDriverException("Unknown", ccEx); |
|
307 |
} |
|
289 | 308 |
|
290 |
if (idFontStyle != -1) { |
|
291 |
fontStyle = ((NumericValue) vv[idFontStyle]).intValue(); |
|
292 |
} |
|
309 |
// a null value |
|
310 |
// Logger.getAnonymousLogger(). |
|
311 |
// warning("Null text height value for text |
|
312 |
// '"+vv[idTextField].toString()+"'"); |
|
313 |
continue; |
|
314 |
} |
|
315 |
} else { |
|
316 |
// otherwise will use the size in the symbol |
|
317 |
} |
|
293 | 318 |
|
294 |
if (idRotationField != -1) { |
|
295 |
// text rotation is defined in the table |
|
296 |
rotation = ((NumericValue) vv[idRotationField]) |
|
297 |
.doubleValue(); |
|
298 |
} |
|
319 |
// size = CartographicSupportToolkit. |
|
320 |
// toScreenUnitYAxis(size, |
|
321 |
// unit, |
|
322 |
// viewPort |
|
323 |
// ); |
|
324 |
// if (size <= 3) { |
|
325 |
// // label is too small to be readable, will be skipped |
|
326 |
// // this speeds up the rendering in wider zooms |
|
327 |
// continue; |
|
328 |
// } |
|
329 |
if (idFontName != -1) { |
|
330 |
fontName = ((StringValue) vv[idFontName]).toString(); |
|
331 |
} |
|
299 | 332 |
|
300 |
if (idFontColor != -1) { |
|
301 |
// text rotation is defined in the table |
|
302 |
fontColor = ((NumericValue) vv[idFontColor]).intValue(); |
|
303 |
sym.setFontColor(new Color(fontColor)); |
|
304 |
} |
|
333 |
if (idFontStyle != -1) { |
|
334 |
fontStyle = ((NumericValue) vv[idFontStyle]).intValue(); |
|
335 |
} |
|
305 | 336 |
|
306 |
if (bitSet.get(i)) {
|
|
307 |
sym = (FSymbol) sym.getSymbolForSelection();
|
|
308 |
}
|
|
309 |
IGeometry geom = source.getShape(i);
|
|
337 |
if (idRotationField != -1) {
|
|
338 |
// text rotation is defined in the table
|
|
339 |
rotation = ((NumericValue) vv[idRotationField]).doubleValue();
|
|
340 |
}
|
|
310 | 341 |
|
311 |
sym.setFont(new Font(fontName, fontStyle, (int) size)); |
|
342 |
if (idFontColor != -1) { |
|
343 |
// text rotation is defined in the table |
|
344 |
fontColor = ((NumericValue) vv[idFontColor]).intValue(); |
|
345 |
sym.setFontColor(new Color(fontColor)); |
|
346 |
} |
|
312 | 347 |
|
313 |
// sym.setDescription(vv[idTextField].toString()); |
|
314 |
// sym.setRotation((int) rotation); |
|
315 |
FLabel[] aux = geom.createLabels(0, true); |
|
316 |
aux[0].setHeight(size); |
|
317 |
aux[0].setRotation((int) rotation); |
|
318 |
aux[0].setString(vv[idTextField].toString()); |
|
319 |
if (sym.isShapeVisible()) { |
|
320 |
symbolPoint.draw((Graphics2D) g, viewPort |
|
321 |
.getAffineTransform(), new FPoint2D(viewPort |
|
322 |
.fromMapPoint(aux[0].getOrig()))); |
|
323 |
} |
|
324 |
FGraphicUtilities.DrawAnnotation(g, viewPort |
|
325 |
.getAffineTransform(), sym, aux[0], metrics, false); |
|
326 |
} |
|
327 |
} catch (Exception e) { |
|
328 |
// Logger.getAnonymousLogger().log(Level.SEVERE, "Could not get the |
|
329 |
// layer extent.\n" + |
|
330 |
// e.getMessage()); |
|
331 |
e.printStackTrace(); |
|
332 |
} |
|
348 |
if (bitSet.get(i)) { |
|
349 |
sym = (FSymbol) sym.getSymbolForSelection(); |
|
350 |
} |
|
333 | 351 |
|
334 |
// }
|
|
335 |
}
|
|
352 |
IGeometry geom = source.getShape(i);
|
|
353 |
sym.setFont(new Font(fontName, fontStyle, (int) size));
|
|
336 | 354 |
|
337 |
// /** |
|
338 |
// * @see |
|
339 |
// com.iver.cit.gvsig.fmap.operations.LayerOperations#draw(java.awt.image.BufferedImage, |
|
340 |
// * java.awt.Graphics2D, ISymbol) |
|
341 |
// */ |
|
342 |
// public void print(BufferedImage image, Graphics2D g, ViewPort viewPort, |
|
343 |
// Cancellable cancel) throws DriverException { |
|
344 |
// |
|
345 |
// // Rectangle2D elExtent = viewPort.getAdjustedExtent(); |
|
346 |
// // graphics=g; |
|
347 |
// // Annotation_Layer lyrAnnotation=(Annotation_Layer)capa; |
|
348 |
// // List lstIndexes=null; |
|
349 |
// // |
|
350 |
// // VectorialLegend l=(VectorialLegend)lyrAnnotation.getLegend(); |
|
351 |
// // FBitSet bitSet=lyrAnnotation.getRecordset().getSelection(); |
|
352 |
// // |
|
353 |
// // boolean inPixels=lyrAnnotation.isInPixels(); |
|
354 |
// // FSymbol theSymbol = (FSymbol) l.getDefaultSymbol(); |
|
355 |
// // theSymbol.setFontSizeInPixels(inPixels); |
|
356 |
// // this.viewPort=viewPort;//capa.getFMap().getViewPort(); |
|
357 |
// // AffineTransform at=viewPort.getAffineTransform(); |
|
358 |
// // try { |
|
359 |
// // int sc; |
|
360 |
// // sc=lyrAnnotation.getSource().getShapeCount(); |
|
361 |
// // // If area of needed extent is less than fullExtent / 4, |
|
362 |
// // // it will be worthy to use SpatialIndex. |
|
363 |
// // // Otherwhise, we will not use it. |
|
364 |
// // boolean bUseSpatialIndex = false; |
|
365 |
// // if(lyrAnnotation.getISpatialIndex() != null) |
|
366 |
// // { |
|
367 |
// // if(isSpatialIndexNecessary(elExtent)){ |
|
368 |
// // lstIndexes = lyrAnnotation.getISpatialIndex().query(elExtent); |
|
369 |
// // sc = lstIndexes.size(); |
|
370 |
// // bUseSpatialIndex = true; |
|
371 |
// // }//if |
|
372 |
// // }//if |
|
373 |
// // |
|
374 |
// // FontMetrics metrics = g.getFontMetrics(); |
|
375 |
// // //SpatialCache cache = lyrAnnotation.createSpatialCache(); |
|
376 |
// // int numOriginal; |
|
377 |
// // for (int numReg = 0; numReg < sc; numReg++) { |
|
378 |
// // if (cancel.isCanceled()){ |
|
379 |
// // break; |
|
380 |
// // } |
|
381 |
// // if (bUseSpatialIndex){ |
|
382 |
// // Integer idRec = (Integer) lstIndexes.get(numReg); |
|
383 |
// // numOriginal = idRec.intValue(); |
|
384 |
// // }else{ |
|
385 |
// // numOriginal = numReg; |
|
386 |
// // } |
|
387 |
// // /* if (lyrAnnotation.getSource() instanceof EditableAdapter) |
|
388 |
// // |
|
389 |
// numOriginal=((EditableAdapter)lyrAnnotation.getSource()).getCalculatedIndex(numOriginal);*/ |
|
390 |
// // |
|
391 |
// // FLabel theLabel = lyrAnnotation.getLabel(numOriginal); |
|
392 |
// // if ((theLabel == null) || (theLabel.getOrig() == null)) |
|
393 |
// // continue; |
|
394 |
// // |
|
395 |
// // |
|
396 |
// // Rectangle2D r=null; |
|
397 |
// // if (inPixels && lyrAnnotation.getMapping().getColumnHeight()==-1) { |
|
398 |
// // |
|
399 |
// r=getDefaultBoundBoxinPixels(metrics,theLabel.getOrig(),theLabel.getString()); |
|
400 |
// // }else { |
|
401 |
// // r=getBoundBox(theLabel.getOrig(),(float)theLabel.getHeight(), |
|
402 |
// theLabel.getJustification(),theLabel.getString()); |
|
403 |
// // } |
|
404 |
// // theLabel.setBoundBox(r); |
|
405 |
// // |
|
406 |
// // if (elExtent.intersects(r)) |
|
407 |
// // { |
|
408 |
// // FPoint2D p=new FPoint2D(viewPort.fromMapPoint(new |
|
409 |
// Point2D.Double(r.getX(),r.getY()))); |
|
410 |
// // FGraphicUtilities.DrawShape(g,at,p,symbolPoint); |
|
411 |
// // if (bitSet.get(numOriginal)) { |
|
412 |
// // FGraphicUtilities.DrawAnnotation(g, at, theSymbol, |
|
413 |
// theLabel,metrics,true); |
|
414 |
// // }else{ |
|
415 |
// // FGraphicUtilities.DrawAnnotation(g, at, theSymbol, |
|
416 |
// theLabel,metrics,false); |
|
417 |
// // } |
|
418 |
// // |
|
419 |
// // |
|
420 |
// // } // XIntersects |
|
421 |
// // |
|
422 |
// // |
|
423 |
// // } |
|
424 |
// // |
|
425 |
// // } catch (DriverIOException e) { |
|
426 |
// // e.printStackTrace(); |
|
427 |
// // } |
|
428 |
// // heightDefault=-1; |
|
429 |
// } |
|
355 |
// sym.setDescription(vv[idTextField].toString()); |
|
356 |
// sym.setRotation((int) rotation); |
|
357 |
FLabel[] aux = geom.createLabels(0, true); |
|
358 |
aux[0].setHeight(size); |
|
359 |
aux[0].setRotation((int) rotation); |
|
360 |
aux[0].setString(vv[idTextField].toString()); |
|
430 | 361 |
|
431 |
// public Rectangle2D getDefaultBoundBoxinPixels(FontMetrics metrics, |
|
432 |
// Point2D p, String s) { |
|
433 |
// int w = metrics.stringWidth(s); |
|
434 |
// double width = viewPort.toMapDistance(w); |
|
435 |
// if (heightDefault == -1) { |
|
436 |
// int h = metrics.getMaxAscent(); |
|
437 |
// heightDefault = viewPort.toMapDistance(h); |
|
438 |
// } |
|
439 |
// return new Rectangle2D.Double(p.getX(), p.getY(), width, heightDefault); |
|
440 |
// |
|
441 |
// } |
|
362 |
if (sym.isShapeVisible()) { |
|
363 |
symbolPoint.draw((Graphics2D) g, |
|
364 |
viewPort.getAffineTransform(), |
|
365 |
new FPoint2D(viewPort.fromMapPoint(aux[0].getOrig()))); |
|
366 |
} |
|
442 | 367 |
|
443 |
/** |
|
444 |
* Construcci?n del rect?ngulo |
|
445 |
* |
|
446 |
* @param p |
|
447 |
* @param g |
|
448 |
* DOCUMENT ME! |
|
449 |
* @param justification |
|
450 |
* DOCUMENT ME! |
|
451 |
* @param vp |
|
452 |
* DOCUMENT ME! |
|
453 |
* |
|
454 |
* @return |
|
455 |
*/ |
|
456 |
// public Rectangle2D getBoundBox(Point2D p, float hp, |
|
457 |
// int justification,String s) { |
|
458 |
// //Rectangle2D bounding=null; |
|
459 |
// if (((Annotation_Layer)capa).isInPixels()){ |
|
460 |
// graphics.setFont(graphics.getFont().deriveFont(hp)); |
|
461 |
// }else{ |
|
462 |
// float alturaPixels = (float) ((hp * |
|
463 |
// viewPort.getAffineTransform().getScaleX())*FConstant.FONT_HEIGHT_SCALE_FACTOR); |
|
464 |
// graphics.setFont(graphics.getFont().deriveFont(alturaPixels)); |
|
465 |
// } |
|
466 |
// FontMetrics metrics = graphics.getFontMetrics(); |
|
467 |
// int w = metrics.stringWidth(s); |
|
468 |
// double width = viewPort.toMapDistance(w); |
|
469 |
// int h = metrics.getMaxAscent(); |
|
470 |
// double height = viewPort.toMapDistance(h); |
|
471 |
// //double dist = viewPort.toMapDistance(3); |
|
472 |
// return new Rectangle2D.Double(p.getX(), p.getY(), width, height); |
|
473 |
// /* switch (justification) { |
|
474 |
// case FLabel.LEFT_BOTTOM: |
|
475 |
// bounding=justification(p, width,height, 0, 0); |
|
476 |
// |
|
477 |
// break; |
|
478 |
// |
|
479 |
// case FLabel.LEFT_CENTER: |
|
480 |
// bounding=justification(p, width,height, 0, -(height / 2)); |
|
481 |
// |
|
482 |
// break; |
|
483 |
// |
|
484 |
// case FLabel.LEFT_TOP: |
|
485 |
// bounding=justification(p,width,height, 0, -height); |
|
486 |
// |
|
487 |
// break; |
|
488 |
// |
|
489 |
// case FLabel.CENTER_BOTTOM: |
|
490 |
// bounding=justification(p, width,height, -(width / 2), -dist); |
|
491 |
// |
|
492 |
// break; |
|
493 |
// |
|
494 |
// case FLabel.CENTER_CENTER: |
|
495 |
// bounding=justification(p, width,height, -(width / 2), -(height / 2)); |
|
496 |
// |
|
497 |
// break; |
|
498 |
// |
|
499 |
// case FLabel.CENTER_TOP: |
|
500 |
// bounding=justification(p, width,height, -(width / 2), -height); |
|
501 |
// |
|
502 |
// break; |
|
503 |
// |
|
504 |
// case FLabel.RIGHT_BOTTOM: |
|
505 |
// bounding=justification(p, width,height, -width, -dist); |
|
506 |
// |
|
507 |
// break; |
|
508 |
// |
|
509 |
// case FLabel.RIGHT_CENTER: |
|
510 |
// bounding=justification(p, width,height, -width, -(height / 2)); |
|
511 |
// |
|
512 |
// break; |
|
513 |
// |
|
514 |
// case FLabel.RIGHT_TOP: |
|
515 |
// bounding=justification(p, width,height, -width, -height); |
|
516 |
// |
|
517 |
// break; |
|
518 |
// } |
|
519 |
// |
|
520 |
// return bounding; |
|
521 |
// */ |
|
522 |
// } |
|
523 |
/* |
|
524 |
* private Rectangle2D justification(Point2D p, double w,double h, double x, |
|
525 |
* double y) { Rectangle2D r=new Rectangle2D.Double(p.getX() + x, p.getY() - |
|
526 |
* y, w, h); return r; } |
|
527 |
*/ |
|
368 |
FGraphicUtilities.DrawAnnotation(g, |
|
369 |
viewPort.getAffineTransform(), sym, aux[0], metrics, false); |
|
370 |
} |
|
371 |
} catch (Exception e) { |
|
372 |
// Logger.getAnonymousLogger().log(Level.SEVERE, "Could not get the |
|
373 |
// layer extent.\n" + |
|
374 |
// e.getMessage()); |
|
375 |
e.printStackTrace(); |
|
376 |
} |
|
528 | 377 |
|
529 |
/* |
|
530 |
* (non-Javadoc) |
|
531 |
* |
|
532 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#queryByShape(com.iver.cit.gvsig.fmap.core.IGeometry, |
|
533 |
* int) |
|
534 |
*/ |
|
535 |
public FBitSet queryByShape(IGeometry g, int relationship) |
|
536 |
throws DriverException, VisitException { |
|
537 |
// Si hay un ?ndice espacial, lo usamos para hacer el query. |
|
538 |
FLyrVect lyr = (FLyrVect) capa; |
|
539 |
// if (lyr.getSpatialIndex() == null) |
|
540 |
if (lyr.getISpatialIndex() == null) |
|
541 |
return super.queryByShape(g, relationship); |
|
378 |
// } |
|
379 |
} |
|
542 | 380 |
|
543 |
long t1 = System.currentTimeMillis(); |
|
544 |
ReadableVectorial va = lyr.getSource(); |
|
545 |
ICoordTrans ct = lyr.getCoordTrans(); |
|
546 |
Rectangle2D bounds = g.getBounds2D(); |
|
547 |
// Coordinate c1 = new Coordinate(bounds.getMinX(), bounds.getMinY()); |
|
548 |
// Coordinate c2 = new Coordinate(bounds.getMaxX(), bounds.getMaxY()); |
|
549 |
// Envelope env = new Envelope(c1, c2); |
|
550 |
// List lstRecs = lyr.getSpatialIndex().query(env); |
|
551 |
List lstRecs = lyr.getISpatialIndex().query(bounds); |
|
552 |
Integer idRec; |
|
553 |
FBitSet bitset = new FBitSet(); |
|
554 |
Geometry jtsShape = g.toJTSGeometry(); |
|
555 |
IntersectionMatrix m; |
|
556 |
int index; |
|
557 |
try { |
|
558 |
va.start(); |
|
559 |
// Annotation_Legend aLegend=(Annotation_Legend)capa.getLegend(); |
|
560 |
for (int i = 0; i < lstRecs.size(); i++) { |
|
561 |
idRec = (Integer) lstRecs.get(i); |
|
562 |
index = idRec.intValue(); |
|
563 |
IGeometry geom = va.getShape(index); |
|
564 |
// FSymbol symbol=(FSymbol)aLegend.getSymbol(index); |
|
565 |
// IGeometry geom=aLegend.getTextWrappingGeometry(symbol,index); |
|
566 |
// IGeometry |
|
567 |
// geom=getGeometry(((Annotation_Layer)capa).getLabel(index).getBoundBox()); |
|
568 |
if (ct != null) { |
|
569 |
geom.reProject(ct); |
|
570 |
} |
|
571 |
Geometry jtsGeom = geom.toJTSGeometry(); |
|
572 |
switch (relationship) { |
|
573 |
case CONTAINS: |
|
574 |
m = jtsShape.relate(jtsGeom); |
|
575 |
if (m.isContains()) { |
|
576 |
bitset.set(index, true); |
|
577 |
} |
|
578 |
break; |
|
381 |
// /** |
|
382 |
// * @see |
|
383 |
// com.iver.cit.gvsig.fmap.operations.LayerOperations#draw(java.awt.image.BufferedImage, |
|
384 |
// * java.awt.Graphics2D, ISymbol) |
|
385 |
// */ |
|
386 |
// public void print(BufferedImage image, Graphics2D g, ViewPort viewPort, |
|
387 |
// Cancellable cancel) throws DriverException { |
|
388 |
// |
|
389 |
// // Rectangle2D elExtent = viewPort.getAdjustedExtent(); |
|
390 |
// // graphics=g; |
|
391 |
// // Annotation_Layer lyrAnnotation=(Annotation_Layer)capa; |
|
392 |
// // List lstIndexes=null; |
|
393 |
// // |
|
394 |
// // VectorialLegend l=(VectorialLegend)lyrAnnotation.getLegend(); |
|
395 |
// // FBitSet bitSet=lyrAnnotation.getRecordset().getSelection(); |
|
396 |
// // |
|
397 |
// // boolean inPixels=lyrAnnotation.isInPixels(); |
|
398 |
// // FSymbol theSymbol = (FSymbol) l.getDefaultSymbol(); |
|
399 |
// // theSymbol.setFontSizeInPixels(inPixels); |
|
400 |
// // this.viewPort=viewPort;//capa.getFMap().getViewPort(); |
|
401 |
// // AffineTransform at=viewPort.getAffineTransform(); |
|
402 |
// // try { |
|
403 |
// // int sc; |
|
404 |
// // sc=lyrAnnotation.getSource().getShapeCount(); |
|
405 |
// // // If area of needed extent is less than fullExtent / 4, |
|
406 |
// // // it will be worthy to use SpatialIndex. |
|
407 |
// // // Otherwhise, we will not use it. |
|
408 |
// // boolean bUseSpatialIndex = false; |
|
409 |
// // if(lyrAnnotation.getISpatialIndex() != null) |
|
410 |
// // { |
|
411 |
// // if(isSpatialIndexNecessary(elExtent)){ |
|
412 |
// // lstIndexes = lyrAnnotation.getISpatialIndex().query(elExtent); |
|
413 |
// // sc = lstIndexes.size(); |
|
414 |
// // bUseSpatialIndex = true; |
|
415 |
// // }//if |
|
416 |
// // }//if |
|
417 |
// // |
|
418 |
// // FontMetrics metrics = g.getFontMetrics(); |
|
419 |
// // //SpatialCache cache = lyrAnnotation.createSpatialCache(); |
|
420 |
// // int numOriginal; |
|
421 |
// // for (int numReg = 0; numReg < sc; numReg++) { |
|
422 |
// // if (cancel.isCanceled()){ |
|
423 |
// // break; |
|
424 |
// // } |
|
425 |
// // if (bUseSpatialIndex){ |
|
426 |
// // Integer idRec = (Integer) lstIndexes.get(numReg); |
|
427 |
// // numOriginal = idRec.intValue(); |
|
428 |
// // }else{ |
|
429 |
// // numOriginal = numReg; |
|
430 |
// // } |
|
431 |
// // /* if (lyrAnnotation.getSource() instanceof EditableAdapter) |
|
432 |
// // |
|
433 |
// numOriginal=((EditableAdapter)lyrAnnotation.getSource()).getCalculatedIndex(numOriginal);*/ |
|
434 |
// // |
|
435 |
// // FLabel theLabel = lyrAnnotation.getLabel(numOriginal); |
|
436 |
// // if ((theLabel == null) || (theLabel.getOrig() == null)) |
|
437 |
// // continue; |
|
438 |
// // |
|
439 |
// // |
|
440 |
// // Rectangle2D r=null; |
|
441 |
// // if (inPixels && lyrAnnotation.getMapping().getColumnHeight()==-1) { |
|
442 |
// // |
|
443 |
// r=getDefaultBoundBoxinPixels(metrics,theLabel.getOrig(),theLabel.getString()); |
|
444 |
// // }else { |
|
445 |
// // r=getBoundBox(theLabel.getOrig(),(float)theLabel.getHeight(), |
|
446 |
// theLabel.getJustification(),theLabel.getString()); |
|
447 |
// // } |
|
448 |
// // theLabel.setBoundBox(r); |
|
449 |
// // |
|
450 |
// // if (elExtent.intersects(r)) |
|
451 |
// // { |
|
452 |
// // FPoint2D p=new FPoint2D(viewPort.fromMapPoint(new |
|
453 |
// Point2D.Double(r.getX(),r.getY()))); |
|
454 |
// // FGraphicUtilities.DrawShape(g,at,p,symbolPoint); |
|
455 |
// // if (bitSet.get(numOriginal)) { |
|
456 |
// // FGraphicUtilities.DrawAnnotation(g, at, theSymbol, |
|
457 |
// theLabel,metrics,true); |
|
458 |
// // }else{ |
|
459 |
// // FGraphicUtilities.DrawAnnotation(g, at, theSymbol, |
|
460 |
// theLabel,metrics,false); |
|
461 |
// // } |
|
462 |
// // |
|
463 |
// // |
|
464 |
// // } // XIntersects |
|
465 |
// // |
|
466 |
// // |
|
467 |
// // } |
|
468 |
// // |
|
469 |
// // } catch (DriverIOException e) { |
|
470 |
// // e.printStackTrace(); |
|
471 |
// // } |
|
472 |
// // heightDefault=-1; |
|
473 |
// } |
|
474 |
// public Rectangle2D getDefaultBoundBoxinPixels(FontMetrics metrics, |
|
475 |
// Point2D p, String s) { |
|
476 |
// int w = metrics.stringWidth(s); |
|
477 |
// double width = viewPort.toMapDistance(w); |
|
478 |
// if (heightDefault == -1) { |
|
479 |
// int h = metrics.getMaxAscent(); |
|
480 |
// heightDefault = viewPort.toMapDistance(h); |
|
481 |
// } |
|
482 |
// return new Rectangle2D.Double(p.getX(), p.getY(), width, heightDefault); |
|
483 |
// |
|
484 |
// } |
|
579 | 485 |
|
580 |
case CROSSES: |
|
581 |
m = jtsShape.relate(jtsGeom); |
|
582 |
if (m.isCrosses(jtsGeom.getDimension(), jtsShape |
|
583 |
.getDimension())) { |
|
584 |
bitset.set(index, true); |
|
585 |
} |
|
586 |
break; |
|
486 |
/** |
|
487 |
* Construcci?n del rect?ngulo |
|
488 |
* |
|
489 |
* @param g DOCUMENT ME! |
|
490 |
* @param relationship |
|
491 |
* |
|
492 |
* @return |
|
493 |
* |
|
494 |
* @throws DriverException DOCUMENT ME! |
|
495 |
* @throws VisitException DOCUMENT ME! |
|
496 |
*/ |
|
587 | 497 |
|
588 |
case DISJOINT: |
|
589 |
// TODO: CREO QUE EL DISJOINT NO SE PUEDE METER AQUI |
|
590 |
m = jtsShape.relate(jtsGeom); |
|
591 |
if (m.isDisjoint()) { |
|
592 |
bitset.set(index, true); |
|
593 |
} |
|
594 |
break; |
|
498 |
// public Rectangle2D getBoundBox(Point2D p, float hp, |
|
499 |
// int justification,String s) { |
|
500 |
// //Rectangle2D bounding=null; |
|
501 |
// if (((Annotation_Layer)capa).isInPixels()){ |
|
502 |
// graphics.setFont(graphics.getFont().deriveFont(hp)); |
|
503 |
// }else{ |
|
504 |
// float alturaPixels = (float) ((hp * |
|
505 |
// viewPort.getAffineTransform().getScaleX())*FConstant.FONT_HEIGHT_SCALE_FACTOR); |
|
506 |
// graphics.setFont(graphics.getFont().deriveFont(alturaPixels)); |
|
507 |
// } |
|
508 |
// FontMetrics metrics = graphics.getFontMetrics(); |
|
509 |
// int w = metrics.stringWidth(s); |
|
510 |
// double width = viewPort.toMapDistance(w); |
|
511 |
// int h = metrics.getMaxAscent(); |
|
512 |
// double height = viewPort.toMapDistance(h); |
|
513 |
// //double dist = viewPort.toMapDistance(3); |
|
514 |
// return new Rectangle2D.Double(p.getX(), p.getY(), width, height); |
|
515 |
// /* switch (justification) { |
|
516 |
// case FLabel.LEFT_BOTTOM: |
|
517 |
// bounding=justification(p, width,height, 0, 0); |
|
518 |
// |
|
519 |
// break; |
|
520 |
// |
|
521 |
// case FLabel.LEFT_CENTER: |
|
522 |
// bounding=justification(p, width,height, 0, -(height / 2)); |
|
523 |
// |
|
524 |
// break; |
|
525 |
// |
|
526 |
// case FLabel.LEFT_TOP: |
|
527 |
// bounding=justification(p,width,height, 0, -height); |
|
528 |
// |
|
529 |
// break; |
|
530 |
// |
|
531 |
// case FLabel.CENTER_BOTTOM: |
|
532 |
// bounding=justification(p, width,height, -(width / 2), -dist); |
|
533 |
// |
|
534 |
// break; |
|
535 |
// |
|
536 |
// case FLabel.CENTER_CENTER: |
|
537 |
// bounding=justification(p, width,height, -(width / 2), -(height / 2)); |
|
538 |
// |
|
539 |
// break; |
|
540 |
// |
|
541 |
// case FLabel.CENTER_TOP: |
|
542 |
// bounding=justification(p, width,height, -(width / 2), -height); |
|
543 |
// |
|
544 |
// break; |
|
545 |
// |
|
546 |
// case FLabel.RIGHT_BOTTOM: |
|
547 |
// bounding=justification(p, width,height, -width, -dist); |
|
548 |
// |
|
549 |
// break; |
|
550 |
// |
|
551 |
// case FLabel.RIGHT_CENTER: |
|
552 |
// bounding=justification(p, width,height, -width, -(height / 2)); |
|
553 |
// |
|
554 |
// break; |
|
555 |
// |
|
556 |
// case FLabel.RIGHT_TOP: |
|
557 |
// bounding=justification(p, width,height, -width, -height); |
|
558 |
// |
|
559 |
// break; |
|
560 |
// } |
|
561 |
// |
|
562 |
// return bounding; |
|
563 |
// */ |
|
564 |
// } |
|
595 | 565 |
|
596 |
case EQUALS: |
|
597 |
m = jtsShape.relate(jtsGeom); |
|
598 |
if (m.isEquals(jtsGeom.getDimension(), jtsShape |
|
599 |
.getDimension())) { |
|
600 |
bitset.set(index, true); |
|
601 |
} |
|
602 |
break; |
|
566 |
/* |
|
567 |
* private Rectangle2D justification(Point2D p, double w,double h, double x, |
|
568 |
* double y) { Rectangle2D r=new Rectangle2D.Double(p.getX() + x, p.getY() - |
|
569 |
* y, w, h); return r; } |
|
570 |
*/ |
|
571 |
/* |
|
572 |
* (non-Javadoc) |
|
573 |
* |
|
574 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#queryByShape(com.iver.cit.gvsig.fmap.core.IGeometry, |
|
575 |
* int) |
|
576 |
*/ |
|
577 |
public FBitSet queryByShape(IGeometry g, int relationship) |
|
578 |
throws DriverException, VisitException { |
|
579 |
// Si hay un ?ndice espacial, lo usamos para hacer el query. |
|
580 |
FLyrVect lyr = (FLyrVect) capa; |
|
603 | 581 |
|
604 |
case INTERSECTS: |
|
605 |
m = jtsShape.relate(jtsGeom); |
|
606 |
if (m.isIntersects()) { |
|
607 |
bitset.set(index, true); |
|
608 |
} |
|
609 |
break; |
|
582 |
// if (lyr.getSpatialIndex() == null) |
|
583 |
if (lyr.getISpatialIndex() == null) { |
|
584 |
return super.queryByShape(g, relationship); |
|
585 |
} |
|
610 | 586 |
|
611 |
case OVERLAPS: |
|
612 |
m = jtsShape.relate(jtsGeom); |
|
613 |
if (m.isOverlaps(jtsGeom.getDimension(), jtsShape |
|
614 |
.getDimension())) { |
|
615 |
bitset.set(index, true); |
|
616 |
} |
|
587 |
long t1 = System.currentTimeMillis(); |
|
588 |
ReadableVectorial va = lyr.getSource(); |
|
589 |
ICoordTrans ct = lyr.getCoordTrans(); |
|
590 |
Rectangle2D bounds = g.getBounds2D(); |
|
617 | 591 |
|
618 |
break; |
|
592 |
// Coordinate c1 = new Coordinate(bounds.getMinX(), bounds.getMinY()); |
|
593 |
// Coordinate c2 = new Coordinate(bounds.getMaxX(), bounds.getMaxY()); |
|
594 |
// Envelope env = new Envelope(c1, c2); |
|
595 |
// List lstRecs = lyr.getSpatialIndex().query(env); |
|
596 |
List lstRecs = lyr.getISpatialIndex().query(bounds); |
|
597 |
Integer idRec; |
|
598 |
FBitSet bitset = new FBitSet(); |
|
599 |
Geometry jtsShape = g.toJTSGeometry(); |
|
600 |
IntersectionMatrix m; |
|
601 |
int index; |
|
619 | 602 |
|
620 |
case TOUCHES: |
|
621 |
m = jtsShape.relate(jtsGeom); |
|
622 |
if (m.isTouches(jtsGeom.getDimension(), jtsShape |
|
623 |
.getDimension())) { |
|
624 |
bitset.set(index, true); |
|
625 |
} |
|
603 |
try { |
|
604 |
va.start(); |
|
626 | 605 |
|
627 |
break; |
|
606 |
// Annotation_Legend aLegend=(Annotation_Legend)capa.getLegend(); |
|
607 |
for (int i = 0; i < lstRecs.size(); i++) { |
|
608 |
idRec = (Integer) lstRecs.get(i); |
|
609 |
index = idRec.intValue(); |
|
628 | 610 |
|
629 |
case WITHIN: |
|
630 |
m = jtsShape.relate(jtsGeom); |
|
631 |
if (m.isWithin()) { |
|
632 |
bitset.set(index, true); |
|
633 |
} |
|
611 |
IGeometry geom = va.getShape(index); |
|
634 | 612 |
|
635 |
break; |
|
636 |
} |
|
637 |
} |
|
638 |
va.stop(); |
|
639 |
} catch (DriverIOException e) { |
|
640 |
// TODO Auto-generated catch block |
|
641 |
e.printStackTrace(); |
|
642 |
} |
|
643 |
long t2 = System.currentTimeMillis(); |
|
644 |
// logger.debug("queryByShape optimizado sobre la capa " + lyr.getName() |
|
645 |
// + ". " + (t2-t1) + " mseg."); |
|
646 |
return bitset; |
|
647 |
} |
|
613 |
// FSymbol symbol=(FSymbol)aLegend.getSymbol(index); |
|
614 |
// IGeometry geom=aLegend.getTextWrappingGeometry(symbol,index); |
|
615 |
// IGeometry |
|
616 |
// geom=getGeometry(((Annotation_Layer)capa).getLabel(index).getBoundBox()); |
|
617 |
if (ct != null) { |
|
618 |
geom.reProject(ct); |
|
619 |
} |
|
648 | 620 |
|
649 |
public FBitSet queryByRect(Rectangle2D rect) throws DriverException { |
|
650 |
// Si hay un ?ndice espacial, lo usamos para hacer el query. |
|
651 |
Annotation_Layer lyr = (Annotation_Layer) capa; |
|
652 |
// if (lyr.getSpatialIndex() == null) |
|
653 |
if (lyr.getISpatialIndex() == null) |
|
654 |
return super.queryByRect(rect); |
|
621 |
Geometry jtsGeom = geom.toJTSGeometry(); |
|
655 | 622 |
|
656 |
ReadableVectorial va = lyr.getSource(); |
|
657 |
ICoordTrans ct = lyr.getCoordTrans(); |
|
658 |
Rectangle2D bounds = rect; |
|
659 |
// Coordinate c1 = new Coordinate(bounds.getMinX(), bounds.getMinY()); |
|
660 |
// Coordinate c2 = new Coordinate(bounds.getMaxX(), bounds.getMaxY()); |
|
661 |
// Envelope env = new Envelope(c1, c2); |
|
662 |
// |
|
663 |
// List lstRecs = lyr.getSpatialIndex().query(env); |
|
664 |
// azabala |
|
665 |
List lstRecs = lyr.getISpatialIndex().query(bounds); |
|
666 |
Integer idRec; |
|
667 |
FBitSet bitset = new FBitSet(); |
|
668 |
int index; |
|
669 |
try { |
|
670 |
va.start(); |
|
671 |
DriverAttributes attr = va.getDriverAttributes(); |
|
672 |
boolean bMustClone = false; |
|
673 |
if (attr != null) { |
|
674 |
if (attr.isLoadedInMemory()) { |
|
675 |
bMustClone = attr.isLoadedInMemory(); |
|
676 |
} |
|
677 |
} |
|
678 |
// Annotation_Legend aLegend=(Annotation_Legend)capa.getLegend(); |
|
679 |
for (int i = 0; i < lstRecs.size(); i++) { |
|
680 |
idRec = (Integer) lstRecs.get(i); |
|
681 |
index = idRec.intValue(); |
|
682 |
// FSymbol symbol=(FSymbol)aLegend.getSymbol(index); |
|
683 |
// IGeometry geom=aLegend.getTextWrappingGeometry(symbol,index); |
|
684 |
Annotation_Mapping mapping = ((Annotation_Layer) capa) |
|
685 |
.getAnnotatonMapping(); |
|
686 |
NumericValue vRotation = (NumericValue) va.getRecordset() |
|
687 |
.getFieldValue(index, mapping.getColumnRotate()); |
|
688 |
NumericValue vHeight = (NumericValue) va.getRecordset() |
|
689 |
.getFieldValue(index, mapping.getColumnHeight()); |
|
690 |
Value vText = va.getRecordset().getFieldValue(index, |
|
691 |
mapping.getColumnText()); |
|
692 |
IGeometry geom = ((Annotation_Layer) capa) |
|
693 |
.getTextWrappingGeometry(vHeight.floatValue(), vText |
|
694 |
.toString(), vRotation.doubleValue(), index); |
|
695 |
// IGeometry geom=va.getShape(index); |
|
696 |
// IGeometry |
|
697 |
// geom=getGeometry(((Annotation_Layer)capa).getLabel(index).getBoundBox()); |
|
698 |
if (ct != null) { |
|
699 |
if (bMustClone) |
|
700 |
geom = geom.cloneGeometry(); |
|
701 |
geom.reProject(ct); |
|
702 |
} |
|
703 |
// System.out.println("Rect?ngulo de selecci?n = "+ rect); |
|
704 |
// System.out.println("Rect?ngulo de la geometr?a = "+ |
|
705 |
// geom.getBounds2D()); |
|
706 |
if (geom.intersects(rect)) { |
|
707 |
bitset.set(index, true); |
|
708 |
} |
|
623 |
switch (relationship) { |
|
624 |
case CONTAINS: |
|
625 |
m = jtsShape.relate(jtsGeom); |
|
709 | 626 |
|
710 |
} |
|
711 |
va.stop(); |
|
712 |
} catch (DriverIOException e) { |
|
713 |
// TODO Auto-generated catch block |
|
714 |
e.printStackTrace(); |
|
715 |
} catch (DriverLoadException e) { |
|
716 |
// TODO Auto-generated catch block |
|
717 |
e.printStackTrace(); |
|
718 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) { |
|
719 |
// TODO Auto-generated catch block |
|
720 |
e.printStackTrace(); |
|
721 |
} |
|
722 |
return bitset; |
|
627 |
if (m.isContains()) { |
|
628 |
bitset.set(index, true); |
|
629 |
} |
|
723 | 630 |
|
724 |
}
|
|
631 |
break;
|
|
725 | 632 |
|
726 |
/* |
|
727 |
* (non-Javadoc) |
|
728 |
* |
|
729 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#queryByPoint(java.awt.geom.Point2D, |
|
730 |
* double) |
|
731 |
*/ |
|
732 |
public FBitSet queryByPoint(Point2D p, double tolerance) |
|
733 |
throws DriverException { |
|
734 |
// TODO: OJO!!!!. Est? implementado como un rectangulo. |
|
735 |
// Lo correcto deber?a ser calculando las distancias reales |
|
736 |
// es decir, con un c?rculo. |
|
737 |
Rectangle2D recPoint = new Rectangle2D.Double(p.getX() |
|
738 |
- (tolerance / 2), p.getY() - (tolerance / 2), tolerance, |
|
739 |
tolerance); |
|
740 |
return queryByRect(recPoint); |
|
741 |
} |
|
633 |
case CROSSES: |
|
634 |
m = jtsShape.relate(jtsGeom); |
|
742 | 635 |
|
743 |
// private IGeometry getGeometry(Rectangle2D r){ |
|
744 |
// GeneralPathX resul = new GeneralPathX(); |
|
745 |
// Point2D[] vs=new Point2D[4]; |
|
746 |
// vs[0]=new Point2D.Double(r.getX(),r.getY()); |
|
747 |
// vs[1]=new Point2D.Double(r.getMaxX(),r.getY()); |
|
748 |
// vs[2]=new Point2D.Double(r.getMaxX(),r.getMaxY()); |
|
749 |
// vs[3]=new Point2D.Double(r.getX(),r.getMaxY()); |
|
750 |
// //vs[4]=new Point2D.Double(r.getX(),r.getY()); |
|
751 |
// for (int i = 0; i < vs.length; i++) { |
|
752 |
// if (i == 0) { |
|
753 |
// resul.moveTo(vs[i].getX(),vs[i].getY()); |
|
754 |
// } else { |
|
755 |
// resul.lineTo(vs[i].getX(),vs[i].getY()); |
|
756 |
// } |
|
757 |
// } |
|
758 |
// resul.closePath(); |
|
759 |
// return ShapeFactory.createPolygon2D(resul); |
|
760 |
// } |
|
761 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
|
762 |
PrintRequestAttributeSet properties) throws DriverException { |
|
763 |
capa.beforePrinting(properties); |
|
764 |
draw(null, g, viewPort, cancel); |
|
765 |
capa.afterPrinting(); |
|
766 |
} |
|
636 |
if (m.isCrosses(jtsGeom.getDimension(), |
|
637 |
jtsShape.getDimension())) { |
|
638 |
bitset.set(index, true); |
|
639 |
} |
|
640 |
|
|
641 |
break; |
|
642 |
|
|
643 |
case DISJOINT: |
|
644 |
|
|
645 |
// TODO: CREO QUE EL DISJOINT NO SE PUEDE METER AQUI |
|
646 |
m = jtsShape.relate(jtsGeom); |
|
647 |
|
|
648 |
if (m.isDisjoint()) { |
|
649 |
bitset.set(index, true); |
|
650 |
} |
|
651 |
|
|
652 |
break; |
|
653 |
|
|
654 |
case EQUALS: |
|
655 |
m = jtsShape.relate(jtsGeom); |
|
656 |
|
|
657 |
if (m.isEquals(jtsGeom.getDimension(), |
|
658 |
jtsShape.getDimension())) { |
|
659 |
bitset.set(index, true); |
|
660 |
} |
|
661 |
|
|
662 |
break; |
|
663 |
|
|
664 |
case INTERSECTS: |
|
665 |
m = jtsShape.relate(jtsGeom); |
|
666 |
|
|
667 |
if (m.isIntersects()) { |
|
668 |
bitset.set(index, true); |
|
669 |
} |
|
670 |
|
|
671 |
break; |
|
672 |
|
|
673 |
case OVERLAPS: |
|
674 |
m = jtsShape.relate(jtsGeom); |
|
675 |
|
|
676 |
if (m.isOverlaps(jtsGeom.getDimension(), |
|
677 |
jtsShape.getDimension())) { |
|
678 |
bitset.set(index, true); |
|
679 |
} |
|
680 |
|
|
681 |
break; |
|
682 |
|
|
683 |
case TOUCHES: |
|
684 |
m = jtsShape.relate(jtsGeom); |
|
685 |
|
|
686 |
if (m.isTouches(jtsGeom.getDimension(), |
|
687 |
jtsShape.getDimension())) { |
|
688 |
bitset.set(index, true); |
|
689 |
} |
|
690 |
|
|
691 |
break; |
|
692 |
|
|
693 |
case WITHIN: |
|
694 |
m = jtsShape.relate(jtsGeom); |
|
695 |
|
|
696 |
if (m.isWithin()) { |
|
697 |
bitset.set(index, true); |
|
698 |
} |
|
699 |
|
|
700 |
break; |
|
701 |
} |
|
702 |
} |
|
703 |
|
|
704 |
va.stop(); |
|
705 |
} catch (DriverIOException e) { |
|
706 |
// TODO Auto-generated catch block |
|
707 |
e.printStackTrace(); |
|
708 |
} |
|
709 |
|
|
710 |
long t2 = System.currentTimeMillis(); |
|
711 |
|
|
712 |
// logger.debug("queryByShape optimizado sobre la capa " + lyr.getName() |
|
713 |
// + ". " + (t2-t1) + " mseg."); |
|
714 |
return bitset; |
|
715 |
} |
|
716 |
|
|
717 |
/** |
|
718 |
* DOCUMENT ME! |
|
719 |
* |
|
720 |
* @param rect DOCUMENT ME! |
|
721 |
* |
|
722 |
* @return DOCUMENT ME! |
|
723 |
* |
|
724 |
* @throws DriverException DOCUMENT ME! |
|
725 |
*/ |
|
726 |
public FBitSet queryByRect(Rectangle2D rect) throws DriverException { |
|
727 |
// Si hay un ?ndice espacial, lo usamos para hacer el query. |
|
728 |
Annotation_Layer lyr = (Annotation_Layer) capa; |
|
729 |
ReadableVectorial va = lyr.getSource(); |
|
730 |
ICoordTrans ct = lyr.getCoordTrans(); |
|
731 |
Rectangle2D bounds = rect; |
|
732 |
// if (lyr.getSpatialIndex() == null) |
|
733 |
if (lyr.getISpatialIndex() == null) { |
|
734 |
return super.queryByRect(rect); |
|
735 |
} |
|
736 |
// Coordinate c1 = new Coordinate(bounds.getMinX(), bounds.getMinY()); |
|
737 |
// Coordinate c2 = new Coordinate(bounds.getMaxX(), bounds.getMaxY()); |
|
738 |
// Envelope env = new Envelope(c1, c2); |
|
739 |
// |
|
740 |
// List lstRecs = lyr.getSpatialIndex().query(env); |
|
741 |
// azabala |
|
742 |
List lstRecs = lyr.getISpatialIndex().query(bounds); |
|
743 |
Integer idRec; |
|
744 |
FBitSet bitset = new FBitSet(); |
|
745 |
int index; |
|
746 |
|
|
747 |
try { |
|
748 |
va.start(); |
|
749 |
|
|
750 |
DriverAttributes attr = va.getDriverAttributes(); |
|
751 |
boolean bMustClone = false; |
|
752 |
|
|
753 |
if (attr != null) { |
|
754 |
if (attr.isLoadedInMemory()) { |
|
755 |
bMustClone = attr.isLoadedInMemory(); |
|
756 |
} |
|
757 |
} |
|
758 |
|
|
759 |
// Annotation_Legend aLegend=(Annotation_Legend)capa.getLegend(); |
|
760 |
for (int i = 0; i < lstRecs.size(); i++) { |
|
761 |
idRec = (Integer) lstRecs.get(i); |
|
762 |
index = idRec.intValue(); |
|
763 |
|
|
764 |
Annotation_Mapping mapping = ((Annotation_Layer) capa).getAnnotatonMapping(); |
|
765 |
NumericValue vRotation = (NumericValue) va.getRecordset() |
|
766 |
.getFieldValue(index, |
|
767 |
mapping.getColumnRotate()); |
|
768 |
NumericValue vHeight = (NumericValue) va.getRecordset() |
|
769 |
.getFieldValue(index, |
|
770 |
mapping.getColumnHeight()); |
|
771 |
Value vText = va.getRecordset().getFieldValue(index, |
|
772 |
mapping.getColumnText()); |
|
773 |
IGeometry geom = ((Annotation_Layer) capa).getTextWrappingGeometry(vHeight.floatValue(), |
|
774 |
vText.toString(), vRotation.doubleValue(), index); |
|
775 |
|
|
776 |
if (ct != null) { |
|
777 |
if (bMustClone) { |
|
778 |
geom = geom.cloneGeometry(); |
|
779 |
} |
|
780 |
|
|
781 |
geom.reProject(ct); |
|
782 |
} |
|
783 |
|
|
784 |
if (geom.intersects(rect)) { |
|
785 |
bitset.set(index, true); |
|
786 |
} |
|
787 |
} |
|
788 |
|
|
789 |
va.stop(); |
|
790 |
} catch (DriverIOException e) { |
|
791 |
// TODO Auto-generated catch block |
|
792 |
e.printStackTrace(); |
|
793 |
} catch (DriverLoadException e) { |
|
794 |
// TODO Auto-generated catch block |
|
795 |
e.printStackTrace(); |
|
796 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) { |
|
797 |
// TODO Auto-generated catch block |
|
798 |
e.printStackTrace(); |
|
799 |
} |
|
800 |
|
|
801 |
return bitset; |
|
802 |
} |
|
803 |
|
|
804 |
/* |
|
805 |
* (non-Javadoc) |
|
806 |
* |
|
807 |
* @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#queryByPoint(java.awt.geom.Point2D, |
|
808 |
* double) |
|
809 |
*/ |
|
810 |
public FBitSet queryByPoint(Point2D p, double tolerance) |
|
811 |
throws DriverException { |
|
812 |
// TODO: OJO!!!!. Est? implementado como un rectangulo. |
|
813 |
// Lo correcto deber?a ser calculando las distancias reales |
|
814 |
// es decir, con un c?rculo. |
|
815 |
Rectangle2D recPoint = new Rectangle2D.Double(p.getX() - |
|
816 |
(tolerance / 2), p.getY() - (tolerance / 2), tolerance, |
|
817 |
tolerance); |
|
818 |
|
|
819 |
return queryByRect(recPoint); |
|
820 |
} |
|
821 |
|
|
822 |
// private IGeometry getGeometry(Rectangle2D r){ |
|
823 |
// GeneralPathX resul = new GeneralPathX(); |
|
824 |
// Point2D[] vs=new Point2D[4]; |
|
825 |
// vs[0]=new Point2D.Double(r.getX(),r.getY()); |
|
826 |
// vs[1]=new Point2D.Double(r.getMaxX(),r.getY()); |
|
827 |
// vs[2]=new Point2D.Double(r.getMaxX(),r.getMaxY()); |
|
828 |
// vs[3]=new Point2D.Double(r.getX(),r.getMaxY()); |
|
829 |
// //vs[4]=new Point2D.Double(r.getX(),r.getY()); |
|
830 |
// for (int i = 0; i < vs.length; i++) { |
|
831 |
// if (i == 0) { |
|
832 |
// resul.moveTo(vs[i].getX(),vs[i].getY()); |
|
833 |
// } else { |
|
834 |
// resul.lineTo(vs[i].getX(),vs[i].getY()); |
|
835 |
// } |
|
836 |
// } |
|
837 |
// resul.closePath(); |
|
838 |
// return ShapeFactory.createPolygon2D(resul); |
|
839 |
// } |
|
840 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
|
841 |
PrintRequestAttributeSet properties) throws DriverException { |
|
842 |
capa.beforePrinting(properties); |
|
843 |
draw(null, g, viewPort, cancel); |
|
844 |
capa.afterPrinting(); |
|
845 |
} |
|
767 | 846 |
} |
Also available in: Unified diff