e77b53fb19e26c38493de2b8c202bb3a62910f1e
[sixth-3d-demos.git] / src / main / java / eu / svjatoslav / sixth / e3d / examples / launcher / MenuPanel.java
1 /*
2  * Sixth 3D engine demos. Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of version 3 of the GNU Lesser General Public License
6  * or later as published by the Free Software Foundation.
7  */
8
9 package eu.svjatoslav.sixth.e3d.examples.launcher;
10
11 import eu.svjatoslav.sixth.e3d.examples.*;
12
13 import javax.swing.*;
14 import javax.swing.GroupLayout.Alignment;
15 import javax.swing.LayoutStyle.ComponentPlacement;
16 import java.awt.event.ActionEvent;
17 import java.io.IOException;
18
19 class MenuPanel extends JPanel {
20     private static final long serialVersionUID = 2012721856427052560L;
21
22     public MenuPanel() {
23
24         final JLabel lblNewLabel = new JLabel("Choose an example to launch.");
25
26         final JButton btnNewButton = new JButton("Demo 1");
27         btnNewButton.addActionListener(e -> {
28         });
29         Action action = new SwingAction();
30         btnNewButton.setAction(action);
31
32         final JButton btnNewButton_1 = new JButton("Demo 2");
33         Action action_1 = new SwingAction_1();
34         btnNewButton_1.setAction(action_1);
35
36         final JButton button = new JButton("New button");
37         Action action_2 = new SwingAction_2();
38         button.setAction(action_2);
39
40         final JButton btnNewButton_2 = new JButton("New button");
41         Action action_3 = new SwingAction_3();
42         btnNewButton_2.setAction(action_3);
43
44         final JButton btnNewButton_3 = new JButton("New button");
45         Action action_4 = new SwingAction_4();
46         btnNewButton_3.setAction(action_4);
47
48         final JButton btnNewButton_4 = new JButton("New button");
49         Action action_5 = new SwingAction_5();
50         btnNewButton_4.setAction(action_5);
51         final GroupLayout groupLayout = new GroupLayout(this);
52         groupLayout
53                 .setHorizontalGroup(groupLayout
54                         .createParallelGroup(Alignment.LEADING)
55                         .addGroup(
56                                 groupLayout
57                                         .createSequentialGroup()
58                                         .addContainerGap()
59                                         .addGroup(
60                                                 groupLayout
61                                                         .createParallelGroup(
62                                                                 Alignment.LEADING)
63                                                         .addGroup(
64                                                                 Alignment.TRAILING,
65                                                                 groupLayout
66                                                                         .createSequentialGroup()
67                                                                         .addComponent(
68                                                                                 lblNewLabel,
69                                                                                 GroupLayout.PREFERRED_SIZE,
70                                                                                 426,
71                                                                                 GroupLayout.PREFERRED_SIZE)
72                                                                         .addContainerGap(
73                                                                                 GroupLayout.DEFAULT_SIZE,
74                                                                                 Short.MAX_VALUE))
75                                                         .addGroup(
76                                                                 Alignment.TRAILING,
77                                                                 groupLayout
78                                                                         .createSequentialGroup()
79                                                                         .addGroup(
80                                                                                 groupLayout
81                                                                                         .createParallelGroup(
82                                                                                                 Alignment.TRAILING)
83                                                                                         .addComponent(
84                                                                                                 btnNewButton_4,
85                                                                                                 Alignment.LEADING,
86                                                                                                 GroupLayout.DEFAULT_SIZE,
87                                                                                                 331,
88                                                                                                 Short.MAX_VALUE)
89                                                                                         .addComponent(
90                                                                                                 btnNewButton_3,
91                                                                                                 Alignment.LEADING,
92                                                                                                 GroupLayout.DEFAULT_SIZE,
93                                                                                                 331,
94                                                                                                 Short.MAX_VALUE)
95                                                                                         .addComponent(
96                                                                                                 btnNewButton_2,
97                                                                                                 Alignment.LEADING,
98                                                                                                 GroupLayout.DEFAULT_SIZE,
99                                                                                                 331,
100                                                                                                 Short.MAX_VALUE)
101                                                                                         .addComponent(
102                                                                                                 button,
103                                                                                                 Alignment.LEADING,
104                                                                                                 GroupLayout.DEFAULT_SIZE,
105                                                                                                 331,
106                                                                                                 Short.MAX_VALUE)
107                                                                                         .addComponent(
108                                                                                                 btnNewButton_1,
109                                                                                                 Alignment.LEADING,
110                                                                                                 GroupLayout.DEFAULT_SIZE,
111                                                                                                 GroupLayout.DEFAULT_SIZE,
112                                                                                                 Short.MAX_VALUE)
113                                                                                         .addComponent(
114                                                                                                 btnNewButton,
115                                                                                                 GroupLayout.DEFAULT_SIZE,
116                                                                                                 331,
117                                                                                                 Short.MAX_VALUE))
118                                                                         .addGap(107)))));
119         groupLayout.setVerticalGroup(groupLayout.createParallelGroup(
120                 Alignment.LEADING).addGroup(
121                 groupLayout
122                         .createSequentialGroup()
123                         .addGap(7)
124                         .addComponent(lblNewLabel, GroupLayout.PREFERRED_SIZE,
125                                 58, GroupLayout.PREFERRED_SIZE)
126                         .addPreferredGap(ComponentPlacement.RELATED)
127                         .addComponent(btnNewButton)
128                         .addPreferredGap(ComponentPlacement.RELATED)
129                         .addComponent(btnNewButton_1)
130                         .addPreferredGap(ComponentPlacement.RELATED)
131                         .addComponent(button)
132                         .addPreferredGap(ComponentPlacement.RELATED)
133                         .addComponent(btnNewButton_2)
134                         .addPreferredGap(ComponentPlacement.RELATED)
135                         .addComponent(btnNewButton_3)
136                         .addPreferredGap(ComponentPlacement.RELATED)
137                         .addComponent(btnNewButton_4)
138                         .addContainerGap(137, Short.MAX_VALUE)));
139         setLayout(groupLayout);
140
141     }
142
143     private class SwingAction extends AbstractAction {
144         private static final long serialVersionUID = 5197962166765841015L;
145
146         public SwingAction() {
147             putValue(NAME, "Text editors");
148             putValue(SHORT_DESCRIPTION, "Some short description");
149         }
150
151         @Override
152         public void actionPerformed(final ActionEvent e) {
153             TextEditorDemo.main(null);
154         }
155     }
156
157     private class SwingAction_1 extends AbstractAction {
158         private static final long serialVersionUID = -896479509963403828L;
159
160         public SwingAction_1() {
161             putValue(NAME, "Wireframe sphere and ploygon landscape");
162             putValue(SHORT_DESCRIPTION, "Some short description");
163         }
164
165         @Override
166         public void actionPerformed(final ActionEvent e) {
167             SphereDemo.main(null);
168
169         }
170     }
171
172     private class SwingAction_2 extends AbstractAction {
173         private static final long serialVersionUID = 8566009849873897321L;
174
175         public SwingAction_2() {
176             putValue(NAME, "Raining numbers");
177             putValue(SHORT_DESCRIPTION, "Some short description");
178         }
179
180         @Override
181         public void actionPerformed(final ActionEvent e) {
182             try {
183                 RainingNumbersDemo.main(null);
184             } catch (final IOException e1) {
185                 e1.printStackTrace();
186             }
187         }
188     }
189
190     private class SwingAction_3 extends AbstractAction {
191         private static final long serialVersionUID = -5369105936409884389L;
192
193         public SwingAction_3() {
194             putValue(NAME, "Pointcloud galaxy");
195             putValue(SHORT_DESCRIPTION, "Some short description");
196         }
197
198         @Override
199         public void actionPerformed(final ActionEvent e) {
200             PointCloudDemo.main(null);
201         }
202     }
203
204     private class SwingAction_4 extends AbstractAction {
205         private static final long serialVersionUID = -8486796142555764460L;
206
207         public SwingAction_4() {
208             putValue(NAME, "Mathematical graphs");
209             putValue(SHORT_DESCRIPTION, "Some short description");
210         }
211
212         @Override
213         public void actionPerformed(final ActionEvent e) {
214             try {
215                 GraphDemo.main(null);
216             } catch (final IOException e1) {
217                 e1.printStackTrace();
218             }
219         }
220     }
221
222     private class SwingAction_5 extends AbstractAction {
223         private static final long serialVersionUID = -6210703594848004946L;
224
225         public SwingAction_5() {
226             putValue(NAME, "Volumetric Octree");
227             putValue(SHORT_DESCRIPTION, "Some short description");
228         }
229
230         @Override
231         public void actionPerformed(final ActionEvent e) {
232             try {
233                 OctreeDemo.main(null);
234             } catch (final IOException e1) {
235                 e1.printStackTrace();
236             }
237         }
238     }
239 }