root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / fframes / FFrameGraphics.java @ 9392
History | View | Annotate | Download (21.1 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 com.iver.cit.gvsig.project.documents.layout.fframes; |
46 |
|
47 |
import java.awt.BasicStroke; |
48 |
import java.awt.Color; |
49 |
import java.awt.Graphics2D; |
50 |
import java.awt.geom.AffineTransform; |
51 |
import java.awt.geom.Point2D; |
52 |
import java.awt.geom.Rectangle2D; |
53 |
import java.awt.image.BufferedImage; |
54 |
import java.util.BitSet; |
55 |
|
56 |
import com.iver.andami.PluginServices; |
57 |
import com.iver.cit.gvsig.fmap.DriverException; |
58 |
import com.iver.cit.gvsig.fmap.core.ISymbol; |
59 |
import com.iver.cit.gvsig.fmap.core.adapter.CircleAdapter; |
60 |
import com.iver.cit.gvsig.fmap.core.adapter.GeometryAdapter; |
61 |
import com.iver.cit.gvsig.fmap.core.adapter.PointAdapter; |
62 |
import com.iver.cit.gvsig.fmap.core.adapter.PolyLineAdapter; |
63 |
import com.iver.cit.gvsig.fmap.core.adapter.PolygonAdapter; |
64 |
import com.iver.cit.gvsig.fmap.core.adapter.RectangleAdapter; |
65 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
66 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
67 |
import com.iver.cit.gvsig.project.documents.exceptions.SaveException; |
68 |
import com.iver.cit.gvsig.project.documents.layout.FLayoutUtilities; |
69 |
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.FFrameGraphicsDialog; |
70 |
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.IFFrameDialog; |
71 |
import com.iver.cit.gvsig.project.documents.layout.gui.Layout; |
72 |
import com.iver.utiles.XMLEntity; |
73 |
|
74 |
|
75 |
/**
|
76 |
* FFrame para contener un gr?fico.
|
77 |
*
|
78 |
* @author Vicente Caballero Navarro
|
79 |
*/
|
80 |
public class FFrameGraphics extends FFrame implements IFFrameEditableVertex { |
81 |
private static double TOL = 0.2; |
82 |
public static final int POINT = 21; |
83 |
public static final int LINE = 22; |
84 |
public static final int POLYLINE = 23; |
85 |
public static final int RECTANGLE = 24; |
86 |
public static final int CIRCLE = 25; |
87 |
public static final int POLYGON = 26; |
88 |
public static final int RECTANGLEGROUP = 16; |
89 |
public static final int RECTANGLESYMBOL = 17; |
90 |
private int m_type = POINT; |
91 |
private ISymbol m_symbol = null; |
92 |
private Color m_color = null; |
93 |
private GeometryAdapter geometry;
|
94 |
private GeometryAdapter geometryEdit;
|
95 |
private boolean editing = false; |
96 |
private double size = 0.5; |
97 |
private BitSet index = new BitSet(); |
98 |
|
99 |
/**
|
100 |
* Crea un nuevo FFrameGraphics.
|
101 |
*/
|
102 |
public FFrameGraphics() {
|
103 |
} |
104 |
|
105 |
/**
|
106 |
* DOCUMENT ME!
|
107 |
*
|
108 |
* @param geom DOCUMENT ME!
|
109 |
*/
|
110 |
public void setGeometryAdapter(GeometryAdapter geom) { |
111 |
geometry = geom; |
112 |
} |
113 |
|
114 |
/**
|
115 |
* Rellena el color que se utlizar? para dibujar el s?mbolo.
|
116 |
*
|
117 |
* @param color
|
118 |
*/
|
119 |
public void setColor(Color color) { |
120 |
m_color = color; |
121 |
} |
122 |
|
123 |
/**
|
124 |
* Actualiza el Fsymbol a partir del tipo de Gr?fico que se pase como
|
125 |
* par?metro.
|
126 |
*
|
127 |
* @param type tipo de gr?fico.
|
128 |
* @param at Transformada.
|
129 |
*/
|
130 |
public void update(int type, AffineTransform at) { |
131 |
m_type = type; |
132 |
|
133 |
//aT = at;
|
134 |
if (m_color == null) { |
135 |
m_color = Color.black;
|
136 |
} |
137 |
switch (m_type) {
|
138 |
case (POINT):
|
139 |
|
140 |
FSymbol symbolPoint= new FSymbol(FConstant.SHAPE_TYPE_POINT, m_color);
|
141 |
symbolPoint.setSize((int) FLayoutUtilities.fromSheetDistance(
|
142 |
size, at)); |
143 |
m_symbol=symbolPoint; |
144 |
break;
|
145 |
|
146 |
case (RECTANGLE):
|
147 |
FSymbol symbolRectangle= new FSymbol(FConstant.SYMBOL_TYPE_FILL, m_color);
|
148 |
symbolRectangle.setColor(null);
|
149 |
m_symbol=symbolRectangle; |
150 |
break;
|
151 |
|
152 |
case (LINE):
|
153 |
FSymbol symbolLine= new FSymbol(FConstant.SYMBOL_TYPE_LINE, m_color);
|
154 |
m_symbol=symbolLine; |
155 |
break;
|
156 |
|
157 |
case (POLYLINE):
|
158 |
FSymbol symbolPolyline= new FSymbol(FConstant.SYMBOL_TYPE_LINE, m_color);
|
159 |
m_symbol=symbolPolyline; |
160 |
break;
|
161 |
|
162 |
case (POLYGON):
|
163 |
FSymbol symbolPolygon= new FSymbol(FConstant.SYMBOL_TYPE_FILL, m_color);
|
164 |
symbolPolygon.setStyle(FConstant.SYMBOL_STYLE_FILL_SOLID); |
165 |
symbolPolygon.setOutlined(true);
|
166 |
symbolPolygon.setOutlineColor(m_color); |
167 |
symbolPolygon.setColor(null);
|
168 |
m_symbol=symbolPolygon; |
169 |
break;
|
170 |
|
171 |
case (CIRCLE):
|
172 |
FSymbol symbolCircle= new FSymbol(FConstant.SYMBOL_TYPE_FILL, m_color);
|
173 |
symbolCircle.setStyle(FConstant.SYMBOL_STYLE_FILL_SOLID); |
174 |
symbolCircle.setOutlined(true);
|
175 |
symbolCircle.setOutlineColor(m_color); |
176 |
symbolCircle.setColor(null);
|
177 |
m_symbol=symbolCircle; |
178 |
break;
|
179 |
} |
180 |
} |
181 |
|
182 |
/**
|
183 |
* Devuelve el FSymbol que se representa.
|
184 |
*
|
185 |
* @return DOCUMENT ME!
|
186 |
*/
|
187 |
public ISymbol getFSymbol() {
|
188 |
return m_symbol;
|
189 |
} |
190 |
|
191 |
/**
|
192 |
* Rellena el FSymbol que se representara al dibujar.
|
193 |
*
|
194 |
* @param fs2d
|
195 |
*/
|
196 |
public void setFSymbol(ISymbol symbol) { |
197 |
m_symbol = symbol; |
198 |
} |
199 |
|
200 |
/**
|
201 |
* M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
|
202 |
* la transformada afin que se debe de aplicar y el rect?ngulo que se debe
|
203 |
* de dibujar.
|
204 |
*
|
205 |
* @param g Graphics
|
206 |
* @param at Transformada afin.
|
207 |
* @param rv rect?ngulo sobre el que hacer un clip.
|
208 |
* @param imgBase DOCUMENT ME!
|
209 |
*/
|
210 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
211 |
BufferedImage imgBase) {
|
212 |
Rectangle2D.Double rect = getBoundingBox(at);
|
213 |
g.rotate(Math.toRadians(getRotation()), rect.x + (rect.width / 2), |
214 |
rect.y + (rect.height / 2));
|
215 |
|
216 |
if (intersects(rv, rect)) {
|
217 |
g.setColor(Color.black);
|
218 |
|
219 |
if (m_type == POINT) {
|
220 |
((FSymbol)m_symbol).setSize((int) (rect.getWidth() * 0.7)); |
221 |
} |
222 |
float stroke=0; |
223 |
if (((FSymbol)m_symbol).getStroke() != null) { |
224 |
stroke=((BasicStroke)((FSymbol)m_symbol).getStroke()).getLineWidth();
|
225 |
BasicStroke basicStroke = new BasicStroke((float)FLayoutUtilities.fromSheetDistance(stroke,at)/100); |
226 |
((FSymbol)m_symbol).setStroke(basicStroke); |
227 |
} |
228 |
|
229 |
geometry.draw(g, at, m_symbol); |
230 |
|
231 |
if (((FSymbol)m_symbol).getStroke() != null) { |
232 |
BasicStroke basicStroke = new BasicStroke(stroke); |
233 |
((FSymbol)m_symbol).setStroke(basicStroke); |
234 |
} |
235 |
|
236 |
if (editing) {
|
237 |
g.setColor(Color.red);
|
238 |
geometry.drawVertex(g, at); |
239 |
} |
240 |
} |
241 |
|
242 |
g.rotate(Math.toRadians(-getRotation()), rect.x + (rect.width / 2), |
243 |
rect.y + (rect.height / 2));
|
244 |
} |
245 |
|
246 |
/**
|
247 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getXMLEntity()
|
248 |
*/
|
249 |
public XMLEntity getXMLEntity() throws SaveException { |
250 |
XMLEntity xml = super.getXMLEntity();
|
251 |
|
252 |
try {
|
253 |
// xml.putProperty("type", Layout.GRAPHICS);
|
254 |
xml.putProperty("m_type", m_type);
|
255 |
xml.addChild(m_symbol.getXMLEntity()); |
256 |
if (geometry!=null) { |
257 |
xml.addChild(geometry.getXMLEntity()); |
258 |
} |
259 |
// xml.addChild(geometryEdit.getXMLEntity());
|
260 |
} catch (Exception e) { |
261 |
throw new SaveException(e, this.getClass().getName()); |
262 |
} |
263 |
|
264 |
return xml;
|
265 |
} |
266 |
|
267 |
/**
|
268 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#updateNum()
|
269 |
*/
|
270 |
public void updateNum() { |
271 |
} |
272 |
|
273 |
/**
|
274 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getNum()
|
275 |
*/
|
276 |
public int getNum() { |
277 |
return 0; |
278 |
} |
279 |
|
280 |
/**
|
281 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
282 |
* com.iver.cit.gvsig.project.Project)
|
283 |
*/
|
284 |
public void setXMLEntity(XMLEntity xml) { |
285 |
m_Selected = xml.getIntProperty("m_Selected");
|
286 |
|
287 |
setRotation(xml.getDoubleProperty("m_rotation"));
|
288 |
m_symbol = FSymbol.createFromXML(xml.getChild(0));
|
289 |
if (xml.contains("m_type")) { |
290 |
m_type = xml.getIntProperty("m_type");
|
291 |
// return;
|
292 |
} |
293 |
if (m_type==RECTANGLESYMBOL)
|
294 |
return;
|
295 |
if (xml.getChildrenCount() ==1) { |
296 |
Rectangle2D r = (Rectangle2D) getBoundBox().clone(); |
297 |
|
298 |
if (m_type == LINE) {
|
299 |
geometry = new PolyLineAdapter();
|
300 |
} else if (m_type == RECTANGLE || |
301 |
m_type == RECTANGLEGROUP) { |
302 |
geometry = new RectangleAdapter();
|
303 |
geometry.addPoint(new Point2D.Double(r.getX(), r.getY())); |
304 |
geometry.addPoint(new Point2D.Double(r.getMaxX(), r.getMaxY())); |
305 |
} else if (m_type == POLYLINE) { |
306 |
geometry = new PolyLineAdapter();
|
307 |
} else if (m_type == POLYGON) { |
308 |
geometry = new PolygonAdapter();
|
309 |
} else if (m_type == CIRCLE) { |
310 |
geometry = new CircleAdapter();
|
311 |
geometry.addPoint(new Point2D.Double(r.getCenterX(), |
312 |
r.getCenterY())); |
313 |
|
314 |
if (r.getWidth() < r.getHeight()) {
|
315 |
geometry.addPoint(new Point2D.Double(r.getMaxX(), |
316 |
r.getCenterY())); |
317 |
} else {
|
318 |
geometry.addPoint(new Point2D.Double(r.getCenterX(), |
319 |
r.getY())); |
320 |
} |
321 |
} else if (m_type == POINT) { |
322 |
geometry = new PointAdapter();
|
323 |
geometry.addPoint(new Point2D.Double(r.getCenterX(), |
324 |
r.getCenterY())); |
325 |
} |
326 |
|
327 |
geometry.end(); |
328 |
} else {
|
329 |
geometry = GeometryAdapter.createFromXML(xml.getChild(1));
|
330 |
// geometryEdit = GeometryAdapter.createFromXML(xml.getChild(2));
|
331 |
} |
332 |
} |
333 |
|
334 |
/**
|
335 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
336 |
* com.iver.cit.gvsig.project.Project)
|
337 |
*/
|
338 |
public void setXMLEntity03(XMLEntity xml, Layout p) { |
339 |
m_Selected = xml.getIntProperty("m_Selected");
|
340 |
m_type = xml.getIntProperty("m_type");
|
341 |
m_symbol = FSymbol.createFromXML03(xml.getChild(0));
|
342 |
|
343 |
Rectangle2D r = (Rectangle2D) getBoundBox().clone(); |
344 |
|
345 |
if (m_type == LINE) {
|
346 |
geometry = new PolyLineAdapter();
|
347 |
} else if (m_type == RECTANGLE) { |
348 |
geometry = new RectangleAdapter();
|
349 |
geometry.addPoint(new Point2D.Double(r.getX(), r.getY())); |
350 |
geometry.addPoint(new Point2D.Double(r.getMaxX(), r.getMaxY())); |
351 |
} else if (m_type == POLYLINE) { |
352 |
geometry = new PolyLineAdapter();
|
353 |
} else if (m_type == POLYGON) { |
354 |
geometry = new PolygonAdapter();
|
355 |
} else if (m_type == CIRCLE) { |
356 |
geometry = new CircleAdapter();
|
357 |
geometry.addPoint(new Point2D.Double(r.getCenterX(), r.getCenterY())); |
358 |
|
359 |
if (r.getWidth() < r.getHeight()) {
|
360 |
geometry.addPoint(new Point2D.Double(r.getMaxX(), r.getCenterY())); |
361 |
} else {
|
362 |
geometry.addPoint(new Point2D.Double(r.getCenterX(), r.getY())); |
363 |
} |
364 |
} else if (m_type == POINT) { |
365 |
geometry = new PointAdapter();
|
366 |
geometry.addPoint(new Point2D.Double(r.getCenterX(), r.getCenterY())); |
367 |
} |
368 |
|
369 |
geometry.end(); |
370 |
} |
371 |
|
372 |
/**
|
373 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getNameFFrame()
|
374 |
*/
|
375 |
public String getNameFFrame() { |
376 |
return PluginServices.getText(this, "Graficos")+ num; |
377 |
} |
378 |
|
379 |
/**
|
380 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#print(java.awt.Graphics2D,
|
381 |
* java.awt.geom.AffineTransform)
|
382 |
*/
|
383 |
public void print(Graphics2D g, AffineTransform at) |
384 |
throws DriverException {
|
385 |
draw(g, at, null, null); |
386 |
} |
387 |
|
388 |
/**
|
389 |
* Inserta el tama?o del punto.
|
390 |
*
|
391 |
* @param size entero que representa el tama?o del punto.
|
392 |
*/
|
393 |
public void setSize(double size) { |
394 |
this.size = size;
|
395 |
if (m_type==RECTANGLESYMBOL) {
|
396 |
return;
|
397 |
} |
398 |
Rectangle2D r = geometry.getBounds2D();
|
399 |
super.setBoundBox(new Rectangle2D.Double(r.getX() - size, |
400 |
r.getY() - size, size * 2, size * 2)); |
401 |
} |
402 |
|
403 |
/**
|
404 |
* Devuelve el tipo de gr?fico que contiene el fframe.
|
405 |
*
|
406 |
* @return tipo de
|
407 |
*/
|
408 |
public int getType() { |
409 |
return m_type;
|
410 |
} |
411 |
public void setType(int type) { |
412 |
m_type = type; |
413 |
} |
414 |
/**
|
415 |
* DOCUMENT ME!
|
416 |
*
|
417 |
* @param r DOCUMENT ME!
|
418 |
*/
|
419 |
public void setBoundBox(Rectangle2D r) { |
420 |
if (m_type==RECTANGLESYMBOL) {
|
421 |
super.setBoundBox(r);
|
422 |
return;
|
423 |
} |
424 |
AffineTransform aT = new AffineTransform(); |
425 |
|
426 |
if (getBoundBox().getWidth() != 0) { |
427 |
double w = r.getWidth() / getBoundBox().getWidth();
|
428 |
double h = r.getHeight() / getBoundBox().getHeight();
|
429 |
|
430 |
AffineTransform trans2 = AffineTransform.getTranslateInstance(r.getX(), |
431 |
r.getY()); |
432 |
aT.concatenate(trans2); |
433 |
|
434 |
AffineTransform scale1 = AffineTransform.getScaleInstance(w, h); |
435 |
aT.concatenate(scale1); |
436 |
|
437 |
AffineTransform trans1 = AffineTransform.getTranslateInstance(-getBoundBox() |
438 |
.getX(), |
439 |
-getBoundBox().getY()); |
440 |
aT.concatenate(trans1); |
441 |
geometry.applyTransform(aT); |
442 |
|
443 |
size = aT.getScaleX() * size; |
444 |
} |
445 |
|
446 |
super.setBoundBox(r);
|
447 |
} |
448 |
|
449 |
/**
|
450 |
* DOCUMENT ME!
|
451 |
*/
|
452 |
public void startEditing() { |
453 |
editing = true;
|
454 |
} |
455 |
|
456 |
/**
|
457 |
* DOCUMENT ME!
|
458 |
*/
|
459 |
public void stopEditing() { |
460 |
editing = false;
|
461 |
} |
462 |
|
463 |
/**
|
464 |
* DOCUMENT ME!
|
465 |
*
|
466 |
* @return DOCUMENT ME!
|
467 |
*/
|
468 |
public boolean isEditing() { |
469 |
return editing;
|
470 |
} |
471 |
|
472 |
/**
|
473 |
* DOCUMENT ME!
|
474 |
*
|
475 |
* @param point DOCUMENT ME!
|
476 |
* @param geom DOCUMENT ME!
|
477 |
*/
|
478 |
public void pointReleased(Point2D point, GeometryAdapter geom) { |
479 |
index.clear(); |
480 |
geometry = geom; |
481 |
|
482 |
Rectangle2D r = geometry.getBounds2D();
|
483 |
super.setBoundBox(r);
|
484 |
} |
485 |
|
486 |
/**
|
487 |
* DOCUMENT ME!
|
488 |
*
|
489 |
* @param point DOCUMENT ME!
|
490 |
*/
|
491 |
public void pointPressed(Point2D point) { |
492 |
Rectangle2D.Double rect = getBoundBox();
|
493 |
Point2D[] points = geometry.getPoints(); |
494 |
geometryEdit = geometry.cloneAdapter();//GeometryAdapter.createFromXML(geometry.getXMLEntity());
|
495 |
|
496 |
Point2D pAux1 = new Point2D.Double(); |
497 |
index.clear(); |
498 |
for (int i = 0; i < points.length; i++) { |
499 |
if (getRotation() != 0) { |
500 |
AffineTransform af = AffineTransform.getRotateInstance(Math.toRadians( |
501 |
-getRotation()), rect.x + (rect.width / 2),
|
502 |
rect.y + (rect.height / 2));
|
503 |
af.transform(point, pAux1); |
504 |
|
505 |
if (points[i].distance(pAux1) <= TOL) {
|
506 |
index.set(i); |
507 |
} |
508 |
} else {
|
509 |
if (points[i].distance(point) <= TOL) {
|
510 |
index.set(i); |
511 |
} |
512 |
} |
513 |
} |
514 |
} |
515 |
|
516 |
/**
|
517 |
* DOCUMENT ME!
|
518 |
*
|
519 |
* @param point DOCUMENT ME!
|
520 |
*/
|
521 |
public void pointDragged(Point2D point) { |
522 |
//Point2D[] points = geometry.getPoints();
|
523 |
|
524 |
for (int j = index.nextSetBit(0); j >= 0; |
525 |
j = index.nextSetBit(j + 1)) {
|
526 |
if (getRotation() != 0) { |
527 |
Rectangle2D.Double rect = getBoundBox();
|
528 |
AffineTransform af = AffineTransform.getRotateInstance(Math.toRadians( |
529 |
-getRotation()), rect.x + (rect.width / 2),
|
530 |
rect.y + (rect.height / 2));
|
531 |
af.transform(point, point); |
532 |
} |
533 |
|
534 |
//points[j] = new Point2D.Double(point.getX(), point.getY());
|
535 |
geometryEdit.changePoint(j,point); |
536 |
} |
537 |
//geometryEdit.setPoints(points);
|
538 |
geometryEdit.end(); |
539 |
} |
540 |
|
541 |
/**
|
542 |
* DOCUMENT ME!
|
543 |
*
|
544 |
* @param g DOCUMENT ME!
|
545 |
* @param at DOCUMENT ME!
|
546 |
*/
|
547 |
public void paint(Graphics2D g, AffineTransform at) { |
548 |
if (geometryEdit != null) { |
549 |
Rectangle2D.Double rect = getBoundingBox(at);
|
550 |
if (getRotation()!=0){ |
551 |
g.rotate(Math.toRadians(getRotation()), rect.x + (rect.width / 2), |
552 |
rect.y + (rect.height / 2));
|
553 |
geometryEdit.paint(g,at,false);
|
554 |
/* FShape m_shape = null;
|
555 |
GeneralPathX polyLine = new GeneralPathX(geometryEdit.getShape());
|
556 |
polyLine.transform(at);
|
557 |
m_shape = new FPolyline2D(polyLine);
|
558 |
FGraphicUtilities.DrawShape(g, mT, m_shape, m_symbol);
|
559 |
*/
|
560 |
g.rotate(Math.toRadians(-getRotation()), rect.x + (rect.width / 2), |
561 |
rect.y + (rect.height / 2));
|
562 |
}else{
|
563 |
geometryEdit.paint(g,at,false);
|
564 |
} |
565 |
} |
566 |
} |
567 |
|
568 |
/**
|
569 |
* DOCUMENT ME!
|
570 |
*
|
571 |
* @return DOCUMENT ME!
|
572 |
*/
|
573 |
public GeometryAdapter getGeometry() {
|
574 |
return geometryEdit;
|
575 |
} |
576 |
|
577 |
public void initialize() { |
578 |
// TODO Auto-generated method stub
|
579 |
|
580 |
} |
581 |
/**
|
582 |
* Devuelve un entero que representa donde esta contenido el punto que se
|
583 |
* pasa como par?metro.
|
584 |
*
|
585 |
* @param p punto a comparar.
|
586 |
*
|
587 |
* @return entero que representa como esta contenido el punto.
|
588 |
*/
|
589 |
public int getContains(Point2D p) { |
590 |
if (geometry instanceof CircleAdapter) { |
591 |
if (ne.contains(p.getX(), p.getY())) {
|
592 |
return NE;
|
593 |
} else if (se.contains(p.getX(), p.getY())) { |
594 |
return SE;
|
595 |
} else if (so.contains(p.getX(), p.getY())) { |
596 |
return SO;
|
597 |
} else if (no.contains(p.getX(), p.getY())) { |
598 |
return NO;
|
599 |
} else if (getBoundingBox(null).contains(p.getX(), p.getY())) { |
600 |
return RECT;
|
601 |
} |
602 |
return NOSELECT;
|
603 |
} |
604 |
return super.getContains(p); |
605 |
} |
606 |
|
607 |
/**
|
608 |
* Dibuja los handlers sobre el boundingBox en el graphics que se pasa como
|
609 |
* par?metro.
|
610 |
*
|
611 |
* @param g
|
612 |
* Graphics sobre el que dibujar.
|
613 |
*/
|
614 |
public void drawHandlers(Graphics2D g) { |
615 |
if (geometry instanceof CircleAdapter) { |
616 |
int size = 10; |
617 |
Rectangle2D r = getBoundingBox(null); |
618 |
Point2D p = new Point2D.Double(); |
619 |
g.rotate(Math.toRadians(getRotation()), r.getX()
|
620 |
+ (r.getWidth() / 2), r.getY() + (r.getHeight() / 2)); |
621 |
|
622 |
AffineTransform atRotate = new AffineTransform(); |
623 |
atRotate.rotate(Math.toRadians(getRotation()), r.getX()
|
624 |
+ (r.getWidth() / 2), r.getY() + (r.getHeight() / 2)); |
625 |
|
626 |
g.fillRect((int) r.getX() - size, (int) r.getY() - size, |
627 |
size, size); |
628 |
atRotate.transform(new Point2D.Double(r.getX() - size, r.getY() |
629 |
- size), p); |
630 |
no.setRect((int) p.getX(), (int) p.getY(), size, size); |
631 |
|
632 |
g.fillRect((int) r.getMaxX(), (int) r.getY() - size, size, size); |
633 |
atRotate.transform( |
634 |
new Point2D.Double(r.getMaxX(), r.getY() - size), p); |
635 |
ne.setRect((int) p.getX(), (int) p.getY(), size, size); |
636 |
|
637 |
g.fillRect((int) r.getX() - size, (int) r.getMaxY(), size, size); |
638 |
atRotate.transform( |
639 |
new Point2D.Double(r.getX() - size, r.getMaxY()), p); |
640 |
so.setRect((int) p.getX(), (int) p.getY(), size, size); |
641 |
|
642 |
g.fillRect((int) r.getMaxX(), (int) r.getMaxY(), size, size); |
643 |
atRotate.transform(new Point2D.Double(r.getMaxX(), r.getMaxY()), p); |
644 |
se.setRect((int) p.getX(), (int) p.getY(), size, size); |
645 |
|
646 |
g.rotate(Math.toRadians(-getRotation()), r.getX()
|
647 |
+ (r.getWidth() / 2), r.getY() + (r.getHeight() / 2)); |
648 |
} |
649 |
else
|
650 |
super.drawHandlers(g);
|
651 |
} |
652 |
|
653 |
public void cloneActions(IFFrame frame) { |
654 |
// TODO Auto-generated method stub
|
655 |
|
656 |
} |
657 |
|
658 |
public IFFrameDialog getPropertyDialog() {
|
659 |
return new FFrameGraphicsDialog(getLayout(),this); |
660 |
} |
661 |
|
662 |
} |