Revision 355
tags/org.gvsig.app.document.layout2.app-2.0.45/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
2 |
|
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.app.document.layout2.app</artifactId> |
|
5 |
<packaging>pom</packaging> |
|
6 |
<version>2.0.45</version> |
|
7 |
|
|
8 |
<name>${project.artifactId}</name> |
|
9 |
<description>This plugin adds creation/management of layout (map) documents.</description> |
|
10 |
|
|
11 |
<parent> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.desktop</artifactId> |
|
14 |
<version>2.0.90</version> |
|
15 |
</parent> |
|
16 |
|
|
17 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-app-document-layout</url> |
|
18 |
|
|
19 |
<scm> |
|
20 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-app-document-layout/tags/org.gvsig.app.document.layout2.app-2.0.45</connection> |
|
21 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-app-document-layout/tags/org.gvsig.app.document.layout2.app-2.0.45</developerConnection> |
|
22 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-app-document-layout/repository/show/tags/org.gvsig.app.document.layout2.app-2.0.45</url> |
|
23 |
</scm> |
|
24 |
<repositories> |
|
25 |
<repository> |
|
26 |
<id>gvsig-public-http-repository</id> |
|
27 |
<name>gvSIG maven public HTTP repository</name> |
|
28 |
<url>http://devel.gvsig.org/m2repo/j2se</url> |
|
29 |
<releases> |
|
30 |
<enabled>true</enabled> |
|
31 |
<updatePolicy>daily</updatePolicy> |
|
32 |
<checksumPolicy>warn</checksumPolicy> |
|
33 |
</releases> |
|
34 |
<snapshots> |
|
35 |
<enabled>true</enabled> |
|
36 |
<updatePolicy>daily</updatePolicy> |
|
37 |
<checksumPolicy>warn</checksumPolicy> |
|
38 |
</snapshots> |
|
39 |
</repository> |
|
40 |
</repositories> |
|
41 |
|
|
42 |
<build> |
|
43 |
<plugins> |
|
44 |
<plugin> |
|
45 |
<groupId>org.apache.maven.plugins</groupId> |
|
46 |
<artifactId>maven-release-plugin</artifactId> |
|
47 |
<configuration> |
|
48 |
<tagBase>https://devel.gvsig.org/svn/gvsig-app-document-layout/tags</tagBase> |
|
49 |
</configuration> |
|
50 |
</plugin> |
|
51 |
</plugins> |
|
52 |
</build> |
|
53 |
|
|
54 |
<modules> |
|
55 |
<module>org.gvsig.app.document.layout2.app.mainplugin</module> |
|
56 |
</modules> |
|
57 |
|
|
58 |
</project> |
|
0 | 59 |
tags/org.gvsig.app.document.layout2.app-2.0.45/org.gvsig.app.document.layout2.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
</files> |
|
17 |
|
|
18 |
<fileSets> |
|
19 |
<fileSet> |
|
20 |
<directory>src/main/resources-plugin</directory> |
|
21 |
<outputDirectory>.</outputDirectory> |
|
22 |
</fileSet> |
|
23 |
</fileSets> |
|
24 |
|
|
25 |
<dependencySets> |
|
26 |
|
|
27 |
<!-- |
|
28 |
<dependencySet> |
|
29 |
<useProjectArtifact>false</useProjectArtifact> |
|
30 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
31 |
<outputDirectory>lib</outputDirectory> |
|
32 |
<includes> |
|
33 |
</includes> |
|
34 |
</dependencySet> |
|
35 |
|
|
36 |
--> |
|
37 |
|
|
38 |
</dependencySets> |
|
39 |
|
|
40 |
</assembly> |
|
0 | 41 |
tags/org.gvsig.app.document.layout2.app-2.0.45/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/gui/LayoutPanel.java | ||
---|---|---|
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.Graphics2D; |
|
25 |
import java.awt.print.PrinterJob; |
|
26 |
|
|
27 |
import javax.swing.JComponent; |
|
28 |
import javax.swing.JPanel; |
|
29 |
|
|
30 |
import org.gvsig.app.project.documents.gui.IDocumentWindow; |
|
31 |
import org.gvsig.app.project.documents.layout.LayoutContext; |
|
32 |
import org.gvsig.app.project.documents.layout.LayoutControl; |
|
33 |
import org.gvsig.app.project.documents.layout.LayoutManager; |
|
34 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
|
35 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog; |
|
36 |
import org.gvsig.fmap.mapcontext.events.listeners.ViewPortListener; |
|
37 |
import org.gvsig.tools.observer.Observer; |
|
38 |
import org.gvsig.tools.persistence.Persistent; |
|
39 |
|
|
40 |
/** |
|
41 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a> |
|
42 |
*/ |
|
43 |
public abstract class LayoutPanel extends JPanel implements IDocumentWindow, |
|
44 |
Observer, Persistent { |
|
45 |
|
|
46 |
private static final long serialVersionUID = 5961147362842287273L; |
|
47 |
|
|
48 |
/** |
|
49 |
* Returns the LayoutContext. |
|
50 |
* |
|
51 |
* @return LayoutContext. |
|
52 |
*/ |
|
53 |
public abstract LayoutContext getLayoutContext(); |
|
54 |
|
|
55 |
/** |
|
56 |
* Returns LayoutControl. |
|
57 |
* |
|
58 |
* @return LayoutControl. |
|
59 |
*/ |
|
60 |
public abstract LayoutControl getLayoutControl(); |
|
61 |
|
|
62 |
/** |
|
63 |
* @return Returns the bShowIconTag. |
|
64 |
*/ |
|
65 |
public abstract boolean isShowIconTag(); |
|
66 |
|
|
67 |
/** |
|
68 |
* @param modeDebug |
|
69 |
* The bModeDebug to set. |
|
70 |
*/ |
|
71 |
public abstract void setShowIconTag(boolean modeDebug); |
|
72 |
|
|
73 |
/** |
|
74 |
* It opens a dialog to select pdf file where to save the Layout in this |
|
75 |
* format. |
|
76 |
*/ |
|
77 |
public abstract void layoutToPDF(); |
|
78 |
|
|
79 |
/** |
|
80 |
* Opens a dialog where to pick a PDF-file to save the current Layout |
|
81 |
* suggesting a name for the file given by the first argument |
|
82 |
* |
|
83 |
* @param suggestedName |
|
84 |
*/ |
|
85 |
public abstract void layoutToPDF(String suggestedName); |
|
86 |
|
|
87 |
/** |
|
88 |
* It opens a dialog to select ps file where to save the Layout in this |
|
89 |
* format. |
|
90 |
*/ |
|
91 |
public abstract void layoutToPS(); |
|
92 |
|
|
93 |
/** |
|
94 |
* Opens a dialog where to pick a PS-file to save the current Layout |
|
95 |
* suggesting a name for the file given by the first argument |
|
96 |
* |
|
97 |
* @param suggestedName |
|
98 |
*/ |
|
99 |
public abstract void layoutToPS(String suggestedName); |
|
100 |
|
|
101 |
/** |
|
102 |
* The dialogs are created here each time that are needed. |
|
103 |
* |
|
104 |
* @param fframe |
|
105 |
* Rectangle that represents the place that occupied the element |
|
106 |
* added. |
|
107 |
* |
|
108 |
* @return IFFrame Returns the FFrame added or null if the fframe has not |
|
109 |
* been added. |
|
110 |
*/ |
|
111 |
public abstract IFFrameDialog createFFrameDialog(IFFrame fframe); |
|
112 |
|
|
113 |
/** |
|
114 |
* It obtains the rect?ngulo that represents the sheet with the |
|
115 |
* characteristics |
|
116 |
* that contains attributes and differentiating if is to visualize in screen |
|
117 |
* or |
|
118 |
* for print. |
|
119 |
* |
|
120 |
*/ |
|
121 |
public abstract void obtainRect(boolean isPrint); |
|
122 |
|
|
123 |
/** |
|
124 |
* It shows the dialog of configuration of the Layout. |
|
125 |
*/ |
|
126 |
public abstract void showFConfig(); |
|
127 |
|
|
128 |
/** |
|
129 |
* It shows the dialog of Layout?s properties. |
|
130 |
*/ |
|
131 |
public abstract boolean showFProperties(); |
|
132 |
|
|
133 |
/** |
|
134 |
* It shows the dialog of printing of the Layout. |
|
135 |
* |
|
136 |
* @param job |
|
137 |
* PrinterJob |
|
138 |
*/ |
|
139 |
public abstract void showPrintDialog(PrinterJob job); |
|
140 |
|
|
141 |
public abstract void setLayoutManager(LayoutManager layoutManager); |
|
142 |
|
|
143 |
public abstract void drawLayoutPrint(Graphics2D g2); |
|
144 |
|
|
145 |
public abstract void hideToc(); |
|
146 |
|
|
147 |
public abstract void showToc(); |
|
148 |
|
|
149 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.45/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/gui/FPopupMenu.java | ||
---|---|---|
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.Font; |
|
25 |
import java.awt.event.ActionEvent; |
|
26 |
import java.awt.event.ActionListener; |
|
27 |
|
|
28 |
import javax.swing.JMenuItem; |
|
29 |
import javax.swing.JPopupMenu; |
|
30 |
|
|
31 |
import org.gvsig.app.project.ProjectManager; |
|
32 |
import org.gvsig.app.project.documents.layout.LayoutManager; |
|
33 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
|
34 |
import org.gvsig.app.project.documents.view.IContextMenuAction; |
|
35 |
|
|
36 |
/** |
|
37 |
* Menu de bot?n derecho para el Layout. |
|
38 |
* Se pueden a?adir entradas facilmente desde una extensi?n, |
|
39 |
* creando una clase derivando de LayoutMenuEntry, y a?adiendola en |
|
40 |
* est?tico (o en tiempo de carga de la extensi?n) a FPopupMenu. |
|
41 |
* (Las entradas actuales est?n hechas de esa manera). |
|
42 |
* |
|
43 |
* @author Vicente Caballero Navarro |
|
44 |
* |
|
45 |
*/ |
|
46 |
|
|
47 |
public class FPopupMenu extends JPopupMenu { |
|
48 |
|
|
49 |
/** |
|
50 |
* |
|
51 |
*/ |
|
52 |
private static final long serialVersionUID = 5340224239252101704L; |
|
53 |
// private static ArrayList menuEntrys = new ArrayList(); |
|
54 |
protected LayoutPanel layout; |
|
55 |
private IFFrame[] selecteds; |
|
56 |
|
|
57 |
// private JMenuItem capa; |
|
58 |
// Lo de fijar la fuente es porque en linux se ve?a mal si no se fija. |
|
59 |
// TODO: Esto no funcionar? para idiomas como el chino. Hay que cambiarlo. |
|
60 |
public final static Font theFont = new Font("SansSerif", Font.PLAIN, 10); |
|
61 |
|
|
62 |
|
|
63 |
/** |
|
64 |
* Creates a new FPopupMenu object. |
|
65 |
* |
|
66 |
* @param nodo |
|
67 |
* DOCUMENT ME! |
|
68 |
* @param vista |
|
69 |
* DOCUMENT ME! |
|
70 |
*/ |
|
71 |
public FPopupMenu(LayoutPanel layout) { |
|
72 |
super(); |
|
73 |
this.initialize(layout); |
|
74 |
} |
|
75 |
|
|
76 |
private void initialize(LayoutPanel layout) { |
|
77 |
this.layout = layout; |
|
78 |
this.selecteds = this.layout.getLayoutContext().getSelectedFFrames(); |
|
79 |
LayoutManager layoutManager = |
|
80 |
(LayoutManager) ProjectManager.getInstance() |
|
81 |
.getDocumentManager("project.document.layout"); |
|
82 |
|
|
83 |
IContextMenuAction[] actions = layoutManager.createLayoutMenuActions(layout); |
|
84 |
this.createMenuElements(actions); |
|
85 |
} |
|
86 |
|
|
87 |
|
|
88 |
private void createMenuElements(IContextMenuAction[] actions) { |
|
89 |
String group = null; |
|
90 |
for (int i = 0; i < actions.length; i++) { |
|
91 |
IContextMenuAction action = actions[i]; |
|
92 |
MenuItem item = new MenuItem(action.getText(), action); |
|
93 |
item.setFont(theFont); |
|
94 |
item.setEnabled(action.isEnabled(null, this.selecteds)); |
|
95 |
if (!action.getGroup().equals(group)) { |
|
96 |
if (group != null) { |
|
97 |
this.addSeparator(); |
|
98 |
} |
|
99 |
group = action.getGroup(); |
|
100 |
} |
|
101 |
this.add(item); |
|
102 |
} |
|
103 |
|
|
104 |
} |
|
105 |
|
|
106 |
public class MenuItem extends JMenuItem implements ActionListener { |
|
107 |
|
|
108 |
/** |
|
109 |
* |
|
110 |
*/ |
|
111 |
private static final long serialVersionUID = 2518112362194914446L; |
|
112 |
private IContextMenuAction action; |
|
113 |
|
|
114 |
public MenuItem(String text, IContextMenuAction documentAction) { |
|
115 |
super(text); |
|
116 |
this.action = documentAction; |
|
117 |
String tip = this.action.getDescription(); |
|
118 |
if (tip != null && tip.length() > 0) { |
|
119 |
this.setToolTipText(tip); |
|
120 |
} |
|
121 |
this.addActionListener(this); |
|
122 |
} |
|
123 |
|
|
124 |
public void actionPerformed(ActionEvent e) { |
|
125 |
this.action.execute(layout.getLayoutContext(), |
|
126 |
FPopupMenu.this.selecteds); |
|
127 |
} |
|
128 |
} |
|
129 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.45/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/gui/DefaultLayoutPanel.java | ||
---|---|---|
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.ActionEvent; |
|
28 |
import java.awt.event.ActionListener; |
|
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.JOptionPane; |
|
51 |
import javax.swing.JPanel; |
|
52 |
import javax.swing.JSplitPane; |
|
53 |
import javax.swing.filechooser.FileFilter; |
|
54 |
|
|
55 |
import org.gvsig.andami.PluginServices; |
|
56 |
import org.gvsig.andami.PluginsLocator; |
|
57 |
import org.gvsig.andami.messages.NotificationManager; |
|
58 |
import org.gvsig.andami.ui.mdiManager.IWindowListener; |
|
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.LayoutPanelListener; |
|
74 |
import org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog; |
|
75 |
import org.gvsig.app.project.documents.layout.gui.dialogs.FConfigLayoutDialog; |
|
76 |
import org.gvsig.app.project.documents.layout.toc.TocModelObserver; |
|
77 |
import org.gvsig.app.project.documents.view.toc.gui.TOC; |
|
78 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
79 |
import org.gvsig.fmap.mapcontext.events.ColorEvent; |
|
80 |
import org.gvsig.gui.beans.swing.JFileChooser; |
|
81 |
import org.gvsig.tools.ToolsLocator; |
|
82 |
import org.gvsig.tools.dynobject.DynStruct; |
|
83 |
import org.gvsig.tools.observer.Observable; |
|
84 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
85 |
import org.gvsig.tools.persistence.PersistentState; |
|
86 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
87 |
import org.gvsig.utils.GenericFileFilter; |
|
88 |
import org.gvsig.utils.XMLEntity; |
|
89 |
|
|
90 |
/** |
|
91 |
* Graphic representation of the elements to print. |
|
92 |
* |
|
93 |
* @author Vicente Caballero Navarro |
|
94 |
*/ |
|
95 |
public class DefaultLayoutPanel extends LayoutPanel { |
|
96 |
|
|
97 |
private static final long serialVersionUID = 916830228032567624L; |
|
98 |
|
|
99 |
private static final int DEFAULT_HEIGHT = 450; |
|
100 |
|
|
101 |
private static final int DEFAULT_WIDTH = 700; |
|
102 |
|
|
103 |
public static final String PERSISTENCE_DEFINITION_NAME = "LayoutPanel"; |
|
104 |
private static final String LAYOUTCONTEXT_OBJECT = "LayoutContext"; |
|
105 |
private static final String LAYOUTDOCUMENT_OBJECT = "LayoutDocument"; |
|
106 |
|
|
107 |
public static final String PDF_AND_PS_FILECHOOSER = |
|
108 |
"PDF_AND_PS_FILECHOOSER"; |
|
109 |
|
|
110 |
public static File defaultPDFFolderPath; |
|
111 |
|
|
112 |
private MapProperties m_propertiesLayout = null; |
|
113 |
private PrintService[] m_cachePrintServices = null; |
|
114 |
private PrintService m_cachePrintService = null; |
|
115 |
private LayoutDocument layoutDocument = null; |
|
116 |
private Doc doc = null; |
|
117 |
private PrintRequestAttributeSet att = null; |
|
118 |
private WindowInfo m_viewInfo = null; |
|
119 |
/** |
|
120 |
* We use it when we are doing a layout and assigning tags. |
|
121 |
* It is put in debug when we do a VIEW_TAGS |
|
122 |
*/ |
|
123 |
private boolean bShowIconTag = false; |
|
124 |
private LayoutControl layoutControl = null; |
|
125 |
private LayoutContext layoutContext = null; |
|
126 |
private LayoutManager layoutManager = null; |
|
127 |
private JPanel leftPanel; |
|
128 |
private TOC toc = null; |
|
129 |
|
|
130 |
private JSplitPane splitPane; |
|
131 |
private int lastPanePos = 150; |
|
132 |
|
|
133 |
private Boolean b_isTocEnabled = null; |
|
134 |
|
|
135 |
/** |
|
136 |
* Creates a new Layout object. |
|
137 |
*/ |
|
138 |
public DefaultLayoutPanel() { |
|
139 |
DefaultLayoutControl defaultLayoutControl = new DefaultLayoutControl(); |
|
140 |
this.layoutControl = defaultLayoutControl; |
|
141 |
defaultLayoutControl.initialize(this); |
|
142 |
this.initComponents(); |
|
143 |
} |
|
144 |
|
|
145 |
public void setDocument(Document document) { |
|
146 |
layoutDocument = (LayoutDocument) document; |
|
147 |
setLayoutContext(layoutDocument.getLayoutContext()); |
|
148 |
this.setName(document.getName()); |
|
149 |
layoutDocument.addPropertyChangeListener(new PropertyChangeListener() { |
|
150 |
|
|
151 |
public void propertyChange(PropertyChangeEvent evt) { |
|
152 |
if (evt.getPropertyName().equals("name")) { |
|
153 |
PluginServices |
|
154 |
.getMDIManager() |
|
155 |
.getWindowInfo(DefaultLayoutPanel.this) |
|
156 |
.setTitle( |
|
157 |
PluginServices.getText(this, "Mapa") + " : " |
|
158 |
+ (String) evt.getNewValue()); |
|
159 |
} |
|
160 |
} |
|
161 |
}); |
|
162 |
|
|
163 |
setToc(); |
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
167 |
* It initializes the components. |
|
168 |
*/ |
|
169 |
private void initComponents() { |
|
170 |
this.setLayout(new BorderLayout()); |
|
171 |
if (isTocEnabled()) { |
|
172 |
leftPanel = new JPanel(new BorderLayout()); |
|
173 |
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, |
|
174 |
leftPanel, layoutControl.getComponent()); |
|
175 |
splitPane.setResizeWeight(0.2); |
|
176 |
splitPane.setOneTouchExpandable(true); |
|
177 |
splitPane.setContinuousLayout(true); |
|
178 |
setToc(); |
|
179 |
add(splitPane, BorderLayout.CENTER); |
|
180 |
} |
|
181 |
else { |
|
182 |
add(layoutControl.getComponent(), BorderLayout.CENTER); |
|
183 |
} |
|
184 |
layoutControl.getComponent().setDoubleBuffered(true); |
|
185 |
} |
|
186 |
|
|
187 |
private boolean isTocEnabled() { |
|
188 |
if (b_isTocEnabled==null) { |
|
189 |
XMLEntity entity = PluginsLocator.getManager().getPlugin(this).getPersistentXML(); |
|
190 |
if (entity.contains(PreferenceKeys.DEFAULT_SHOW_LAYOUT_TOC_KEY_NAME)) { |
|
191 |
b_isTocEnabled = entity.getBooleanProperty(PreferenceKeys.DEFAULT_SHOW_LAYOUT_TOC_KEY_NAME); |
|
192 |
} |
|
193 |
else { |
|
194 |
b_isTocEnabled = PreferenceKeys.FACTORY_DEFAULT_SHOW_LAYOUT_TOC; |
|
195 |
} |
|
196 |
} |
|
197 |
return b_isTocEnabled; |
|
198 |
} |
|
199 |
|
|
200 |
protected void createToc() { |
|
201 |
if (toc==null) { |
|
202 |
toc = new TOC(); |
|
203 |
} |
|
204 |
toc.setMapContext(getLayoutContext().getTocModel()); |
|
205 |
leftPanel.removeAll(); |
|
206 |
leftPanel.add(toc); |
|
207 |
} |
|
208 |
|
|
209 |
protected void setToc() { |
|
210 |
if (isTocEnabled()) { |
|
211 |
if (getLayoutContext()!=null) { |
|
212 |
if (getLayoutContext().getTocModel()!=null) { |
|
213 |
createToc(); |
|
214 |
} |
|
215 |
else if (toc!=null) { |
|
216 |
DefaultLayoutPanel.this.leftPanel.remove(toc); |
|
217 |
} |
|
218 |
|
|
219 |
this.getLayoutContext().addTocObserver(new TocModelObserver() { |
|
220 |
|
|
221 |
public void tocUpdated(Object observable, |
|
222 |
TocModelChangedNotification notification) { |
|
223 |
if (TocModelChangedNotification.Type.ITEM_UPDATED==notification.getType()) { |
|
224 |
if (DefaultLayoutPanel.this.toc!=null){ |
|
225 |
DefaultLayoutPanel.this.toc.repaint(); |
|
226 |
} |
|
227 |
} |
|
228 |
else if (TocModelChangedNotification.Type.MODEL_CHANGED==notification.getType()) { |
|
229 |
if (DefaultLayoutPanel.this.toc!=null){ |
|
230 |
DefaultLayoutPanel.this.toc.refresh(); |
|
231 |
} |
|
232 |
} |
|
233 |
else if (TocModelChangedNotification.Type.MODEL_SET==notification.getType()) { |
|
234 |
MapContext mapContext = notification.getModel(); |
|
235 |
if (mapContext!=null) { |
|
236 |
createToc(); |
|
237 |
} |
|
238 |
else if (DefaultLayoutPanel.this.toc!=null){ |
|
239 |
DefaultLayoutPanel.this.leftPanel.remove(DefaultLayoutPanel.this.toc); |
|
240 |
DefaultLayoutPanel.this.leftPanel.repaint(); |
|
241 |
} |
|
242 |
} |
|
243 |
} |
|
244 |
}); |
|
245 |
} |
|
246 |
} |
|
247 |
} |
|
248 |
|
|
249 |
/** |
|
250 |
* Open the dialog of Layout properties. |
|
251 |
* |
|
252 |
* @param job |
|
253 |
* PrinterJob |
|
254 |
*/ |
|
255 |
public void showPagePropertiesWindow(PrinterJob job) { |
|
256 |
PageFormat pf1; |
|
257 |
|
|
258 |
pf1 = layoutContext.getAttributes().getPageFormat(); |
|
259 |
pf1 = job.pageDialog(pf1); |
|
260 |
layoutContext.getAttributes().setPageFormat(pf1); |
|
261 |
layoutControl.refresh(); |
|
262 |
} |
|
263 |
|
|
264 |
public void obtainRect(boolean isPrint) { |
|
265 |
layoutContext.getAttributes().obtainRect(isPrint, |
|
266 |
layoutControl.getRect(), getWidth(), getHeight()); |
|
267 |
} |
|
268 |
|
|
269 |
public void showFConfig() { |
|
270 |
FConfigLayoutDialog m_configLayout = new FConfigLayoutDialog(this); |
|
271 |
PluginServices.getMDIManager().addCentredWindow(m_configLayout); |
|
272 |
} |
|
273 |
|
|
274 |
public boolean showFProperties() { |
|
275 |
if (layoutDocument == null) { |
|
276 |
layoutDocument = new DefaultLayoutDocument(); |
|
277 |
layoutDocument.setName(getName()); |
|
278 |
} |
|
279 |
|
|
280 |
m_propertiesLayout = new MapProperties(layoutDocument); |
|
281 |
PluginServices.getMDIManager().addWindow(m_propertiesLayout); |
|
282 |
return m_propertiesLayout.isAccepted(); |
|
283 |
} |
|
284 |
|
|
285 |
public void showPrintDialog(PrinterJob job) { |
|
286 |
if (job != null) { |
|
287 |
job.printDialog(); |
|
288 |
|
|
289 |
try { |
|
290 |
job.setPrintable((Printable) PluginServices |
|
291 |
.getExtension(org.gvsig.app.extension.Print.class)); |
|
292 |
job.print(); |
|
293 |
} catch (PrinterException e) { |
|
294 |
e.printStackTrace(); |
|
295 |
} |
|
296 |
} else { |
|
297 |
// Actualizar attributes |
|
298 |
att = layoutContext.getAttributes().toPrintRequestAttributeSet(); |
|
299 |
|
|
300 |
// ------------------ The Printing things --------------------- // |
|
301 |
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; |
|
302 |
|
|
303 |
// returns the set of printers that support printing a specific |
|
304 |
// document type (such as GIF) |
|
305 |
// with a specific set of attributes (such as two sided). |
|
306 |
// PrintRequestAttributeSet pras = new |
|
307 |
// HashPrintRequestAttributeSet(); |
|
308 |
// interestingly, the printer dialog's default behavior has changed |
|
309 |
// with the new API: by default the dialog is not shown. |
|
310 |
// So we must use the ServiceUI class to create a print dialog |
|
311 |
// returns the default print service. |
|
312 |
if (m_cachePrintServices == null) { |
|
313 |
m_cachePrintServices = |
|
314 |
PrintServiceLookup.lookupPrintServices(flavor, null); |
|
315 |
} |
|
316 |
|
|
317 |
PrintService defaultService = null; |
|
318 |
|
|
319 |
if (m_cachePrintService == null) { |
|
320 |
defaultService = PrintServiceLookup.lookupDefaultPrintService(); |
|
321 |
} |
|
322 |
|
|
323 |
if ((defaultService == null) && (m_cachePrintService == null)) { |
|
324 |
JOptionPane.showMessageDialog((Component) PluginServices |
|
325 |
.getMainFrame(), PluginServices.getText(this, |
|
326 |
"ninguna_impresora_configurada")); |
|
327 |
|
|
328 |
return; |
|
329 |
} |
|
330 |
|
|
331 |
if (m_cachePrintService == null) { |
|
332 |
m_cachePrintService = |
|
333 |
ServiceUI.printDialog(null, 200, 200, m_cachePrintServices, |
|
334 |
defaultService, flavor, att); |
|
335 |
} else { |
|
336 |
m_cachePrintService = |
|
337 |
ServiceUI.printDialog(null, 200, 200, m_cachePrintServices, |
|
338 |
m_cachePrintService, flavor, att); |
|
339 |
} |
|
340 |
|
|
341 |
if (m_cachePrintService != null) { |
|
342 |
DocPrintJob jobNuevo = m_cachePrintService.createPrintJob(); |
|
343 |
PrintJobListener pjlistener = new PrintJobAdapter() { |
|
344 |
|
|
345 |
public void printDataTransferCompleted(PrintJobEvent e) { |
|
346 |
// System.out.println("Fin de impresi?n"); |
|
347 |
layoutControl.fullRect(); |
|
348 |
} |
|
349 |
}; |
|
350 |
|
|
351 |
jobNuevo.addPrintJobListener(pjlistener); |
|
352 |
|
|
353 |
Printable pb = null; |
|
354 |
Class repClass = null; |
|
355 |
try { |
|
356 |
repClass = Class.forName(flavor.getRepresentationClassName()); |
|
357 |
} catch (Throwable e) { |
|
358 |
throw new IllegalArgumentException("unknown representation class"); |
|
359 |
} |
|
360 |
|
|
361 |
Object printData = PluginServices.getExtension(org.gvsig.app.extension.Print.class); |
|
362 |
|
|
363 |
doc = new SimpleDoc(printData, flavor, null); |
|
364 |
|
|
365 |
try { |
|
366 |
jobNuevo.print(doc, att); |
|
367 |
|
|
368 |
} catch (PrintException pe) { |
|
369 |
NotificationManager.addError(pe); |
|
370 |
} |
|
371 |
} |
|
372 |
} |
|
373 |
} |
|
374 |
|
|
375 |
public IFFrameDialog createFFrameDialog(IFFrame fframe) { |
|
376 |
return layoutManager.createFFrameDialog(fframe, this); |
|
377 |
} |
|
378 |
|
|
379 |
/** |
|
380 |
* This method is used to get <strong>an initial</strong> ViewInfo object |
|
381 |
* for this Map. It is not intended to retrieve the ViewInfo object in a |
|
382 |
* later time. <strong>Use PluginServices.getMDIManager().getViewInfo(view) |
|
383 |
* to retrieve the ViewInfo object at any time after the creation of the |
|
384 |
* object. |
|
385 |
* |
|
386 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo() |
|
387 |
*/ |
|
388 |
public WindowInfo getWindowInfo() { |
|
389 |
if (m_viewInfo == null) { |
|
390 |
m_viewInfo = |
|
391 |
new WindowInfo(WindowInfo.ICONIFIABLE | WindowInfo.RESIZABLE |
|
392 |
| WindowInfo.MAXIMIZABLE); |
|
393 |
m_viewInfo.setWidth(DEFAULT_WIDTH); |
|
394 |
m_viewInfo.setHeight(DEFAULT_HEIGHT); |
|
395 |
|
|
396 |
m_viewInfo.setTitle(PluginServices.getText(this, "Mapa") + " : " |
|
397 |
+ layoutDocument.getName()); |
|
398 |
} |
|
399 |
return m_viewInfo; |
|
400 |
} |
|
401 |
|
|
402 |
public LayoutContext getLayoutContext() { |
|
403 |
return layoutContext; |
|
404 |
} |
|
405 |
|
|
406 |
public LayoutControl getLayoutControl() { |
|
407 |
return layoutControl; |
|
408 |
} |
|
409 |
|
|
410 |
private boolean isInitConfigDialogEnabled() { |
|
411 |
XMLEntity entity = PluginsLocator.getManager().getPlugin(this).getPersistentXML(); |
|
412 |
if (entity.contains(PreferenceKeys.DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_KEY_NAME)) { |
|
413 |
return entity.getBooleanProperty(PreferenceKeys.DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_KEY_NAME); |
|
414 |
} |
|
415 |
else { |
|
416 |
return PreferenceKeys.FACTORY_DEFAULT_SHOW_INITIAL_CONFIG_DIALOG_FOR_LAYOUT; |
|
417 |
} |
|
418 |
} |
|
419 |
|
|
420 |
|
|
421 |
protected void onInitialConfigCanceled() { |
|
422 |
if (layoutDocument!=null) { |
|
423 |
ApplicationLocator.getManager().getUIManager().closeWindow(this); |
|
424 |
ApplicationLocator.getProjectManager().getCurrentProject().removeDocument(layoutDocument); |
|
425 |
} |
|
426 |
} |
|
427 |
|
|
428 |
/** |
|
429 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated() |
|
430 |
*/ |
|
431 |
public void windowActivated() { |
|
432 |
if (getLayoutContext()!=null && !getLayoutContext().hasDocBeenOpened()) { |
|
433 |
getLayoutContext().setHasDocBeenOpened(true); |
|
434 |
if (isInitConfigDialogEnabled()) { |
|
435 |
FConfigLayoutDialog configDialog = new FConfigLayoutDialog(this, true); |
|
436 |
ApplicationLocator.getManager().getUIManager().addCentredWindow(configDialog); |
|
437 |
configDialog.addCancelButtonActionListener(new ActionListener() { |
|
438 |
|
|
439 |
public void actionPerformed(ActionEvent e) { |
|
440 |
DefaultLayoutPanel.this.onInitialConfigCanceled(); |
|
441 |
} |
|
442 |
|
|
443 |
}); |
|
444 |
} |
|
445 |
} |
|
446 |
layoutControl.refresh(); |
|
447 |
PluginServices |
|
448 |
.getMainFrame() |
|
449 |
.getStatusBar() |
|
450 |
.setMessage( |
|
451 |
"units", |
|
452 |
PluginServices.getText(this, layoutContext.getAttributes() |
|
453 |
.getNameUnit())); |
|
454 |
// ensure requestFocus is enabled |
|
455 |
if (!layoutControl.getComponent().isRequestFocusEnabled()) { |
|
456 |
layoutControl.getComponent().setRequestFocusEnabled(true); |
|
457 |
} |
|
458 |
// notify fframes |
|
459 |
IFFrame[] frames = layoutContext.getFFrames(); |
|
460 |
for (int i=0; i<frames.length; i++) { |
|
461 |
if (frames[i] instanceof LayoutPanelListener) { |
|
462 |
((LayoutPanelListener)frames[i]).windowActivated(); |
|
463 |
} |
|
464 |
} |
|
465 |
requestFocus(); |
|
466 |
layoutControl.getComponent().requestFocus(); |
|
467 |
} |
|
468 |
|
|
469 |
/** |
|
470 |
* @see com.iver.mdiApp.ui.MDIManager.SingletonWindow#getWindowModel() |
|
471 |
*/ |
|
472 |
public Object getWindowModel() { |
|
473 |
return layoutDocument; |
|
474 |
} |
|
475 |
|
|
476 |
public Document getDocument() { |
|
477 |
return layoutDocument; |
|
478 |
} |
|
479 |
|
|
480 |
/** |
|
481 |
* @see org.gvsig.andami.ui.mdiManager.IWindowListener#windowClosed() |
|
482 |
*/ |
|
483 |
public void windowClosed() { |
|
484 |
IFFrame[] frames = layoutContext.getFFrames(); |
|
485 |
for (int i=0; i<frames.length; i++) { |
|
486 |
if (frames[i] instanceof LayoutPanelListener) { |
|
487 |
((LayoutPanelListener)frames[i]).windowClosed(); |
|
488 |
} |
|
489 |
} |
|
490 |
} |
|
491 |
|
|
492 |
/** |
|
493 |
* @see org.gvsig.fmap.mapcontext.events.listeners.ViewPortListener#backColorChanged(org.gvsig.fmap.mapcontext.events.ColorEvent) |
|
494 |
*/ |
|
495 |
public void backColorChanged(ColorEvent e) { |
|
496 |
// refresh(); |
|
497 |
} |
|
498 |
|
|
499 |
public void layoutToPDF(String suggestedName) { |
|
500 |
FileFilter pdfFilter = |
|
501 |
new GenericFileFilter("pdf", PluginServices.getText(this, "pdf")); |
|
502 |
|
|
503 |
JFileChooser jfc = |
|
504 |
new JFileChooser(PDF_AND_PS_FILECHOOSER, defaultPDFFolderPath); |
|
505 |
if (suggestedName != null) { |
|
506 |
jfc.setSelectedFile(new File(suggestedName)); |
|
507 |
} |
|
508 |
jfc.addChoosableFileFilter(pdfFilter); |
|
509 |
jfc.setFileFilter(pdfFilter); |
|
510 |
|
|
511 |
if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) { |
|
512 |
File f = jfc.getSelectedFile(); |
|
513 |
File faux = null; |
|
514 |
|
|
515 |
if (f.getName().endsWith(".pdf") || f.getName().endsWith(".PDF")) { |
|
516 |
faux = f; |
|
517 |
} else { |
|
518 |
faux = new File(f.getPath() + ".pdf"); |
|
519 |
} |
|
520 |
|
|
521 |
layoutControl.getLayoutDraw().toPDF(faux); |
|
522 |
} |
|
523 |
} |
|
524 |
|
|
525 |
public void layoutToPS(String suggestedName) { |
|
526 |
FileFilter pdfFilter = |
|
527 |
new GenericFileFilter("ps", PluginServices.getText(this, "ps")); |
|
528 |
|
|
529 |
JFileChooser jfc = |
|
530 |
new JFileChooser(PDF_AND_PS_FILECHOOSER, defaultPDFFolderPath); |
|
531 |
if (suggestedName != null) { |
|
532 |
jfc.setSelectedFile(new File(suggestedName)); |
|
533 |
} |
|
534 |
jfc.addChoosableFileFilter(pdfFilter); |
|
535 |
jfc.setFileFilter(pdfFilter); |
|
536 |
|
|
537 |
if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) { |
|
538 |
File f = jfc.getSelectedFile(); |
|
539 |
File faux = null; |
|
540 |
|
|
541 |
if (f.getName().endsWith(".ps") || f.getName().endsWith(".PS")) { |
|
542 |
faux = f; |
|
543 |
} else { |
|
544 |
faux = new File(f.getPath() + ".ps"); |
|
545 |
} |
|
546 |
|
|
547 |
layoutControl.getLayoutDraw().toPS(faux); |
|
548 |
} |
|
549 |
} |
|
550 |
|
|
551 |
public void layoutToPDF() { |
|
552 |
layoutToPDF(null); |
|
553 |
} |
|
554 |
|
|
555 |
public void layoutToPS() { |
|
556 |
layoutToPS(null); |
|
557 |
} |
|
558 |
|
|
559 |
public boolean isShowIconTag() { |
|
560 |
return bShowIconTag; |
|
561 |
} |
|
562 |
|
|
563 |
public void setShowIconTag(boolean modeDebug) { |
|
564 |
bShowIconTag = modeDebug; |
|
565 |
} |
|
566 |
|
|
567 |
public void update(Observable observable, Object notification) { |
|
568 |
this.layoutContext.updateFFrames(); |
|
569 |
this.layoutControl.refresh(); |
|
570 |
} |
|
571 |
|
|
572 |
public Object getWindowProfile() { |
|
573 |
return WindowInfo.EDITOR_PROFILE; |
|
574 |
} |
|
575 |
|
|
576 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
577 |
state.set(LAYOUTCONTEXT_OBJECT, layoutContext); |
|
578 |
state.set(LAYOUTDOCUMENT_OBJECT, layoutDocument); |
|
579 |
} |
|
580 |
|
|
581 |
public void loadFromState(PersistentState state) |
|
582 |
throws PersistenceException { |
|
583 |
this.layoutContext = (LayoutContext) state.get(LAYOUTCONTEXT_OBJECT); |
|
584 |
this.setDocument((LayoutDocument) state.get(LAYOUTDOCUMENT_OBJECT)); |
|
585 |
} |
|
586 |
|
|
587 |
public static void registerPersistent() { |
|
588 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
589 |
if (manager.getDefinition(PERSISTENCE_DEFINITION_NAME) == null) { |
|
590 |
DynStruct definition = |
|
591 |
manager.addDefinition(DefaultLayoutPanel.class, |
|
592 |
PERSISTENCE_DEFINITION_NAME, |
|
593 |
"Layout panel persistence definition", null, null); |
|
594 |
|
|
595 |
definition.addDynFieldObject(LAYOUTCONTEXT_OBJECT) |
|
596 |
.setClassOfValue(LayoutContext.class).setMandatory(true); |
|
597 |
definition.addDynFieldObject(LAYOUTDOCUMENT_OBJECT) |
|
598 |
.setClassOfValue(LayoutDocument.class).setMandatory(true); |
|
599 |
} |
|
600 |
} |
|
601 |
|
|
602 |
public WindowLayout getWindowLayout() { |
|
603 |
return null; |
|
604 |
} |
|
605 |
|
|
606 |
public void setWindowLayout(WindowLayout layout) { |
|
607 |
|
|
608 |
} |
|
609 |
|
|
610 |
private void setLayoutContext(LayoutContext theLayoutcontext) { |
|
611 |
this.layoutContext = theLayoutcontext; |
|
612 |
this.layoutControl.setLayoutContext(theLayoutcontext); |
|
613 |
layoutContext.getAttributes().calculateGridGapX(layoutControl.getRect()); |
|
614 |
layoutContext.getAttributes().calculateGridGapY(layoutControl.getRect()); |
|
615 |
layoutControl.setDefaultTool(); |
|
616 |
} |
|
617 |
|
|
618 |
@Override |
|
619 |
public void setLayoutManager(LayoutManager layoutManager) { |
|
620 |
this.layoutManager = layoutManager; |
|
621 |
} |
|
622 |
|
|
623 |
|
|
624 |
/** |
|
625 |
* Method to print the Layout without modify the Affinetransform. |
|
626 |
* |
|
627 |
* @param g2 Geaphics2D |
|
628 |
*/ |
|
629 |
public void drawLayoutPrint(Graphics2D g2) { |
|
630 |
layoutControl.setCancelDrawing(false); |
|
631 |
|
|
632 |
double scale = 0; |
|
633 |
scale = layoutControl.getRect().height / layoutContext.getAttributes().m_sizePaper.getHeight() * 1; |
|
634 |
AffineTransform escalado = new AffineTransform(); |
|
635 |
AffineTransform translacion = new AffineTransform(); |
|
636 |
translacion.setToTranslation(layoutControl.getRect().getMinX(), layoutControl.getRect().getMinY()); |
|
637 |
escalado.setToScale(scale, scale); |
|
638 |
layoutControl.getAT().setToIdentity(); |
|
639 |
layoutControl.getAT().concatenate(translacion); |
|
640 |
layoutControl.getAT().concatenate(escalado); |
|
641 |
layoutContext.getAttributes().calculateGridGapX(layoutControl.getRect()); |
|
642 |
layoutContext.getAttributes().calculateGridGapY(layoutControl.getRect()); |
|
643 |
IFFrame[] fframes=layoutContext.getFFrames(); |
|
644 |
|
|
645 |
for (int i = 0; i < fframes.length; i++) { |
|
646 |
fframes[i].print( |
|
647 |
g2, |
|
648 |
layoutControl.getAT(), |
|
649 |
null, |
|
650 |
layoutContext.getAttributes().toPrintAttributes()); |
|
651 |
} |
|
652 |
} |
|
653 |
|
|
654 |
public void hideToc() { |
|
655 |
if (isTocEnabled()) { |
|
656 |
lastPanePos = splitPane.getDividerLocation(); |
|
657 |
splitPane.setDividerLocation(0); |
|
658 |
} |
|
659 |
} |
|
660 |
|
|
661 |
public void showToc() { |
|
662 |
if (isTocEnabled()) { |
|
663 |
splitPane.setDividerLocation(lastPanePos); |
|
664 |
} |
|
665 |
} |
|
666 |
|
|
667 |
} |
tags/org.gvsig.app.document.layout2.app-2.0.45/org.gvsig.app.document.layout2.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/gui/dialogs/EventsFAlign.java | ||
---|---|---|
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.dialogs; |
|
23 |
|
|
24 |
import java.awt.event.ActionEvent; |
|
25 |
import java.awt.event.ActionListener; |
|
26 |
import java.awt.geom.Rectangle2D; |
|
27 |
import java.util.Iterator; |
|
28 |
import java.util.TreeMap; |
|
29 |
|
|
30 |
import org.slf4j.Logger; |
|
31 |
import org.slf4j.LoggerFactory; |
|
32 |
|
|
33 |
import org.gvsig.andami.PluginServices; |
|
34 |
import org.gvsig.app.project.documents.layout.commands.FrameCommandsRecord; |
|
35 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
|
36 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
|
37 |
|
|
38 |
/** |
|
39 |
* Clase que hace de Listener de FAlignDialog. |
|
40 |
* |
|
41 |
* @author Vicente Caballero Navarro |
|
42 |
*/ |
|
43 |
public class EventsFAlign implements ActionListener { |
|
44 |
|
|
45 |
protected static final Logger LOG = LoggerFactory |
|
46 |
.getLogger(EventsFAlign.class); |
|
47 |
private LayoutPanel m_layout; |
|
48 |
private boolean inLayout = false; |
|
49 |
|
|
50 |
/** |
|
51 |
* Crea un nuevo FAlign. |
|
52 |
* |
|
53 |
* @param layout |
|
54 |
* Referencia al Layout. |
|
55 |
*/ |
|
56 |
public EventsFAlign(LayoutPanel layout) { |
|
57 |
m_layout = layout; |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* Desplaza los fframes seleccionados a la izquierda del fframe m?s |
|
62 |
* occidental. |
|
63 |
* |
|
64 |
* @throws CloneNotSupportedException |
|
65 |
*/ |
|
66 |
private void alignLeft() throws CloneNotSupportedException { |
|
67 |
double xmin = Double.MAX_VALUE; |
|
68 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
|
69 |
|
|
70 |
for (int i = 0; i < fframes.length; i++) { |
|
71 |
IFFrame fframe = fframes[i]; |
|
72 |
|
|
73 |
if (xmin > fframe.getBoundBox().getMinX()) { |
|
74 |
xmin = fframe.getBoundBox().getMinX(); |
|
75 |
} |
|
76 |
} |
|
77 |
|
|
78 |
FrameCommandsRecord efs = |
|
79 |
m_layout.getLayoutContext().getFrameCommandsRecord(); |
|
80 |
efs.startComplex(PluginServices.getText(this, "align_left")); |
|
81 |
|
|
82 |
for (int i = fframes.length - 1; i >= 0; i--) { |
|
83 |
IFFrame fframe = (IFFrame) fframes[i].clone(); |
|
84 |
|
|
85 |
Rectangle2D.Double r = |
|
86 |
(Rectangle2D.Double) fframe.getBoundBox().clone(); |
|
87 |
r.x = xmin; |
|
88 |
fframe.setBoundBox(r); |
|
89 |
efs.update(fframes[i], fframe); |
|
90 |
} |
|
91 |
|
|
92 |
efs.endComplex(); |
|
93 |
} |
|
94 |
|
|
95 |
/** |
|
96 |
* Desplaza los fframes seleccionados a la izquierda del Layout. |
|
97 |
* |
|
98 |
* @throws CloneNotSupportedException |
|
99 |
*/ |
|
100 |
private void alignLeftL() throws CloneNotSupportedException { |
|
101 |
double xmin = 0; |
|
102 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
|
103 |
FrameCommandsRecord efs = |
|
104 |
m_layout.getLayoutContext().getFrameCommandsRecord(); |
|
105 |
efs.startComplex(PluginServices.getText(this, "align_to_layout_left")); |
|
106 |
|
|
107 |
for (int i = 0; i < fframes.length; i++) { |
|
108 |
IFFrame fframe = (IFFrame) fframes[i].clone(); |
|
109 |
|
|
110 |
Rectangle2D.Double r = |
|
111 |
(Rectangle2D.Double) fframe.getBoundBox().clone(); |
|
112 |
r.x = xmin; |
|
113 |
fframe.setBoundBox(r); |
|
114 |
efs.update(fframes[i], fframe); |
|
115 |
} |
|
116 |
|
|
117 |
efs.endComplex(); |
|
118 |
} |
|
119 |
|
|
120 |
/** |
|
121 |
* Desplaza los fframes seleccionados al centro del fframe mas ancho de |
|
122 |
* forma horizontal. |
|
123 |
* |
|
124 |
* @throws CloneNotSupportedException |
|
125 |
*/ |
|
126 |
private void alignCenterV() throws CloneNotSupportedException { |
|
127 |
double xcenter = 0; |
|
128 |
double w = Double.NEGATIVE_INFINITY; |
|
129 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
|
130 |
|
|
131 |
for (int i = 0; i < fframes.length; i++) { |
|
132 |
IFFrame fframe = fframes[i]; |
|
133 |
|
|
134 |
if (w < fframe.getBoundBox().getWidth()) { |
|
135 |
w = fframe.getBoundBox().getWidth(); |
|
136 |
xcenter = fframe.getBoundBox().getCenterX(); |
|
137 |
} |
|
138 |
} |
|
139 |
|
|
140 |
FrameCommandsRecord efs = |
|
141 |
m_layout.getLayoutContext().getFrameCommandsRecord(); |
|
142 |
efs.startComplex(PluginServices.getText(this, "align_center")); |
|
143 |
|
|
144 |
for (int i = 0; i < fframes.length; i++) { |
|
145 |
IFFrame fframe = (IFFrame) fframes[i].clone(); |
|
146 |
|
|
147 |
Rectangle2D.Double r = |
|
148 |
(Rectangle2D.Double) fframe.getBoundBox().clone(); |
|
149 |
r.x = xcenter - (fframe.getBoundBox().width / 2); |
|
150 |
fframe.setBoundBox(r); |
|
151 |
efs.update(fframes[i], fframe); |
|
152 |
} |
|
153 |
|
|
154 |
efs.endComplex(); |
|
155 |
} |
|
156 |
|
|
157 |
/** |
|
158 |
* Desplaza los fframes seleccionados al centro del Layout horizontalmente. |
|
159 |
* |
|
160 |
* @throws CloneNotSupportedException |
|
161 |
*/ |
|
162 |
private void alignCenterVL() throws CloneNotSupportedException { |
|
163 |
double xcenter = 0; |
|
164 |
xcenter = |
|
165 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getWidth() / 2; |
|
166 |
|
|
167 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
|
168 |
FrameCommandsRecord efs = |
|
169 |
m_layout.getLayoutContext().getFrameCommandsRecord(); |
|
170 |
efs.startComplex(PluginServices.getText(this, "align_to_layout_center")); |
|
171 |
|
|
172 |
for (int i = 0; i < fframes.length; i++) { |
|
173 |
IFFrame fframe = (IFFrame) fframes[i].clone(); |
|
174 |
|
|
175 |
Rectangle2D.Double r = |
|
176 |
(Rectangle2D.Double) fframe.getBoundBox().clone(); |
|
177 |
r.x = xcenter - (fframe.getBoundBox().width / 2); |
|
178 |
fframe.setBoundBox(r); |
|
179 |
efs.update(fframes[i], fframe); |
|
180 |
} |
|
181 |
|
|
182 |
efs.endComplex(); |
|
183 |
} |
|
184 |
|
|
185 |
/** |
|
186 |
* Desplaza los fframes seleccionados a la parte derecha del fframe m?s |
|
187 |
* oriental. |
|
188 |
* |
|
189 |
* @throws CloneNotSupportedException |
|
190 |
*/ |
|
191 |
private void alignRight() throws CloneNotSupportedException { |
|
192 |
double xmax = Double.NEGATIVE_INFINITY; |
|
193 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
|
194 |
|
|
195 |
for (int i = 0; i < fframes.length; i++) { |
|
196 |
IFFrame fframe = fframes[i]; |
|
197 |
|
|
198 |
if (xmax < fframe.getBoundBox().getMaxX()) { |
|
199 |
xmax = fframe.getBoundBox().getMaxX(); |
|
200 |
} |
|
201 |
} |
|
202 |
|
|
203 |
FrameCommandsRecord efs = |
|
204 |
m_layout.getLayoutContext().getFrameCommandsRecord(); |
|
205 |
efs.startComplex(PluginServices.getText(this, "align_right")); |
|
206 |
|
|
207 |
for (int i = 0; i < fframes.length; i++) { |
|
208 |
IFFrame fframe = (IFFrame) fframes[i].clone(); |
|
209 |
|
|
210 |
Rectangle2D.Double r = |
|
211 |
(Rectangle2D.Double) fframe.getBoundBox().clone(); |
|
212 |
r.x = xmax - fframes[i].getBoundBox().width; |
|
213 |
fframe.setBoundBox(r); |
|
214 |
efs.update(fframes[i], fframe); |
|
215 |
} |
|
216 |
|
|
217 |
efs.endComplex(); |
|
218 |
} |
|
219 |
|
|
220 |
/** |
|
221 |
* Desplaza los fframes seleccionados a la parte derecha del Layout. |
|
222 |
* |
|
223 |
* @throws CloneNotSupportedException |
|
224 |
*/ |
|
225 |
private void alignRightL() throws CloneNotSupportedException { |
|
226 |
double xmax = 0; |
|
227 |
xmax = |
|
228 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getWidth(); |
|
229 |
|
|
230 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
|
231 |
FrameCommandsRecord efs = |
|
232 |
m_layout.getLayoutContext().getFrameCommandsRecord(); |
|
233 |
efs.startComplex(PluginServices.getText(this, "align_to_layout_right")); |
|
234 |
|
|
235 |
for (int i = 0; i < fframes.length; i++) { |
|
236 |
IFFrame fframe = (IFFrame) fframes[i].clone(); |
|
237 |
|
|
238 |
Rectangle2D.Double r = |
|
239 |
(Rectangle2D.Double) fframe.getBoundBox().clone(); |
|
240 |
r.x = xmax - fframes[i].getBoundBox().width; |
|
241 |
fframe.setBoundBox(r); |
|
242 |
efs.update(fframes[i], fframe); |
|
243 |
} |
|
244 |
|
|
245 |
efs.endComplex(); |
|
246 |
} |
|
247 |
|
|
248 |
/** |
|
249 |
* Desplaza los fframes seleccionados a la parte inferior del fframe m?s |
|
250 |
* hacia abajo. |
|
251 |
* |
|
252 |
* @throws CloneNotSupportedException |
|
253 |
*/ |
|
254 |
private void alignDown() throws CloneNotSupportedException { |
|
255 |
double ymax = Double.NEGATIVE_INFINITY; |
|
256 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
|
257 |
|
|
258 |
for (int i = 0; i < fframes.length; i++) { |
|
259 |
IFFrame fframe = fframes[i]; |
|
260 |
|
|
261 |
if (ymax < fframe.getBoundBox().getMaxY()) { |
|
262 |
ymax = fframe.getBoundBox().getMaxY(); |
|
263 |
} |
|
264 |
} |
|
265 |
|
|
266 |
FrameCommandsRecord efs = |
|
267 |
m_layout.getLayoutContext().getFrameCommandsRecord(); |
|
268 |
efs.startComplex(PluginServices.getText(this, "align_down")); |
|
269 |
|
|
270 |
for (int i = 0; i < fframes.length; i++) { |
|
271 |
IFFrame fframe = (IFFrame) fframes[i].clone(); |
|
272 |
|
|
273 |
Rectangle2D.Double r = |
|
274 |
(Rectangle2D.Double) fframe.getBoundBox().clone(); |
|
275 |
r.y = ymax - fframe.getBoundBox().height; |
|
276 |
fframe.setBoundBox(r); |
|
277 |
efs.update(fframes[i], fframe); |
|
278 |
} |
|
279 |
|
|
280 |
efs.endComplex(); |
|
281 |
} |
|
282 |
|
|
283 |
/** |
|
284 |
* Desplaza los fframes seleccionados a la parte inferior del Layout. |
|
285 |
* |
|
286 |
* @throws CloneNotSupportedException |
|
287 |
*/ |
|
288 |
private void alignDownL() throws CloneNotSupportedException { |
|
289 |
double ymax = 0; |
|
290 |
ymax = |
|
291 |
m_layout.getLayoutContext().getAttributes().m_sizePaper.getHeight(); |
|
292 |
|
|
293 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
|
294 |
FrameCommandsRecord efs = |
|
295 |
m_layout.getLayoutContext().getFrameCommandsRecord(); |
|
296 |
efs.startComplex(PluginServices.getText(this, "align_to_layout_down")); |
|
297 |
|
|
298 |
for (int i = 0; i < fframes.length; i++) { |
|
299 |
IFFrame fframe = (IFFrame) fframes[i].clone(); |
|
300 |
Rectangle2D.Double r = |
|
301 |
(Rectangle2D.Double) fframe.getBoundBox().clone(); |
|
302 |
r.y = ymax - fframe.getBoundBox().height; |
|
303 |
fframe.setBoundBox(r); |
|
304 |
efs.update(fframes[i], fframe); |
|
305 |
} |
|
306 |
|
|
307 |
efs.endComplex(); |
|
308 |
} |
|
309 |
|
|
310 |
/** |
|
311 |
* Desplaza los fframes seleccionados a la parte superior del fframe que |
|
312 |
* m?s arriba este colocado. |
|
313 |
* |
|
314 |
* @throws CloneNotSupportedException |
|
315 |
*/ |
|
316 |
private void alignUp() throws CloneNotSupportedException { |
|
317 |
double ymin = Double.MAX_VALUE; |
|
318 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
|
319 |
|
|
320 |
for (int i = 0; i < fframes.length; i++) { |
|
321 |
IFFrame fframe = fframes[i]; |
|
322 |
|
|
323 |
if (ymin > fframe.getBoundBox().getMinY()) { |
|
324 |
ymin = fframe.getBoundBox().getMinY(); |
|
325 |
} |
|
326 |
} |
|
327 |
|
|
328 |
FrameCommandsRecord efs = |
|
329 |
m_layout.getLayoutContext().getFrameCommandsRecord(); |
|
330 |
efs.startComplex(PluginServices.getText(this, "align_up")); |
|
331 |
|
|
332 |
for (int i = 0; i < fframes.length; i++) { |
|
333 |
IFFrame fframe = (IFFrame) fframes[i].clone(); |
|
334 |
Rectangle2D.Double r = |
|
335 |
(Rectangle2D.Double) fframe.getBoundBox().clone(); |
|
336 |
r.y = ymin; |
|
337 |
fframe.setBoundBox(r); |
|
338 |
efs.update(fframes[i], fframe); |
|
339 |
} |
|
340 |
|
|
341 |
efs.endComplex(); |
|
342 |
} |
|
343 |
|
|
344 |
/** |
|
345 |
* Desplaza los fframes seleccionados a la parte superior del Layout. |
|
346 |
* |
|
347 |
* @throws CloneNotSupportedException |
|
348 |
*/ |
|
349 |
private void alignUpL() throws CloneNotSupportedException { |
|
350 |
double ymin = 0; |
|
351 |
IFFrame[] fframes = m_layout.getLayoutContext().getSelectedFFrames(); |
|
352 |
FrameCommandsRecord efs = |
|
353 |
m_layout.getLayoutContext().getFrameCommandsRecord(); |
|
354 |
efs.startComplex(PluginServices.getText(this, "align_to_layout_up")); |
|
355 |
|
Also available in: Unified diff