svn-gvsig-desktop / tags / v1_1_Build_914 / extensions / extCAD / src / com / iver / cit / gvsig / gui / preferences / GridPage.java @ 11873
History | View | Annotate | Download (6.74 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
|
42 |
/* CVS MESSAGES:
|
43 |
*
|
44 |
* $Id: GridPage.java 11873 2007-05-29 12:35:24Z $
|
45 |
* $Log$
|
46 |
* Revision 1.4 2006-08-22 12:27:53 jaume
|
47 |
* improved performances when saving
|
48 |
*
|
49 |
* Revision 1.3 2006/08/22 07:37:32 jaume
|
50 |
* *** empty log message ***
|
51 |
*
|
52 |
* Revision 1.2 2006/08/10 11:13:02 caballero
|
53 |
* mostrar unidades
|
54 |
*
|
55 |
* Revision 1.1 2006/08/10 08:18:35 caballero
|
56 |
* configurar grid
|
57 |
*
|
58 |
* Revision 1.1 2006/08/04 11:41:05 caballero
|
59 |
* poder especificar el zoom a aplicar en las vistas
|
60 |
*
|
61 |
* Revision 1.3 2006/07/31 10:02:31 jaume
|
62 |
* *** empty log message ***
|
63 |
*
|
64 |
* Revision 1.2 2006/06/13 07:43:08 fjp
|
65 |
* Ajustes sobre los cuadros de dialogos de preferencias
|
66 |
*
|
67 |
* Revision 1.1 2006/06/12 16:04:28 caballero
|
68 |
* Preferencias
|
69 |
*
|
70 |
* Revision 1.11 2006/06/06 10:26:31 jaume
|
71 |
* *** empty log message ***
|
72 |
*
|
73 |
* Revision 1.10 2006/06/05 17:07:17 jaume
|
74 |
* *** empty log message ***
|
75 |
*
|
76 |
* Revision 1.9 2006/06/05 17:00:44 jaume
|
77 |
* *** empty log message ***
|
78 |
*
|
79 |
* Revision 1.8 2006/06/05 16:57:59 jaume
|
80 |
* *** empty log message ***
|
81 |
*
|
82 |
* Revision 1.7 2006/06/05 14:45:06 jaume
|
83 |
* *** empty log message ***
|
84 |
*
|
85 |
* Revision 1.6 2006/06/05 11:00:09 jaume
|
86 |
* *** empty log message ***
|
87 |
*
|
88 |
* Revision 1.5 2006/06/05 10:39:02 jaume
|
89 |
* *** empty log message ***
|
90 |
*
|
91 |
* Revision 1.4 2006/06/05 10:13:40 jaume
|
92 |
* *** empty log message ***
|
93 |
*
|
94 |
* Revision 1.3 2006/06/05 10:06:08 jaume
|
95 |
* *** empty log message ***
|
96 |
*
|
97 |
* Revision 1.2 2006/06/05 09:51:56 jaume
|
98 |
* *** empty log message ***
|
99 |
*
|
100 |
* Revision 1.1 2006/06/02 10:50:18 jaume
|
101 |
* *** empty log message ***
|
102 |
*
|
103 |
*
|
104 |
*/
|
105 |
package com.iver.cit.gvsig.gui.preferences; |
106 |
|
107 |
import java.util.prefs.Preferences; |
108 |
|
109 |
import javax.swing.ImageIcon; |
110 |
import javax.swing.JCheckBox; |
111 |
import javax.swing.JLabel; |
112 |
import javax.swing.JPanel; |
113 |
import javax.swing.JTextField; |
114 |
|
115 |
import com.iver.andami.PluginServices; |
116 |
import com.iver.andami.preferences.AbstractPreferencePage; |
117 |
import com.iver.andami.preferences.StoreException; |
118 |
import com.iver.cit.gvsig.CADExtension; |
119 |
import com.iver.cit.gvsig.fmap.ViewPort; |
120 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
121 |
import com.iver.cit.gvsig.gui.cad.CADGrid; |
122 |
import com.iver.cit.gvsig.gui.cad.CADToolAdapter; |
123 |
|
124 |
public class GridPage extends AbstractPreferencePage { |
125 |
private static Preferences prefs = Preferences.userRoot().node( "cadtooladapter" ); |
126 |
private CADToolAdapter cta;
|
127 |
private JCheckBox chkShowGrid; |
128 |
private JCheckBox chkAdjustGrid; |
129 |
private JTextField txtDistanceX; |
130 |
private JTextField txtDistanceY; |
131 |
private JLabel lblUnits=new JLabel(); |
132 |
private ImageIcon icon; |
133 |
|
134 |
public GridPage() {
|
135 |
super();
|
136 |
icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/Grid.png")); |
137 |
chkShowGrid=new JCheckBox(PluginServices.getText(this,"mostrar_rejilla")); |
138 |
addComponent(chkShowGrid); |
139 |
chkAdjustGrid=new JCheckBox(PluginServices.getText(this,"ajustar_rejilla")); |
140 |
addComponent(chkAdjustGrid); |
141 |
addComponent(lblUnits); |
142 |
|
143 |
// distance x
|
144 |
addComponent(PluginServices.getText(this, "distance_x") + ":", |
145 |
txtDistanceX = new JTextField("", 15)); |
146 |
// distance y
|
147 |
addComponent(PluginServices.getText(this, "distance_y") + ":", |
148 |
txtDistanceY = new JTextField("", 15)); |
149 |
|
150 |
} |
151 |
|
152 |
public void initializeValues() { |
153 |
cta=CADExtension.getCADToolAdapter(); |
154 |
cta.initializeGrid(); |
155 |
ViewPort vp=cta.getMapControl().getViewPort(); |
156 |
// boolean showGrid = prefs.getBoolean("grid.showgrid",cta.getGrid().isShowGrid());
|
157 |
// boolean adjustGrid = prefs.getBoolean("grid.adjustgrid",cta.getGrid().isAdjustGrid());
|
158 |
//
|
159 |
// double dx = prefs.getDouble("grid.distancex",cta.getGrid().getGridSizeX());
|
160 |
// double dy = prefs.getDouble("grid.distancey",cta.getGrid().getGridSizeY());
|
161 |
CADGrid cg=cta.getGrid(); |
162 |
chkShowGrid.setSelected(cg.isShowGrid()); |
163 |
chkAdjustGrid.setSelected(cg.isAdjustGrid()); |
164 |
txtDistanceX.setText(String.valueOf(cg.getGridSizeX()));
|
165 |
txtDistanceY.setText(String.valueOf(cg.getGridSizeY()));
|
166 |
lblUnits.setText(PluginServices.getText(this,"Unidades")+ " "+PluginServices.getText(this,FConstant.NAMES[vp.getDistanceUnits()])); |
167 |
|
168 |
// cta.setGridVisibility(showGrid);
|
169 |
// cta.setAdjustGrid(adjustGrid);
|
170 |
// cta.getGrid().setGridSizeX(dx);
|
171 |
// cta.getGrid().setGridSizeY(dy);
|
172 |
|
173 |
} |
174 |
|
175 |
public String getID() { |
176 |
return this.getClass().getName(); |
177 |
} |
178 |
|
179 |
public String getTitle() { |
180 |
return PluginServices.getText(this, "Grid"); |
181 |
} |
182 |
|
183 |
public JPanel getPanel() { |
184 |
return this; |
185 |
} |
186 |
|
187 |
public void storeValues() throws StoreException { |
188 |
boolean showGrid;
|
189 |
boolean adjustGrid;
|
190 |
double dx;
|
191 |
double dy;
|
192 |
|
193 |
showGrid=chkShowGrid.isSelected(); |
194 |
adjustGrid=chkAdjustGrid.isSelected(); |
195 |
try{
|
196 |
dx=Double.parseDouble(txtDistanceX.getText());
|
197 |
dy=Double.parseDouble(txtDistanceY.getText());
|
198 |
}catch (Exception e) { |
199 |
throw new StoreException(PluginServices.getText(this,"distancia_malla_incorrecta")); |
200 |
} |
201 |
prefs.putBoolean("grid.showgrid",showGrid);
|
202 |
prefs.putBoolean("grid.adjustgrid",adjustGrid);
|
203 |
prefs.putDouble("grid.distancex", dx);
|
204 |
prefs.putDouble("grid.distancey", dy);
|
205 |
|
206 |
cta.setGridVisibility(showGrid); |
207 |
cta.setAdjustGrid(adjustGrid); |
208 |
cta.getGrid().setGridSizeX(dx); |
209 |
cta.getGrid().setGridSizeY(dy); |
210 |
|
211 |
} |
212 |
|
213 |
public void initializeDefaults() { |
214 |
chkShowGrid.setSelected(cta.getGrid().isShowGrid()); |
215 |
chkAdjustGrid.setSelected(cta.getGrid().isAdjustGrid()); |
216 |
ViewPort vp=cta.getMapControl().getViewPort(); |
217 |
lblUnits.setText(PluginServices.getText(this,"Unidades")+ " "+PluginServices.getText(this,FConstant.NAMES[vp.getDistanceUnits()])); |
218 |
txtDistanceX.setText(String.valueOf(cta.getGrid().getGridSizeX()));
|
219 |
txtDistanceY.setText(String.valueOf(cta.getGrid().getGridSizeY()));
|
220 |
} |
221 |
|
222 |
public ImageIcon getIcon() { |
223 |
return icon;
|
224 |
} |
225 |
|
226 |
public boolean isValueChanged() { |
227 |
return super.hasChanged(); |
228 |
} |
229 |
|
230 |
public void setChangesApplied() { |
231 |
setChanged(false);
|
232 |
} |
233 |
} |