Statistics
| Revision:

svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / gui / DefaultLayoutPanel.java @ 228

History | View | Annotate | Download (22.4 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.project.documents.layout.gui;
23

    
24
import java.awt.BorderLayout;
25
import java.awt.Component;
26
import java.awt.Graphics2D;
27
import java.awt.event.MouseEvent;
28
import java.awt.event.MouseListener;
29
import java.awt.geom.AffineTransform;
30
import java.awt.print.PageFormat;
31
import java.awt.print.Printable;
32
import java.awt.print.PrinterException;
33
import java.awt.print.PrinterJob;
34
import java.beans.PropertyChangeEvent;
35
import java.beans.PropertyChangeListener;
36
import java.io.File;
37

    
38
import javax.print.Doc;
39
import javax.print.DocFlavor;
40
import javax.print.DocPrintJob;
41
import javax.print.PrintException;
42
import javax.print.PrintService;
43
import javax.print.PrintServiceLookup;
44
import javax.print.ServiceUI;
45
import javax.print.SimpleDoc;
46
import javax.print.attribute.PrintRequestAttributeSet;
47
import javax.print.event.PrintJobAdapter;
48
import javax.print.event.PrintJobEvent;
49
import javax.print.event.PrintJobListener;
50
import javax.swing.JComponent;
51
import javax.swing.JOptionPane;
52
import javax.swing.JPanel;
53
import javax.swing.JSplitPane;
54
import javax.swing.filechooser.FileFilter;
55

    
56
import org.gvsig.andami.PluginServices;
57
import org.gvsig.andami.PluginsLocator;
58
import org.gvsig.andami.messages.NotificationManager;
59
import org.gvsig.andami.ui.mdiManager.WindowInfo;
60
import org.gvsig.app.ApplicationLocator;
61
import org.gvsig.app.gui.preferencespage.PreferenceKeys;
62
import org.gvsig.app.project.documents.Document;
63
import org.gvsig.app.project.documents.gui.WindowLayout;
64
import org.gvsig.app.project.documents.layout.DefaultLayoutControl;
65
import org.gvsig.app.project.documents.layout.DefaultLayoutDocument;
66
import org.gvsig.app.project.documents.layout.LayoutContext;
67
import org.gvsig.app.project.documents.layout.LayoutControl;
68
import org.gvsig.app.project.documents.layout.LayoutDocument;
69
import org.gvsig.app.project.documents.layout.LayoutManager;
70
import org.gvsig.app.project.documents.layout.TocModelChangedNotification;
71
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
72
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap;
73
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog;
74
import org.gvsig.app.project.documents.layout.gui.dialogs.FConfigLayoutDialog;
75
import org.gvsig.app.project.documents.layout.toc.TocModelObserver;
76
import org.gvsig.app.project.documents.view.toc.gui.TOC;
77
import org.gvsig.fmap.mapcontext.MapContext;
78
import org.gvsig.fmap.mapcontext.events.ColorEvent;
79
import org.gvsig.fmap.mapcontext.events.ExtentEvent;
80
import org.gvsig.fmap.mapcontext.events.ProjectionEvent;
81
import org.gvsig.gui.beans.swing.JFileChooser;
82
import org.gvsig.tools.ToolsLocator;
83
import org.gvsig.tools.dynobject.DynStruct;
84
import org.gvsig.tools.observer.Observable;
85
import org.gvsig.tools.persistence.PersistenceManager;
86
import org.gvsig.tools.persistence.PersistentState;
87
import org.gvsig.tools.persistence.exception.PersistenceException;
88
import org.gvsig.utils.GenericFileFilter;
89
import org.gvsig.utils.XMLEntity;
90

    
91
/**
92
 * Graphic representation of the elements to print.
93
 * 
94
 * @author Vicente Caballero Navarro
95
 */
96
public class DefaultLayoutPanel extends LayoutPanel {
97

    
98
    private static final long serialVersionUID = 916830228032567624L;
99

    
100
    private static final int DEFAULT_HEIGHT = 450;
101

    
102
    private static final int DEFAULT_WIDTH = 700;
103

    
104
    public static final String PERSISTENCE_DEFINITION_NAME = "LayoutPanel";
105
    private static final String LAYOUTCONTEXT_OBJECT = "LayoutContext";
106
    private static final String LAYOUTDOCUMENT_OBJECT = "LayoutDocument";
107

    
108
    public static final String PDF_AND_PS_FILECHOOSER =
109
        "PDF_AND_PS_FILECHOOSER";
110

    
111
    public static File defaultPDFFolderPath;
112

    
113
    private MapProperties m_propertiesLayout = null;
114
    private PrintService[] m_cachePrintServices = null;
115
    private PrintService m_cachePrintService = null;
116
    private LayoutDocument layoutDocument = null;
117
    private Doc doc = null;
118
    private PrintRequestAttributeSet att = null;
119
    private WindowInfo m_viewInfo = null;
120
    /**
121
     * We use it when we are doing a layout and assigning tags.
122
     * It is put in debug when we do a VIEW_TAGS
123
     */
124
    private boolean bShowIconTag = false;
125
    private LayoutControl layoutControl = null;
126
    private LayoutContext layoutContext = null;
127
    private LayoutManager layoutManager = null;
128
        private JPanel leftPanel;
129
        private TOC toc = null;
130

    
131
        private JSplitPane splitPane;
132
        private int lastPanePos = 150;
133

    
134
        private Boolean b_isTocEnabled = null;
135
        private boolean b_firstTimeOpened = true;
136

    
137
    /**
138
     * Creates a new Layout object.
139
     */
140
    public DefaultLayoutPanel() {
141
        DefaultLayoutControl defaultLayoutControl = new DefaultLayoutControl();
142
        this.layoutControl = defaultLayoutControl;
143
        defaultLayoutControl.initialize(this);       
144
        this.initComponents();
145
    }
146

    
147
    public void setDocument(Document document) {
148
        layoutDocument = (LayoutDocument) document;
149
        setLayoutContext(layoutDocument.getLayoutContext());
150
        this.setName(document.getName());
151
        layoutDocument.addPropertyChangeListener(new PropertyChangeListener() {
152

    
153
            public void propertyChange(PropertyChangeEvent evt) {
154
                if (evt.getPropertyName().equals("name")) {
155
                    PluginServices
156
                        .getMDIManager()
157
                        .getWindowInfo(DefaultLayoutPanel.this)
158
                        .setTitle(
159
                            PluginServices.getText(this, "Mapa") + " : "
160
                                + (String) evt.getNewValue());
161
                }
162
            }
163
        });
164
        
165
        setToc();
166
    }
167
  
168
    /**
169
     * It initializes the components.
170
     */
171
    private void initComponents() {
172
            this.setLayout(new BorderLayout());
173
            if (isTocEnabled()) {
174
                    leftPanel = new JPanel(new BorderLayout());
175
                    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
176
                                    leftPanel, layoutControl.getComponent());
177
                    splitPane.setResizeWeight(0.2);
178
                    splitPane.setOneTouchExpandable(true);
179
                    splitPane.setContinuousLayout(true);
180
                    setToc();
181
                    add(splitPane, BorderLayout.CENTER);
182
            }
183
            else {
184
                    add(layoutControl.getComponent(), BorderLayout.CENTER);
185
            }
186
        layoutControl.getComponent().setDoubleBuffered(true);
187
    }
188
    
189
    private boolean isTocEnabled() {
190
            if (b_isTocEnabled==null) {
191
                    XMLEntity entity = PluginsLocator.getManager().getPlugin(this).getPersistentXML();
192
                    if (entity.contains(PreferenceKeys.DEFAULT_SHOW_LAYOUT_TOC_KEY_NAME)) {
193
                            b_isTocEnabled = entity.getBooleanProperty(PreferenceKeys.DEFAULT_SHOW_LAYOUT_TOC_KEY_NAME);
194
                    }
195
                    else {
196
                            b_isTocEnabled = PreferenceKeys.FACTORY_DEFAULT_SHOW_LAYOUT_TOC;
197
                    }
198
            }
199
            return b_isTocEnabled;
200
    }
201
    
202
    protected void createToc() {
203
                if (toc==null) {
204
                        toc = new TOC();
205
                }
206
                toc.setMapContext(getLayoutContext().getTocModel());
207
                leftPanel.removeAll();
208
                leftPanel.add(toc);
209
    }
210
    
211
    protected void setToc() {
212
            if (isTocEnabled()) {
213
                    if (getLayoutContext()!=null) {
214
                            if (getLayoutContext().getTocModel()!=null) {
215
                                    createToc();
216
                            }
217
                            else if (toc!=null) {
218
                                    DefaultLayoutPanel.this.leftPanel.remove(toc);
219
                            }
220

    
221
                            this.getLayoutContext().addTocObserver(new TocModelObserver() {
222

    
223
                                    public void tocUpdated(Object observable,
224
                                                    TocModelChangedNotification notification) {
225
                                            if (TocModelChangedNotification.Type.MODEL_CHANGED==notification.getType()) {
226
                                                    if (DefaultLayoutPanel.this.toc!=null){
227
                                                            DefaultLayoutPanel.this.toc.refresh();
228
                                                    }
229
                                            }
230
                                            else if (TocModelChangedNotification.Type.MODEL_SET==notification.getType()) {
231
                                                    MapContext mapContext = notification.getModel();
232
                                                    if (mapContext!=null) {
233
                                                            createToc();
234
                                                    }
235
                                                    else if (DefaultLayoutPanel.this.toc!=null){
236
                                                            DefaultLayoutPanel.this.leftPanel.remove(DefaultLayoutPanel.this.toc);
237
                                                            DefaultLayoutPanel.this.leftPanel.repaint();
238
                                                    }
239
                                            }
240
                                    }
241
                            });
242
                    }
243
            }
244
    }
245

    
246
    /**
247
     * Open the dialog of Layout properties.
248
     * 
249
     * @param job
250
     *            PrinterJob
251
     */
252
    public void showPagePropertiesWindow(PrinterJob job) {
253
        PageFormat pf1;
254

    
255
        pf1 = layoutContext.getAttributes().getPageFormat();
256
        pf1 = job.pageDialog(pf1);
257
        layoutContext.getAttributes().setPageFormat(pf1);
258
        layoutControl.refresh();
259
    }
260

    
261
    public void obtainRect(boolean isPrint) {
262
        layoutContext.getAttributes().obtainRect(isPrint,
263
            layoutControl.getRect(), getWidth(), getHeight());
264
    }
265
    
266
    public void showFConfig() {
267
        FConfigLayoutDialog m_configLayout = new FConfigLayoutDialog(this);
268
        PluginServices.getMDIManager().addCentredWindow(m_configLayout);
269
    }
270

    
271
    public boolean showFProperties() {
272
        if (layoutDocument == null) {
273
            layoutDocument = new DefaultLayoutDocument();
274
            layoutDocument.setName(getName());
275
        }
276

    
277
        m_propertiesLayout = new MapProperties(layoutDocument);
278
        PluginServices.getMDIManager().addWindow(m_propertiesLayout);
279
        return m_propertiesLayout.isAccepted();
280
    }
281

    
282
    public void showPrintDialog(PrinterJob job) {
283
        if (job != null) {
284
            job.printDialog();
285

    
286
            try {
287
                job.setPrintable((Printable) PluginServices
288
                    .getExtension(org.gvsig.app.extension.Print.class));
289
                job.print();
290
            } catch (PrinterException e) {
291
                e.printStackTrace();
292
            }
293
        } else {
294
            // Actualizar attributes
295
            att = layoutContext.getAttributes().toPrintRequestAttributeSet();
296

    
297
            // ------------------ The Printing things --------------------- //
298
            DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
299

    
300
            // returns the set of printers that support printing a specific
301
            // document type (such as GIF)
302
            // with a specific set of attributes (such as two sided).
303
            // PrintRequestAttributeSet pras = new
304
            // HashPrintRequestAttributeSet();
305
            // interestingly, the printer dialog's default behavior has changed
306
            // with the new API: by default the dialog is not shown.
307
            // So we must use the ServiceUI class to create a print dialog
308
            // returns the default print service.
309
            if (m_cachePrintServices == null) {
310
                m_cachePrintServices =
311
                    PrintServiceLookup.lookupPrintServices(flavor, null);
312
            }
313

    
314
            PrintService defaultService = null;
315

    
316
            if (m_cachePrintService == null) {
317
                defaultService = PrintServiceLookup.lookupDefaultPrintService();
318
            }
319

    
320
            if ((defaultService == null) && (m_cachePrintService == null)) {
321
                JOptionPane.showMessageDialog((Component) PluginServices
322
                    .getMainFrame(), PluginServices.getText(this,
323
                    "ninguna_impresora_configurada"));
324

    
325
                return;
326
            }
327

    
328
            if (m_cachePrintService == null) {
329
                m_cachePrintService =
330
                    ServiceUI.printDialog(null, 200, 200, m_cachePrintServices,
331
                        defaultService, flavor, att);
332
            } else {
333
                m_cachePrintService =
334
                    ServiceUI.printDialog(null, 200, 200, m_cachePrintServices,
335
                        m_cachePrintService, flavor, att);
336
            }
337

    
338
            if (m_cachePrintService != null) {
339
                DocPrintJob jobNuevo = m_cachePrintService.createPrintJob();
340
                PrintJobListener pjlistener = new PrintJobAdapter() {
341

    
342
                    public void printDataTransferCompleted(PrintJobEvent e) {
343
                        // System.out.println("Fin de impresi?n");
344
                        layoutControl.fullRect();
345
                    }
346
                };
347

    
348
                jobNuevo.addPrintJobListener(pjlistener);
349

    
350
                Printable pb = null;
351
                Class repClass = null;
352
                try {
353
                     repClass = Class.forName(flavor.getRepresentationClassName());
354
                } catch (Throwable e) {
355
                    throw new IllegalArgumentException("unknown representation class");
356
                }
357

    
358
                Object printData = PluginServices.getExtension(org.gvsig.app.extension.Print.class);
359
                
360
                doc = new SimpleDoc(printData, flavor, null);
361

    
362
                try {
363
                    jobNuevo.print(doc, att);
364

    
365
                } catch (PrintException pe) {
366
                    NotificationManager.addError(pe);
367
                }
368
            }
369
        }
370
    }
371

    
372
    public IFFrameDialog createFFrameDialog(IFFrame fframe) {
373
        return layoutManager.createFFrameDialog(fframe, this);
374
    }
375

    
376
    /**
377
     * This method is used to get <strong>an initial</strong> ViewInfo object
378
     * for this Map. It is not intended to retrieve the ViewInfo object in a
379
     * later time. <strong>Use PluginServices.getMDIManager().getViewInfo(view)
380
     * to retrieve the ViewInfo object at any time after the creation of the
381
     * object.
382
     * 
383
     * @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
384
     */
385
    public WindowInfo getWindowInfo() {
386
        if (m_viewInfo == null) {
387
            m_viewInfo =
388
                new WindowInfo(WindowInfo.ICONIFIABLE | WindowInfo.RESIZABLE
389
                    | WindowInfo.MAXIMIZABLE);
390
            m_viewInfo.setWidth(DEFAULT_WIDTH);
391
            m_viewInfo.setHeight(DEFAULT_HEIGHT);
392

    
393
            m_viewInfo.setTitle(PluginServices.getText(this, "Mapa") + " : "
394
                + layoutDocument.getName());
395
        }
396
        return m_viewInfo;
397
    }
398

    
399
    public LayoutContext getLayoutContext() {
400
        return layoutContext;
401
    }
402

    
403
    public LayoutControl getLayoutControl() {
404
        return layoutControl;
405
    }
406
    
407
    private boolean isInitConfigDialogEnabled() {
408
            XMLEntity entity = PluginsLocator.getManager().getPlugin(this).getPersistentXML();
409
            if (entity.contains(PreferenceKeys.DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_KEY_NAME)) {
410
                    return entity.getBooleanProperty(PreferenceKeys.DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_KEY_NAME);
411
            }
412
            else {
413
                    return PreferenceKeys.FACTORY_DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_FOR_LAYOUT;
414
            }
415
    }
416

    
417
    /**
418
     * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
419
     */
420
    public void windowActivated() {
421
                if (b_firstTimeOpened) {
422
                        b_firstTimeOpened = false;
423
            if (isInitConfigDialogEnabled()) {
424
                    FConfigLayoutDialog configDialog = new FConfigLayoutDialog(this, true);
425
                    ApplicationLocator.getManager().getUIManager().addCentredWindow(configDialog);
426
            }
427
            }
428
        layoutControl.refresh();
429
        PluginServices
430
            .getMainFrame()
431
            .getStatusBar()
432
            .setMessage(
433
                "units",
434
                PluginServices.getText(this, layoutContext.getAttributes()
435
                    .getNameUnit()));
436
        // ensure requestFocus is enabled
437
        if (!layoutControl.getComponent().isRequestFocusEnabled()) {
438
            layoutControl.getComponent().setRequestFocusEnabled(true);
439
        }
440
        IFFrameUseFMap[] selectedViews = layoutContext.getSelectedFFrames(IFFrameUseFMap.class);
441
        if (selectedViews.length==1) {
442
                IFFrameUseFMap ffview = selectedViews[0];
443
                // FIXME CMI: we should do sth more specific to update the ScaleControl
444
                ffview.refresh();
445
        }
446
        requestFocus();
447
        layoutControl.getComponent().requestFocus();
448
    }
449

    
450
    /**
451
     * @see com.iver.mdiApp.ui.MDIManager.SingletonWindow#getWindowModel()
452
     */
453
    public Object getWindowModel() {
454
        return layoutDocument;
455
    }
456

    
457
    public Document getDocument() {
458
        return layoutDocument;
459
    }
460

    
461
    /**
462
     * @see org.gvsig.andami.ui.mdiManager.IWindowListener#windowClosed()
463
     */
464
    public void windowClosed() {
465
        
466
    }
467

    
468
    /**
469
     * @see org.gvsig.fmap.mapcontext.events.listeners.ViewPortListener#backColorChanged(org.gvsig.fmap.mapcontext.events.ColorEvent)
470
     */
471
    public void backColorChanged(ColorEvent e) {
472
        // refresh();
473
    }
474

    
475
    public void layoutToPDF(String suggestedName) {
476
        FileFilter pdfFilter =
477
            new GenericFileFilter("pdf", PluginServices.getText(this, "pdf"));
478

    
479
        JFileChooser jfc =
480
            new JFileChooser(PDF_AND_PS_FILECHOOSER, defaultPDFFolderPath);
481
        if (suggestedName != null) {
482
            jfc.setSelectedFile(new File(suggestedName));
483
        }
484
        jfc.addChoosableFileFilter(pdfFilter);
485
        jfc.setFileFilter(pdfFilter);
486

    
487
        if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) {
488
            File f = jfc.getSelectedFile();
489
            File faux = null;
490

    
491
            if (f.getName().endsWith(".pdf") || f.getName().endsWith(".PDF")) {
492
                faux = f;
493
            } else {
494
                faux = new File(f.getPath() + ".pdf");
495
            }
496

    
497
            layoutControl.getLayoutDraw().toPDF(faux);
498
        }
499
    }
