svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / fframes / FFrameGraphics.java @ 10626
History | View | Annotate | Download (21.6 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.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 com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
56 |
import com.iver.andami.PluginServices; |
57 |
import com.iver.cit.gvsig.fmap.core.FShape; |
58 |
import com.iver.cit.gvsig.fmap.core.adapter.CircleAdapter; |
59 |
import com.iver.cit.gvsig.fmap.core.adapter.GeometryAdapter; |
60 |
import com.iver.cit.gvsig.fmap.core.adapter.PointAdapter; |
61 |
import com.iver.cit.gvsig.fmap.core.adapter.PolyLineAdapter; |
62 |
import com.iver.cit.gvsig.fmap.core.adapter.PolygonAdapter; |
63 |
import com.iver.cit.gvsig.fmap.core.adapter.RectangleAdapter; |
64 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
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) throws ReadDriverException { |
212 |
Rectangle2D.Double rect = getBoundingBox(at);
|
213 |
g.rotate(Math.toRadians(getRotation()), rect.x + (rect.width / 2), |
214 |
rect.y + (rect.height / 2));
|
215 |
if (intersects(rv, rect)) {
|
216 |
g.setColor(Color.black);
|
217 |
|
218 |
if (m_type == POINT) {
|
219 |
((FSymbol)m_symbol).setSize((int) (rect.getWidth() * 0.7)); |
220 |
} |
221 |
// float stroke=0;
|
222 |
// if (((FSymbol)m_symbol).getStroke() != null) {
|
223 |
// stroke=((BasicStroke)((FSymbol)m_symbol).getStroke()).getLineWidth();
|
224 |
// BasicStroke basicStroke = new BasicStroke((float)FLayoutUtilities.fromSheetDistance(stroke,at)/100);
|
225 |
// ((FSymbol)m_symbol).setStroke(basicStroke);
|
226 |
// }
|
227 |
geometry.draw(g, at, m_symbol); |
228 |
|
229 |
// if (((FSymbol)m_symbol).getStroke() != null) {
|
230 |
// BasicStroke basicStroke = new BasicStroke(stroke);
|
231 |
// ((FSymbol)m_symbol).setStroke(basicStroke);
|
232 |
// }
|
233 |
|
234 |
if (editing) {
|
235 |
g.setColor(Color.red);
|
236 |
geometry.drawVertex(g, at); |
237 |
} |
238 |
} |
239 |
|
240 |
g.rotate(Math.toRadians(-getRotation()), rect.x + (rect.width / 2), |
241 |
rect.y + (rect.height / 2));
|
242 |
} |
243 |
|
244 |
/**
|
245 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getXMLEntity()
|
246 |
*/
|
247 |
public XMLEntity getXMLEntity() throws SaveException { |
248 |
XMLEntity xml = super.getXMLEntity();
|
249 |
|
250 |
try {
|
251 |
// xml.putProperty("type", Layout.GRAPHICS);
|
252 |
xml.putProperty("m_type", m_type);
|
253 |
xml.addChild(m_symbol.getXMLEntity()); |
254 |
if (geometry!=null) { |
255 |
xml.addChild(geometry.getXMLEntity()); |
256 |
} |
257 |
// xml.addChild(geometryEdit.getXMLEntity());
|
258 |
} catch (Exception e) { |
259 |
throw new SaveException(e, this.getClass().getName()); |
260 |
} |
261 |
|
262 |
return xml;
|
263 |
} |
264 |
|
265 |
/**
|
266 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#updateNum()
|
267 |
*/
|
268 |
public void updateNum() { |
269 |
} |
270 |
|
271 |
/**
|
272 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getNum()
|
273 |
*/
|
274 |
public int getNum() { |
275 |
return 0; |
276 |
} |
277 |
|
278 |
/**
|
279 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
280 |
* com.iver.cit.gvsig.project.Project)
|
281 |
*/
|
282 |
public void setXMLEntity(XMLEntity xml) { |
283 |
m_Selected = xml.getIntProperty("m_Selected");
|
284 |
|
285 |
setRotation(xml.getDoubleProperty("m_rotation"));
|
286 |
m_symbol = FSymbol.createFromXML(xml.getChild(0));
|
287 |
if (xml.contains("m_type")) { |
288 |
m_type = xml.getIntProperty("m_type");
|
289 |
// return;
|
290 |
} |
291 |
if (m_type==RECTANGLESYMBOL)
|
292 |
return;
|
293 |
if (xml.getChildrenCount() ==1) { |
294 |
Rectangle2D r = (Rectangle2D) getBoundBox().clone(); |
295 |
|
296 |
if (m_type == LINE) {
|
297 |
geometry = new PolyLineAdapter();
|
298 |
} else if (m_type == RECTANGLE || |
299 |
m_type == RECTANGLEGROUP) { |
300 |
geometry = new RectangleAdapter();
|
301 |
geometry.addPoint(new Point2D.Double(r.getX(), r.getY())); |
302 |
geometry.addPoint(new Point2D.Double(r.getMaxX(), r.getMaxY())); |
303 |
} else if (m_type == POLYLINE) { |
304 |
geometry = new PolyLineAdapter();
|
305 |
} else if (m_type == POLYGON) { |
306 |
geometry = new PolygonAdapter();
|
307 |
} else if (m_type == CIRCLE) { |
308 |
geometry = new CircleAdapter();
|
309 |
geometry.addPoint(new Point2D.Double(r.getCenterX(), |
310 |
r.getCenterY())); |
311 |
|
312 |
if (r.getWidth() < r.getHeight()) {
|
313 |
geometry.addPoint(new Point2D.Double(r.getMaxX(), |
314 |
r.getCenterY())); |
315 |
} else {
|
316 |
geometry.addPoint(new Point2D.Double(r.getCenterX(), |
317 |
r.getY())); |
318 |
} |
319 |
} else if (m_type == POINT) { |
320 |
geometry = new PointAdapter();
|
321 |
geometry.addPoint(new Point2D.Double(r.getCenterX(), |
322 |
r.getCenterY())); |
323 |
} |
324 |
|
325 |
geometry.end(); |
326 |
} else {
|
327 |
geometry = GeometryAdapter.createFromXML(xml.getChild(1));
|
328 |
// geometryEdit = GeometryAdapter.createFromXML(xml.getChild(2));
|
329 |
} |
330 |
} |
331 |
|
332 |
/**
|
333 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
334 |
* com.iver.cit.gvsig.project.Project)
|
335 |
*/
|
336 |
public void setXMLEntity03(XMLEntity xml, Layout p) { |
337 |
m_Selected = xml.getIntProperty("m_Selected");
|
338 |
m_type = xml.getIntProperty("m_type");
|
339 |
m_symbol = FSymbol.createFromXML03(xml.getChild(0));
|
340 |
|
341 |
Rectangle2D r = (Rectangle2D) getBoundBox().clone(); |
342 |
|
343 |
if (m_type == LINE) {
|
344 |
geometry = new PolyLineAdapter();
|
345 |
} else if (m_type == RECTANGLE) { |
346 |
geometry = new RectangleAdapter();
|
347 |
geometry.addPoint(new Point2D.Double(r.getX(), r.getY())); |
348 |
geometry.addPoint(new Point2D.Double(r.getMaxX(), r.getMaxY())); |
349 |
} else if (m_type == POLYLINE) { |
350 |
geometry = new PolyLineAdapter();
|
351 |
} else if (m_type == POLYGON) { |
352 |
geometry = new PolygonAdapter();
|
353 |
} else if (m_type == CIRCLE) { |
354 |
geometry = new CircleAdapter();
|
355 |
geometry.addPoint(new Point2D.Double(r.getCenterX(), r.getCenterY())); |
356 |
|
357 |
if (r.getWidth() < r.getHeight()) {
|
358 |
geometry.addPoint(new Point2D.Double(r.getMaxX(), r.getCenterY())); |
359 |
} else {
|
360 |
geometry.addPoint(new Point2D.Double(r.getCenterX(), r.getY())); |
361 |
} |
362 |
} else if (m_type == POINT) { |
363 |
geometry = new PointAdapter();
|
364 |
geometry.addPoint(new Point2D.Double(r.getCenterX(), r.getCenterY())); |
365 |
} |
366 |
|
367 |
geometry.end(); |
368 |
} |
369 |
|
370 |
/**
|
371 |
* @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getNameFFrame()
|
372 |
*/
|
373 |
public String getNameFFrame() { |
374 |
return PluginServices.getText(this, "Graficos")+ num; |
375 |
} |
376 |
|
377 |
/**
|
378 |
* Inserta el tama?o del punto.
|
379 |
*
|
380 |
* @param size entero que representa el tama?o del punto.
|
381 |
*/
|
382 |
public void setSize(double size) { |
383 |
this.size = size;
|
384 |
if (m_type==RECTANGLESYMBOL) {
|
385 |
return;
|
386 |
} |
387 |
Rectangle2D r = geometry.getBounds2D();
|
388 |
super.setBoundBox(new Rectangle2D.Double(r.getX() - size, |
389 |
r.getY() - size, size * 2, size * 2)); |
390 |
} |
391 |
|
392 |
/**
|
393 |
* Devuelve el tipo de gr?fico que contiene el fframe.
|
394 |
*
|
395 |
* @return tipo de
|
396 |
*/
|
397 |
public int getType() { |
398 |
return m_type;
|
399 |
} |
400 |
public void setType(int type) { |
401 |
m_type = type; |
402 |
} |
403 |
/**
|
404 |
* DOCUMENT ME!
|
405 |
*
|
406 |
* @param r DOCUMENT ME!
|
407 |
*/
|
408 |
public void setBoundBox(Rectangle2D r) { |
409 |
if (m_type==RECTANGLESYMBOL) {
|
410 |
super.setBoundBox(r);
|
411 |
return;
|
412 |
} |
413 |
AffineTransform aT = new AffineTransform(); |
414 |
|
415 |
if (getBoundBox().getWidth() != 0) { |
416 |
double w = r.getWidth() / getBoundBox().getWidth();
|
417 |
double h = r.getHeight() / getBoundBox().getHeight();
|
418 |
|
419 |
AffineTransform trans2 = AffineTransform.getTranslateInstance(r.getX(), |
420 |
r.getY()); |
421 |
aT.concatenate(trans2); |
422 |
|
423 |
AffineTransform scale1 = AffineTransform.getScaleInstance(w, h); |
424 |
aT.concatenate(scale1); |
425 |
|
426 |
AffineTransform trans1 = AffineTransform.getTranslateInstance(-getBoundBox() |
427 |
.getX(), |
428 |
-getBoundBox().getY()); |
429 |
aT.concatenate(trans1); |
430 |
geometry.applyTransform(aT); |
431 |
|
432 |
size = aT.getScaleX() * size; |
433 |
} |
434 |
|
435 |
super.setBoundBox(r);
|
436 |
} |
437 |
|
438 |
/**
|
439 |
* DOCUMENT ME!
|
440 |
*/
|
441 |
public void startEditing() { |
442 |
editing = true;
|
443 |
} |
444 |
|
445 |
/**
|
446 |
* DOCUMENT ME!
|
447 |
*/
|
448 |
public void stopEditing() { |
449 |
editing = false;
|
450 |
} |
451 |
|
452 |
/**
|
453 |
* DOCUMENT ME!
|
454 |
*
|
455 |
* @return DOCUMENT ME!
|
456 |
*/
|
457 |
public boolean isEditing() { |
458 |
return editing;
|
459 |
} |
460 |
|
461 |
/**
|
462 |
* DOCUMENT ME!
|
463 |
*
|
464 |
* @param point DOCUMENT ME!
|
465 |
* @param geom DOCUMENT ME!
|
466 |
*/
|
467 |
public void pointReleased(Point2D point, GeometryAdapter geom) { |
468 |
index.clear(); |
469 |
geometry = geom; |
470 |
|
471 |
Rectangle2D r = geometry.getBounds2D();
|
472 |
super.setBoundBox(r);
|
473 |
} |
474 |
|
475 |
/**
|
476 |
* DOCUMENT ME!
|
477 |
*
|
478 |
* @param point DOCUMENT ME!
|
479 |
*/
|
480 |
public void pointPressed(Point2D point) { |
481 |
Rectangle2D.Double rect = getBoundBox();
|
482 |
Point2D[] points = geometry.getPoints(); |
483 |
geometryEdit = geometry.cloneAdapter();//GeometryAdapter.createFromXML(geometry.getXMLEntity());
|
484 |
|
485 |
Point2D pAux1 = new Point2D.Double(); |
486 |
index.clear(); |
487 |
for (int i = 0; i < points.length; i++) { |
488 |
if (getRotation() != 0) { |
489 |
AffineTransform af = AffineTransform.getRotateInstance(Math.toRadians( |
490 |
-getRotation()), rect.x + (rect.width / 2),
|
491 |
rect.y + (rect.height / 2));
|
492 |
af.transform(point, pAux1); |
493 |
|
494 |
if (points[i].distance(pAux1) <= TOL) {
|
495 |
index.set(i); |
496 |
} |
497 |
} else {
|
498 |
if (points[i].distance(point) <= TOL) {
|
499 |
index.set(i); |
500 |
} |
501 |
} |
502 |
} |
503 |
} |
504 |
|
505 |
/**
|
506 |
* DOCUMENT ME!
|
507 |
*
|
508 |
* @param point DOCUMENT ME!
|
509 |
*/
|
510 |
public void pointDragged(Point2D point) { |
511 |
//Point2D[] points = geometry.getPoints();
|
512 |
|
513 |
for (int j = index.nextSetBit(0); j >= 0; |
514 |
j = index.nextSetBit(j + 1)) {
|
515 |
if (getRotation() != 0) { |
516 |
Rectangle2D.Double rect = getBoundBox();
|
517 |
AffineTransform af = AffineTransform.getRotateInstance(Math.toRadians( |
518 |
-getRotation()), rect.x + (rect.width / 2),
|
519 |
rect.y + (rect.height / 2));
|
520 |
af.transform(point, point); |
521 |
} |
522 |
|
523 |
//points[j] = new Point2D.Double(point.getX(), point.getY());
|
524 |
geometryEdit.changePoint(j,point); |
525 |
} |
526 |
//geometryEdit.setPoints(points);
|
527 |
geometryEdit.end(); |
528 |
} |
529 |
|
530 |
/**
|
531 |
* DOCUMENT ME!
|
532 |
*
|
533 |
* @param g DOCUMENT ME!
|
534 |
* @param at DOCUMENT ME!
|
535 |
*/
|
536 |
public void paint(Graphics2D g, AffineTransform at) { |
537 |
if (geometryEdit != null) { |
538 |
Rectangle2D.Double rect = getBoundingBox(at);
|
539 |
if (getRotation()!=0){ |
540 |
g.rotate(Math.toRadians(getRotation()), rect.x + (rect.width / 2), |
541 |
rect.y + (rect.height / 2));
|
542 |
geometryEdit.paint(g,at,false);
|
543 |
/* FShape m_shape = null;
|
544 |
GeneralPathX polyLine = new GeneralPathX(geometryEdit.getShape());
|
545 |
polyLine.transform(at);
|
546 |
m_shape = new FPolyline2D(polyLine);
|
547 |
FGraphicUtilities.DrawShape(g, mT, m_shape, m_symbol);
|
548 |
*/
|
549 |
g.rotate(Math.toRadians(-getRotation()), rect.x + (rect.width / 2), |
550 |
rect.y + (rect.height / 2));
|
551 |
}else{
|
552 |
geometryEdit.paint(g,at,false);
|
553 |
} |
554 |
} |
555 |
} |
556 |
|
557 |
/**
|
558 |
* DOCUMENT ME!
|
559 |
*
|
560 |
* @return DOCUMENT ME!
|
561 |
*/
|
562 |
public GeometryAdapter getGeometry() {
|
563 |
return geometryEdit;
|
564 |
} |
565 |
|
566 |
public void initialize() { |
567 |
// TODO Auto-generated method stub
|
568 |
|
569 |
} |
570 |
/**
|
571 |
* Devuelve un entero que representa donde esta contenido el punto que se
|
572 |
* pasa como par?metro.
|
573 |
*
|
574 |
* @param p punto a comparar.
|
575 |
*
|
576 |
* @return entero que representa como esta contenido el punto.
|
577 |
*/
|
578 |
public int getContains(Point2D p) { |
579 |
if (geometry instanceof CircleAdapter) { |
580 |
if (ne.contains(p.getX(), p.getY())) {
|
581 |
return NE;
|
582 |
} else if (se.contains(p.getX(), p.getY())) { |
583 |
return SE;
|
584 |
} else if (so.contains(p.getX(), p.getY())) { |
585 |
return SO;
|
586 |
} else if (no.contains(p.getX(), p.getY())) { |
587 |
return NO;
|
588 |
} else if (getBoundingBox(null).contains(p.getX(), p.getY())) { |
589 |
return RECT;
|
590 |
} |
591 |
return NOSELECT;
|
592 |
} |
593 |
return super.getContains(p); |
594 |
} |
595 |
|
596 |
/**
|
597 |
* Dibuja los handlers sobre el boundingBox en el graphics que se pasa como
|
598 |
* par?metro.
|
599 |
*
|
600 |
* @param g
|
601 |
* Graphics sobre el que dibujar.
|
602 |
*/
|
603 |
public void drawHandlers(Graphics2D g) { |
604 |
if (geometry instanceof CircleAdapter) { |
605 |
int size = 10; |
606 |
Rectangle2D r = getBoundingBox(null); |
607 |
Point2D p = new Point2D.Double(); |
608 |
g.rotate(Math.toRadians(getRotation()), r.getX()
|
609 |
+ (r.getWidth() / 2), r.getY() + (r.getHeight() / 2)); |
610 |
|
611 |
AffineTransform atRotate = new AffineTransform(); |
612 |
atRotate.rotate(Math.toRadians(getRotation()), r.getX()
|
613 |
+ (r.getWidth() / 2), r.getY() + (r.getHeight() / 2)); |
614 |
|
615 |
g.fillRect((int) r.getX() - size, (int) r.getY() - size, |
616 |
size, size); |
617 |
atRotate.transform(new Point2D.Double(r.getX() - size, r.getY() |
618 |
- size), p); |
619 |
no.setRect((int) p.getX(), (int) p.getY(), size, size); |
620 |
|
621 |
g.fillRect((int) r.getMaxX(), (int) r.getY() - size, size, size); |
622 |
atRotate.transform( |
623 |
new Point2D.Double(r.getMaxX(), r.getY() - size), p); |
624 |
ne.setRect((int) p.getX(), (int) p.getY(), size, size); |
625 |
|
626 |
g.fillRect((int) r.getX() - size, (int) r.getMaxY(), size, size); |
627 |
atRotate.transform( |
628 |
new Point2D.Double(r.getX() - size, r.getMaxY()), p); |
629 |
so.setRect((int) p.getX(), (int) p.getY(), size, size); |
630 |
|
631 |
g.fillRect((int) r.getMaxX(), (int) r.getMaxY(), size, size); |
632 |
atRotate.transform(new Point2D.Double(r.getMaxX(), r.getMaxY()), p); |
633 |
se.setRect((int) p.getX(), (int) p.getY(), size, size); |
634 |
|
635 |
g.rotate(Math.toRadians(-getRotation()), r.getX()
|
636 |
+ (r.getWidth() / 2), r.getY() + (r.getHeight() / 2)); |
637 |
} |
638 |
else
|
639 |
super.drawHandlers(g);
|
640 |
} |
641 |
|
642 |
public void cloneActions(IFFrame frame) { |
643 |
// TODO Auto-generated method stub
|
644 |
|
645 |
} |
646 |
|
647 |
public IFFrameDialog getPropertyDialog() {
|
648 |
return new FFrameGraphicsDialog(getLayout(),this); |
649 |
} |
650 |
|
651 |
public void print(Graphics2D g, AffineTransform at, FShape shape) throws ReadDriverException { |
652 |
Rectangle2D.Double rect = getBoundingBox(at);
|
653 |
g.rotate(Math.toRadians(getRotation()), rect.x + (rect.width / 2), |
654 |
rect.y + (rect.height / 2));
|
655 |
g.setColor(Color.black);
|
656 |
|
657 |
if (m_type == POINT) {
|
658 |
((FSymbol)m_symbol).setSize((int) (rect.getWidth() * 0.7)); |
659 |
} |
660 |
m_symbol.setPrintingProperties(printingProperties); |
661 |
geometry.draw(g, at, m_symbol); |
662 |
m_symbol.setPrintingProperties(null);
|
663 |
g.rotate(Math.toRadians(-getRotation()), rect.x + (rect.width / 2), |
664 |
rect.y + (rect.height / 2));
|
665 |
} |
666 |
|
667 |
|
668 |
} |