svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.snapping.app / org.gvsig.snapping.app.mainplugin / src / main / java / org / gvsig / app / gui / preferencespage / GridPage.java @ 42037
History | View | Annotate | Download (6.95 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
/* CVS MESSAGES:
|
25 |
*
|
26 |
* $Id: GridPage.java 21668 2008-06-19 09:05:14Z vcaballero $
|
27 |
* $Log$
|
28 |
* Revision 1.4 2006-08-22 12:27:53 jaume
|
29 |
* improved performances when saving
|
30 |
*
|
31 |
* Revision 1.3 2006/08/22 07:37:32 jaume
|
32 |
* *** empty log message ***
|
33 |
*
|
34 |
* Revision 1.2 2006/08/10 11:13:02 caballero
|
35 |
* mostrar unidades
|
36 |
*
|
37 |
* Revision 1.1 2006/08/10 08:18:35 caballero
|
38 |
* configurar grid
|
39 |
*
|
40 |
* Revision 1.1 2006/08/04 11:41:05 caballero
|
41 |
* poder especificar el zoom a aplicar en las vistas
|
42 |
*
|
43 |
* Revision 1.3 2006/07/31 10:02:31 jaume
|
44 |
* *** empty log message ***
|
45 |
*
|
46 |
* Revision 1.2 2006/06/13 07:43:08 fjp
|
47 |
* Ajustes sobre los cuadros de dialogos de preferencias
|
48 |
*
|
49 |
* Revision 1.1 2006/06/12 16:04:28 caballero
|
50 |
* Preferencias
|
51 |
*
|
52 |
* Revision 1.11 2006/06/06 10:26:31 jaume
|
53 |
* *** empty log message ***
|
54 |
*
|
55 |
* Revision 1.10 2006/06/05 17:07:17 jaume
|
56 |
* *** empty log message ***
|
57 |
*
|
58 |
* Revision 1.9 2006/06/05 17:00:44 jaume
|
59 |
* *** empty log message ***
|
60 |
*
|
61 |
* Revision 1.8 2006/06/05 16:57:59 jaume
|
62 |
* *** empty log message ***
|
63 |
*
|
64 |
* Revision 1.7 2006/06/05 14:45:06 jaume
|
65 |
* *** empty log message ***
|
66 |
*
|
67 |
* Revision 1.6 2006/06/05 11:00:09 jaume
|
68 |
* *** empty log message ***
|
69 |
*
|
70 |
* Revision 1.5 2006/06/05 10:39:02 jaume
|
71 |
* *** empty log message ***
|
72 |
*
|
73 |
* Revision 1.4 2006/06/05 10:13:40 jaume
|
74 |
* *** empty log message ***
|
75 |
*
|
76 |
* Revision 1.3 2006/06/05 10:06:08 jaume
|
77 |
* *** empty log message ***
|
78 |
*
|
79 |
* Revision 1.2 2006/06/05 09:51:56 jaume
|
80 |
* *** empty log message ***
|
81 |
*
|
82 |
* Revision 1.1 2006/06/02 10:50:18 jaume
|
83 |
* *** empty log message ***
|
84 |
*
|
85 |
*
|
86 |
*/
|
87 |
package org.gvsig.app.gui.preferencespage; |
88 |
|
89 |
import javax.swing.ImageIcon; |
90 |
import javax.swing.JCheckBox; |
91 |
import javax.swing.JLabel; |
92 |
import javax.swing.JPanel; |
93 |
import javax.swing.JTextField; |
94 |
|
95 |
import org.gvsig.andami.IconThemeHelper; |
96 |
import org.gvsig.andami.PluginServices; |
97 |
import org.gvsig.andami.PluginsLocator; |
98 |
import org.gvsig.andami.PluginsManager; |
99 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
100 |
import org.gvsig.andami.preferences.StoreException; |
101 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
102 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
103 |
import org.gvsig.fmap.mapcontrol.MapControl; |
104 |
import org.gvsig.fmap.mapcontrol.tools.grid.Grid; |
105 |
import org.gvsig.tools.dynobject.DynObject; |
106 |
|
107 |
|
108 |
public class GridPage extends AbstractPreferencePage { |
109 |
public static final String ID = GridPage.class.getName(); |
110 |
|
111 |
private org.gvsig.fmap.mapcontrol.MapControl mapControl;
|
112 |
private JCheckBox chkShowGrid; |
113 |
private JCheckBox chkAdjustGrid; |
114 |
private JTextField txtDistanceX; |
115 |
private JTextField txtDistanceY; |
116 |
private JLabel lblUnits=new JLabel(); |
117 |
private ImageIcon icon; |
118 |
|
119 |
private DynObject pluginProperties;
|
120 |
private PluginServices plugin;
|
121 |
|
122 |
|
123 |
|
124 |
public GridPage() {
|
125 |
super();
|
126 |
PluginsManager pluginManager = PluginsLocator.getManager(); |
127 |
this.plugin = pluginManager.getPlugin(this); |
128 |
this.pluginProperties = this.plugin.getPluginProperties(); |
129 |
|
130 |
icon = IconThemeHelper.getImageIcon("grid-preferences");
|
131 |
|
132 |
chkShowGrid=new JCheckBox(PluginServices.getText(this,"mostrar_rejilla")); |
133 |
addComponent(chkShowGrid); |
134 |
chkAdjustGrid=new JCheckBox(PluginServices.getText(this,"ajustar_rejilla")); |
135 |
addComponent(chkAdjustGrid); |
136 |
addComponent(lblUnits); |
137 |
|
138 |
// distance x
|
139 |
addComponent(PluginServices.getText(this, "distance_x") + ":", |
140 |
txtDistanceX = new JTextField("", 15)); |
141 |
// distance y
|
142 |
addComponent(PluginServices.getText(this, "distance_y") + ":", |
143 |
txtDistanceY = new JTextField("", 15)); |
144 |
// setParentID(ViewPage.id);
|
145 |
|
146 |
} |
147 |
|
148 |
public void initializeValues() { |
149 |
boolean showGrid = ((Boolean)pluginProperties.getDynValue("showgrid")).booleanValue(); |
150 |
boolean adjustGrid = ((Boolean)pluginProperties.getDynValue("adjustgrid")).booleanValue(); |
151 |
|
152 |
double dx = ((Double)pluginProperties.getDynValue("griddistancex")).doubleValue(); |
153 |
double dy = ((Double)pluginProperties.getDynValue("griddistancey")).doubleValue(); |
154 |
|
155 |
Grid.SHOWGRID=showGrid; |
156 |
Grid.ADJUSTGRID=adjustGrid; |
157 |
Grid.GRIDSIZEX=dx; |
158 |
Grid.GRIDSIZEY=dy; |
159 |
|
160 |
chkShowGrid.setSelected(showGrid); |
161 |
chkAdjustGrid.setSelected(adjustGrid); |
162 |
txtDistanceX.setText(String.valueOf(dx));
|
163 |
txtDistanceY.setText(String.valueOf(dy));
|
164 |
} |
165 |
|
166 |
public String getID() { |
167 |
return ID;
|
168 |
} |
169 |
|
170 |
public String getTitle() { |
171 |
return PluginServices.getText(this, "Grid"); |
172 |
} |
173 |
|
174 |
public JPanel getPanel() { |
175 |
return this; |
176 |
} |
177 |
|
178 |
public void storeValues() throws StoreException { |
179 |
boolean showGrid;
|
180 |
boolean adjustGrid;
|
181 |
double dx;
|
182 |
double dy;
|
183 |
|
184 |
showGrid=chkShowGrid.isSelected(); |
185 |
adjustGrid=chkAdjustGrid.isSelected(); |
186 |
try{
|
187 |
dx=Double.parseDouble(txtDistanceX.getText());
|
188 |
dy=Double.parseDouble(txtDistanceY.getText());
|
189 |
}catch (Exception e) { |
190 |
throw new StoreException(PluginServices.getText(this,"distancia_malla_incorrecta")); |
191 |
} |
192 |
|
193 |
this.pluginProperties.setDynValue("showgrid", showGrid); |
194 |
this.pluginProperties.setDynValue("adjustgrid", adjustGrid); |
195 |
this.pluginProperties.setDynValue("griddistancex", dx); |
196 |
this.pluginProperties.setDynValue("griddistancey", dy); |
197 |
|
198 |
|
199 |
Grid.SHOWGRID=showGrid; |
200 |
Grid.ADJUSTGRID=adjustGrid; |
201 |
Grid.GRIDSIZEX=dx; |
202 |
Grid.GRIDSIZEY=dy; |
203 |
|
204 |
IWindow window=PluginServices.getMDIManager().getActiveWindow(); |
205 |
if (window instanceof DefaultViewPanel){ |
206 |
MapControl mc=((DefaultViewPanel)window).getMapControl(); |
207 |
Grid cadGrid=mc.getGrid(); |
208 |
cadGrid.setShowGrid(showGrid); |
209 |
cadGrid.setAdjustGrid(adjustGrid); |
210 |
cadGrid.setGridSizeX(dx); |
211 |
cadGrid.setGridSizeY(dy); |
212 |
} |
213 |
|
214 |
} |
215 |
|
216 |
public void initializeDefaults() { |
217 |
chkShowGrid.setSelected(Grid.DefaultShowGrid); |
218 |
chkAdjustGrid.setSelected(Grid.DefaultAdjustGrid); |
219 |
txtDistanceX.setText(String.valueOf(Grid.DefaultGridSizeX));
|
220 |
txtDistanceY.setText(String.valueOf(Grid.DefaultGridSizeY));
|
221 |
} |
222 |
|
223 |
public ImageIcon getIcon() { |
224 |
return icon;
|
225 |
} |
226 |
|
227 |
public boolean isValueChanged() { |
228 |
return super.hasChanged(); |
229 |
} |
230 |
|
231 |
public void setChangesApplied() { |
232 |
setChanged(false);
|
233 |
} |
234 |
} |