500

    
501
    public void layoutToPS(String suggestedName) {
502
        FileFilter pdfFilter =
503
            new GenericFileFilter("ps", PluginServices.getText(this, "ps"));
504

    
505
        JFileChooser jfc =
506
            new JFileChooser(PDF_AND_PS_FILECHOOSER, defaultPDFFolderPath);
507
        if (suggestedName != null) {
508
            jfc.setSelectedFile(new File(suggestedName));
509
        }
510
        jfc.addChoosableFileFilter(pdfFilter);
511
        jfc.setFileFilter(pdfFilter);
512

    
513
        if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) {
514
            File f = jfc.getSelectedFile();
515
            File faux = null;
516

    
517
            if (f.getName().endsWith(".ps") || f.getName().endsWith(".PS")) {
518
                faux = f;
519
            } else {
520
                faux = new File(f.getPath() + ".ps");
521
            }
522

    
523
            layoutControl.getLayoutDraw().toPS(faux);
524
        }
525
    }
526

    
527
    public void layoutToPDF() {
528
        layoutToPDF(null);
529
    }
530

    
531
    public void layoutToPS() {
532
        layoutToPS(null);
533
    }
534

    
535
    public boolean isShowIconTag() {
536
        return bShowIconTag;
537
    }
538

    
539
    public void setShowIconTag(boolean modeDebug) {
540
        bShowIconTag = modeDebug;
541
    }
