Revision 12529 branches/v10/extensions/extAnnotations/src/com/iver/cit/gvsig/fmap/operation/strategies/Annotation_Strategy.java
Annotation_Strategy.java | ||
---|---|---|
44 | 44 |
|
45 | 45 |
import java.awt.Color; |
46 | 46 |
import java.awt.Font; |
47 |
import java.awt.FontMetrics; |
|
48 | 47 |
import java.awt.Graphics2D; |
49 | 48 |
import java.awt.geom.AffineTransform; |
50 | 49 |
import java.awt.geom.NoninvertibleTransformException; |
... | ... | |
64 | 63 |
import com.hardcode.gdbms.engine.values.StringValue; |
65 | 64 |
import com.hardcode.gdbms.engine.values.Value; |
66 | 65 |
import com.iver.andami.messages.NotificationManager; |
67 |
import com.iver.cit.gvsig.PrintProperties; |
|
68 | 66 |
import com.iver.cit.gvsig.fmap.DriverException; |
69 | 67 |
import com.iver.cit.gvsig.fmap.ViewPort; |
70 | 68 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
71 | 69 |
import com.iver.cit.gvsig.fmap.core.FShape; |
72 | 70 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
73 | 71 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
74 |
import com.iver.cit.gvsig.fmap.core.v02.FGraphicUtilities; |
|
75 |
import com.iver.cit.gvsig.fmap.core.v02.FLabel; |
|
76 | 72 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
77 | 73 |
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
78 | 74 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
... | ... | |
114 | 110 |
|
115 | 111 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
116 | 112 |
Cancellable cancel) { |
117 |
BufferedImage bi=new BufferedImage(image.getWidth(),image.getHeight(),BufferedImage.TYPE_INT_ARGB); |
|
118 |
Graphics2D gBi=(Graphics2D)bi.getGraphics(); |
|
119 |
Point2D offset=viewPort.getOffset(); |
|
120 |
gBi.translate(-offset.getX(),-offset.getY()); |
|
121 |
Annotation_Legend l = (Annotation_Legend) capa.getLegend(); |
|
122 |
FSymbol sym = (FSymbol) l.getDefaultSymbol(); |
|
113 |
drawAnnotations(image,g,viewPort,cancel,null); |
|
114 |
} |
|
115 |
private void drawAnnotations(BufferedImage image, Graphics2D g, ViewPort viewPort, |
|
116 |
Cancellable cancel,PrintRequestAttributeSet properties) { |
|
117 |
BufferedImage bi=new BufferedImage(image.getWidth(),image.getHeight(),BufferedImage.TYPE_INT_ARGB); |
|
118 |
Graphics2D gBi=(Graphics2D)bi.getGraphics(); |
|
119 |
Point2D offset=viewPort.getOffset(); |
|
120 |
gBi.translate(-offset.getX(),-offset.getY()); |
|
121 |
Annotation_Legend l = (Annotation_Legend) capa.getLegend(); |
|
122 |
FSymbol sym = (FSymbol) l.getDefaultSymbol(); |
|
123 | 123 |
|
124 |
try { |
|
125 |
ReadableVectorial source = capa.getSource(); |
|
126 |
// limit the labeling to the visible extent |
|
127 |
FBitSet bs = capa.queryByRect(viewPort.getAdjustedExtent()); |
|
124 |
try {
|
|
125 |
ReadableVectorial source = capa.getSource();
|
|
126 |
// limit the labeling to the visible extent
|
|
127 |
FBitSet bs = capa.queryByRect(viewPort.getAdjustedExtent());
|
|
128 | 128 |
|
129 |
SelectableDataSource recordSet = source.getRecordset(); |
|
130 |
recordSet.start(); |
|
131 |
FBitSet bitSet = recordSet.getSelection(); |
|
132 |
Annotation_Mapping mapping = ((Annotation_Layer) capa).getAnnotatonMapping(); |
|
133 |
int idHeightField = mapping.getColumnHeight(); |
|
134 |
int idFontName = mapping.getColumnTypeFont(); |
|
135 |
int idFontStyle = mapping.getColumnStyleFont(); |
|
136 |
int idRotationField = mapping.getColumnRotate(); |
|
137 |
int idFontColor = mapping.getColumnColor(); |
|
138 |
int idTextField = mapping.getColumnText(); |
|
129 |
SelectableDataSource recordSet = source.getRecordset();
|
|
130 |
recordSet.start();
|
|
131 |
FBitSet bitSet = recordSet.getSelection();
|
|
132 |
Annotation_Mapping mapping = ((Annotation_Layer) capa).getAnnotatonMapping();
|
|
133 |
int idHeightField = mapping.getColumnHeight();
|
|
134 |
int idFontName = mapping.getColumnTypeFont();
|
|
135 |
int idFontStyle = mapping.getColumnStyleFont();
|
|
136 |
int idRotationField = mapping.getColumnRotate();
|
|
137 |
int idFontColor = mapping.getColumnColor();
|
|
138 |
int idTextField = mapping.getColumnText();
|
|
139 | 139 |
|
140 |
double rotation = 0D; |
|
141 |
float size = sym.getFont().getSize()* (float)FConstant.FONT_HEIGHT_SCALE_FACTOR; |
|
140 |
double rotation = 0D;
|
|
141 |
float size = sym.getFont().getSize()* (float)FConstant.FONT_HEIGHT_SCALE_FACTOR;
|
|
142 | 142 |
|
143 |
String fontName = "Dialog"; |
|
144 |
int fontStyle = sym.getFont().getStyle(); |
|
145 |
int fontColor = sym.getFontColor().getRGB(); |
|
146 |
long t1 = System.currentTimeMillis(); |
|
143 |
String fontName = "Dialog";
|
|
144 |
int fontStyle = sym.getFont().getStyle();
|
|
145 |
int fontColor = sym.getFontColor().getRGB();
|
|
146 |
long t1 = System.currentTimeMillis();
|
|
147 | 147 |
|
148 |
for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) { |
|
149 |
if (cancel.isCanceled()) { |
|
150 |
break; |
|
151 |
} |
|
148 |
for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) {
|
|
149 |
if (cancel.isCanceled()) {
|
|
150 |
break;
|
|
151 |
}
|
|
152 | 152 |
|
153 |
Value[] vv = recordSet.getRow(i); |
|
153 |
Value[] vv = recordSet.getRow(i);
|
|
154 | 154 |
|
155 |
if (idHeightField != -1) { |
|
156 |
// text size is defined in the table |
|
157 |
try { |
|
158 |
size = (float)(((NumericValue) vv[idHeightField]).doubleValue() * FConstant.FONT_HEIGHT_SCALE_FACTOR); |
|
159 |
} catch (ClassCastException ccEx) { |
|
160 |
if (!NullValue.class.equals( |
|
161 |
vv[idHeightField].getClass())) { |
|
162 |
} |
|
163 |
continue; |
|
164 |
} |
|
165 |
} |
|
155 |
if (idHeightField != -1) {
|
|
156 |
// text size is defined in the table
|
|
157 |
try {
|
|
158 |
size = (float)(((NumericValue) vv[idHeightField]).doubleValue() * FConstant.FONT_HEIGHT_SCALE_FACTOR);
|
|
159 |
} catch (ClassCastException ccEx) {
|
|
160 |
if (!NullValue.class.equals(
|
|
161 |
vv[idHeightField].getClass())) {
|
|
162 |
}
|
|
163 |
continue;
|
|
164 |
}
|
|
165 |
}
|
|
166 | 166 |
|
167 |
if (idFontName != -1) { |
|
168 |
fontName = ((StringValue) vv[idFontName]).toString(); |
|
169 |
} |
|
167 |
if (idFontName != -1) {
|
|
168 |
fontName = ((StringValue) vv[idFontName]).toString();
|
|
169 |
}
|
|
170 | 170 |
|
171 |
if (idFontStyle != -1) { |
|
172 |
fontStyle = ((NumericValue) vv[idFontStyle]).intValue(); |
|
173 |
} |
|
171 |
if (idFontStyle != -1) {
|
|
172 |
fontStyle = ((NumericValue) vv[idFontStyle]).intValue();
|
|
173 |
}
|
|
174 | 174 |
|
175 |
if (idRotationField != -1) { |
|
176 |
// text rotation is defined in the table |
|
177 |
rotation = ((NumericValue) vv[idRotationField]).doubleValue(); |
|
178 |
sym.setRotation((int)rotation); |
|
179 |
} |
|
175 |
if (idRotationField != -1) {
|
|
176 |
// text rotation is defined in the table
|
|
177 |
rotation = ((NumericValue) vv[idRotationField]).doubleValue();
|
|
178 |
sym.setRotation((int)rotation);
|
|
179 |
}
|
|
180 | 180 |
|
181 |
if (idFontColor != -1) { |
|
182 |
// text rotation is defined in the table |
|
183 |
fontColor = ((NumericValue) vv[idFontColor]).intValue(); |
|
184 |
sym.setFontColor(new Color(fontColor)); |
|
185 |
} |
|
181 |
if (idFontColor != -1) {
|
|
182 |
// text rotation is defined in the table
|
|
183 |
fontColor = ((NumericValue) vv[idFontColor]).intValue();
|
|
184 |
sym.setFontColor(new Color(fontColor));
|
|
185 |
}
|
|
186 | 186 |
|
187 |
if (bitSet.get(i)) { |
|
188 |
sym = (FSymbol) sym.getSymbolForSelection(); |
|
189 |
} |
|
187 |
if (bitSet.get(i)) {
|
|
188 |
sym = (FSymbol) sym.getSymbolForSelection();
|
|
189 |
}
|
|
190 | 190 |
|
191 |
sym.setFont(new Font(fontName, fontStyle, (int) size)); |
|
191 |
sym.setFont(new Font(fontName, fontStyle, (int) size)); |
|
192 |
source.start(); |
|
193 |
IGeometry geom = source.getShape(i); |
|
194 |
source.stop(); |
|
195 |
geom.transform(viewPort.getAffineTransform()); |
|
196 |
FPoint2D fpPixels=(FPoint2D)geom.getInternalShape();//new FPoint2D(rPixels.getX(),rPixels.getY()); |
|
197 |
//Si el tama?o de la fuente est? en unidades de mapa. |
|
198 |
if (!sym.isFontSizeInPixels()){ |
|
199 |
boolean draw=false; |
|
200 |
Rectangle2D r=capa.getTextWrappingGeometryInPixels(size,vv[idTextField].toString(),rotation,fontName, fontStyle,i,viewPort,geom).getBounds2D(); |
|
201 |
Rectangle2D rPixels=new Rectangle2D.Double(r.getX(),r.getY()+r.getHeight(),r.getWidth(),r.getHeight()); |
|
192 | 202 |
|
193 |
//Si el tama?o de la fuente est? en unidades de mapa. |
|
194 |
if (!sym.isFontSizeInPixels()){ |
|
195 |
boolean draw=false; |
|
196 |
Rectangle2D r=capa.getTextWrappingGeometryInPixels(size,vv[idTextField].toString(),rotation,fontName, fontStyle,i,viewPort).getBounds2D(); |
|
197 |
Rectangle2D rPixels=new Rectangle2D.Double(r.getX(),r.getY()+r.getHeight(),r.getWidth(),r.getHeight()); |
|
198 |
Point2D p=new Point2D.Double(rPixels.getX(),rPixels.getY()); |
|
199 |
FPoint2D fpPixels=new FPoint2D(rPixels.getX(),rPixels.getY()); |
|
203 |
Point2D p=new Point2D.Double(fpPixels.getX(),fpPixels.getY()); |
|
200 | 204 |
|
201 |
if (!capa.isEditing() && l.isAvoidOverLapping()){ |
|
202 |
p=getPoint(bi,rPixels,l.isDelOverLapping()); |
|
203 |
if (p!=null) |
|
204 |
draw=true; |
|
205 |
}else{ |
|
206 |
if (!capa.isEditing() && l.isDelOverLapping()){ |
|
207 |
if (isOverlapping(bi,rPixels)){ |
|
208 |
draw=true; |
|
209 |
} |
|
210 |
}else{ |
|
211 |
draw=true; |
|
212 |
} |
|
213 |
} |
|
214 |
if (draw){ |
|
215 |
if (sym.isShapeVisible()) { |
|
216 |
symbolPoint.draw(gBi, |
|
217 |
ati, |
|
218 |
fpPixels); |
|
219 |
} |
|
220 |
// g.drawRect((int)rPixels.getX(),(int)rPixels.getY(),(int)rPixels.getWidth(),(int)rPixels.getHeight()); |
|
221 |
// FGraphicUtilities.DrawAnnotation(gBi, |
|
222 |
// ati, sym, aux[0], metrics, false); |
|
223 |
DrawAnnotation(gBi,sym, p, vv[idTextField].toString(),viewPort,null);
|
|
224 |
} |
|
225 |
}else{ |
|
205 |
if (!capa.isEditing() && l.isAvoidOverLapping()){
|
|
206 |
p=getPoint(bi,rPixels,l.isDelOverLapping());
|
|
207 |
if (p!=null)
|
|
208 |
draw=true;
|
|
209 |
}else{
|
|
210 |
if (!capa.isEditing() && l.isDelOverLapping()){
|
|
211 |
if (isOverlapping(bi,rPixels)){
|
|
212 |
draw=true;
|
|
213 |
}
|
|
214 |
}else{
|
|
215 |
draw=true;
|
|
216 |
}
|
|
217 |
}
|
|
218 |
if (draw){
|
|
219 |
if (sym.isShapeVisible()) {
|
|
220 |
symbolPoint.draw(gBi,
|
|
221 |
ati,
|
|
222 |
fpPixels);
|
|
223 |
}
|
|
224 |
// g.drawRect((int)rPixels.getX(),(int)rPixels.getY(),(int)rPixels.getWidth(),(int)rPixels.getHeight());
|
|
225 |
// FGraphicUtilities.DrawAnnotation(gBi,
|
|
226 |
// ati, sym, aux[0], metrics, false);
|
|
227 |
DrawAnnotation(gBi,sym, p, vv[idTextField].toString(),viewPort,properties);
|
|
228 |
}
|
|
229 |
}else{
|
|
226 | 230 |
|
227 |
// Si el tama?o de la fuente est? en pixels. |
|
228 |
boolean draw=false; |
|
229 |
Rectangle2D r=capa.getTextWrappingGeometryInPixels(size,vv[idTextField].toString(),rotation,fontName,fontStyle,i,viewPort).getBounds2D(); |
|
231 |
// Si el tama?o de la fuente est? en pixels. |
|
232 |
boolean draw=false; |
|
233 |
Rectangle2D r=capa.getTextWrappingGeometryInPixels(size,vv[idTextField].toString(),rotation,fontName,fontStyle,i,viewPort,geom).getBounds2D(); |
|
234 |
// g.draw(capa.getTextWrappingGeometryInPixels(size,vv[idTextField].toString(),rotation,fontName,fontStyle,i,viewPort,geom)); |
|
235 |
Rectangle2D rPixels= new Rectangle2D.Double(r.getX(),r.getY()+r.getHeight(),r.getWidth(),r.getHeight()); |
|
230 | 236 |
|
231 |
Rectangle2D rPixels= new Rectangle2D.Double(r.getX(),r.getY()+r.getHeight(),r.getWidth(),r.getHeight()); |
|
232 |
FPoint2D fp=new FPoint2D(rPixels.getX(),rPixels.getY()); |
|
233 |
Point2D p=new Point2D.Double(rPixels.getX(),rPixels.getY()); |
|
237 |
Point2D pSearch = new Point2D.Double(fpPixels.getX(),fpPixels.getY()); |
|
234 | 238 |
|
235 |
if (!capa.isEditing() && l.isAvoidOverLapping()){ |
|
236 |
p=getPoint(bi,rPixels,l.isDelOverLapping()); |
|
237 |
if (p!=null){ |
|
238 |
draw=true; |
|
239 |
} |
|
240 |
}else{ |
|
241 |
if (!capa.isEditing() && l.isDelOverLapping()){ |
|
242 |
if (isOverlapping(bi,rPixels)){ |
|
243 |
draw=true; |
|
244 |
} |
|
245 |
}else{ |
|
246 |
draw=true; |
|
247 |
} |
|
248 |
} |
|
249 |
if (draw){ |
|
250 |
if (sym.isShapeVisible()) { |
|
251 |
symbolPoint.draw(gBi, |
|
252 |
ati, |
|
253 |
fp); |
|
254 |
} |
|
255 |
// g.drawRect((int)p.getX(),(int)(p.getY()-rPixels.getHeight()),(int)rPixels.getWidth(),(int)rPixels.getHeight()); |
|
256 |
// FGraphicUtilities.DrawAnnotation(gBi, |
|
257 |
// ati, sym, aux[0], metrics, false); |
|
258 |
DrawAnnotation(gBi,sym, p, vv[idTextField].toString(),viewPort,null); |
|
259 |
} |
|
260 |
} |
|
261 |
//Al dibujar esta imagen sobre el graphics la trasparencia no puede existir. |
|
262 |
if (i%1000==0){ |
|
263 |
g.drawImage(bi,0,0,null); |
|
264 |
} |
|
265 |
} |
|
266 |
gBi.translate(offset.getX(),offset.getY()); |
|
267 |
g.drawImage(bi,(int)offset.getX(),(int)offset.getY(),null); |
|
268 |
System.err.println(System.currentTimeMillis()-t1+"millis"); |
|
269 |
recordSet.stop(); |
|
270 |
} catch (Exception e) { |
|
271 |
NotificationManager.addError(e); |
|
272 |
} |
|
273 |
} |
|
274 |
|
|
239 |
if (!capa.isEditing() && l.isAvoidOverLapping()){ |
|
240 |
pSearch =getPoint(bi,rPixels,l.isDelOverLapping()); |
|
241 |
if (pSearch !=null){ |
|
242 |
draw=true; |
|
243 |
} |
|
244 |
}else{ |
|
245 |
if (!capa.isEditing() && l.isDelOverLapping()){ |
|
246 |
if (isOverlapping(bi,rPixels)){ |
|
247 |
draw=true; |
|
248 |
} |
|
249 |
}else{ |
|
250 |
draw=true; |
|
251 |
} |
|
252 |
} |
|
253 |
if (draw){ |
|
254 |
if (sym.isShapeVisible()) { |
|
255 |
symbolPoint.draw(gBi, |
|
256 |
ati, |
|
257 |
fpPixels); |
|
258 |
} |
|
259 |
// g.drawRect((int)pSearch.getX(),(int)(pSearch.getY()-rPixels.getHeight()),(int)rPixels.getWidth(),(int)rPixels.getHeight()); |
|
260 |
// FGraphicUtilities.DrawAnnotation(gBi, |
|
261 |
// ati, sym, aux[0], metrics, false); |
|
262 |
DrawAnnotation(gBi,sym, pSearch , vv[idTextField].toString(),viewPort,properties); |
|
263 |
} |
|
264 |
} |
|
265 |
//Al dibujar esta imagen sobre el graphics la trasparencia no puede existir. |
|
266 |
if (i%1000==0){ |
|
267 |
g.drawImage(bi,0,0,null); |
|
268 |
} |
|
269 |
} |
|
270 |
gBi.translate(offset.getX(),offset.getY()); |
|
271 |
g.drawImage(bi,(int)offset.getX(),(int)offset.getY(),null); |
|
272 |
System.err.println(System.currentTimeMillis()-t1+"millis"); |
|
273 |
recordSet.stop(); |
|
274 |
} catch (Exception e) { |
|
275 |
NotificationManager.addError(e); |
|
276 |
} |
|
277 |
} |
|
275 | 278 |
private Point2D getPoint(BufferedImage bi, Rectangle2D rec, boolean b) { |
276 | 279 |
Rectangle2D r=new Rectangle2D.Double(rec.getX(),rec.getY()-rec.getHeight(),rec.getWidth(),rec.getHeight()); |
277 | 280 |
if (isOverlapping(bi,r)) |
... | ... | |
522 | 525 |
StringValue vType = (StringValue) sds.getFieldValue(index,mapping.getColumnTypeFont()); |
523 | 526 |
Value vText = sds.getFieldValue(index, |
524 | 527 |
mapping.getColumnText()); |
525 |
IGeometry geom = ((Annotation_Layer) capa).getTextWrappingGeometryInPixels(vHeight.floatValue(), |
|
526 |
vText.toString(), vRotation.doubleValue(),vType.getValue(),vStyle.intValue(), index, vp); |
|
527 |
geom.transform(vp.getAffineTransform().createInverse()); |
|
528 |
va.start(); |
|
529 |
IGeometry geom = va.getShape(i); |
|
530 |
va.stop(); |
|
531 |
geom.transform(vp.getAffineTransform()); |
|
532 |
IGeometry geom1 = ((Annotation_Layer) capa).getTextWrappingGeometryInPixels(vHeight.floatValue(), |
|
533 |
vText.toString(), vRotation.doubleValue(),vType.getValue(),vStyle.intValue(), index, vp,geom); |
|
534 |
geom1.transform(vp.getAffineTransform().createInverse()); |
|
528 | 535 |
if (ct != null) { |
529 | 536 |
if (bMustClone) { |
530 |
geom = geom.cloneGeometry();
|
|
537 |
geom1 = geom1.cloneGeometry();
|
|
531 | 538 |
} |
532 | 539 |
|
533 |
geom.reProject(ct); |
|
540 |
geom1.reProject(ct);
|
|
534 | 541 |
} |
535 | 542 |
|
536 |
if (geom.intersects(rect)) { |
|
543 |
if (geom1.intersects(rect)) {
|
|
537 | 544 |
bitset.set(index, true); |
538 | 545 |
} |
539 | 546 |
} |
... | ... | |
570 | 577 |
return queryByRect(recPoint); |
571 | 578 |
} |
572 | 579 |
|
573 |
// private IGeometry getGeometry(Rectangle2D r){ |
|
574 |
// GeneralPathX resul = new GeneralPathX(); |
|
575 |
// Point2D[] vs=new Point2D[4]; |
|
576 |
// vs[0]=new Point2D.Double(r.getX(),r.getY()); |
|
577 |
// vs[1]=new Point2D.Double(r.getMaxX(),r.getY()); |
|
578 |
// vs[2]=new Point2D.Double(r.getMaxX(),r.getMaxY()); |
|
579 |
// vs[3]=new Point2D.Double(r.getX(),r.getMaxY()); |
|
580 |
// //vs[4]=new Point2D.Double(r.getX(),r.getY()); |
|
581 |
// for (int i = 0; i < vs.length; i++) { |
|
582 |
// if (i == 0) { |
|
583 |
// resul.moveTo(vs[i].getX(),vs[i].getY()); |
|
584 |
// } else { |
|
585 |
// resul.lineTo(vs[i].getX(),vs[i].getY()); |
|
586 |
// } |
|
587 |
// } |
|
588 |
// resul.closePath(); |
|
589 |
// return ShapeFactory.createPolygon2D(resul); |
|
590 |
// } |
|
591 | 580 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
592 | 581 |
PrintRequestAttributeSet properties) throws DriverException { |
593 | 582 |
capa.beforePrinting(properties); |
594 |
drawAllAnnotations(g, viewPort, cancel, properties);
|
|
583 |
drawAnnotations(null,g, viewPort, cancel, properties);
|
|
595 | 584 |
capa.afterPrinting(); |
596 | 585 |
} |
597 |
private void drawAllAnnotations(Graphics2D g, ViewPort viewPort, |
|
598 |
Cancellable cancel,PrintRequestAttributeSet properties){ |
|
599 |
Annotation_Legend l = (Annotation_Legend) capa.getLegend(); |
|
600 |
FSymbol sym = (FSymbol) l.getDefaultSymbol(); |
|
601 |
|
|
602 |
try { |
|
603 |
ReadableVectorial source = capa.getSource(); |
|
604 |
FBitSet bs = capa.queryByRect(viewPort.getAdjustedExtent()); |
|
605 |
|
|
606 |
SelectableDataSource recordSet = source.getRecordset(); |
|
607 |
recordSet.start(); |
|
608 |
FBitSet bitSet = recordSet.getSelection(); |
|
609 |
Annotation_Mapping mapping = ((Annotation_Layer) capa).getAnnotatonMapping(); |
|
610 |
int idHeightField = mapping.getColumnHeight(); |
|
611 |
int idFontName = mapping.getColumnTypeFont(); |
|
612 |
int idFontStyle = mapping.getColumnStyleFont(); |
|
613 |
int idRotationField = mapping.getColumnRotate(); |
|
614 |
int idFontColor = mapping.getColumnColor(); |
|
615 |
int idTextField = mapping.getColumnText(); |
|
616 |
|
|
617 |
double rotation = 0D; |
|
618 |
float size = sym.getFont().getSize()* (float)FConstant.FONT_HEIGHT_SCALE_FACTOR; |
|
619 |
String fontName = "Dialog"; |
|
620 |
int fontStyle = sym.getFont().getStyle(); |
|
621 |
int fontColor = sym.getFontColor().getRGB(); |
|
622 |
for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) { |
|
623 |
if (cancel.isCanceled()) { |
|
624 |
break; |
|
625 |
} |
|
626 |
|
|
627 |
Value[] vv = recordSet.getRow(i); |
|
628 |
|
|
629 |
if (idHeightField != -1) { |
|
630 |
// text size is defined in the table |
|
631 |
try { |
|
632 |
size = (float)(((NumericValue) vv[idHeightField]).doubleValue() * FConstant.FONT_HEIGHT_SCALE_FACTOR); |
|
633 |
} catch (ClassCastException ccEx) { |
|
634 |
if (!NullValue.class.equals( |
|
635 |
vv[idHeightField].getClass())) { |
|
636 |
// throw new ReadDriverException("Unknown", ccEx); |
|
637 |
} |
|
638 |
continue; |
|
639 |
} |
|
640 |
} else { |
|
641 |
// otherwise will use the size in the symbol |
|
642 |
} |
|
643 |
|
|
644 |
if (idFontName != -1) { |
|
645 |
fontName = ((StringValue) vv[idFontName]).toString(); |
|
646 |
} |
|
647 |
if (idFontStyle != -1) { |
|
648 |
fontStyle = ((NumericValue) vv[idFontStyle]).intValue(); |
|
649 |
} |
|
650 |
if (idRotationField != -1) { |
|
651 |
// text rotation is defined in the table |
|
652 |
rotation = ((NumericValue) vv[idRotationField]).doubleValue(); |
|
653 |
sym.setRotation((int)rotation); |
|
654 |
} |
|
655 |
if (idFontColor != -1) { |
|
656 |
// text rotation is defined in the table |
|
657 |
fontColor = ((NumericValue) vv[idFontColor]).intValue(); |
|
658 |
sym.setFontColor(new Color(fontColor)); |
|
659 |
} |
|
660 |
if (bitSet.get(i)) { |
|
661 |
sym = (FSymbol) sym.getSymbolForSelection(); |
|
662 |
} |
|
663 |
sym.setFont(new Font(fontName, fontStyle, (int) size)); |
|
664 |
|
|
665 |
//Si el tama?o de la fuente est? en unidades de mapa. |
|
666 |
if (!sym.isFontSizeInPixels()){ |
|
667 |
Rectangle2D r=capa.getTextWrappingGeometryInPixels(size,vv[idTextField].toString(),rotation,fontName, fontStyle,i,viewPort).getBounds2D(); |
|
668 |
Rectangle2D rPixels=new Rectangle2D.Double(r.getX(),r.getY()+r.getHeight(),r.getWidth(),r.getHeight()); |
|
669 |
Point2D p=new Point2D.Double(rPixels.getX(),rPixels.getY()); |
|
670 |
FPoint2D fpPixels=new FPoint2D(rPixels.getX(),rPixels.getY()); |
|
671 |
sym.setRotation((int)rotation); |
|
672 |
if (sym.isShapeVisible()) { |
|
673 |
symbolPoint.draw(g, |
|
674 |
viewPort.getAffineTransform(), |
|
675 |
fpPixels); |
|
676 |
} |
|
677 |
DrawAnnotation(g,sym, p, vv[idTextField].toString(),viewPort,properties); |
|
678 |
// FGraphicUtilities.DrawAnnotation(g, |
|
679 |
// ati, sym, aux[0], metrics, false); |
|
680 |
}else{ |
|
681 |
// Si el tama?o de la fuente est? en pixels. |
|
682 |
Rectangle2D r=capa.getTextWrappingGeometryInPixels(size,vv[idTextField].toString(),rotation,fontName,fontStyle,i,viewPort).getBounds2D(); |
|
683 |
Rectangle2D rPixels= new Rectangle2D.Double(r.getX(),r.getY()+r.getHeight(),r.getWidth(),r.getHeight()); |
|
684 |
FPoint2D fp=new FPoint2D(rPixels.getX(),rPixels.getY()); |
|
685 |
Point2D p=new Point2D.Double(rPixels.getX(),rPixels.getY()); |
|
686 |
if (sym.isShapeVisible()) { |
|
687 |
symbolPoint.draw(g, |
|
688 |
ati, |
|
689 |
fp); |
|
690 |
} |
|
691 |
DrawAnnotation(g,sym, p, vv[idTextField].toString(),viewPort,properties); |
|
692 |
// FGraphicUtilities.DrawAnnotation(g, |
|
693 |
// ati, sym, aux[0], metrics, false); |
|
694 |
|
|
695 |
} |
|
696 |
recordSet.stop(); |
|
697 |
} |
|
698 |
} catch (Exception e) { |
|
699 |
NotificationManager.addError(e); |
|
700 |
} |
|
701 |
} |
|
702 | 586 |
private static void DrawAnnotation(Graphics2D g2, |
703 | 587 |
FSymbol theSymbol,Point2D pAux, String text,ViewPort viewPort,PrintRequestAttributeSet properties) { |
704 | 588 |
float x; |
Also available in: Unified diff