root / branches / piloto3d / applications / appgvSIG / src / com / iver / cit / gvsig / LayoutControls.java @ 9529
History | View | Annotate | Download (4.85 KB)
1 |
/*
|
---|---|
2 |
* Created on 05-may-2004
|
3 |
*
|
4 |
* To change the template for this generated file go to
|
5 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
6 |
*/
|
7 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
8 |
*
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
10 |
*
|
11 |
* This program is free software; you can redistribute it and/or
|
12 |
* modify it under the terms of the GNU General Public License
|
13 |
* as published by the Free Software Foundation; either version 2
|
14 |
* of the License, or (at your option) any later version.
|
15 |
*
|
16 |
* This program is distributed in the hope that it will be useful,
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
* GNU General Public License for more details.
|
20 |
*
|
21 |
* You should have received a copy of the GNU General Public License
|
22 |
* along with this program; if not, write to the Free Software
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
24 |
*
|
25 |
* For more information, contact:
|
26 |
*
|
27 |
* Generalitat Valenciana
|
28 |
* Conselleria d'Infraestructures i Transport
|
29 |
* Av. Blasco Ib??ez, 50
|
30 |
* 46010 VALENCIA
|
31 |
* SPAIN
|
32 |
*
|
33 |
* +34 963862235
|
34 |
* gvsig@gva.es
|
35 |
* www.gvsig.gva.es
|
36 |
*
|
37 |
* or
|
38 |
*
|
39 |
* IVER T.I. S.A
|
40 |
* Salamanca 50
|
41 |
* 46005 Valencia
|
42 |
* Spain
|
43 |
*
|
44 |
* +34 963163400
|
45 |
* dac@iver.es
|
46 |
*/
|
47 |
package com.iver.cit.gvsig; |
48 |
|
49 |
import java.awt.Component; |
50 |
import java.io.File; |
51 |
import java.io.FileWriter; |
52 |
|
53 |
import javax.swing.JFileChooser; |
54 |
|
55 |
import org.apache.log4j.Logger; |
56 |
import org.exolab.castor.xml.Marshaller; |
57 |
|
58 |
import com.iver.andami.PluginServices; |
59 |
import com.iver.andami.messages.NotificationManager; |
60 |
import com.iver.andami.plugins.Extension; |
61 |
import com.iver.andami.preferences.IPreference; |
62 |
import com.iver.andami.preferences.IPreferenceExtension; |
63 |
import com.iver.andami.ui.mdiManager.IWindow; |
64 |
import com.iver.cit.gvsig.gui.layout.Layout; |
65 |
import com.iver.cit.gvsig.gui.preferencespage.LayoutPage; |
66 |
import com.iver.cit.gvsig.project.documents.layout.FLayoutZooms; |
67 |
import com.iver.utiles.GenericFileFilter; |
68 |
|
69 |
|
70 |
/**
|
71 |
* Extensi?n para controlar las operaciones basicas sobre el Layout.
|
72 |
*
|
73 |
* @author Vicente Caballero Navarro
|
74 |
*/
|
75 |
public class LayoutControls extends Extension implements IPreferenceExtension { |
76 |
private static Logger logger = Logger.getLogger(LayoutControls.class.getName()); |
77 |
private Layout layout = null; |
78 |
private static LayoutPage layoutPropertiesPage=new LayoutPage(); |
79 |
|
80 |
/**
|
81 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
82 |
*/
|
83 |
public void execute(String s) { |
84 |
layout = (Layout) PluginServices.getMDIManager().getActiveWindow(); |
85 |
|
86 |
FLayoutZooms zooms = new FLayoutZooms(layout);
|
87 |
logger.debug("Comand : " + s);
|
88 |
|
89 |
if (s.equals("PAN")) { |
90 |
layout.setTool(Layout.PAN); |
91 |
} else if (s.equals("ZOOM_IN")) { |
92 |
layout.setTool(Layout.ZOOM_MAS); |
93 |
} else if (s.equals("ZOOM_OUT")) { |
94 |
layout.setTool(Layout.ZOOM_MENOS); |
95 |
} else if (s.equals("FULL")) { |
96 |
layout.fullRect(); |
97 |
} else if (s.equals("REALZOOM")) { |
98 |
zooms.realZoom(); |
99 |
} else if (s.equals("ZOOMOUT")) { |
100 |
zooms.zoomOut(); |
101 |
} else if (s.equals("ZOOMIN")) { |
102 |
zooms.zoomIn(); |
103 |
} else if (s.equals("ZOOMSELECT")) { |
104 |
zooms.zoomSelect(); |
105 |
} else if (s.equals("SAVETEMPLATE")){ |
106 |
saveLayout(); |
107 |
} |
108 |
} |
109 |
private void saveLayout() { |
110 |
layout = (Layout) PluginServices.getMDIManager().getActiveWindow(); |
111 |
JFileChooser jfc = new JFileChooser(); |
112 |
jfc.addChoosableFileFilter(new GenericFileFilter("gvt", |
113 |
PluginServices.getText(this, "plantilla"))); |
114 |
|
115 |
if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) { |
116 |
File file=jfc.getSelectedFile();
|
117 |
if (!(file.getPath().endsWith(".gvt") || file.getPath().endsWith(".GVT"))){ |
118 |
file=new File(file.getPath()+".gvt"); |
119 |
} |
120 |
try {
|
121 |
FileWriter writer = new FileWriter(file.getAbsolutePath()); |
122 |
Marshaller m = new Marshaller(writer);
|
123 |
m.setEncoding("ISO-8859-1");
|
124 |
m.marshal(layout.getXMLEntity().getXmlTag()); |
125 |
} catch (Exception e) { |
126 |
NotificationManager.addError(PluginServices.getText(this, "Error_guardando_la_plantilla"), e); |
127 |
} |
128 |
} |
129 |
} |
130 |
/**
|
131 |
* @see com.iver.mdiApp.plugins.IExtension#isVisible()
|
132 |
*/
|
133 |
public boolean isVisible() { |
134 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
135 |
|
136 |
if (f == null) { |
137 |
return false; |
138 |
} |
139 |
|
140 |
if (f instanceof Layout) { |
141 |
// Layout layout = (Layout) f;
|
142 |
|
143 |
return true; //layout.m_Display.getMapControl().getMapContext().getLayers().layerCount() > 0; |
144 |
} else {
|
145 |
return false; |
146 |
} |
147 |
} |
148 |
|
149 |
/**
|
150 |
* @see com.iver.andami.plugins.IExtension#initialize()
|
151 |
*/
|
152 |
public void initialize() { |
153 |
} |
154 |
|
155 |
/**
|
156 |
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
157 |
*/
|
158 |
public boolean isEnabled() { |
159 |
return true; |
160 |
} |
161 |
|
162 |
/**
|
163 |
* Devuelve el Layout sobre el que se opera.
|
164 |
*
|
165 |
* @return Layout.
|
166 |
*/
|
167 |
public Layout getLayout() {
|
168 |
return layout;
|
169 |
} |
170 |
|
171 |
public IPreference getPreferencesPage() {
|
172 |
return layoutPropertiesPage;
|
173 |
} |
174 |
} |