Added Game of Life demo to application launcher.
[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 java.awt.event.ActionEvent;
15 import java.io.IOException;
16
17 class MenuPanel extends JPanel {
18     private static final long serialVersionUID = 2012721856427052560L;
19
20     public MenuPanel() {
21
22         final GroupLayout groupLayout = new GroupLayout(this);
23         GroupLayout.SequentialGroup sequentialGroup = groupLayout.createSequentialGroup();
24         sequentialGroup.addComponent(new JLabel("Choose an example to launch:"));
25         sequentialGroup.addComponent(new JButton(new ShowOctree()));
26         sequentialGroup.addComponent(new JButton(new ShowMathGraphs()));
27         sequentialGroup.addComponent(new JButton(new ShowPointcloud()));
28         sequentialGroup.addComponent(new JButton(new ShowRain()));
29         sequentialGroup.addComponent(new JButton(new ShowSinusMap()));
30         sequentialGroup.addComponent(new JButton(new ShowTextEditors()));
31         sequentialGroup.addComponent(new JButton(new ShowGameOfLife()));
32     }
33
34     private class ShowTextEditors extends AbstractAction {
35         public ShowTextEditors() {
36             putValue(NAME, "Text editors");
37         }
38
39         @Override
40         public void actionPerformed(final ActionEvent e) {
41             TextEditorDemo.main(null);
42         }
43     }
44
45     private class ShowSinusMap extends AbstractAction {
46         public ShowSinusMap() {
47             putValue(NAME, "Wireframe sphere and ploygon landscape");
48         }
49
50         @Override
51         public void actionPerformed(final ActionEvent e) {
52             SphereDemo.main(null);
53         }
54     }
55
56     private class ShowRain extends AbstractAction {
57         public ShowRain() {
58             putValue(NAME, "Raining numbers");
59         }
60
61         @Override
62         public void actionPerformed(final ActionEvent e) {
63             try {
64                 RainingNumbersDemo.main(null);
65             } catch (final IOException e1) {
66                 e1.printStackTrace();
67             }
68         }
69     }
70
71     private class ShowPointcloud extends AbstractAction {
72         public ShowPointcloud() {
73             putValue(NAME, "Pointcloud galaxy");
74         }
75
76         @Override
77         public void actionPerformed(final ActionEvent e) {
78             PointCloudDemo.main(null);
79         }
80     }
81
82     private class ShowMathGraphs extends AbstractAction {
83         public ShowMathGraphs() {
84             putValue(NAME, "Mathematical graphs");
85         }
86
87         @Override
88         public void actionPerformed(final ActionEvent e) {
89             try {
90                 GraphDemo.main(null);
91             } catch (final IOException e1) {
92                 e1.printStackTrace();
93             }
94         }
95     }
96
97     private class ShowOctree extends AbstractAction {
98         public ShowOctree() {
99             putValue(NAME, "Volumetric Octree");
100         }
101
102         @Override
103         public void actionPerformed(final ActionEvent e) {
104             try {
105                 OctreeDemo.main(null);
106             } catch (final IOException e1) {
107                 e1.printStackTrace();
108             }
109         }
110     }
111
112     private class ShowGameOfLife extends AbstractAction {
113         public ShowGameOfLife() {
114             putValue(NAME, "Game of Life");
115         }
116
117         @Override
118         public void actionPerformed(final ActionEvent e) {
119             eu.svjatoslav.sixth.e3d.examples.life.Main.main(null);
120         }
121     }
122
123 }