Revision 1822 branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/Layout.java
Layout.java | ||
---|---|---|
59 | 59 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
60 | 60 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
61 | 61 |
import com.iver.cit.gvsig.gui.cad.CADToolAdapter; |
62 |
import com.iver.cit.gvsig.gui.cad.CadGrid; |
|
63 | 62 |
import com.iver.cit.gvsig.gui.cad.CadTool; |
64 | 63 |
import com.iver.cit.gvsig.gui.cad.tools.ArcCadTool; |
65 | 64 |
import com.iver.cit.gvsig.gui.cad.tools.CircleCadTool; |
... | ... | |
72 | 71 |
import com.iver.cit.gvsig.gui.cad.tools.SelectionCadTool; |
73 | 72 |
import com.iver.cit.gvsig.gui.layout.dialogs.FConfigLayoutDialog; |
74 | 73 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrame; |
75 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGraphics;
|
|
74 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGraphic; |
|
76 | 75 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameLegend; |
77 | 76 |
import com.iver.cit.gvsig.gui.layout.fframes.FFramePicture; |
78 | 77 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameScaleBar; |
... | ... | |
106 | 105 |
import java.awt.event.ActionListener; |
107 | 106 |
import java.awt.event.KeyEvent; |
108 | 107 |
import java.awt.geom.AffineTransform; |
109 |
import java.awt.geom.Point2D; |
|
110 | 108 |
import java.awt.geom.Rectangle2D; |
111 | 109 |
import java.awt.image.BufferedImage; |
112 | 110 |
import java.awt.image.MemoryImageSource; |
... | ... | |
114 | 112 |
import java.awt.print.Printable; |
115 | 113 |
import java.awt.print.PrinterException; |
116 | 114 |
import java.awt.print.PrinterJob; |
115 |
|
|
117 | 116 |
import java.io.IOException; |
118 | 117 |
|
119 | 118 |
import java.util.ArrayList; |
120 | 119 |
import java.util.BitSet; |
121 | 120 |
import java.util.HashMap; |
122 | 121 |
import java.util.Hashtable; |
123 |
import java.util.Stack; |
|
124 | 122 |
|
125 | 123 |
import javax.print.Doc; |
126 | 124 |
import javax.print.DocFlavor; |
... | ... | |
164 | 162 |
public static final int RECTANGLE = 10; |
165 | 163 |
public static final int ACTUALIZADO = 11; |
166 | 164 |
public static final int SELECT = 12; |
167 |
//public static final int POINT = 13; |
|
168 |
//public static final int LINE = 14; |
|
169 |
//public static final int POLYLINE = 15; |
|
170 |
//public static final int RECTANGLESIMPLE = 16; |
|
171 |
//public static final int CIRCLE = 17; |
|
172 |
//public static final int POLYGON = 18; |
|
173 | 165 |
public static final int GRAPHICS = 19; |
174 | 166 |
public static final int RECTANGLESYMBOL = 20; |
175 | 167 |
public static final int RECTANGLEGROUP = 21; |
... | ... | |
196 | 188 |
.getResource("images/CruxCursor.png")).getImage(); |
197 | 189 |
public static final Image itag = new ImageIcon(Abrir.class.getClassLoader() |
198 | 190 |
.getResource("images/tagCursor.gif")).getImage(); |
199 |
/*public static final Image iPoint = new ImageIcon(Abrir.class.getClassLoader() |
|
200 |
.getResource("images/PointCursor.png")).getImage(); |
|
201 |
public static final Image iRect = new ImageIcon(Abrir.class.getClassLoader() |
|
202 |
.getResource("images/RectCursor.png")).getImage(); |
|
203 |
public static final Image iLine = new ImageIcon(Abrir.class.getClassLoader() |
|
204 |
.getResource("images/LineCursor.png")).getImage(); |
|
205 |
public static final Image iRectangle = new ImageIcon(Abrir.class.getClassLoader() |
|
206 |
.getResource("images/RectangleCursor.png")).getImage(); |
|
207 |
public static final Image iCircle = new ImageIcon(Abrir.class.getClassLoader() |
|
208 |
.getResource("images/CircleCursor.png")).getImage(); |
|
209 |
public static final Image iPoligon = new ImageIcon(Abrir.class.getClassLoader() |
|
210 |
.getResource("images/PoligonCursor.png")).getImage(); |
|
211 |
*/ |
|
212 | 191 |
public static Hashtable nums = new Hashtable(); |
213 | 192 |
private Point origin = new Point(50, 50); |
214 | 193 |
private Point rectOrigin = new Point(origin); |
... | ... | |
237 | 216 |
private ProjectMap map = null; |
238 | 217 |
private Rectangle reSel = null; |
239 | 218 |
private boolean isReSel = true; |
240 |
|
|
241 |
// private String m_name = null; |
|
219 |
private BitSet validates = new BitSet(); |
|
242 | 220 |
private boolean m_showRuler = true; |
243 | 221 |
private FLayoutDraw layoutPaint = null; |
244 | 222 |
private boolean isDrawCuadricula = true; |
245 | 223 |
private Doc doc = null; |
246 | 224 |
private PrintRequestAttributeSet att = null; |
247 |
//private boolean cadtool = false; |
|
248 | 225 |
private HashMap namesCadTools = new HashMap(); |
249 |
///private LayoutCADToolAdapter cadToolAdapter; |
|
250 |
//private HashMap namesMapTools = new HashMap(); |
|
251 |
//private Stack toolStack = new Stack(); |
|
252 |
private FFrameGraphics fframegraphics; |
|
253 |
private LayoutAdapter ladapter; |
|
254 |
// Menu contextual |
|
226 |
private LayoutCADToolAdapter ladapter; |
|
227 |
|
|
228 |
// Menu contextual |
|
255 | 229 |
private JPopupMenu popup = new JPopupMenu(); |
230 |
|
|
256 | 231 |
/** |
257 | 232 |
* Creates a new Layout object. |
258 | 233 |
*/ |
259 | 234 |
public Layout() { |
260 | 235 |
this.setLayout(null); |
261 |
///cadToolAdapter=new LayoutCADToolAdapter(this); |
|
262 |
|
|
263 |
ladapter=new LayoutAdapter(this); |
|
264 |
fframegraphics=new FFrameGraphics(ladapter.getCADToolAdapter()); |
|
265 |
///addFFrame(fg,true); |
|
236 |
ladapter = new LayoutCADToolAdapter(this); |
|
266 | 237 |
events = new EventsHandler(this); |
267 | 238 |
layoutPaint = new FLayoutDraw(this); |
268 |
FBitSet selection=new FBitSet(); |
|
269 |
getCadToolAdapter().setEditableFeatureSource(new LayoutEditableFeature(this,selection),selection); |
|
239 |
|
|
240 |
FBitSet selection = new FBitSet(); |
|
241 |
getCadToolAdapter().setEditableFeatureSource(new LayoutEditableFeature( |
|
242 |
this, selection), selection); |
|
243 |
|
|
270 | 244 |
try { |
271 | 245 |
getCadToolAdapter().getEditableFeatureSource().startEdition(); |
272 | 246 |
} catch (EditionException e) { |
273 | 247 |
e.printStackTrace(); |
274 | 248 |
} |
249 |
|
|
275 | 250 |
addComponentListener(events); |
276 | 251 |
addMouseMotionListener(events); |
277 | 252 |
addMouseListener(events); |
278 | 253 |
m_MatrizTransf = new AffineTransform(); |
279 | 254 |
m_MatrizTransf.setToIdentity(); |
280 | 255 |
this.initComponents(); |
281 |
|
|
282 |
|
|
283 | 256 |
} |
284 | 257 |
|
285 | 258 |
/** |
... | ... | |
337 | 310 |
public synchronized void setCancelDrawing(boolean b) { |
338 | 311 |
m_bCancelDrawing = b; |
339 | 312 |
|
340 |
for (int i = 0; i < getFFrames().size(); i++) { |
|
341 |
IFFrame fframe = (IFFrame) getFFrames().get(i); |
|
313 |
IFFrame[] frames = getFFrames1(); |
|
342 | 314 |
|
315 |
for (int i = 0; i < frames.length; i++) { |
|
316 |
IFFrame fframe = frames[i]; //(IFFrame) getFFrames().get(i); |
|
317 |
|
|
343 | 318 |
if (fframe instanceof FFrameView && |
344 | 319 |
(((FFrameView) fframe).getFMap() != null)) { |
345 | 320 |
////TODO((FFrameView) getFFrames().get(i)).getFMap().setCancelDrawing(b); |
... | ... | |
352 | 327 |
* |
353 | 328 |
* @return Array con todos los fframes que contiene el Layout. |
354 | 329 |
*/ |
355 |
public ArrayList getFFrames() { |
|
330 |
public IFFrame[] getFFrames1() { |
|
331 |
ArrayList fframes = new ArrayList(); |
|
332 |
|
|
333 |
for (int i = 0; i < getAllFFrames().size(); i++) { |
|
334 |
if (!validates.get(i)) { |
|
335 |
fframes.add(getAllFFrames().get(i)); |
|
336 |
} |
|
337 |
} |
|
338 |
|
|
339 |
return (IFFrame[]) fframes.toArray(new IFFrame[0]); |
|
340 |
} |
|
341 |
|
|
342 |
/** |
|
343 |
* Devuelve todos los FFrames que hay en el Layout los invalidados y los |
|
344 |
* que no. |
|
345 |
* |
|
346 |
* @return ArrayList con todos los FFrames del Layout, incluidos lo que |
|
347 |
* estan invalidados. |
|
348 |
*/ |
|
349 |
public ArrayList getAllFFrames() { |
|
356 | 350 |
return m_fframes; |
357 | 351 |
} |
358 | 352 |
|
359 | 353 |
/** |
354 |
* Inserta la opci?n de valido o no valido a un FFrame a partir de su |
|
355 |
* ?ndice. |
|
356 |
* |
|
357 |
* @param index ?ndice. |
|
358 |
* @param b True si es invalidado. |
|
359 |
*/ |
|
360 |
public void setInvalidate(int index, boolean b) { |
|
361 |
validates.set(index, b); |
|
362 |
} |
|
363 |
|
|
364 |
/** |
|
365 |
* Devuelve si un FFrame es v?lido a partir de su ?ndice. |
|
366 |
* |
|
367 |
* @param index ?ndice del FFrame. |
|
368 |
* |
|
369 |
* @return True si est? invalidado el FFrame que corresponde al ?ndice. |
|
370 |
*/ |
|
371 |
public boolean isInvalidate(int index) { |
|
372 |
return validates.get(index); |
|
373 |
} |
|
374 |
|
|
375 |
/** |
|
360 | 376 |
* Obtiene el rect que se ajusta al tama?o de la ventana, para ver el folio |
361 | 377 |
* entero. |
362 | 378 |
*/ |
... | ... | |
380 | 396 |
* M?todo para imprimir el Layout sin modificar la matriz de |
381 | 397 |
* transformaci?n. |
382 | 398 |
* |
383 |
* @param g2 |
|
399 |
* @param g2 Graphics so bre el que dibujar.
|
|
384 | 400 |
*/ |
385 | 401 |
public void drawLayoutPrint(Graphics2D g2) { |
386 | 402 |
setCancelDrawing(false); |
... | ... | |
388 | 404 |
setCursor(Cursor.getDefaultCursor()); |
389 | 405 |
|
390 | 406 |
double scale = 0; |
391 |
|
|
392 |
///if (rect.width > rect.height) { |
|
393 |
/// scale = rect.width / m_attributes.m_sizePaper.getAlto() * 1; |
|
394 |
///} else { |
|
395 | 407 |
scale = rect.height / m_attributes.m_sizePaper.getAlto() * 1; |
396 | 408 |
|
397 |
///} |
|
398 | 409 |
AffineTransform escalado = new AffineTransform(); |
399 | 410 |
AffineTransform translacion = new AffineTransform(); |
400 | 411 |
translacion.setToTranslation(rect.getMinX(), rect.getMinY()); |
... | ... | |
405 | 416 |
m_attributes.setDistanceUnitX(rect); |
406 | 417 |
m_attributes.setDistanceUnitY(rect); |
407 | 418 |
|
408 |
for (int i = 0; i < getFFrames().size(); i++) { |
|
419 |
IFFrame[] frames = getFFrames1(); |
|
420 |
|
|
421 |
for (int i = 0; i < frames.length; i++) { |
|
409 | 422 |
try { |
410 |
((IFFrame) getFFrames().get(i)).print(g2, getAT());
|
|
423 |
frames[i].print(g2, getAT());
|
|
411 | 424 |
} catch (DriverException e) { |
412 | 425 |
NotificationManager.addError(e.getMessage(), e); |
413 | 426 |
} |
... | ... | |
446 | 459 |
addCadTool("line", lineCADTool); |
447 | 460 |
|
448 | 461 |
//Herramienta de CAD de a?adir c?rculo |
449 |
CircleCadTool circleCADTool=new CircleCadTool();
|
|
450 |
addCadTool("circle",circleCADTool); |
|
462 |
CircleCadTool circleCADTool = new CircleCadTool();
|
|
463 |
addCadTool("circle", circleCADTool);
|
|
451 | 464 |
|
452 | 465 |
//Herramienta de CAD de a?adir c?rculo |
453 |
EllipseCadTool ellipseCADTool=new EllipseCadTool();
|
|
466 |
EllipseCadTool ellipseCADTool = new EllipseCadTool();
|
|
454 | 467 |
addCadTool("ellipse", ellipseCADTool); |
455 | 468 |
|
456 | 469 |
//Herramienta de CAD de a?adir c?rculo |
457 |
ArcCadTool arcCADTool=new ArcCadTool();
|
|
458 |
addCadTool("arc",arcCADTool); |
|
470 |
ArcCadTool arcCADTool = new ArcCadTool();
|
|
471 |
addCadTool("arc", arcCADTool);
|
|
459 | 472 |
|
460 | 473 |
//Herramienta de CAD de a?adir polyl?nea |
461 | 474 |
PolyLineCadTool polylineCADTool = new PolyLineCadTool(); |
... | ... | |
468 | 481 |
//Herramienta de CAD de a?adir pol?gono. |
469 | 482 |
PolygonCadTool polygonCADTool = new PolygonCadTool(); |
470 | 483 |
addCadTool("polygon", polygonCADTool); |
471 |
|
|
472 |
SelectionCadTool selectionCADTool=new SelectionCadTool();
|
|
473 |
addCadTool("selection",selectionCADTool); |
|
484 |
|
|
485 |
SelectionCadTool selectionCADTool = new SelectionCadTool();
|
|
486 |
addCadTool("selection", selectionCADTool);
|
|
474 | 487 |
} |
475 | 488 |
|
476 | 489 |
/** |
... | ... | |
480 | 493 |
private void actionDelFFrame() { |
481 | 494 |
Action doNothing = new AbstractAction() { |
482 | 495 |
public void actionPerformed(ActionEvent e) { |
483 |
for (int i = getFFrames().size() - 1; i >= 0; i--) { |
|
484 |
IFFrame fframe = (IFFrame) getFFrames().get(i); |
|
485 |
getCadToolAdapter().getEditableFeatureSource().startComplexGeometry(); |
|
486 |
if (fframe.getSelected() != FFrame.NOSELECT) { |
|
487 |
((LayoutEditableFeature)getCadToolAdapter().getEditableFeatureSource()).removeFFrame(i); |
|
496 |
ArrayList frames = getAllFFrames(); |
|
497 |
getCadToolAdapter().getEditableFeatureSource() |
|
498 |
.startComplexGeometry(); |
|
499 |
|
|
500 |
for (int i = frames.size() - 1; i >= 0; i--) { |
|
501 |
IFFrame fframe = (IFFrame) frames.get(i); |
|
502 |
|
|
503 |
if ((fframe.getSelected() != IFFrame.NOSELECT) && |
|
504 |
!validates.get(i)) { |
|
505 |
try { |
|
506 |
((LayoutEditableFeature) getCadToolAdapter() |
|
507 |
.getEditableFeatureSource()).removeFFrame(fframe, |
|
508 |
i); |
|
509 |
} catch (DriverIOException e2) { |
|
510 |
e2.printStackTrace(); |
|
511 |
} catch (IOException e2) { |
|
512 |
e2.printStackTrace(); |
|
513 |
} |
|
488 | 514 |
} |
489 | 515 |
} |
516 |
|
|
490 | 517 |
try { |
491 |
getCadToolAdapter().getEditableFeatureSource().endComplexGeometry(); |
|
518 |
getCadToolAdapter().getEditableFeatureSource() |
|
519 |
.endComplexGeometry(); |
|
492 | 520 |
} catch (IOException e1) { |
493 | 521 |
e1.printStackTrace(); |
494 | 522 |
} catch (DriverIOException e1) { |
495 | 523 |
e1.printStackTrace(); |
496 | 524 |
} |
525 |
|
|
497 | 526 |
getCadToolAdapter().keyPressed("eliminar"); |
498 |
|
|
527 |
|
|
499 | 528 |
refresh(); |
500 | 529 |
} |
501 | 530 |
}; |
... | ... | |
531 | 560 |
g.drawImage(img, 0, 0, this); |
532 | 561 |
|
533 | 562 |
g.setClip(rClip); |
534 |
ladapter.getCADToolAdapter().drawGrid(g);
|
|
563 |
ladapter.drawGrid(g); |
|
535 | 564 |
layoutPaint.drawRuler((Graphics2D) g, Color.black); |
536 | 565 |
g.setColor(Color.black); |
537 | 566 |
g.setXORMode(Color.white); |
... | ... | |
550 | 579 |
g.drawImage(img, 0, 0, this); |
551 | 580 |
|
552 | 581 |
g.setClip(rClip); |
553 |
ladapter.getCADToolAdapter().drawGrid(g);
|
|
582 |
ladapter.drawGrid(g); |
|
554 | 583 |
layoutPaint.drawRuler((Graphics2D) g, Color.black); |
555 | 584 |
g.setColor(Color.black); |
556 | 585 |
g.setXORMode(Color.white); |
... | ... | |
565 | 594 |
} |
566 | 595 |
|
567 | 596 |
g.drawRect(re.x, re.y, re.width, re.height); |
568 |
|
|
597 |
|
|
569 | 598 |
break; |
570 | 599 |
|
571 | 600 |
case PAN: |
601 |
logger.debug("pan"); |
|
602 |
rect.x = rectOrigin.x + (m_LastPoint.x - m_PointAnt.x); |
|
603 |
rect.y = rectOrigin.y + (m_LastPoint.y - m_PointAnt.y); |
|
604 |
layoutPaint.drawRectangle((Graphics2D) g); |
|
572 | 605 |
|
573 |
logger.debug("pan"); |
|
574 |
rect.x = rectOrigin.x + (m_LastPoint.x - m_PointAnt.x); |
|
575 |
rect.y = rectOrigin.y + (m_LastPoint.y - m_PointAnt.y); |
|
576 |
layoutPaint.drawRectangle((Graphics2D) g); |
|
577 |
if (img != null) { |
|
578 |
g.drawImage(img, (getLastPoint().x - getPointAnt().x), |
|
579 |
(m_LastPoint.y - m_PointAnt.y), this); |
|
580 |
} |
|
581 |
g.setClip(rClip); |
|
582 |
layoutPaint.drawRuler((Graphics2D) g, Color.black); |
|
583 |
|
|
606 |
if (img != null) { |
|
607 |
g.drawImage(img, (getLastPoint().x - getPointAnt().x), |
|
608 |
(m_LastPoint.y - m_PointAnt.y), this); |
|
609 |
} |
|
610 |
|
|
611 |
g.setClip(rClip); |
|
612 |
layoutPaint.drawRuler((Graphics2D) g, Color.black); |
|
613 |
|
|
584 | 614 |
break; |
585 | 615 |
|
586 | 616 |
case VIEW_PAN: |
587 |
|
|
588 | 617 |
layoutPaint.drawRectangle((Graphics2D) g); |
589 | 618 |
|
590 |
for (int i = 0; i < getFFrames().size(); i++) { |
|
591 |
if (getFFrames().get(i) instanceof FFrameView) { |
|
592 |
FFrameView fframe = (FFrameView) getFFrames().get(i); |
|
619 |
IFFrame[] frames = getFFrames1(); |
|
593 | 620 |
|
594 |
if (fframe.getSelected() != FFrame.NOSELECT) { |
|
621 |
for (int i = 0; i < frames.length; i++) { |
|
622 |
if (frames[i] instanceof FFrameView) { |
|
623 |
FFrameView fframe = (FFrameView) frames[i]; |
|
624 |
|
|
625 |
if (fframe.getSelected() != IFFrame.NOSELECT) { |
|
595 | 626 |
Rectangle2D.Double rec = fframe.getBoundingBox(getAT()); |
596 | 627 |
|
597 | 628 |
if (img != null) { |
... | ... | |
617 | 648 |
} |
618 | 649 |
|
619 | 650 |
g.setClip(rClip); |
620 |
ladapter.getCADToolAdapter().drawGrid(g);
|
|
651 |
ladapter.drawGrid(g); |
|
621 | 652 |
layoutPaint.drawRuler((Graphics2D) g, Color.black); |
653 |
|
|
622 | 654 |
break; |
623 | 655 |
|
624 | 656 |
case SELECT: |
... | ... | |
633 | 665 |
g.drawRect(reSel.x, reSel.y, reSel.width, reSel.height); |
634 | 666 |
} |
635 | 667 |
|
636 |
for (int i = 0; i < getFFrames().size(); i++) { |
|
637 |
IFFrame fframe = (IFFrame) getFFrames().get(i); |
|
668 |
IFFrame[] frames2 = getFFrames1(); |
|
638 | 669 |
|
639 |
if (fframe.getSelected() != FFrame.NOSELECT) { |
|
670 |
for (int i = 0; i < frames2.length; i++) { |
|
671 |
IFFrame fframe = frames2[i]; //(IFFrame) getFFrames().get(i); |
|
672 |
|
|
673 |
if (fframe.getSelected() != IFFrame.NOSELECT) { |
|
640 | 674 |
g.setColor(Color.black); |
641 | 675 |
fframe.drawHandlers((Graphics2D) g); |
642 | 676 |
|
... | ... | |
665 | 699 |
} |
666 | 700 |
|
667 | 701 |
g.setClip(rClip); |
668 |
ladapter.getCADToolAdapter().drawGrid(g);
|
|
702 |
ladapter.drawGrid(g); |
|
669 | 703 |
layoutPaint.drawRuler((Graphics2D) g, Color.black); |
670 | 704 |
|
671 | 705 |
break; |
672 | 706 |
|
673 | 707 |
case GRAPHICS: |
708 |
|
|
674 | 709 |
Graphics gima = img.getGraphics(); |
675 |
try { |
|
676 |
getFFrameGraphics().draw((Graphics2D)gima,getAT(),getRect(),null); |
|
677 |
} catch (DriverException e1) { |
|
678 |
e1.printStackTrace(); |
|
679 |
} |
|
680 | 710 |
setStatus(ACTUALIZADO); |
681 | 711 |
repaint(); |
712 |
|
|
682 | 713 |
break; |
683 | 714 |
|
684 | 715 |
case DESACTUALIZADO: |
... | ... | |
699 | 730 |
} catch (DriverException e) { |
700 | 731 |
e.printStackTrace(); |
701 | 732 |
} |
702 |
ladapter.getCADToolAdapter().drawGrid(gimag); |
|
703 |
//g.setClip(rClip);
|
|
733 |
|
|
734 |
ladapter.drawGrid(gimag);
|
|
704 | 735 |
layoutPaint.drawRectangle((Graphics2D) g); |
705 |
//cadToolAdapter.drawGrid(g); |
|
706 | 736 |
g.drawImage(img, 0, 0, this); |
707 | 737 |
g.setClip(rClip); |
708 |
|
|
709 |
|
|
738 |
|
|
710 | 739 |
layoutPaint.drawHandlers((Graphics2D) g, Color.black); |
711 | 740 |
layoutPaint.drawRuler((Graphics2D) g, Color.black); |
712 |
if (getTool()==GRAPHICS){ |
|
713 |
ladapter.getCADToolAdapter().drawCursor(g); |
|
714 |
ladapter.getCADToolAdapter().paintComponent(g); |
|
741 |
|
|
742 |
if (getTool() == GRAPHICS) { |
|
743 |
ladapter.drawCursor(g); |
|
744 |
ladapter.paintComponent(g); |
|
715 | 745 |
} |
716 |
|
|
746 |
|
|
717 | 747 |
break; |
718 | 748 |
|
719 | 749 |
case ACTUALIZADO: |
720 | 750 |
layoutPaint.drawRectangle((Graphics2D) g); |
721 |
|
|
722 | 751 |
g.drawImage(img, 0, 0, this); |
723 | 752 |
|
724 | 753 |
g.setClip(rClip); |
725 | 754 |
layoutPaint.drawHandlers((Graphics2D) g, Color.black); |
726 | 755 |
layoutPaint.drawRuler((Graphics2D) g, Color.black); |
727 |
//cadToolAdapter.drawGrid(g); |
|
728 |
if (getTool()==GRAPHICS){
|
|
729 |
ladapter.getCADToolAdapter().drawCursor(g);
|
|
730 |
ladapter.getCADToolAdapter().paintComponent(g);
|
|
756 |
|
|
757 |
if (getTool() == GRAPHICS) {
|
|
758 |
ladapter.drawCursor(g); |
|
759 |
ladapter.paintComponent(g); |
|
731 | 760 |
} |
732 |
|
|
733 |
|
|
734 | 761 |
} |
735 | 762 |
} |
736 | 763 |
|
... | ... | |
741 | 768 |
* @param clearSelection para que se quede seleccionado ?nicamente el que |
742 | 769 |
* a?adimos y false si lo que se pretende es que no se |
743 | 770 |
* deseleccionen lo que ya est?n seleccionados. |
771 |
* |
|
772 |
* @return ?ndice |
|
744 | 773 |
*/ |
745 | 774 |
public int addFFrame(IFFrame frame, boolean clearSelection) { |
746 |
|
|
775 |
IFFrame[] frames = getFFrames1(); |
|
776 |
|
|
747 | 777 |
if (clearSelection) { |
748 |
for (int i = getFFrames().size() - 1; i >= 0; i--) {
|
|
749 |
IFFrame fframe1 = (IFFrame) getFFrames().get(i); |
|
778 |
for (int i = frames.length - 1; i >= 0; i--) {
|
|
779 |
IFFrame fframe1 = frames[i]; //(IFFrame) getFFrames().get(i);
|
|
750 | 780 |
fframe1.setSelected(false); |
751 | 781 |
} |
752 | 782 |
} |
... | ... | |
765 | 795 |
} |
766 | 796 |
|
767 | 797 |
frame.setNum(Integer.parseInt(nums.get(frame.getClass()).toString())); |
768 |
getFFrames().add(frame); |
|
798 |
getAllFFrames().add(frame);
|
|
769 | 799 |
frame.setSelected(true); |
770 |
return getFFrames().size()-1; |
|
800 |
|
|
801 |
return getAllFFrames().size() - 1; |
|
771 | 802 |
} |
772 | 803 |
|
773 | 804 |
/** |
... | ... | |
849 | 880 |
//Actualizar attributes |
850 | 881 |
att = m_attributes.toPrintAttributes(); |
851 | 882 |
|
852 |
//------------------ The Printing things --------------------- // |
|
853 | 883 |
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; |
854 | 884 |
|
855 |
// returns the set of printers that support printing a specific document type (such as GIF) |
|
856 |
// with a specific set of attributes (such as two sided). |
|
857 |
// PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); |
|
858 |
// interestingly, the printer dialog's default behavior has changed with the new API: by default the dialog is not shown. |
|
859 |
// So we must use the ServiceUI class to create a print dialog |
|
860 |
// returns the default print service. |
|
861 | 885 |
if (m_cachePrintServices == null) { |
862 | 886 |
m_cachePrintServices = PrintServiceLookup.lookupPrintServices(flavor, |
863 | 887 |
null); |
... | ... | |
872 | 896 |
if (m_cachePrintService == null) { |
873 | 897 |
m_cachePrintService = ServiceUI.printDialog(null, 200, 200, |
874 | 898 |
m_cachePrintServices, defaultService, flavor, att); |
875 |
|
|
876 |
// m_cachePrintRequestAtributeSet = new HashPrintRequestAttributeSet(); |
|
877 |
// m_cachePrintRequestAtributeSet.addAll(pras); |
|
878 | 899 |
} else { |
879 | 900 |
m_cachePrintService = ServiceUI.printDialog(null, 200, 200, |
880 | 901 |
m_cachePrintServices, m_cachePrintService, flavor, att); |
... | ... | |
889 | 910 |
}; |
890 | 911 |
|
891 | 912 |
jobNuevo.addPrintJobListener(pjlistener); |
892 |
|
|
893 |
// DocAttributeSet das = new HashDocAttributeSet(); |
|
894 | 913 |
doc = new SimpleDoc((Printable) PluginServices.getExtension( |
895 | 914 |
com.iver.cit.gvsig.Print.class), flavor, null); |
896 | 915 |
|
897 | 916 |
try { |
898 | 917 |
jobNuevo.print(doc, att); |
899 |
|
|
900 |
// m_attributes. |
|
901 | 918 |
} catch (PrintException pe) { |
902 | 919 |
pe.printStackTrace(); |
903 | 920 |
} |
904 | 921 |
} |
905 | 922 |
} |
906 | 923 |
|
907 |
/* try { |
|
908 |
print = job.printDialog(att); |
|
909 |
} catch (Exception e) { |
|
910 |
logger.error("Abriendo el Di?logo de imprimir"); //System.out.println("Excepci?n "+e); |
|
911 |
} |
|
912 |
if (print) { |
|
913 |
job.setPrintable((Printable) App.instance.getPc().getExtension(com.iver.cit.gvsig.Print.class)); |
|
914 |
try { |
|
915 |
job.print(att); |
|
916 |
} catch (Exception ex) { |
|
917 |
ex.printStackTrace(); |
|
918 |
} |
|
919 |
} */ |
|
920 | 924 |
fullRect(); |
921 | 925 |
} |
922 | 926 |
|
... | ... | |
955 | 959 |
setMapCursor(izoomin); |
956 | 960 |
} else if (getTool() == ZOOM_MENOS) { |
957 | 961 |
setMapCursor(izoomout); |
958 |
} else if (getTool() == RECTANGLEVIEW || |
|
959 |
getTool() == RECTANGLEPICTURE || |
|
960 |
getTool() == RECTANGLESCALEBAR || |
|
961 |
getTool() == RECTANGLELEGEND || |
|
962 |
getTool() == RECTANGLETEXT) { |
|
962 |
} else if ((getTool() == RECTANGLEVIEW) || |
|
963 |
(getTool() == RECTANGLEPICTURE) || |
|
964 |
(getTool() == RECTANGLESCALEBAR) || |
|
965 |
(getTool() == RECTANGLELEGEND) || (getTool() == RECTANGLETEXT)) { |
|
963 | 966 |
setMapCursor(icrux); |
964 | 967 |
} else if (getTool() == SELECT) { |
965 | 968 |
setCursor(Cursor.getDefaultCursor()); |
966 | 969 |
} else if (getTool() == SET_TAG) { |
967 | 970 |
setMapCursor(itag); |
968 |
}else if (getTool() == GRAPHICS) { |
|
971 |
} else if (getTool() == GRAPHICS) {
|
|
969 | 972 |
clearMouseImage(); |
970 |
}
|
|
973 |
} |
|
971 | 974 |
} |
972 |
private void clearMouseImage(){ |
|
975 |
|
|
976 |
/** |
|
977 |
* Quita la imagen del puntero del rat?n. |
|
978 |
*/ |
|
979 |
private void clearMouseImage() { |
|
973 | 980 |
int[] pixels = new int[16 * 16]; |
974 |
Image image = Toolkit.getDefaultToolkit().createImage( |
|
975 |
new MemoryImageSource(16, 16, pixels, 0, 16));
|
|
976 |
Cursor transparentCursor = |
|
977 |
Toolkit.getDefaultToolkit().createCustomCursor
|
|
978 |
(image, new Point(0,0), "invisiblecursor");
|
|
981 |
Image image = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(
|
|
982 |
16, 16, pixels, 0, 16));
|
|
983 |
Cursor transparentCursor = Toolkit.getDefaultToolkit()
|
|
984 |
.createCustomCursor(image,
|
|
985 |
new Point(0, 0), "invisiblecursor");
|
|
979 | 986 |
this.setCursor(transparentCursor); |
980 | 987 |
} |
988 |
|
|
981 | 989 |
/** |
982 | 990 |
* Se crean aqu? los dialogos cada vez que se necesitan. |
983 | 991 |
* |
... | ... | |
1017 | 1025 |
break; |
1018 | 1026 |
|
1019 | 1027 |
case GRAPHICS: |
1020 |
/* fframedialog = new FFrameGraphicsDialog(this,
|
|
1021 |
(FFrameGraphics) fframe);
|
|
1028 |
fframedialog = new FFrameGraphicsDialog(this, |
|
1029 |
(FFrameGraphic) fframe); |
|
1022 | 1030 |
|
1023 |
*/ |
|
1024 | 1031 |
break; |
1025 | 1032 |
|
1026 | 1033 |
default: |
... | ... | |
1204 | 1211 |
* @throws DriverException |
1205 | 1212 |
*/ |
1206 | 1213 |
public void viewFull() throws DriverException { |
1207 |
for (int i = 0; i < getFFrames().size(); i++) { |
|
1208 |
if (getFFrames().get(i) instanceof FFrameView) { |
|
1209 |
FFrameView fframe = (FFrameView) getFFrames().get(i); |
|
1214 |
IFFrame[] frames = getFFrames1(); |
|
1210 | 1215 |
|
1211 |
if (fframe.getSelected() != FFrame.NOSELECT) { |
|
1216 |
for (int i = 0; i < frames.length; i++) { |
|
1217 |
if (frames[i] instanceof FFrameView) { |
|
1218 |
FFrameView fframe = (FFrameView) frames[i]; //getFFrames().get(i); |
|
1219 |
|
|
1220 |
if (fframe.getSelected() != IFFrame.NOSELECT) { |
|
1212 | 1221 |
fframe.getFMap().getViewPort().setExtent(fframe.getFMap() |
1213 | 1222 |
.getFullExtent()); |
1214 | 1223 |
} |
... | ... | |
1233 | 1242 |
xml.putProperty("m_name", this.getName()); |
1234 | 1243 |
xml.addChild(getAtributes().getXMLEntity()); |
1235 | 1244 |
|
1236 |
for (int i = 0; i < getFFrames().size(); i++) { |
|
1237 |
xml.addChild(((IFFrame) getFFrames().get(i)).getXMLEntity()); |
|
1245 |
IFFrame[] frames = getFFrames1(); |
|
1246 |
|
|
1247 |
for (int i = 0; i < frames.length; i++) { |
|
1248 |
xml.addChild(frames[i].getXMLEntity()); |
|
1238 | 1249 |
} |
1239 | 1250 |
|
1240 | 1251 |
return xml; |
... | ... | |
1254 | 1265 |
layout.setName(xml.getStringProperty("m_name")); |
1255 | 1266 |
layout.m_attributes = Attributes.createAtributes(xml.getChild(0)); |
1256 | 1267 |
layout.m_attributes.setCADToolAdapter(layout.getCadToolAdapter()); |
1268 |
|
|
1257 | 1269 |
for (int i = 1; i < xml.getNumChild(); i++) { |
1258 | 1270 |
if (xml.getChild(i).getStringProperty("className").equals("com.iver.cit.gvsig.gui.layout.fframe.FFrameView")) { |
1259 | 1271 |
layout.addFFrame(FFrame.createFFrame(xml.getChild(i), layout, p), |
... | ... | |
1277 | 1289 |
public void viewActivated() { |
1278 | 1290 |
PluginServices.getMainFrame().getStatusBar().setMessage("1", |
1279 | 1291 |
getAtributes().getNameUnit()); |
1280 |
|
|
1281 |
///System.out.println("---------- 1 "+ getAtributes().getNameUnit()); |
|
1282 | 1292 |
} |
1283 | 1293 |
|
1284 | 1294 |
/** |
... | ... | |
1318 | 1328 |
*/ |
1319 | 1329 |
public void viewClosed() { |
1320 | 1330 |
try { |
1321 |
ladapter.getCADToolAdapter().getEditableFeatureSource().stopEdition(); |
|
1322 |
///PluginServices.getMainFrame().getStatusBar().setMessage("1",""); |
|
1331 |
ladapter.getEditableFeatureSource().stopEdition(); |
|
1323 | 1332 |
} catch (EditionException e) { |
1324 | 1333 |
e.printStackTrace(); |
1325 | 1334 |
} |
... | ... | |
1332 | 1341 |
} |
1333 | 1342 |
|
1334 | 1343 |
/** |
1335 |
* DOCUMENT ME!
|
|
1344 |
* Devuelve una vector con todos FFrames seleccionados.
|
|
1336 | 1345 |
* |
1337 |
* @return DOCUMENT ME!
|
|
1346 |
* @return vector de fframes seleccionados.
|
|
1338 | 1347 |
*/ |
1339 | 1348 |
public IFFrame[] getFFrameSelected() { |
1340 | 1349 |
ArrayList selecList = new ArrayList(); |
1350 |
IFFrame[] frames = getFFrames1(); |
|
1341 | 1351 |
|
1342 |
for (int i = getFFrames().size() - 1; i >= 0; i--) {
|
|
1343 |
IFFrame fframe = (IFFrame) getFFrames().get(i); |
|
1352 |
for (int i = frames.length - 1; i >= 0; i--) {
|
|
1353 |
IFFrame fframe = frames[i]; //(IFFrame) getFFrames().get(i);
|
|
1344 | 1354 |
|
1345 |
if (fframe.getSelected() != FFrame.NOSELECT) { |
|
1355 |
if (fframe.getSelected() != IFFrame.NOSELECT) {
|
|
1346 | 1356 |
selecList.add(fframe); |
1347 | 1357 |
} |
1348 | 1358 |
} |
... | ... | |
1351 | 1361 |
} |
1352 | 1362 |
|
1353 | 1363 |
/** |
1354 |
* DOCUMENT ME!
|
|
1364 |
* A?ade una CadTool al Layout.
|
|
1355 | 1365 |
* |
1356 |
* @param name DOCUMENT ME!
|
|
1357 |
* @param c DOCUMENT ME!
|
|
1366 |
* @param name Nombre de la CadTool.
|
|
1367 |
* @param c CadTool
|
|
1358 | 1368 |
*/ |
1359 | 1369 |
public void addCadTool(String name, CadTool c) { |
1360 | 1370 |
namesCadTools.put(name, c); |
1361 | 1371 |
} |
1362 | 1372 |
|
1363 | 1373 |
/** |
1364 |
* DOCUMENT ME! |
|
1374 |
* A partir del nombre de la CadTool la coloca como herramienta |
|
1375 |
* seleccionada. |
|
1365 | 1376 |
* |
1366 |
* @param text DOCUMENT ME! |
|
1377 |
* @param text nombre de la CadTool. |
|
1378 |
* |
|
1379 |
* @throws RuntimeException Excepci?n lanzada cuando la CadTool que se |
|
1380 |
* quiere seleccionar no existe. |
|
1367 | 1381 |
*/ |
1368 | 1382 |
public void setCadTool(String text) { |
1369 | 1383 |
CadTool ct = (CadTool) namesCadTools.get(text); |
1384 |
|
|
1370 | 1385 |
if (ct == null) { |
1371 | 1386 |
throw new RuntimeException("No such cad tool"); |
1372 | 1387 |
} |
1373 |
ladapter.getCADToolAdapter().setCadTool(ct); |
|
1374 |
//cadtool = true;
|
|
1388 |
|
|
1389 |
ladapter.setCadTool(ct);
|
|
1375 | 1390 |
setTool(GRAPHICS); |
1376 |
//clearMouseImage(); |
|
1377 | 1391 |
} |
1378 | 1392 |
|
1379 | 1393 |
/** |
1380 |
* DOCUMENT ME!
|
|
1394 |
* Devuelve el CADToolAdapter del Layout.
|
|
1381 | 1395 |
* |
1382 |
* @return DOCUMENT ME!
|
|
1396 |
* @return CADToolAdapter.
|
|
1383 | 1397 |
*/ |
1384 | 1398 |
public CADToolAdapter getCadToolAdapter() { |
1385 |
return (CADToolAdapter)ladapter.getCADToolAdapter();
|
|
1399 |
return (CADToolAdapter) ladapter;
|
|
1386 | 1400 |
} |
1387 |
public FFrameGraphics getFFrameGraphics(){ |
|
1388 |
return fframegraphics;
|
|
1389 |
}
|
|
1390 |
public void undo(){
|
|
1391 |
|
|
1401 |
|
|
1402 |
/**
|
|
1403 |
* Deshacer el ?ltimo comando apilado en el Layout.
|
|
1404 |
*/
|
|
1405 |
public void undo() { |
|
1392 | 1406 |
try { |
1393 | 1407 |
getCadToolAdapter().getEditableFeatureSource().undo(); |
1394 | 1408 |
} catch (DriverIOException e) { |
... | ... | |
1397 | 1411 |
e.printStackTrace(); |
1398 | 1412 |
} |
1399 | 1413 |
} |
1400 |
public void redo(){ |
|
1414 |
|
|
1415 |
/** |
|
1416 |
* Rehacer el ?ltimo comando apilado en la pila de comandos de rehacer. |
|
1417 |
*/ |
|
1418 |
public void redo() { |
|
1401 | 1419 |
try { |
1402 | 1420 |
getCadToolAdapter().getEditableFeatureSource().redo(); |
1403 | 1421 |
} catch (DriverIOException e) { |
... | ... | |
1406 | 1424 |
e.printStackTrace(); |
1407 | 1425 |
} |
1408 | 1426 |
} |
1409 |
public void addMenuEntry(String text, String actionCommand){ |
|
1427 |
|
|
1428 |
/** |
|
1429 |
* A?ade una opci?n al popupmenu que corresponde a las herramientas CAD. |
|
1430 |
* |
|
1431 |
* @param text Nombre de la opci?n. |
|
1432 |
* @param actionCommand nombre del ActionCommand. |
|
1433 |
*/ |
|
1434 |
public void addMenuEntry(String text, String actionCommand) { |
|
1410 | 1435 |
JMenuItem menu = new JMenuItem(text); |
1411 | 1436 |
menu.setActionCommand(actionCommand); |
1412 | 1437 |
menu.setEnabled(true); |
1413 | 1438 |
menu.setVisible(true); |
1414 | 1439 |
menu.addActionListener(new ActionListener() { |
1415 |
public void actionPerformed(ActionEvent e) { |
|
1416 |
getCadToolAdapter().transition(e.getActionCommand()); |
|
1417 |
refresh(); |
|
1418 |
} |
|
1419 |
}); |
|
1420 |
|
|
1440 |
public void actionPerformed(ActionEvent e) {
|
|
1441 |
getCadToolAdapter().transition(e.getActionCommand());
|
|
1442 |
refresh();
|
|
1443 |
}
|
|
1444 |
});
|
|
1445 |
|
|
1421 | 1446 |
popup.add(menu); |
1422 | 1447 |
} |
1423 |
public void clearMenu(){ |
|
1448 |
|
|
1449 |
/** |
|
1450 |
* Elimina todas las opciones del men?. |
|
1451 |
*/ |
|
1452 |
public void clearMenu() { |
|
1424 | 1453 |
popup.removeAll(); |
1425 | 1454 |
} |
1426 |
public JPopupMenu getPopup(){ |
|
1455 |
|
|
1456 |
/** |
|
1457 |
* Devuelve el popupmenu con las opciones que ofrecen las herramientas CAD. |
|
1458 |
* |
|
1459 |
* @return JPopupMenu de CAD. |
|
1460 |
*/ |
|
1461 |
public JPopupMenu getPopup() { |
|
1427 | 1462 |
return popup; |
1428 | 1463 |
} |
1429 | 1464 |
} |
Also available in: Unified diff