root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / layout / fframes / FFrameGraphics.java @ 31496
History | View | Annotate | Download (22.7 KB)
1 |
/*
|
---|---|
2 |
* Created on 22-jun-2004
|
3 |
*
|
4 |
*/
|
5 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
6 |
*
|
7 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
8 |
*
|
9 |
* This program is free software; you can redistribute it and/or
|
10 |
* modify it under the terms of the GNU General Public License
|
11 |
* as published by the Free Software Foundation; either version 2
|
12 |
* of the License, or (at your option) any later version.
|
13 |
*
|
14 |
* This program is distributed in the hope that it will be useful,
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
* GNU General Public License for more details.
|
18 |
*
|
19 |
* You should have received a copy of the GNU General Public License
|
20 |
* along with this program; if not, write to the Free Software
|
21 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
22 |
*
|
23 |
* For more information, contact:
|
24 |
*
|
25 |
* Generalitat Valenciana
|
26 |
* Conselleria d'Infraestructures i Transport
|
27 |
* Av. Blasco Ib??ez, 50
|
28 |
* 46010 VALENCIA
|
29 |
* SPAIN
|
30 |
*
|
31 |
* +34 963862235
|
32 |
* gvsig@gva.es
|
33 |
* www.gvsig.gva.es
|
34 |
*
|
35 |
* or
|
36 |
*
|
37 |
* IVER T.I. S.A
|
38 |
* Salamanca 50
|
39 |
* 46005 Valencia
|
40 |
* Spain
|
41 |
*
|
42 |
* +34 963163400
|
43 |
* dac@iver.es
|
44 |
*/
|
45 |
package org.gvsig.app.project.documents.layout.fframes; |
46 |
|
47 |
import java.awt.Color; |
48 |
import java.awt.Graphics2D; |
49 |
import java.awt.geom.AffineTransform; |
50 |
import java.awt.geom.Point2D; |
51 |
import java.awt.geom.Rectangle2D; |
52 |
import java.awt.image.BufferedImage; |
53 |
import java.util.BitSet; |
54 |
|
55 |
import org.gvsig.andami.PluginServices; |
56 |
import org.gvsig.app.project.documents.exceptions.SaveException; |
57 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.FFrameGraphicsDialog; |
58 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog; |
59 |
import org.gvsig.app.project.documents.layout.geometryadapters.CircleAdapter; |
60 |
import org.gvsig.app.project.documents.layout.geometryadapters.GeometryAdapter; |
61 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
62 |
import org.gvsig.compat.print.PrintAttributes; |
63 |
import org.gvsig.fmap.geom.Geometry; |
64 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
65 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
66 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
67 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol; |
68 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol; |
69 |
import org.gvsig.utils.XMLEntity; |
70 |
|
71 |
|
72 |
|
73 |
/**
|
74 |
* FFrame para contener un gr?fico.
|
75 |
*
|
76 |
* @author Vicente Caballero Navarro
|
77 |
*/
|
78 |
public class FFrameGraphics extends FFrame implements IFFrameEditableVertex { |
79 |
private static double TOL = 0.2; |
80 |
public static final int POINT = 21; |
81 |
public static final int LINE = 22; |
82 |
public static final int POLYLINE = 23; |
83 |
public static final int RECTANGLE = 24; |
84 |
public static final int CIRCLE = 25; |
85 |
public static final int POLYGON = 26; |
86 |
public static final int RECTANGLEGROUP = 16; |
87 |
public static final int RECTANGLESYMBOL = 17; |
88 |
protected int m_type = POINT; |
89 |
private ISymbol m_symbol = null; |
90 |
private Color m_color = null; |
91 |
private GeometryAdapter geometry;
|
92 |
private GeometryAdapter geometryEdit;
|
93 |
private boolean editing = false; |
94 |
private double size = 0.5; |
95 |
private BitSet index = new BitSet(); |
96 |
|
97 |
private MapContextManager mapContextManager = MapContextLocator
|
98 |
.getMapContextManager(); |
99 |
|
100 |
/**
|
101 |
* Crea un nuevo FFrameGraphics.
|
102 |
*/
|
103 |
public FFrameGraphics() {
|
104 |
} |
105 |
|
106 |
/**
|
107 |
* DOCUMENT ME!
|
108 |
*
|
109 |
* @param geom DOCUMENT ME!
|
110 |
*/
|
111 |
public void setGeometryAdapter(GeometryAdapter geom) { |
112 |
geometry = geom; |
113 |
} |
114 |
|
115 |
/**
|
116 |
* Rellena el color que se utlizar? para dibujar el s?mbolo.
|
117 |
*
|
118 |
* @param color
|
119 |
*/
|
120 |
public void setColor(Color color) { |
121 |
m_color = color; |
122 |
} |
123 |
|
124 |
/**
|
125 |
* Actualiza el Fsymbol a partir del tipo de Gr?fico que se pase como
|
126 |
* par?metro.
|
127 |
*
|
128 |
* @param type tipo de gr?fico.
|
129 |
* @param at Transformada.
|
130 |
*/
|
131 |
public void update(int type, AffineTransform at) { |
132 |
m_type = type; |
133 |
|
134 |
//aT = at;
|
135 |
if (m_color == null) { |
136 |
m_color = Color.black;
|
137 |
} |
138 |
int shapeType = -1; |
139 |
/*
|
140 |
* (jaume) moved to ISymbol
|
141 |
* switch (m_type) {
|
142 |
case (POINT):
|
143 |
|
144 |
FSymbol symbolPoint= new FSymbol(FConstant.SHAPE_TYPE_POINT, m_color);
|
145 |
symbolPoint.setSize((int) FLayoutUtilities.fromSheetDistance(
|
146 |
size, at));
|
147 |
m_symbol=symbolPoint;
|
148 |
break;
|
149 |
|
150 |
case (RECTANGLE):
|
151 |
FSymbol symbolRectangle= new FSymbol(FConstant.SYMBOL_TYPE_FILL, m_color);
|
152 |
symbolRectangle.setColor(null);
|
153 |
m_symbol=symbolRectangle;
|
154 |
break;
|
155 |
|
156 |
case (LINE):
|
157 |
FSymbol symbolLine= new FSymbol(FConstant.SYMBOL_TYPE_LINE, m_color);
|
158 |
m_symbol=symbolLine;
|
159 |
break;
|
160 |
|
161 |
case (POLYLINE):
|
162 |
FSymbol symbolPolyline= new FSymbol(FConstant.SYMBOL_TYPE_LINE, m_color);
|
163 |
m_symbol=symbolPolyline;
|
164 |
break;
|
165 |
|
166 |
case (POLYGON):
|
167 |
FSymbol symbolPolygon= new FSymbol(FConstant.SYMBOL_TYPE_FILL, m_color);
|
168 |
symbolPolygon.setStyle(FConstant.SYMBOL_STYLE_FILL_SOLID);
|
169 |
symbolPolygon.setOutlined(true);
|
170 |
symbolPolygon.setOutlineColor(m_color);
|
171 |
symbolPolygon.setColor(null);
|
172 |
m_symbol=symbolPolygon;
|
173 |
break;
|
174 |
|
175 |
case (CIRCLE):
|
176 |
FSymbol symbolCircle= new FSymbol(FConstant.SYMBOL_TYPE_FILL, m_color);
|
177 |
symbolCircle.setStyle(FConstant.SYMBOL_STYLE_FILL_SOLID);
|
178 |
symbolCircle.setOutlined(true);
|
179 |
symbolCircle.setOutlineColor(m_color);
|
180 |
symbolCircle.setColor(null);
|
181 |
m_symbol=symbolCircle;
|
182 |
break;
|
183 |
}
|
184 |
*/
|
185 |
switch (m_type) {
|
186 |
case (POINT):
|
187 |
shapeType = Geometry.TYPES.POINT; |
188 |
break;
|
189 |
|
190 |
case (RECTANGLE):
|
191 |
case (POLYGON):
|
192 |
case (CIRCLE):
|
193 |
shapeType = Geometry.TYPES.SURFACE; |
194 |
break;
|
195 |
|
196 |
case (LINE):
|
197 |
case (POLYLINE):
|
198 |
shapeType = Geometry.TYPES.CURVE; |
199 |
break;
|
200 |
} |
201 |
|
202 |
m_symbol = mapContextManager.getSymbolManager().createSymbol(shapeType); |
203 |
if (shapeType==Geometry.TYPES.SURFACE){
|
204 |
((IFillSymbol) m_symbol).setFillColor(null);
|
205 |
} |
206 |
} |
207 |
|
208 |
/**
|
209 |
* Devuelve el FSymbol que se representa.
|
210 |
*
|
211 |
* @return DOCUMENT ME!
|
212 |
*/
|
213 |
public ISymbol getFSymbol() {
|
214 |
return m_symbol;
|
215 |
} |
216 |
|
217 |
/**
|
218 |
* Rellena el FSymbol que se representara al dibujar.
|
219 |
*
|
220 |
* @param fs2d
|
221 |
*/
|
222 |
public void setSymbol(ISymbol symbol) { |
223 |
m_symbol = symbol; |
224 |
} |
225 |
|
226 |
/**
|
227 |
* M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
|
228 |
* la transformada afin que se debe de aplicar y el rect?ngulo que se debe
|
229 |
* de dibujar.
|
230 |
*
|
231 |
* @param g Graphics
|
232 |
* @param at Transformada afin.
|
233 |
* @param rv rect?ngulo sobre el que hacer un clip.
|
234 |
* @param imgBase DOCUMENT ME!
|
235 |
*/
|
236 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
237 |
BufferedImage imgBase) {
|
238 |
Rectangle2D.Double rect = getBoundingBox(at);
|
239 |
g.rotate(Math.toRadians(getRotation()), rect.x + (rect.width / 2), |
240 |
rect.y + (rect.height / 2));
|
241 |
if (intersects(rv, rect)) {
|
242 |
g.setColor(Color.black);
|
243 |
|
244 |
if (m_type == POINT) {
|
245 |
((IMarkerSymbol)m_symbol).setSize((int) (rect.getWidth() * 0.7)); |
246 |
} |
247 |
// float stroke=0;
|
248 |
// if (((FSymbol)m_symbol).getStroke() != null) {
|
249 |
// stroke=((BasicStroke)((FSymbol)m_symbol).getStroke()).getLineWidth();
|
250 |
// BasicStroke basicStroke = new BasicStroke((float)FLayoutUtilities.fromSheetDistance(stroke,at)/100);
|
251 |
// ((FSymbol)m_symbol).setStroke(basicStroke);
|
252 |
// }
|
253 |
geometry.draw(g, at, m_symbol); |
254 |
|
255 |
// if (((FSymbol)m_symbol).getStroke() != null) {
|
256 |
// BasicStroke basicStroke = new BasicStroke(stroke);
|
257 |
// ((FSymbol)m_symbol).setStroke(basicStroke);
|
258 |
// }
|
259 |
|
260 |
if (editing) {
|
261 |
g.setColor(Color.red);
|
262 |
geometry.drawVertex(g, at); |
263 |
} |
264 |
} |
265 |
|
266 |
g.rotate(Math.toRadians(-getRotation()), rect.x + (rect.width / 2), |
267 |
rect.y + (rect.height / 2));
|
268 |
} |
269 |
|
270 |
/**
|
271 |
* @see org.gvsig.app.project.documents.layout.fframes.IFFrame#getXMLEntity()
|
272 |
*/
|
273 |
public XMLEntity getXMLEntity() throws SaveException { |
274 |
XMLEntity xml = super.getXMLEntity();
|
275 |
|
276 |
// try {
|
277 |
//// xml.putProperty("type", Layout.GRAPHICS);
|
278 |
// xml.putProperty("m_type", m_type);
|
279 |
// xml.addChild(m_symbol.getXMLEntity());
|
280 |
// if (geometry!=null) {
|
281 |
// xml.addChild(geometry.getXMLEntity());
|
282 |
// }
|
283 |
// // xml.addChild(geometryEdit.getXMLEntity());
|
284 |
// } catch (Exception e) {
|
285 |
// throw new SaveException(e, this.getClass().getName());
|
286 |
// }
|
287 |
|
288 |
return xml;
|
289 |
} |
290 |
|
291 |
/**
|
292 |
* @see org.gvsig.app.project.documents.layout.fframes.IFFrame#updateNum()
|
293 |
*/
|
294 |
public void updateNum() { |
295 |
} |
296 |
|
297 |
/**
|
298 |
* @see org.gvsig.app.project.documents.layout.fframes.IFFrame#getNum()
|
299 |
*/
|
300 |
public int getNum() { |
301 |
return 0; |
302 |
} |
303 |
|
304 |
/**
|
305 |
* TODO: replace with the new persistence API.
|
306 |
*/
|
307 |
public void setXMLEntity(XMLEntity xml) { |
308 |
// m_Selected = xml.getIntProperty("m_Selected");
|
309 |
//
|
310 |
// setRotation(xml.getDoubleProperty("m_rotation"));
|
311 |
// // jaume; m_symbol = FSymbol.createFromXML(xml.getChild(0));
|
312 |
// m_symbol = SymbologyFactory.createSymbolFromXML(xml.getChild(0), null);
|
313 |
// if (xml.contains("m_type")) {
|
314 |
// m_type = xml.getIntProperty("m_type");
|
315 |
// // return;
|
316 |
// }
|
317 |
// if (m_type==RECTANGLESYMBOL) {
|
318 |
// return;
|
319 |
// }
|
320 |
// if (xml.getChildrenCount() ==1) {
|
321 |
// Rectangle2D r = (Rectangle2D) getBoundBox().clone();
|
322 |
//
|
323 |
// if (m_type == LINE) {
|
324 |
// geometry = new PolyLineAdapter();
|
325 |
// } else if (m_type == RECTANGLE ||
|
326 |
// m_type == RECTANGLEGROUP) {
|
327 |
// geometry = new RectangleAdapter();
|
328 |
// geometry.addPoint(new Point2D.Double(r.getX(), r.getY()));
|
329 |
// geometry.addPoint(new Point2D.Double(r.getMaxX(), r.getMaxY()));
|
330 |
// } else if (m_type == POLYLINE) {
|
331 |
// geometry = new PolyLineAdapter();
|
332 |
// } else if (m_type == POLYGON) {
|
333 |
// geometry = new PolygonAdapter();
|
334 |
// } else if (m_type == CIRCLE) {
|
335 |
// geometry = new CircleAdapter();
|
336 |
// geometry.addPoint(new Point2D.Double(r.getCenterX(),
|
337 |
// r.getCenterY()));
|
338 |
//
|
339 |
// if (r.getWidth() < r.getHeight()) {
|
340 |
// geometry.addPoint(new Point2D.Double(r.getMaxX(),
|
341 |
// r.getCenterY()));
|
342 |
// } else {
|
343 |
// geometry.addPoint(new Point2D.Double(r.getCenterX(),
|
344 |
// r.getY()));
|
345 |
// }
|
346 |
// } else if (m_type == POINT) {
|
347 |
// geometry = new PointAdapter();
|
348 |
// geometry.addPoint(new Point2D.Double(r.getCenterX(),
|
349 |
// r.getCenterY()));
|
350 |
// }
|
351 |
//
|
352 |
// geometry.end();
|
353 |
// } else {
|
354 |
// geometry = GeometryAdapter.createFromXML(xml.getChild(1));
|
355 |
// // geometryEdit = GeometryAdapter.createFromXML(xml.getChild(2));
|
356 |
// }
|
357 |
} |
358 |
|
359 |
/**
|
360 |
* TODO: replace with the new persistence API.
|
361 |
*/
|
362 |
public void setXMLEntity03(XMLEntity xml, LayoutPanel p) { |
363 |
// m_Selected = xml.getIntProperty("m_Selected");
|
364 |
// m_type = xml.getIntProperty("m_type");
|
365 |
// // jaume; m_symbol = FSymbol.createFromXML(xml.getChild(0));
|
366 |
// m_symbol = SymbologyFactory.createSymbolFromXML(xml.getChild(0), null);
|
367 |
//
|
368 |
// Rectangle2D r = (Rectangle2D) getBoundBox().clone();
|
369 |
//
|
370 |
// if (m_type == LINE) {
|
371 |
// geometry = new PolyLineAdapter();
|
372 |
// } else if (m_type == RECTANGLE) {
|
373 |
// geometry = new RectangleAdapter();
|
374 |
// geometry.addPoint(new Point2D.Double(r.getX(), r.getY()));
|
375 |
// geometry.addPoint(new Point2D.Double(r.getMaxX(), r.getMaxY()));
|
376 |
// } else if (m_type == POLYLINE) {
|
377 |
// geometry = new PolyLineAdapter();
|
378 |
// } else if (m_type == POLYGON) {
|
379 |
// geometry = new PolygonAdapter();
|
380 |
// } else if (m_type == CIRCLE) {
|
381 |
// geometry = new CircleAdapter();
|
382 |
// geometry.addPoint(new Point2D.Double(r.getCenterX(), r.getCenterY()));
|
383 |
//
|
384 |
// if (r.getWidth() < r.getHeight()) {
|
385 |
// geometry.addPoint(new Point2D.Double(r.getMaxX(), r.getCenterY()));
|
386 |
// } else {
|
387 |
// geometry.addPoint(new Point2D.Double(r.getCenterX(), r.getY()));
|
388 |
// }
|
389 |
// } else if (m_type == POINT) {
|
390 |
// geometry = new PointAdapter();
|
391 |
// geometry.addPoint(new Point2D.Double(r.getCenterX(), r.getCenterY()));
|
392 |
// }
|
393 |
//
|
394 |
// geometry.end();
|
395 |
} |
396 |
|
397 |
/**
|
398 |
* @see org.gvsig.app.project.documents.layout.fframes.IFFrame#getNameFFrame()
|
399 |
*/
|
400 |
public String getNameFFrame() { |
401 |
return PluginServices.getText(this, "Graficos")+ num; |
402 |
} |
403 |
|
404 |
/**
|
405 |
* Inserta el tama?o del punto.
|
406 |
*
|
407 |
* @param size entero que representa el tama?o del punto.
|
408 |
*/
|
409 |
public void setSize(double size) { |
410 |
this.size = size;
|
411 |
if (m_type==RECTANGLESYMBOL) {
|
412 |
return;
|
413 |
} |
414 |
Rectangle2D r = geometry.getBounds2D();
|
415 |
super.setBoundBox(new Rectangle2D.Double(r.getX() - size, |
416 |
r.getY() - size, size * 2, size * 2)); |
417 |
} |
418 |
|
419 |
/**
|
420 |
* Devuelve el tipo de gr?fico que contiene el fframe.
|
421 |
*
|
422 |
* @return tipo de
|
423 |
*/
|
424 |
public int getType() { |
425 |
return m_type;
|
426 |
} |
427 |
public int getShapeType(){ |
428 |
int shapeType=0; |
429 |
switch (m_type) {
|
430 |
case (POINT):
|
431 |
shapeType = Geometry.TYPES.POINT; |
432 |
break;
|
433 |
|
434 |
case (RECTANGLE):
|
435 |
case (POLYGON):
|
436 |
case (CIRCLE):
|
437 |
shapeType = Geometry.TYPES.SURFACE; |
438 |
break;
|
439 |
|
440 |
case (LINE):
|
441 |
case (POLYLINE):
|
442 |
shapeType = Geometry.TYPES.CURVE; |
443 |
break;
|
444 |
} |
445 |
return shapeType;
|
446 |
} |
447 |
public void setType(int type) { |
448 |
m_type = type; |
449 |
} |
450 |
/**
|
451 |
* DOCUMENT ME!
|
452 |
*
|
453 |
* @param r DOCUMENT ME!
|
454 |
*/
|
455 |
public void setBoundBox(Rectangle2D r) { |
456 |
if (m_type==RECTANGLESYMBOL) {
|
457 |
super.setBoundBox(r);
|
458 |
return;
|
459 |
} |
460 |
AffineTransform aT = new AffineTransform(); |
461 |
|
462 |
if (getBoundBox().getWidth() != 0) { |
463 |
double w = r.getWidth() / getBoundBox().getWidth();
|
464 |
double h = r.getHeight() / getBoundBox().getHeight();
|
465 |
|
466 |
AffineTransform trans2 = AffineTransform.getTranslateInstance(r.getX(), |
467 |
r.getY()); |
468 |
aT.concatenate(trans2); |
469 |
|
470 |
AffineTransform scale1 = AffineTransform.getScaleInstance(w, h); |
471 |
aT.concatenate(scale1); |
472 |
|
473 |
AffineTransform trans1 = AffineTransform.getTranslateInstance(-getBoundBox() |
474 |
.getX(), |
475 |
-getBoundBox().getY()); |
476 |
aT.concatenate(trans1); |
477 |
geometry.applyTransform(aT); |
478 |
|
479 |
size = aT.getScaleX() * size; |
480 |
} |
481 |
|
482 |
super.setBoundBox(r);
|
483 |
} |
484 |
|
485 |
/**
|
486 |
* DOCUMENT ME!
|
487 |
*/
|
488 |
public void startEditing() { |
489 |
editing = true;
|
490 |
} |
491 |
|
492 |
/**
|
493 |
* DOCUMENT ME!
|
494 |
*/
|
495 |
public void stopEditing() { |
496 |
editing = false;
|
497 |
} |
498 |
|
499 |
/**
|
500 |
* DOCUMENT ME!
|
501 |
*
|
502 |
* @return DOCUMENT ME!
|
503 |
*/
|
504 |
public boolean isEditing() { |
505 |
return editing;
|
506 |
} |
507 |
|
508 |
/**
|
509 |
* DOCUMENT ME!
|
510 |
*
|
511 |
* @param point DOCUMENT ME!
|
512 |
* @param geom DOCUMENT ME!
|
513 |
*/
|
514 |
public void pointReleased(Point2D point, GeometryAdapter geom) { |
515 |
index.clear(); |
516 |
geometry = geom; |
517 |
|
518 |
Rectangle2D r = geometry.getBounds2D();
|
519 |
super.setBoundBox(r);
|
520 |
} |
521 |
|
522 |
/**
|
523 |
* DOCUMENT ME!
|
524 |
*
|
525 |
* @param point DOCUMENT ME!
|
526 |
*/
|
527 |
public void pointPressed(Point2D point) { |
528 |
Rectangle2D.Double rect = getBoundBox();
|
529 |
Point2D[] points = geometry.getPoints(); |
530 |
geometryEdit = geometry.cloneAdapter();//GeometryAdapter.createFromXML(geometry.getXMLEntity());
|
531 |
|
532 |
Point2D pAux1 = new Point2D.Double(); |
533 |
index.clear(); |
534 |
for (int i = 0; i < points.length; i++) { |
535 |
if (getRotation() != 0) { |
536 |
AffineTransform af = AffineTransform.getRotateInstance(Math.toRadians( |
537 |
-getRotation()), rect.x + (rect.width / 2),
|
538 |
rect.y + (rect.height / 2));
|
539 |
af.transform(point, pAux1); |
540 |
|
541 |
if (points[i].distance(pAux1) <= TOL) {
|
542 |
index.set(i); |
543 |
} |
544 |
} else {
|
545 |
if (points[i].distance(point) <= TOL) {
|
546 |
index.set(i); |
547 |
} |
548 |
} |
549 |
} |
550 |
} |
551 |
|
552 |
/**
|
553 |
* DOCUMENT ME!
|
554 |
*
|
555 |
* @param point DOCUMENT ME!
|
556 |
*/
|
557 |
public void pointDragged(Point2D point) { |
558 |
//Point2D[] points = geometry.getPoints();
|
559 |
|
560 |
for (int j = index.nextSetBit(0); j >= 0; |
561 |
j = index.nextSetBit(j + 1)) {
|
562 |
if (getRotation() != 0) { |
563 |
Rectangle2D.Double rect = getBoundBox();
|
564 |
AffineTransform af = AffineTransform.getRotateInstance(Math.toRadians( |
565 |
-getRotation()), rect.x + (rect.width / 2),
|
566 |
rect.y + (rect.height / 2));
|
567 |
af.transform(point, point); |
568 |
} |
569 |
|
570 |
//points[j] = new Point2D.Double(point.getX(), point.getY());
|
571 |
geometryEdit.changePoint(j,point); |
572 |
} |
573 |
//geometryEdit.setPoints(points);
|
574 |
geometryEdit.end(); |
575 |
} |
576 |
|
577 |
/**
|
578 |
* DOCUMENT ME!
|
579 |
*
|
580 |
* @param g DOCUMENT ME!
|
581 |
* @param at DOCUMENT ME!
|
582 |
*/
|
583 |
public void paint(Graphics2D g, AffineTransform at) { |
584 |
if (geometryEdit != null) { |
585 |
Rectangle2D.Double rect = getBoundingBox(at);
|
586 |
if (getRotation()!=0){ |
587 |
g.rotate(Math.toRadians(getRotation()), rect.x + (rect.width / 2), |
588 |
rect.y + (rect.height / 2));
|
589 |
geometryEdit.paint(g,at,false);
|
590 |
/* FShape m_shape = null;
|
591 |
GeneralPathX polyLine = new GeneralPathX(geometryEdit.getShape());
|
592 |
polyLine.transform(at);
|
593 |
m_shape = new FPolyline2D(polyLine);
|
594 |
FGraphicUtilities.DrawShape(g, mT, m_shape, m_symbol);
|
595 |
*/
|
596 |
g.rotate(Math.toRadians(-getRotation()), rect.x + (rect.width / 2), |
597 |
rect.y + (rect.height / 2));
|
598 |
}else{
|
599 |
geometryEdit.paint(g,at,false);
|
600 |
} |
601 |
} |
602 |
} |
603 |
|
604 |
/**
|
605 |
* DOCUMENT ME!
|
606 |
*
|
607 |
* @return DOCUMENT ME!
|
608 |
*/
|
609 |
public GeometryAdapter getGeometry() {
|
610 |
return geometryEdit;
|
611 |
} |
612 |
|
613 |
public void initialize() { |
614 |
// TODO Auto-generated method stub
|
615 |
|
616 |
} |
617 |
/**
|
618 |
* Devuelve un entero que representa donde esta contenido el punto que se
|
619 |
* pasa como par?metro.
|
620 |
*
|
621 |
* @param p punto a comparar.
|
622 |
*
|
623 |
* @return entero que representa como esta contenido el punto.
|
624 |
*/
|
625 |
public int getContains(Point2D p) { |
626 |
if (geometry instanceof CircleAdapter) { |
627 |
if (ne.contains(p.getX(), p.getY())) {
|
628 |
return NE;
|
629 |
} else if (se.contains(p.getX(), p.getY())) { |
630 |
return SE;
|
631 |
} else if (so.contains(p.getX(), p.getY())) { |
632 |
return SO;
|
633 |
} else if (no.contains(p.getX(), p.getY())) { |
634 |
return NO;
|
635 |
} else if (getBoundingBox(null).contains(p.getX(), p.getY())) { |
636 |
return RECT;
|
637 |
} |
638 |
return NOSELECT;
|
639 |
} |
640 |
return super.getContains(p); |
641 |
} |
642 |
|
643 |
/**
|
644 |
* Dibuja los handlers sobre el boundingBox en el graphics que se pasa como
|
645 |
* par?metro.
|
646 |
*
|
647 |
* @param g
|
648 |
* Graphics sobre el que dibujar.
|
649 |
*/
|
650 |
public void drawHandlers(Graphics2D g) { |
651 |
if (geometry instanceof CircleAdapter) { |
652 |
int size = 10; |
653 |
Rectangle2D r = getBoundingBox(null); |
654 |
Point2D p = new Point2D.Double(); |
655 |
g.rotate(Math.toRadians(getRotation()), r.getX()
|
656 |
+ (r.getWidth() / 2), r.getY() + (r.getHeight() / 2)); |
657 |
|
658 |
AffineTransform atRotate = new AffineTransform(); |
659 |
atRotate.rotate(Math.toRadians(getRotation()), r.getX()
|
660 |
+ (r.getWidth() / 2), r.getY() + (r.getHeight() / 2)); |
661 |
|
662 |
g.fillRect((int) r.getX() - size, (int) r.getY() - size, |
663 |
size, size); |
664 |
atRotate.transform(new Point2D.Double(r.getX() - size, r.getY() |
665 |
- size), p); |
666 |
no.setRect((int) p.getX(), (int) p.getY(), size, size); |
667 |
|
668 |
g.fillRect((int) r.getMaxX(), (int) r.getY() - size, size, size); |
669 |
atRotate.transform( |
670 |
new Point2D.Double(r.getMaxX(), r.getY() - size), p); |
671 |
ne.setRect((int) p.getX(), (int) p.getY(), size, size); |
672 |
|
673 |
g.fillRect((int) r.getX() - size, (int) r.getMaxY(), size, size); |
674 |
atRotate.transform( |
675 |
new Point2D.Double(r.getX() - size, r.getMaxY()), p); |
676 |
so.setRect((int) p.getX(), (int) p.getY(), size, size); |
677 |
|
678 |
g.fillRect((int) r.getMaxX(), (int) r.getMaxY(), size, size); |
679 |
atRotate.transform(new Point2D.Double(r.getMaxX(), r.getMaxY()), p); |
680 |
se.setRect((int) p.getX(), (int) p.getY(), size, size); |
681 |
|
682 |
g.rotate(Math.toRadians(-getRotation()), r.getX()
|
683 |
+ (r.getWidth() / 2), r.getY() + (r.getHeight() / 2)); |
684 |
} else {
|
685 |
super.drawHandlers(g);
|
686 |
} |
687 |
} |
688 |
|
689 |
public void cloneActions(IFFrame frame) { |
690 |
// TODO Auto-generated method stub
|
691 |
|
692 |
} |
693 |
|
694 |
public IFFrameDialog getPropertyDialog() {
|
695 |
return new FFrameGraphicsDialog(getLayout(),this); |
696 |
} |
697 |
|
698 |
public void print(Graphics2D g, AffineTransform at, Geometry geom, |
699 |
PrintAttributes printingProperties) { |
700 |
Rectangle2D.Double rect = getBoundingBox(at);
|
701 |
g.rotate(Math.toRadians(getRotation()), rect.x + (rect.width / 2), |
702 |
rect.y + (rect.height / 2));
|
703 |
g.setColor(Color.black);
|
704 |
|
705 |
// if (m_type == POINT) {
|
706 |
// ((IMarkerSymbol)m_symbol).setSize((int) (rect.getWidth() * 0.7));
|
707 |
// }
|
708 |
geometry.print(g, at, m_symbol,printingProperties); |
709 |
|
710 |
|
711 |
if (editing) {
|
712 |
g.setColor(Color.red);
|
713 |
geometry.drawVertex(g, at); |
714 |
} |
715 |
|
716 |
g.rotate(Math.toRadians(-getRotation()), rect.x + (rect.width / 2), |
717 |
rect.y + (rect.height / 2));
|
718 |
} |
719 |
|
720 |
|
721 |
} |