542

    
543
    public void update(Observable observable, Object notification) {
544
            this.layoutContext.updateFFrames();
545
            this.layoutControl.refresh();
546
    }
547

    
548
    public Object getWindowProfile() {
549
        return WindowInfo.EDITOR_PROFILE;
550
    }
551

    
552
    public void saveToState(PersistentState state) throws PersistenceException {
553
        state.set(LAYOUTCONTEXT_OBJECT, layoutContext);
554
        state.set(LAYOUTDOCUMENT_OBJECT, layoutDocument);
555
    }
556

    
557
    public void loadFromState(PersistentState state)
558
        throws PersistenceException {
559
        this.layoutContext = (LayoutContext) state.get(LAYOUTCONTEXT_OBJECT);
560
        this.layoutDocument = (LayoutDocument) state.get(LAYOUTDOCUMENT_OBJECT);
561
        this.layoutControl.setLayoutContext(layoutContext);
562
    }
563

    
564
    public static void registerPersistent() {
565
        PersistenceManager manager = ToolsLocator.getPersistenceManager();
566
        if (manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null) {
567
            DynStruct definition =
568
                manager.addDefinition(DefaultLayoutPanel.class,
569
                    PERSISTENCE_DEFINITION_NAME,
570
                    "Layout panel persistence definition", null, null);
571

    
572
            definition.addDynFieldObject(LAYOUTCONTEXT_OBJECT)
573
                .setClassOfValue(LayoutContext.class).setMandatory(true);
574
            definition.addDynFieldObject(LAYOUTDOCUMENT_OBJECT)
575
                .setClassOfValue(LayoutDocument.class).setMandatory(true);
576
        }
577
    }
