Revision 1757 trunk/org.gvsig.app.document.layout2.app/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/FLayoutDraw.java
FLayoutDraw.java | ||
---|---|---|
21 | 21 |
*/ |
22 | 22 |
package org.gvsig.app.project.documents.layout; |
23 | 23 |
|
24 |
import com.lowagie.text.Document; |
|
25 |
import com.lowagie.text.DocumentException; |
|
26 |
import com.lowagie.text.Rectangle; |
|
27 |
import com.lowagie.text.pdf.PdfContentByte; |
|
28 |
import com.lowagie.text.pdf.PdfWriter; |
|
24 | 29 |
import java.awt.Color; |
25 | 30 |
import java.awt.Component; |
26 | 31 |
import java.awt.Cursor; |
... | ... | |
38 | 43 |
import java.io.FileOutputStream; |
39 | 44 |
import java.io.IOException; |
40 | 45 |
import java.io.OutputStream; |
41 |
|
|
42 | 46 |
import javax.print.Doc; |
43 | 47 |
import javax.print.DocFlavor; |
44 | 48 |
import javax.print.DocPrintJob; |
... | ... | |
46 | 50 |
import javax.print.SimpleDoc; |
47 | 51 |
import javax.print.StreamPrintService; |
48 | 52 |
import javax.print.StreamPrintServiceFactory; |
49 |
import javax.print.attribute.DocAttributeSet; |
|
50 |
import javax.print.attribute.HashDocAttributeSet; |
|
51 | 53 |
import javax.print.attribute.PrintRequestAttributeSet; |
52 | 54 |
import javax.swing.JOptionPane; |
53 |
|
|
54 |
import com.lowagie.text.Document; |
|
55 |
import com.lowagie.text.DocumentException; |
|
56 |
import com.lowagie.text.PageSize; |
|
57 |
import com.lowagie.text.Rectangle; |
|
58 |
import com.lowagie.text.pdf.PdfContentByte; |
|
59 |
import com.lowagie.text.pdf.PdfWriter; |
|
60 |
|
|
61 |
import org.slf4j.Logger; |
|
62 |
import org.slf4j.LoggerFactory; |
|
63 | 55 |
import org.gvsig.andami.PluginServices; |
64 | 56 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
65 | 57 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
66 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
67 | 58 |
import org.gvsig.tools.observer.Observable; |
68 | 59 |
import org.gvsig.tools.observer.ObservableHelper; |
69 | 60 |
import org.gvsig.tools.observer.Observer; |
61 |
import org.slf4j.Logger; |
|
62 |
import org.slf4j.LoggerFactory; |
|
70 | 63 |
|
71 | 64 |
/** |
72 | 65 |
* Clase que implementa los m?todos del Layout que dibujan sobre el Graphics. |
... | ... | |
111 | 104 |
* Si es null, est?s imprimiendo. Si no, la usas para el |
112 | 105 |
* c?digo de optimizaci?n. |
113 | 106 |
* |
114 |
* @throws ReadDriverException |
|
115 | 107 |
*/ |
116 | 108 |
public void drawLayout(Graphics2D g2, BufferedImage imgBase) |
117 |
throws ReadException {
|
|
109 |
{ |
|
118 | 110 |
if (!initializeAffineTransform()) { |
119 | 111 |
return; |
120 | 112 |
} |
121 | 113 |
|
122 | 114 |
IFFrame[] fframes = layoutContext.getFFrames(); |
123 |
for (int i = 0; i < fframes.length; i++) { |
|
124 |
IFFrame f = fframes[i]; |
|
115 |
for (IFFrame f : fframes) { |
|
125 | 116 |
f.draw(g2, layoutContext.getAT(), layoutControl.getComponent().getVisibleRect(), |
126 |
imgBase);
|
|
127 |
|
|
117 |
imgBase); |
|
118 |
|
|
128 | 119 |
// Dibuja el s?mbolo de que contiene un tag. |
129 | 120 |
if ((f.getTag() != null) && (layoutPanel.isShowIconTag())) { |
130 | 121 |
f.drawSymbolTag(g2); |
... | ... | |
152 | 143 |
|
153 | 144 |
layoutControl.setCancelDrawing(false); |
154 | 145 |
|
155 |
double scale = 0; |
|
156 |
scale = rLayout.getHeight() / attributes.getPaperSize().getHeight() * 1; // paper (paper units) to screen (pixels) scale |
|
146 |
double scale = rLayout.getHeight() / attributes.getPaperSize().getHeight() * 1; // paper (paper units) to screen (pixels) scale |
|
157 | 147 |
AffineTransform escalado = new AffineTransform(); |
158 | 148 |
AffineTransform translacion = new AffineTransform(); |
159 | 149 |
translacion.setToTranslation(rLayout.getMinX(), rLayout.getMinY()); |
... | ... | |
520 | 510 |
|
521 | 511 |
g.setColor(color); |
522 | 512 |
IFFrame[] fframes = layoutContext.getFFrames(); |
523 |
for (int i = 0; i < fframes.length; i++) { |
|
524 |
IFFrame fframe = fframes[i]; |
|
525 |
|
|
513 |
for (IFFrame fframe : fframes) { |
|
526 | 514 |
if (fframe.getSelected() != IFFrame.NOSELECT) { |
527 | 515 |
fframe.drawHandlers(g); |
528 | 516 |
} |
... | ... | |
575 | 563 |
|
576 | 564 |
// is.close(); |
577 | 565 |
fos.close(); |
578 |
} catch (PrintException e) { |
|
566 |
} catch (PrintException | IOException e) {
|
|
579 | 567 |
LOG.error("Error printing the map", e); |
580 |
} catch (IOException e) { |
|
581 |
LOG.error("Error printing the map", e); |
|
582 | 568 |
} |
583 | 569 |
/* |
584 | 570 |
* PrintService defaultPrintService = |
... | ... | |
648 | 634 |
layoutControl.fullRect(); |
649 | 635 |
} |
650 | 636 |
|
637 |
@Override |
|
651 | 638 |
public int print(Graphics g, PageFormat format, int pi) |
652 | 639 |
throws PrinterException { |
653 | 640 |
initialize(); |
... | ... | |
694 | 681 |
} |
695 | 682 |
|
696 | 683 |
IFFrame[] fframes = layoutContext.getFFrames(); |
697 |
for (int i = 0; i < fframes.length; i++) {
|
|
698 |
fframes[i].print(g2, layoutControl.getAT(), null, layoutContext
|
|
684 |
for (IFFrame fframe : fframes) {
|
|
685 |
fframe.print(g2, layoutControl.getAT(), null, layoutContext |
|
699 | 686 |
.getAttributes().toPrintAttributes()); |
700 | 687 |
} |
701 | 688 |
} |
702 | 689 |
|
690 |
@Override |
|
703 | 691 |
public void addObserver(Observer o) { |
704 | 692 |
observers.addObserver(o); |
705 | 693 |
} |
706 | 694 |
|
695 |
@Override |
|
707 | 696 |
public void deleteObserver(Observer o) { |
708 | 697 |
observers.deleteObserver(o); |
709 | 698 |
} |
710 | 699 |
|
700 |
@Override |
|
711 | 701 |
public void deleteObservers() { |
712 | 702 |
observers.deleteObservers(); |
713 | 703 |
} |
Also available in: Unified diff