svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / gui / preferencespage / GridPage.java @ 40558
History | View | Annotate | Download (7.56 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 java.util.prefs.Preferences; |
90 |
|
91 |
import javax.swing.ImageIcon; |
92 |
import javax.swing.JCheckBox; |
93 |
import javax.swing.JLabel; |
94 |
import javax.swing.JPanel; |
95 |
import javax.swing.JTextField; |
96 |
|
97 |
import org.gvsig.andami.PluginServices; |
98 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
99 |
import org.gvsig.andami.preferences.StoreException; |
100 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
101 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
102 |
import org.gvsig.fmap.mapcontrol.MapControl; |
103 |
import org.gvsig.fmap.mapcontrol.tools.grid.Grid; |
104 |
|
105 |
|
106 |
public class GridPage extends AbstractPreferencePage { |
107 |
public static Preferences prefs = Preferences.userRoot().node( "cadtooladapter" ); |
108 |
private org.gvsig.fmap.mapcontrol.MapControl mapControl;
|
109 |
private JCheckBox chkShowGrid; |
110 |
private JCheckBox chkAdjustGrid; |
111 |
private JTextField txtDistanceX; |
112 |
private JTextField txtDistanceY; |
113 |
private JLabel lblUnits=new JLabel(); |
114 |
private ImageIcon icon; |
115 |
|
116 |
public GridPage() {
|
117 |
super();
|
118 |
icon = PluginServices.getIconTheme().get("grid-icon");
|
119 |
chkShowGrid=new JCheckBox(PluginServices.getText(this,"mostrar_rejilla")); |
120 |
addComponent(chkShowGrid); |
121 |
chkAdjustGrid=new JCheckBox(PluginServices.getText(this,"ajustar_rejilla")); |
122 |
addComponent(chkAdjustGrid); |
123 |
addComponent(lblUnits); |
124 |
|
125 |
// distance x
|
126 |
addComponent(PluginServices.getText(this, "distance_x") + ":", |
127 |
txtDistanceX = new JTextField("", 15)); |
128 |
// distance y
|
129 |
addComponent(PluginServices.getText(this, "distance_y") + ":", |
130 |
txtDistanceY = new JTextField("", 15)); |
131 |
setParentID(ViewPage.id); |
132 |
|
133 |
} |
134 |
|
135 |
public void initializeValues() { |
136 |
boolean showGrid = prefs.getBoolean("grid.showgrid",Grid.DefaultShowGrid); |
137 |
boolean adjustGrid = prefs.getBoolean("grid.adjustgrid",Grid.DefaultAdjustGrid); |
138 |
|
139 |
double dx = prefs.getDouble("grid.distancex",Grid.DefaultGridSizeX); |
140 |
double dy = prefs.getDouble("grid.distancey",Grid.DefaultGridSizeY); |
141 |
|
142 |
Grid.SHOWGRID=showGrid; |
143 |
Grid.ADJUSTGRID=adjustGrid; |
144 |
Grid.GRIDSIZEX=dx; |
145 |
Grid.GRIDSIZEY=dy; |
146 |
|
147 |
// setGridVisibility(showGrid);
|
148 |
// setAdjustGrid(adjustGrid);
|
149 |
// cadgrid.setGridSizeX(dx);
|
150 |
// cadgrid.setGridSizeY(dy);
|
151 |
// cta=CADExtension.getCADToolAdapter();
|
152 |
// cta.initializeGrid();
|
153 |
// ViewPort vp=cta.getMapControl().getViewPort();
|
154 |
// boolean showGrid = prefs.getBoolean("grid.showgrid",cta.getGrid().isShowGrid());
|
155 |
// boolean adjustGrid = prefs.getBoolean("grid.adjustgrid",cta.getGrid().isAdjustGrid());
|
156 |
//
|
157 |
// double dx = prefs.getDouble("grid.distancex",cta.getGrid().getGridSizeX());
|
158 |
// double dy = prefs.getDouble("grid.distancey",cta.getGrid().getGridSizeY());
|
159 |
// CADGrid cg=cta.getGrid();
|
160 |
chkShowGrid.setSelected(showGrid); |
161 |
chkAdjustGrid.setSelected(adjustGrid); |
162 |
txtDistanceX.setText(String.valueOf(dx));
|
163 |
txtDistanceY.setText(String.valueOf(dy));
|
164 |
// lblUnits.setText(PluginServices.getText(this,"Unidades")+ " "+PluginServices.getText(this,MapContext.getDistanceNames()[vp.getDistanceUnits()]));
|
165 |
|
166 |
// cta.setGridVisibility(showGrid);
|
167 |
// cta.setAdjustGrid(adjustGrid);
|
168 |
// cta.getGrid().setGridSizeX(dx);
|
169 |
// cta.getGrid().setGridSizeY(dy);
|
170 |
|
171 |
} |
172 |
|
173 |
public String getID() { |
174 |
return this.getClass().getName(); |
175 |
} |
176 |
|
177 |
public String getTitle() { |
178 |
return PluginServices.getText(this, "Grid"); |
179 |
} |
180 |
|
181 |
public JPanel getPanel() { |
182 |
return this; |
183 |
} |
184 |
|
185 |
public void storeValues() throws StoreException { |
186 |
boolean showGrid;
|
187 |
boolean adjustGrid;
|
188 |
double dx;
|
189 |
double dy;
|
190 |
|
191 |
showGrid=chkShowGrid.isSelected(); |
192 |
adjustGrid=chkAdjustGrid.isSelected(); |
193 |
try{
|
194 |
dx=Double.parseDouble(txtDistanceX.getText());
|
195 |
dy=Double.parseDouble(txtDistanceY.getText());
|
196 |
}catch (Exception e) { |
197 |
throw new StoreException(PluginServices.getText(this,"distancia_malla_incorrecta")); |
198 |
} |
199 |
prefs.putBoolean("grid.showgrid",showGrid);
|
200 |
prefs.putBoolean("grid.adjustgrid",adjustGrid);
|
201 |
prefs.putDouble("grid.distancex", dx);
|
202 |
prefs.putDouble("grid.distancey", dy);
|
203 |
|
204 |
Grid.SHOWGRID=showGrid; |
205 |
Grid.ADJUSTGRID=adjustGrid; |
206 |
Grid.GRIDSIZEX=dx; |
207 |
Grid.GRIDSIZEY=dy; |
208 |
|
209 |
IWindow window=PluginServices.getMDIManager().getActiveWindow(); |
210 |
if (window instanceof DefaultViewPanel){ |
211 |
MapControl mc=((DefaultViewPanel)window).getMapControl(); |
212 |
Grid cadGrid=mc.getGrid(); |
213 |
cadGrid.setShowGrid(showGrid); |
214 |
cadGrid.setAdjustGrid(adjustGrid); |
215 |
cadGrid.setGridSizeX(dx); |
216 |
cadGrid.setGridSizeY(dy); |
217 |
} |
218 |
|
219 |
} |
220 |
|
221 |
public void initializeDefaults() { |
222 |
chkShowGrid.setSelected(Grid.DefaultShowGrid); |
223 |
chkAdjustGrid.setSelected(Grid.DefaultAdjustGrid); |
224 |
// ViewPort vp=cta.getMapControl().getViewPort();
|
225 |
// lblUnits.setText(PluginServices.getText(this,"Unidades")+ " "+PluginServices.getText(this,MapContext.getDistanceNames()[vp.getDistanceUnits()]));
|
226 |
txtDistanceX.setText(String.valueOf(Grid.DefaultGridSizeX));
|
227 |
txtDistanceY.setText(String.valueOf(Grid.DefaultGridSizeY));
|
228 |
} |
229 |
|
230 |
public ImageIcon getIcon() { |
231 |
return icon;
|
232 |
} |
233 |
|
234 |
public boolean isValueChanged() { |
235 |
return super.hasChanged(); |
236 |
} |
237 |
|
238 |
public void setChangesApplied() { |
239 |
setChanged(false);
|
240 |
} |
241 |
} |