578

    
579
    public WindowLayout getWindowLayout() {
580
        return null;
581
    }
582

    
583
    public void setWindowLayout(WindowLayout layout) {
584

    
585
    }
586

    
587
    private void setLayoutContext(LayoutContext theLayoutcontext) {
588
        this.layoutContext = theLayoutcontext;
589
        this.layoutControl.setLayoutContext(theLayoutcontext);
590
        layoutContext.getAttributes().calculateGridGapX(layoutControl.getRect());
591
        layoutContext.getAttributes().calculateGridGapY(layoutControl.getRect());
592
        layoutControl.setDefaultTool();
593
    }
594

    
595
    @Override
596
    public void setLayoutManager(LayoutManager layoutManager) {
597
        this.layoutManager = layoutManager;
598
    }
599
    
600
    
601
    /**
602
     * Method to print the Layout without modify the Affinetransform.
603
     *
604
     * @param g2 Geaphics2D
605
     */
606
    public void drawLayoutPrint(Graphics2D g2) {
607
        layoutControl.setCancelDrawing(false);
608

    
609
        double scale = 0;
610
        scale = layoutControl.getRect().height / layoutContext.getAttributes().m_sizePaper.getHeight() * 1;
611
        AffineTransform escalado = new AffineTransform();
612
        AffineTransform translacion = new AffineTransform();
613
        translacion.setToTranslation(layoutControl.getRect().getMinX(), layoutControl.getRect().getMinY());
614
        escalado.setToScale(scale, scale);
615
        layoutControl.getAT().setToIdentity();
616
        layoutControl.getAT().concatenate(translacion);
617
        layoutControl.getAT().concatenate(escalado);
618
        layoutContext.getAttributes().calculateGridGapX(layoutControl.getRect());
619
        layoutContext.getAttributes().calculateGridGapY(layoutControl.getRect());
620
        IFFrame[] fframes=layoutContext.getFFrames();
621
        
622
        for (int i = 0; i < fframes.length; i++) {
623
            fframes[i].print(
624
                g2,
625
                layoutControl.getAT(),
626
                null,
627
                layoutContext.getAttributes().toPrintAttributes());
628
        }
629
    }
630
        
631
        public void hideToc() {
632
                if (isTocEnabled()) {
633
                        lastPanePos = splitPane.getDividerLocation();
634
                        splitPane.setDividerLocation(0);
635
                }
636
        }
637

    
638
        public void showToc() {
639
                if (isTocEnabled()) {
640
                        splitPane.setDividerLocation(lastPanePos);
641
                }
642
        }
643

    
644
}