root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / LayoutControls.java @ 3545
History | View | Annotate | Download (4.86 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 com.iver.andami.PluginServices; |
56 |
import com.iver.andami.messages.NotificationManager; |
57 |
import com.iver.andami.plugins.Extension; |
58 |
import com.iver.andami.ui.mdiManager.View; |
59 |
|
60 |
import com.iver.cit.gvsig.gui.layout.FLayoutZooms; |
61 |
import com.iver.cit.gvsig.gui.layout.Layout; |
62 |
import com.iver.utiles.GenericFileFilter; |
63 |
|
64 |
import org.apache.log4j.Logger; |
65 |
import org.exolab.castor.xml.Marshaller; |
66 |
|
67 |
|
68 |
/**
|
69 |
* Extensi?n para controlar las operaciones basicas sobre el Layout.
|
70 |
*
|
71 |
* @author Vicente Caballero Navarro
|
72 |
*/
|
73 |
public class LayoutControls implements Extension { |
74 |
private static Logger logger = Logger.getLogger(LayoutControls.class.getName()); |
75 |
private Layout layout = null; |
76 |
|
77 |
/**
|
78 |
* @see com.iver.andami.plugins.Extension#execute(java.lang.String)
|
79 |
*/
|
80 |
public void execute(String s) { |
81 |
layout = (Layout) PluginServices.getMDIManager().getActiveView(); |
82 |
|
83 |
FLayoutZooms zooms = new FLayoutZooms(layout);
|
84 |
logger.debug("Comand : " + s);
|
85 |
|
86 |
if (s.compareTo("PAN") == 0) { |
87 |
layout.setTool(Layout.PAN); |
88 |
} else if (s.compareTo("ZOOM_IN") == 0) { |
89 |
layout.setTool(Layout.ZOOM_MAS); |
90 |
} else if (s.compareTo("ZOOM_OUT") == 0) { |
91 |
layout.setTool(Layout.ZOOM_MENOS); |
92 |
} else if (s.compareTo("CONFIG") == 0) { |
93 |
layout.showFConfig(); |
94 |
layout.fullRect(); |
95 |
} else if (s.compareTo("PROPERTIES") == 0) { |
96 |
layout.showFProperties(); |
97 |
} else if (s.compareTo("FULL") == 0) { |
98 |
layout.fullRect(); |
99 |
} else if (s.compareTo("REALZOOM") == 0) { |
100 |
zooms.realZoom(); |
101 |
} else if (s.compareTo("ZOOMOUT") == 0) { |
102 |
zooms.zoomOut(); |
103 |
} else if (s.compareTo("ZOOMIN") == 0) { |
104 |
zooms.zoomIn(); |
105 |
} else if (s.compareTo("ZOOMSELECT") == 0) { |
106 |
zooms.zoomSelect(); |
107 |
} else if (s.compareTo("PDF")==0){ |
108 |
layout.layoutToPDF(); |
109 |
} else if (s.compareTo("SAVETEMPLATE")==0){ |
110 |
saveLayout(); |
111 |
} else if (s.compareTo("VERTEX")==0){ |
112 |
layout.setTool(Layout.EDIT); |
113 |
} |
114 |
} |
115 |
private void saveLayout() { |
116 |
layout = (Layout) PluginServices.getMDIManager().getActiveView(); |
117 |
JFileChooser jfc = new JFileChooser(); |
118 |
jfc.addChoosableFileFilter(new GenericFileFilter("gvt", |
119 |
PluginServices.getText(this, "plantilla"))); |
120 |
|
121 |
if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) { |
122 |
File file=jfc.getSelectedFile();
|
123 |
if (!(file.getPath().endsWith(".gvt") || file.getPath().endsWith(".GVT"))){ |
124 |
file=new File(file.getPath()+".gvt"); |
125 |
} |
126 |
try {
|
127 |
FileWriter writer = new FileWriter(file.getAbsolutePath()); |
128 |
Marshaller m = new Marshaller(writer);
|
129 |
m.setEncoding("ISO-8859-1");
|
130 |
m.marshal(layout.getXMLEntity().getXmlTag()); |
131 |
} catch (Exception e) { |
132 |
NotificationManager.addError(PluginServices.getText(this, "Error_guardando_la_plantilla"), e); |
133 |
} |
134 |
} |
135 |
} |
136 |
/**
|
137 |
* @see com.iver.mdiApp.plugins.Extension#isVisible()
|
138 |
*/
|
139 |
public boolean isVisible() { |
140 |
View f = PluginServices.getMDIManager().getActiveView();
|
141 |
|
142 |
if (f == null) { |
143 |
return false; |
144 |
} |
145 |
|
146 |
if (f.getClass() == Layout.class) {
|
147 |
// Layout layout = (Layout) f;
|
148 |
|
149 |
return true; //layout.m_Display.getMapControl().getMapContext().getLayers().layerCount() > 0; |
150 |
} else {
|
151 |
return false; |
152 |
} |
153 |
} |
154 |
|
155 |
/**
|
156 |
* @see com.iver.andami.plugins.Extension#inicializar()
|
157 |
*/
|
158 |
public void inicializar() { |
159 |
} |
160 |
|
161 |
/**
|
162 |
* @see com.iver.andami.plugins.Extension#isEnabled()
|
163 |
*/
|
164 |
public boolean isEnabled() { |
165 |
return true; |
166 |
} |
167 |
|
168 |
/**
|
169 |
* Devuelve el Layout sobre el que se opera.
|
170 |
*
|
171 |
* @return Layout.
|
172 |
*/
|
173 |
public Layout getLayout() {
|
174 |
return layout;
|
175 |
} |
176 |
} |