Statistics
| Revision:

gvsig-3d / 2.1 / trunk / org.gvsig.gvsig3d / org.gvsig.gvsig3d.app / org.gvsig.gvsig3d.app.commons / src / main / java / org / gvsig / gvsig3d / app / preferences / View3DPreferences.java @ 385

History | View | Annotate | Download (5.71 KB)

1
/* gvSIG 3D extension for gvSIG
2
 *
3
 * Copyright (C) 2012 Prodevelop.
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
 *   Prodevelop, S.L.
22
 *   Pza. Don Juan de Villarrasa, 14 - 5
23
 *   46001 Valencia
24
 *   Spain
25
 *
26
 *   +34 963 510 612
27
 *   +34 963 510 968
28
 *   prode@prodevelop.es
29
 *   http://www.prodevelop.es
30
 */
31
/*
32
 * AUTHORS:
33
 * 2012 AI2 - Instituto Universitario de Automatica e Informatica Industrial.
34
 * Universitat Politecnica de Valencia (UPV)
35
 * http://www.ai2.upv.es
36
 */
37

    
38

    
39
package org.gvsig.gvsig3d.app.preferences;
40

    
41
import java.awt.event.ActionEvent;
42
import java.util.Enumeration;
43
import java.util.prefs.Preferences;
44

    
45
import javax.swing.AbstractAction;
46
import javax.swing.Action;
47
import javax.swing.ButtonGroup;
48
import javax.swing.ImageIcon;
49
import javax.swing.JLabel;
50
import javax.swing.JPanel;
51
import javax.swing.JRadioButton;
52

    
53
import org.gvsig.andami.PluginServices;
54
import org.gvsig.andami.preferences.AbstractPreferencePage;
55
import org.gvsig.andami.preferences.StoreException;
56
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
57

    
58

    
59
/**
60
 * @author Jesus Zarzoso- jzarzoso@ai2.upv.es
61
 * @version $Id$
62
 * 
63
 */
64
public class View3DPreferences extends AbstractPreferencePage {
65

    
66
    private String id;
67
    private ImageIcon icon;
68
    private GridBagLayoutPanel panel;
69
    private ButtonGroup radioButtonGroup;
70
    private boolean compatibilitySwing = false;
71
    private JRadioButton activeAWT;
72
    private JRadioButton activeGL;
73
    private static Preferences prefs =
74
        Preferences.userRoot().node("gvsig.configuration.3D");
75

    
76
    public View3DPreferences() {
77
        super();
78
        // TODO Auto-generated constructor stub
79
        id = this.getClass().getName();
80
        icon = PluginServices.getIconTheme().get("gnome-settings-theme");
81
    }
82

    
83
    public void setChangesApplied() {
84
        if (compatibilitySwing)
85
            activeAWT.setSelected(true);
86
        else
87
            activeGL.setSelected(true);
88
    }
89

    
90
    public void storeValues() throws StoreException {
91
        // TODO Auto-generated method stub
92
        prefs.putBoolean("compatibilitySwing", compatibilitySwing);
93
    }
94

    
95
    public String getID() {
96
        return id;
97
    }
98

    
99
    public ImageIcon getIcon() {
100
        return icon;
101
    }
102

    
103
    private ButtonGroup getRadioButonGroup() {
104

    
105
        if (radioButtonGroup == null) {
106

    
107
            // Create an action for each radio button
108
            Action AWTaction = new AbstractAction("AWT") {
109

    
110
                // This method is called whenever the radio button is pressed,
111
                // even if it is already selected; this method is not called
112
                // if the radio button was selected programmatically
113
                public void actionPerformed(ActionEvent evt) {
114
                    // ACTION THAT ACTIVATE GL PANEL MODE
115
                    compatibilitySwing = true;
116
                }
117
            };
118

    
119
            Action GLaction = new AbstractAction("GL") {
120

    
121
                // See above
122
                public void actionPerformed(ActionEvent evt) {
123
                    // ACTION THAT ACTIVATE CANVAS MODE
124
                    compatibilitySwing = false;
125
                }
126
            };
127

    
128
            activeAWT.setAction(AWTaction);
129
            activeGL.setAction(GLaction);
130
            // Inicialize the button properties
131
            activeAWT.setName("Si");
132
            activeAWT.setLabel(PluginServices.getText(this, "AWT"));
133
            activeGL.setName("No");
134
            activeGL.setLabel(PluginServices.getText(this, "GL"));
135

    
136
            if (compatibilitySwing)
137
                activeAWT.setSelected(true);
138
            else
139
                activeGL.setSelected(true);
140

    
141
            // Associate the two buttons with a button group
142
            radioButtonGroup = new ButtonGroup();
143
            radioButtonGroup.add(activeAWT);
144
            radioButtonGroup.add(activeGL);
145
        }
146

    
147
        return radioButtonGroup;
148
    }
149

    
150
    public JPanel getPanel() {
151

    
152
        if (radioButtonGroup == null) {
153
            radioButtonGroup = getRadioButonGroup();
154

    
155
            addComponent(new JLabel(PluginServices.getText(this,
156
                "Swing_Compability")));
157
            for (Enumeration e = radioButtonGroup.getElements(); e
158
                .hasMoreElements();) {
159
                JRadioButton b = (JRadioButton) e.nextElement();
160
                addComponent(b);
161
            }
162
            addComponent(new JLabel(PluginServices.getText(this,
163
                "Swing_Compability_Note")));
164
        }
165
        return this;
166
    }
167

    
168
    public String getTitle() {
169
        // TODO Auto-generated method stub
170
        return "3D";
171
    }
172

    
173
    public void initializeDefaults() {
174
        // TODO Auto-generated method stub
175
        this.compatibilitySwing = true;
176

    
177
    }
178

    
179
    public void initializeValues() {
180
        // TODO Auto-generated method stub
181
        compatibilitySwing =
182
            prefs.getBoolean("compatibilitySwing", compatibilitySwing);
183

    
184
        // Create the radio buttons using the actions
185
        activeAWT = new JRadioButton();
186
        activeGL = new JRadioButton();
187

    
188
    }
189

    
190
    public boolean isValueChanged() {
191
        // TODO Auto-generated method stub
192
        return true;
193
    }
194

    
195
}
196