1 | /* |
2 | * Copyright (c) 2005 The PseudoQ Project. |
3 | * |
4 | * This file is part of PseudoQ. |
5 | * |
6 | * PseudoQ is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU Lesser General Public License as published by |
8 | * the Free Software Foundation; either version 2.1 of the License, or |
9 | * (at your option) any later version. |
10 | * |
11 | * PseudoQ 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 Lesser General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU Lesser General Public License |
17 | * along with PseudoQ; if not, write to the Free Software |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
19 | */ |
20 | |
21 | package net.sourceforge.pseudoq.gui; |
22 | |
23 | import java.util.Hashtable; |
24 | import javax.swing.JComponent; |
25 | |
26 | /** |
27 | * Second page of the {@link NewPuzzleWizard}. This would be an inner class, |
28 | * except Netbeans' GUI form designer cannot handle that. |
29 | * @author <a href="http://sourceforge.net/users/stevensa">Andrew Stevens</a> |
30 | */ |
31 | public class NewPuzzleWizardStep2 extends org.pietschy.wizard.PanelWizardStep { |
32 | private NewPuzzleWizard.Model model; |
33 | |
34 | /** |
35 | * Creates new form NewPuzzleWizardStep1 |
36 | */ |
37 | public NewPuzzleWizardStep2() { |
38 | super("Generate or Design?", |
39 | "Select whether to generate a random puzzle or design one yourself"); |
40 | initComponents(); |
41 | } |
42 | |
43 | public void applyState() throws org.pietschy.wizard.InvalidStateException { |
44 | model.setGenerate(jRadioButton1.isSelected()); |
45 | model.setSymmetrical(jRadioButton3.isSelected()); |
46 | model.setDifficulty(jSlider1.getValue()); |
47 | super.applyState(); |
48 | } |
49 | |
50 | public void init(org.pietschy.wizard.WizardModel wizardModel) { |
51 | this.model = (NewPuzzleWizard.Model) wizardModel; |
52 | super.init(wizardModel); |
53 | } |
54 | |
55 | /** This method is called from within the constructor to |
56 | * initialize the form. |
57 | * WARNING: Do NOT modify this code. The content of this method is |
58 | * always regenerated by the Form Editor. |
59 | */ |
60 | // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents |
61 | private void initComponents() { |
62 | java.awt.GridBagConstraints gridBagConstraints; |
63 | |
64 | buttonGroup1 = new javax.swing.ButtonGroup(); |
65 | buttonGroup2 = new javax.swing.ButtonGroup(); |
66 | jLabel3 = new javax.swing.JLabel(); |
67 | jLabel4 = new javax.swing.JLabel(); |
68 | jLabel5 = new javax.swing.JLabel(); |
69 | jLabel6 = new javax.swing.JLabel(); |
70 | jLabel1 = new javax.swing.JLabel(); |
71 | jPanel1 = new javax.swing.JPanel(); |
72 | jRadioButton1 = new javax.swing.JRadioButton(); |
73 | jPanel2 = new javax.swing.JPanel(); |
74 | jLabel7 = new javax.swing.JLabel(); |
75 | jRadioButton3 = new javax.swing.JRadioButton(); |
76 | jRadioButton4 = new javax.swing.JRadioButton(); |
77 | jLabel2 = new javax.swing.JLabel(); |
78 | jSlider1 = new javax.swing.JSlider(); |
79 | jRadioButton2 = new javax.swing.JRadioButton(); |
80 | |
81 | jLabel3.setText("Easy"); |
82 | jLabel4.setText("Medium"); |
83 | jLabel5.setText("Hard"); |
84 | jLabel6.setText("Fiendish"); |
85 | |
86 | setLayout(new java.awt.BorderLayout()); |
87 | |
88 | setBorder(new javax.swing.border.EmptyBorder(new java.awt.Insets(5, 5, 5, 5))); |
89 | setComplete(true); |
90 | jLabel1.setText("Creation method:"); |
91 | add(jLabel1, java.awt.BorderLayout.NORTH); |
92 | |
93 | jPanel1.setLayout(new java.awt.BorderLayout()); |
94 | |
95 | buttonGroup1.add(jRadioButton1); |
96 | jRadioButton1.setMnemonic('g'); |
97 | jRadioButton1.setSelected(true); |
98 | jRadioButton1.setText("Generate automatically"); |
99 | jRadioButton1.addActionListener(new java.awt.event.ActionListener() { |
100 | public void actionPerformed(java.awt.event.ActionEvent evt) { |
101 | jRadioButton1ActionPerformed(evt); |
102 | } |
103 | }); |
104 | |
105 | jPanel1.add(jRadioButton1, java.awt.BorderLayout.NORTH); |
106 | |
107 | jPanel2.setLayout(new java.awt.GridBagLayout()); |
108 | |
109 | jPanel2.setBorder(new javax.swing.border.EtchedBorder()); |
110 | jLabel7.setText("Placement pattern:"); |
111 | jPanel2.add(jLabel7, new java.awt.GridBagConstraints()); |
112 | |
113 | buttonGroup2.add(jRadioButton3); |
114 | jRadioButton3.setSelected(true); |
115 | jRadioButton3.setText("Symmetrical"); |
116 | jPanel2.add(jRadioButton3, new java.awt.GridBagConstraints()); |
117 | |
118 | buttonGroup2.add(jRadioButton4); |
119 | jRadioButton4.setText("Random"); |
120 | jPanel2.add(jRadioButton4, new java.awt.GridBagConstraints()); |
121 | |
122 | jLabel2.setText("Difficulty:"); |
123 | gridBagConstraints = new java.awt.GridBagConstraints(); |
124 | gridBagConstraints.gridx = 0; |
125 | gridBagConstraints.gridy = 1; |
126 | gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
127 | jPanel2.add(jLabel2, gridBagConstraints); |
128 | |
129 | jSlider1.setMajorTickSpacing(2); |
130 | jSlider1.setMaximum(7); |
131 | jSlider1.setMinimum(1); |
132 | jSlider1.setMinorTickSpacing(1); |
133 | jSlider1.setPaintLabels(true); |
134 | jSlider1.setPaintTicks(true); |
135 | jSlider1.setSnapToTicks(true); |
136 | jSlider1.setValue(3); |
137 | Hashtable<Integer, JComponent> dictionary = new Hashtable<Integer, JComponent>(); |
138 | dictionary.put(Integer.valueOf(1), jLabel3); |
139 | dictionary.put(Integer.valueOf(3), jLabel4); |
140 | dictionary.put(Integer.valueOf(5), jLabel5); |
141 | dictionary.put(Integer.valueOf(7), jLabel6); |
142 | jSlider1.setLabelTable(dictionary); |
143 | |
144 | gridBagConstraints = new java.awt.GridBagConstraints(); |
145 | gridBagConstraints.gridx = 1; |
146 | gridBagConstraints.gridy = 1; |
147 | gridBagConstraints.gridwidth = 2; |
148 | jPanel2.add(jSlider1, gridBagConstraints); |
149 | |
150 | jPanel1.add(jPanel2, java.awt.BorderLayout.CENTER); |
151 | |
152 | add(jPanel1, java.awt.BorderLayout.CENTER); |
153 | |
154 | buttonGroup1.add(jRadioButton2); |
155 | jRadioButton2.setMnemonic('d'); |
156 | jRadioButton2.setText("Design manually"); |
157 | jRadioButton2.addActionListener(new java.awt.event.ActionListener() { |
158 | public void actionPerformed(java.awt.event.ActionEvent evt) { |
159 | jRadioButton2ActionPerformed(evt); |
160 | } |
161 | }); |
162 | |
163 | add(jRadioButton2, java.awt.BorderLayout.SOUTH); |
164 | |
165 | } |
166 | // </editor-fold>//GEN-END:initComponents |
167 | |
168 | private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton1ActionPerformed |
169 | jRadioButton3.setEnabled(true); |
170 | jRadioButton4.setEnabled(true); |
171 | jSlider1.setEnabled(true); |
172 | }//GEN-LAST:event_jRadioButton1ActionPerformed |
173 | |
174 | private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton2ActionPerformed |
175 | jRadioButton3.setEnabled(false); |
176 | jRadioButton4.setEnabled(false); |
177 | jSlider1.setEnabled(false); |
178 | }//GEN-LAST:event_jRadioButton2ActionPerformed |
179 | |
180 | // Variables declaration - do not modify//GEN-BEGIN:variables |
181 | private javax.swing.ButtonGroup buttonGroup1; |
182 | private javax.swing.ButtonGroup buttonGroup2; |
183 | private javax.swing.JLabel jLabel1; |
184 | private javax.swing.JLabel jLabel2; |
185 | private javax.swing.JLabel jLabel3; |
186 | private javax.swing.JLabel jLabel4; |
187 | private javax.swing.JLabel jLabel5; |
188 | private javax.swing.JLabel jLabel6; |
189 | private javax.swing.JLabel jLabel7; |
190 | private javax.swing.JPanel jPanel1; |
191 | private javax.swing.JPanel jPanel2; |
192 | private javax.swing.JRadioButton jRadioButton1; |
193 | private javax.swing.JRadioButton jRadioButton2; |
194 | private javax.swing.JRadioButton jRadioButton3; |
195 | private javax.swing.JRadioButton jRadioButton4; |
196 | private javax.swing.JSlider jSlider1; |
197 | // End of variables declaration//GEN-END:variables |
198 | |
199 | } |