Statistics
| Revision:

gvsig-3d / 2.1 / branches / extrusion / org.gvsig.view3d.swing / org.gvsig.view3d.swing.impl / src / main / java / org / gvsig / view3d / swing / impl / properties / AbstractGeneralProperties3DPanel.java @ 657

History | View | Annotate | Download (14.1 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright © 2007-2016 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 2
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

    
25
package org.gvsig.view3d.swing.impl.properties;
26

    
27
import java.awt.BorderLayout;
28
import java.awt.Color;
29
import java.awt.GridBagConstraints;
30
import java.awt.GridBagLayout;
31
import java.awt.Insets;
32

    
33
import javax.swing.BorderFactory;
34
import javax.swing.JButton;
35
import javax.swing.JCheckBox;
36
import javax.swing.JLabel;
37
import javax.swing.JPanel;
38
import javax.swing.JTextField;
39

    
40
import org.gvsig.tools.ToolsLocator;
41
import org.gvsig.tools.i18n.I18nManager;
42
import org.gvsig.view3d.swing.api.properties.GeneralProperties3DPanel;
43

    
44
/**
45
 * Abstract panel for the general properties, i.e. the ones found in the 
46
 * gvSIG main preferences under 3D.
47
 */
48
public abstract class AbstractGeneralProperties3DPanel extends JPanel implements
49
    GeneralProperties3DPanel {
50

    
51
    private static final long serialVersionUID = -7528509541668616886L;
52

    
53
    private Insets insets = new Insets(5, 5, 5, 5);
54

    
55
    private JPanel sizePanel;
56
    private JLabel heightText;
57
    private JTextField heightField;
58
    private JLabel widthText;
59
    private JTextField widthField;
60

    
61
    private JPanel componentsPanel;
62
    private JLabel atmosphereText;
63
    private JCheckBox atmosphereCheckBox;
64
    private JLabel northIndicatorText;
65
    private JCheckBox northIndicatorCheckBox;
66
    private JLabel minimapText;
67
    private JCheckBox minimapCheckBox;
68
    private JLabel starsBackgroundText;
69
    private JCheckBox startsBackgroundCheckBox;
70
    private JLabel scaleText;
71
    private JCheckBox scaleCheckBox;
72
    private JLabel viewPortAnimationText;
73
    private JCheckBox viewPortAnimationCheckBox;
74
    
75
    private JPanel cachePanel;
76
    private JLabel cacheText;
77
    private JTextField cacheField;
78
    private JButton cacheButton;
79

    
80
    public AbstractGeneralProperties3DPanel() {
81
        this.setLayout(new BorderLayout());
82

    
83
        initialize();
84
    }
85

    
86
    private void initialize() {
87
        this.add(getSizePanel(), BorderLayout.NORTH);
88
        this.add(getComponentsPanel(), BorderLayout.CENTER);
89
        this.add(getCachePanel(), BorderLayout.SOUTH);
90
    }
91

    
92
    private JPanel getCachePanel() {
93
        if (cachePanel == null) {
94
            cachePanel = new JPanel(new GridBagLayout());
95
            I18nManager i18nManager = ToolsLocator.getI18nManager();
96
            cachePanel.setBorder(BorderFactory.createTitledBorder(
97
                BorderFactory.createLineBorder(Color.GRAY),
98
                i18nManager.getTranslation("cache")));
99
            
100
            GridBagConstraints cons = new GridBagConstraints();
101
            cons.gridx = 0;
102
            cons.gridy = 0;
103
            cons.weightx = 0;
104
            cons.anchor = GridBagConstraints.EAST;
105
            cons.fill = GridBagConstraints.HORIZONTAL;
106
            cons.insets = insets;
107
            
108
            cachePanel.add(getCacheText(), cons);
109
            
110
            cons = new GridBagConstraints();
111
            cons.gridx = 1;
112
            cons.gridy = 0;
113
            cons.weightx = 1;
114
            cons.fill = GridBagConstraints.HORIZONTAL;
115
            cons.insets = insets;
116
            
117
            cachePanel.add(getCacheField(), cons);
118
            
119
            cons = new GridBagConstraints();
120
            cons.gridx = 0;
121
            cons.gridy = 1;
122
            cons.weightx = 0;
123
            cons.anchor = GridBagConstraints.WEST;
124
            cons.insets = insets;
125
            
126
            cachePanel.add(getCacheButton(), cons);
127
        }
128
        return cachePanel;
129

    
130
    }
131

    
132
    private JLabel getCacheText() {
133
        if(cacheText == null){
134
            I18nManager i18nManager = ToolsLocator.getI18nManager();
135
            cacheText = new JLabel(i18nManager.getTranslation("path_tilecache"));
136
        }
137
        return cacheText;
138
    }
139

    
140
    protected JTextField getCacheField() {
141
        if(cacheField == null){
142
            cacheField = new JTextField();
143
        }
144
        return cacheField;
145
    }
146

    
147
    protected JButton getCacheButton() {
148
        if(cacheButton == null){
149
            I18nManager i18nManager = ToolsLocator.getI18nManager();
150
            cacheButton = new JButton(i18nManager.getTranslation("remove_cache"));
151
        }
152
        return cacheButton;
153
    }
154

    
155
    private JPanel getComponentsPanel() {
156
        if (componentsPanel == null) {
157
            componentsPanel = new JPanel(new GridBagLayout());
158
            I18nManager i18nManager = ToolsLocator.getI18nManager();
159
            componentsPanel.setBorder(BorderFactory.createTitledBorder(
160
                BorderFactory.createLineBorder(Color.GRAY),
161
                i18nManager.getTranslation("components")));
162

    
163
            GridBagConstraints cons = new GridBagConstraints();
164
            cons.gridx = 0;
165
            cons.gridy = 0;
166
            cons.weightx = 0;
167
            cons.anchor = GridBagConstraints.EAST;
168
            cons.fill = GridBagConstraints.HORIZONTAL;
169
            cons.insets = insets;
170

    
171
            componentsPanel.add(getAtmosphereText(), cons);
172

    
173
            cons = new GridBagConstraints();
174
            cons.gridx = 1;
175
            cons.gridy = 0;
176
            cons.weightx = 1;
177
            cons.insets = insets;
178

    
179
            componentsPanel.add(getAtmosphereCheckBox(), cons);
180

    
181
            cons = new GridBagConstraints();
182
            cons.gridx = 0;
183
            cons.gridy = 1;
184
            cons.weightx = 0;
185
            cons.anchor = GridBagConstraints.EAST;
186
            cons.fill = GridBagConstraints.HORIZONTAL;
187
            cons.insets = insets;
188

    
189
            componentsPanel.add(getNorthIndicatorText(), cons);
190

    
191
            cons = new GridBagConstraints();
192
            cons.gridx = 1;
193
            cons.gridy = 1;
194
            cons.weightx = 1;
195
            cons.insets = insets;
196

    
197
            componentsPanel.add(getNorthIndicatorCheckBox(), cons);
198

    
199
            cons = new GridBagConstraints();
200
            cons.gridx = 0;
201
            cons.gridy = 2;
202
            cons.weightx = 0;
203
            cons.anchor = GridBagConstraints.EAST;
204
            cons.fill = GridBagConstraints.HORIZONTAL;
205
            cons.insets = insets;
206

    
207
            componentsPanel.add(getMinimapText(), cons);
208

    
209
            cons = new GridBagConstraints();
210
            cons.gridx = 1;
211
            cons.gridy = 2;
212
            cons.weightx = 1;
213
            cons.insets = insets;
214

    
215
            componentsPanel.add(getMinimapCheckBox(), cons);
216

    
217
            cons = new GridBagConstraints();
218
            cons.gridx = 0;
219
            cons.gridy = 3;
220
            cons.weightx = 0;
221
            cons.anchor = GridBagConstraints.EAST;
222
            cons.fill = GridBagConstraints.HORIZONTAL;
223
            cons.insets = insets;
224

    
225
            componentsPanel.add(getStarsBackgroundText(), cons);
226

    
227
            cons = new GridBagConstraints();
228
            cons.gridx = 1;
229
            cons.gridy = 3;
230
            cons.weightx = 1;
231
            cons.insets = insets;
232

    
233
            componentsPanel.add(getStarsBackGroundCheckBox(), cons);
234

    
235
            cons = new GridBagConstraints();
236
            cons.gridx = 0;
237
            cons.gridy = 4;
238
            cons.weightx = 0;
239
            cons.anchor = GridBagConstraints.EAST;
240
            cons.fill = GridBagConstraints.HORIZONTAL;
241
            cons.insets = insets;
242

    
243
            componentsPanel.add(getScaleText(), cons);
244

    
245
            cons = new GridBagConstraints();
246
            cons.gridx = 1;
247
            cons.gridy = 4;
248
            cons.weightx = 1;
249
            cons.insets = insets;
250

    
251
            componentsPanel.add(getScaleCheckBox(), cons);
252
            
253
            cons = new GridBagConstraints();
254
            cons.gridx = 0;
255
            cons.gridy = 5;
256
            cons.weightx = 0;
257
            cons.anchor = GridBagConstraints.EAST;
258
            cons.fill = GridBagConstraints.HORIZONTAL;
259
            cons.insets = insets;
260

    
261
            componentsPanel.add(getViewPortAnimationText(), cons);
262
            
263
            cons = new GridBagConstraints();
264
            cons.gridx = 1;
265
            cons.gridy = 5;
266
            cons.weightx = 1;
267
            cons.insets = insets;
268
            
269
            componentsPanel.add(getViewPortAnimationCheckBox(), cons);
270
        }
271
        return componentsPanel;         
272
    }
273

    
274
    private JLabel getViewPortAnimationText() {
275
        if(viewPortAnimationText == null){
276
            I18nManager i18nManager = ToolsLocator.getI18nManager();
277
            viewPortAnimationText = new JLabel(i18nManager.getTranslation("view_port_animation"));
278
        }
279
        return viewPortAnimationText;
280
    }
281

    
282
    protected JCheckBox getViewPortAnimationCheckBox() {
283
        if(viewPortAnimationCheckBox == null){
284
            viewPortAnimationCheckBox = new JCheckBox();
285
        }
286
        return viewPortAnimationCheckBox;
287
    }
288

    
289
    private JLabel getAtmosphereText() {
290
        if (atmosphereText == null) {
291
            I18nManager i18nManager = ToolsLocator.getI18nManager();
292
            atmosphereText =
293
                new JLabel(i18nManager.getTranslation("show_atmosphere"));
294
        }
295
        return atmosphereText;
296
    }
297

    
298
    protected JCheckBox getAtmosphereCheckBox() {
299
        if (atmosphereCheckBox == null) {
300
            atmosphereCheckBox = new JCheckBox();
301
        }
302
        return atmosphereCheckBox;
303
    }
304

    
305
    private JLabel getNorthIndicatorText() {
306
        if (northIndicatorText == null) {
307
            I18nManager i18nManager = ToolsLocator.getI18nManager();
308
            northIndicatorText =
309
                new JLabel(i18nManager.getTranslation("show_north_indicator"));
310
        }
311
        return northIndicatorText;
312
    }
313

    
314
    protected JCheckBox getNorthIndicatorCheckBox() {
315
        if (northIndicatorCheckBox == null) {
316
            northIndicatorCheckBox = new JCheckBox();
317
        }
318
        return northIndicatorCheckBox;
319
    }
320

    
321
    private JLabel getMinimapText() {
322
        if (minimapText == null) {
323
            I18nManager i18nManager = ToolsLocator.getI18nManager();
324
            minimapText =
325
                new JLabel(i18nManager.getTranslation("show_minimap"));
326
        }
327
        return minimapText;
328
    }
329

    
330
    protected JCheckBox getMinimapCheckBox() {
331
        if (minimapCheckBox == null) {
332
            minimapCheckBox = new JCheckBox();
333
        }
334
        return minimapCheckBox;
335
    }
336

    
337
    private JLabel getStarsBackgroundText() {
338
        if (starsBackgroundText == null) {
339
            I18nManager i18nManager = ToolsLocator.getI18nManager();
340
            starsBackgroundText =
341
                new JLabel(i18nManager.getTranslation("show_stars_background"));
342
        }
343
        return starsBackgroundText;
344
    }
345

    
346
    protected JCheckBox getStarsBackGroundCheckBox() {
347
        if (startsBackgroundCheckBox == null) {
348
            startsBackgroundCheckBox = new JCheckBox();
349
        }
350
        return startsBackgroundCheckBox;
351
    }
352

    
353
    private JLabel getScaleText() {
354
        if (scaleText == null) {
355
            I18nManager i18nManager = ToolsLocator.getI18nManager();
356
            scaleText = new JLabel(i18nManager.getTranslation("show_scale"));
357
        }
358
        return scaleText;
359
    }
360

    
361
    protected JCheckBox getScaleCheckBox() {
362
        if (scaleCheckBox == null) {
363
            scaleCheckBox = new JCheckBox();
364
        }
365
        return scaleCheckBox;
366
    }
367

    
368
    private JPanel getSizePanel() {
369
        if (sizePanel == null) {
370
            sizePanel = new JPanel(new GridBagLayout());
371
            I18nManager i18nManager = ToolsLocator.getI18nManager();
372
            sizePanel.setBorder(BorderFactory.createTitledBorder(
373
                BorderFactory.createLineBorder(Color.GRAY),
374
                i18nManager.getTranslation("size")));
375

    
376
            GridBagConstraints cons = new GridBagConstraints();
377
            cons.gridx = 0;
378
            cons.gridy = 0;
379
            cons.weightx = 0;
380
            cons.anchor = GridBagConstraints.EAST;
381
            cons.fill = GridBagConstraints.HORIZONTAL;
382
            cons.insets = insets;
383

    
384
            sizePanel.add(getHeightText(), cons);
385

    
386
            cons = new GridBagConstraints();
387
            cons.gridx = 1;
388
            cons.gridy = 0;
389
            cons.weightx = 1;
390
            cons.fill = GridBagConstraints.HORIZONTAL;
391
            cons.insets = insets;
392

    
393
            sizePanel.add(getHeightField(), cons);
394

    
395
            cons = new GridBagConstraints();
396
            cons.gridx = 2;
397
            cons.gridy = 0;
398
            cons.weightx = 0;
399
            cons.anchor = GridBagConstraints.EAST;
400
            cons.fill = GridBagConstraints.HORIZONTAL;
401
            cons.insets = insets;
402

    
403
            sizePanel.add(getWidthtText(), cons);
404

    
405
            cons = new GridBagConstraints();
406
            cons.gridx = 3;
407
            cons.gridy = 0;
408
            cons.weightx = 1;
409
            cons.fill = GridBagConstraints.HORIZONTAL;
410
            cons.insets = insets;
411

    
412
            sizePanel.add(getWidthField(), cons);
413
        }
414
        return sizePanel;
415
    }
416

    
417
    private JLabel getHeightText() {
418
        if (heightText == null) {
419
            I18nManager i18nManager = ToolsLocator.getI18nManager();
420
            heightText = new JLabel(i18nManager.getTranslation("height"));
421
        }
422
        return heightText;
423
    }
424

    
425
    protected JTextField getHeightField() {
426
        if (heightField == null) {
427
            heightField = new JTextField();
428
        }
429
        return heightField;
430
    }
431

    
432
    private JLabel getWidthtText() {
433
        if (widthText == null) {
434
            I18nManager i18nManager = ToolsLocator.getI18nManager();
435
            widthText = new JLabel(i18nManager.getTranslation("width"));
436
        }
437
        return widthText;
438
    }
439

    
440
    protected JTextField getWidthField() {
441
        if (widthField == null) {
442
            widthField = new JTextField();
443
        }
444
        return widthField;
445
    }
446
}