Statistics
| Revision:

root / trunk / extensions / extCAD / src / com / iver / cit / gvsig / gui / preferences / GridPage.java @ 6720

History | View | Annotate | Download (6.51 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 6720 2006-08-10 11:13:02Z caballero $
45
* $Log$
46
* Revision 1.2  2006-08-10 11:13:02  caballero
47
* mostrar unidades
48
*
49
* Revision 1.1  2006/08/10 08:18:35  caballero
50
* configurar grid
51
*
52
* Revision 1.1  2006/08/04 11:41:05  caballero
53
* poder especificar el zoom a aplicar en las vistas
54
*
55
* Revision 1.3  2006/07/31 10:02:31  jaume
56
* *** empty log message ***
57
*
58
* Revision 1.2  2006/06/13 07:43:08  fjp
59
* Ajustes sobre los cuadros de dialogos de preferencias
60
*
61
* Revision 1.1  2006/06/12 16:04:28  caballero
62
* Preferencias
63
*
64
* Revision 1.11  2006/06/06 10:26:31  jaume
65
* *** empty log message ***
66
*
67
* Revision 1.10  2006/06/05 17:07:17  jaume
68
* *** empty log message ***
69
*
70
* Revision 1.9  2006/06/05 17:00:44  jaume
71
* *** empty log message ***
72
*
73
* Revision 1.8  2006/06/05 16:57:59  jaume
74
* *** empty log message ***
75
*
76
* Revision 1.7  2006/06/05 14:45:06  jaume
77
* *** empty log message ***
78
*
79
* Revision 1.6  2006/06/05 11:00:09  jaume
80
* *** empty log message ***
81
*
82
* Revision 1.5  2006/06/05 10:39:02  jaume
83
* *** empty log message ***
84
*
85
* Revision 1.4  2006/06/05 10:13:40  jaume
86
* *** empty log message ***
87
*
88
* Revision 1.3  2006/06/05 10:06:08  jaume
89
* *** empty log message ***
90
*
91
* Revision 1.2  2006/06/05 09:51:56  jaume
92
* *** empty log message ***
93
*
94
* Revision 1.1  2006/06/02 10:50:18  jaume
95
* *** empty log message ***
96
*
97
*
98
*/
99
package com.iver.cit.gvsig.gui.preferences;
100

    
101
import java.util.prefs.Preferences;
102

    
103
import javax.swing.ImageIcon;
104
import javax.swing.JCheckBox;
105
import javax.swing.JLabel;
106
import javax.swing.JPanel;
107
import javax.swing.JTextField;
108

    
109
import com.iver.andami.PluginServices;
110
import com.iver.andami.preferences.AbstractPreferencePage;
111
import com.iver.andami.preferences.StoreException;
112
import com.iver.cit.gvsig.CADExtension;
113
import com.iver.cit.gvsig.fmap.ViewPort;
114
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
115
import com.iver.cit.gvsig.gui.cad.CADGrid;
116
import com.iver.cit.gvsig.gui.cad.CADToolAdapter;
117

    
118
public class GridPage extends AbstractPreferencePage {
119
        private static Preferences prefs = Preferences.userRoot().node( "cadtooladapter" );
120
        private CADToolAdapter cta;
121
        private JCheckBox chkShowGrid;
122
        private JCheckBox chkAdjustGrid;
123
        private JTextField txtDistanceX;
124
        private JTextField txtDistanceY;
125
        private JLabel lblUnits=new JLabel();
126
        private ImageIcon icon;
127

    
128
        public GridPage() {
129
                super();
130
                icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/Grid.png"));
131
                chkShowGrid=new JCheckBox(PluginServices.getText(this,"mostrar_rejilla"));
132
                addComponent(chkShowGrid);
133
                chkAdjustGrid=new JCheckBox(PluginServices.getText(this,"ajustar_rejilla"));
134
                addComponent(chkAdjustGrid);
135
                addComponent(lblUnits);
136

    
137
                // distance x
138
                addComponent(PluginServices.getText(this, "distance_x") + ":",
139
                        txtDistanceX = new JTextField("", 15));
140
                // distance y
141
                addComponent(PluginServices.getText(this, "distance_y") + ":",
142
                        txtDistanceY = new JTextField("", 15));
143

    
144
        }
145

    
146
        public void initializeValues() {
147
                cta=CADExtension.getCADToolAdapter();
148
                cta.initializeGrid();
149
                ViewPort vp=cta.getMapControl().getViewPort();
150
//                boolean showGrid = prefs.getBoolean("grid.showgrid",cta.getGrid().isShowGrid());
151
//                boolean adjustGrid = prefs.getBoolean("grid.adjustgrid",cta.getGrid().isAdjustGrid());
152
//
153
//                double dx = prefs.getDouble("grid.distancex",cta.getGrid().getGridSizeX());
154
//                double dy = prefs.getDouble("grid.distancey",cta.getGrid().getGridSizeY());
155
                CADGrid cg=cta.getGrid();
156
                chkShowGrid.setSelected(cg.isShowGrid());
157
                chkAdjustGrid.setSelected(cg.isAdjustGrid());
158
                txtDistanceX.setText(String.valueOf(cg.getGridSizeX()));
159
                txtDistanceY.setText(String.valueOf(cg.getGridSizeY()));
160
                lblUnits.setText(PluginServices.getText(this,"Unidades")+ "           "+PluginServices.getText(this,FConstant.NAMES[vp.getDistanceUnits()]));
161

    
162
//                cta.setGridVisibility(showGrid);
163
//                cta.setAdjustGrid(adjustGrid);
164
//                cta.getGrid().setGridSizeX(dx);
165
//                cta.getGrid().setGridSizeY(dy);
166

    
167
        }
168

    
169
        public String getID() {
170
                return this.getClass().getName();
171
        }
172

    
173
        public String getTitle() {
174
                return PluginServices.getText(this, "Grid");
175
        }
176

    
177
        public JPanel getPanel() {
178
                return this;
179
        }
180

    
181
        public void storeValues() throws StoreException {
182
                boolean showGrid;
183
                boolean adjustGrid;
184
                double dx;
185
                double dy;
186

    
187
                        showGrid=chkShowGrid.isSelected();
188
                        adjustGrid=chkAdjustGrid.isSelected();
189
                try{
190
                        dx=Double.parseDouble(txtDistanceX.getText());
191
                        dy=Double.parseDouble(txtDistanceY.getText());
192
                }catch (Exception e) {
193
                        throw new StoreException(PluginServices.getText(this,"distancia_malla_incorrecta"));
194
                }
195
                prefs.putBoolean("grid.showgrid",showGrid);
196
                prefs.putBoolean("grid.adjustgrid",adjustGrid);
197
                prefs.putDouble("grid.distancex", dx);
198
                prefs.putDouble("grid.distancey", dy);
199

    
200
                cta.setGridVisibility(showGrid);
201
                cta.setAdjustGrid(adjustGrid);
202
                cta.getGrid().setGridSizeX(dx);
203
                cta.getGrid().setGridSizeY(dy);
204
        }
205

    
206
        public void cancelAction() {
207
                initializeValues();
208
        }
209

    
210
        public void initializeDefaults() {
211
                chkShowGrid.setSelected(cta.getGrid().isShowGrid());
212
                chkAdjustGrid.setSelected(cta.getGrid().isAdjustGrid());
213
                ViewPort vp=cta.getMapControl().getViewPort();
214
                lblUnits.setText(PluginServices.getText(this,"Unidades")+ "           "+PluginServices.getText(this,FConstant.NAMES[vp.getDistanceUnits()]));
215
                txtDistanceX.setText(String.valueOf(cta.getGrid().getGridSizeX()));
216
                txtDistanceY.setText(String.valueOf(cta.getGrid().getGridSizeY()));
217
        }
218

    
219
        public ImageIcon getIcon() {
220
                return icon;
221
        }
222
}