svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / LayoutControls.java @ 3718
History | View | Annotate | Download (4.79 KB)
1 | 312 | fernando | /*
|
---|---|---|---|
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 | 1103 | fjp | /* 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 | 312 | fernando | package com.iver.cit.gvsig; |
48 | |||
49 | 3122 | caballero | import java.awt.Component; |
50 | import java.io.File; |
||
51 | import java.io.FileWriter; |
||
52 | |||
53 | import javax.swing.JFileChooser; |
||
54 | |||
55 | 596 | fernando | import com.iver.andami.PluginServices; |
56 | 3122 | caballero | import com.iver.andami.messages.NotificationManager; |
57 | 596 | fernando | import com.iver.andami.plugins.Extension; |
58 | import com.iver.andami.ui.mdiManager.View; |
||
59 | 1219 | vcaballero | |
60 | 312 | fernando | import com.iver.cit.gvsig.gui.layout.FLayoutZooms; |
61 | import com.iver.cit.gvsig.gui.layout.Layout; |
||
62 | 3122 | caballero | import com.iver.utiles.GenericFileFilter; |
63 | 312 | fernando | |
64 | 1219 | vcaballero | import org.apache.log4j.Logger; |
65 | 3122 | caballero | import org.exolab.castor.xml.Marshaller; |
66 | 312 | fernando | |
67 | 1219 | vcaballero | |
68 | 312 | fernando | /**
|
69 | 1219 | vcaballero | * Extensi?n para controlar las operaciones basicas sobre el Layout.
|
70 | 312 | fernando | *
|
71 | * @author Vicente Caballero Navarro
|
||
72 | */
|
||
73 | 596 | fernando | public class LayoutControls implements Extension { |
74 | 1219 | vcaballero | 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 | 2362 | vcaballero | layout.fullRect(); |
95 | 1219 | vcaballero | } 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 | 2342 | vcaballero | } else if (s.compareTo("PDF")==0){ |
108 | layout.layoutToPDF(); |
||
109 | 3115 | caballero | } else if (s.compareTo("SAVETEMPLATE")==0){ |
110 | 3122 | caballero | saveLayout(); |
111 | 3573 | caballero | } |
112 | 1219 | vcaballero | } |
113 | 3122 | caballero | private void saveLayout() { |
114 | layout = (Layout) PluginServices.getMDIManager().getActiveView(); |
||
115 | JFileChooser jfc = new JFileChooser(); |
||
116 | jfc.addChoosableFileFilter(new GenericFileFilter("gvt", |
||
117 | PluginServices.getText(this, "plantilla"))); |
||
118 | 312 | fernando | |
119 | 3122 | caballero | if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) { |
120 | File file=jfc.getSelectedFile();
|
||
121 | if (!(file.getPath().endsWith(".gvt") || file.getPath().endsWith(".GVT"))){ |
||
122 | file=new File(file.getPath()+".gvt"); |
||
123 | } |
||
124 | try {
|
||
125 | FileWriter writer = new FileWriter(file.getAbsolutePath()); |
||
126 | Marshaller m = new Marshaller(writer);
|
||
127 | m.setEncoding("ISO-8859-1");
|
||
128 | m.marshal(layout.getXMLEntity().getXmlTag()); |
||
129 | } catch (Exception e) { |
||
130 | NotificationManager.addError(PluginServices.getText(this, "Error_guardando_la_plantilla"), e); |
||
131 | } |
||
132 | } |
||
133 | } |
||
134 | 1219 | vcaballero | /**
|
135 | * @see com.iver.mdiApp.plugins.Extension#isVisible()
|
||
136 | */
|
||
137 | public boolean isVisible() { |
||
138 | View f = PluginServices.getMDIManager().getActiveView();
|
||
139 | 312 | fernando | |
140 | 1219 | vcaballero | if (f == null) { |
141 | return false; |
||
142 | } |
||
143 | 312 | fernando | |
144 | 1219 | vcaballero | if (f.getClass() == Layout.class) {
|
145 | 2429 | caballero | // Layout layout = (Layout) f;
|
146 | 312 | fernando | |
147 | 1219 | vcaballero | return true; //layout.m_Display.getMapControl().getMapContext().getLayers().layerCount() > 0; |
148 | } else {
|
||
149 | return false; |
||
150 | } |
||
151 | } |
||
152 | 596 | fernando | |
153 | /**
|
||
154 | * @see com.iver.andami.plugins.Extension#inicializar()
|
||
155 | */
|
||
156 | public void inicializar() { |
||
157 | } |
||
158 | |||
159 | /**
|
||
160 | * @see com.iver.andami.plugins.Extension#isEnabled()
|
||
161 | */
|
||
162 | public boolean isEnabled() { |
||
163 | 644 | fernando | return true; |
164 | 596 | fernando | } |
165 | 1219 | vcaballero | |
166 | /**
|
||
167 | * Devuelve el Layout sobre el que se opera.
|
||
168 | *
|
||
169 | * @return Layout.
|
||
170 | */
|
||
171 | public Layout getLayout() {
|
||
172 | 677 | vcaballero | return layout;
|
173 | } |
||
174 | 312 | fernando | } |