X-Git-Url: http://www2.svjatoslav.eu/gitweb/?p=sixth-3d-demos.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fsixth%2Fe3d%2Fexamples%2Flauncher%2FMenuPanel.java;h=0a6079823cd778a85954260371fea74a4638ed1e;hp=e77b53fb19e26c38493de2b8c202bb3a62910f1e;hb=fd099c489d7f4df2624c07d1d3ba24f658b147a7;hpb=ee85b7fbac8b2f5e329b7fa590a0dcf7691a1084 diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/launcher/MenuPanel.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/launcher/MenuPanel.java index e77b53f..0a60798 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/launcher/MenuPanel.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/launcher/MenuPanel.java @@ -1,151 +1,35 @@ /* - * Sixth 3D engine demos. Copyright ©2012-2016, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * Sixth 3D engine demos. Author: Svjatoslav Agejenko. + * This project is released under Creative Commons Zero (CC0) license. * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 3 of the GNU Lesser General Public License - * or later as published by the Free Software Foundation. - */ +*/ package eu.svjatoslav.sixth.e3d.examples.launcher; import eu.svjatoslav.sixth.e3d.examples.*; import javax.swing.*; -import javax.swing.GroupLayout.Alignment; -import javax.swing.LayoutStyle.ComponentPlacement; import java.awt.event.ActionEvent; -import java.io.IOException; class MenuPanel extends JPanel { private static final long serialVersionUID = 2012721856427052560L; - public MenuPanel() { - - final JLabel lblNewLabel = new JLabel("Choose an example to launch."); - - final JButton btnNewButton = new JButton("Demo 1"); - btnNewButton.addActionListener(e -> { - }); - Action action = new SwingAction(); - btnNewButton.setAction(action); - - final JButton btnNewButton_1 = new JButton("Demo 2"); - Action action_1 = new SwingAction_1(); - btnNewButton_1.setAction(action_1); - - final JButton button = new JButton("New button"); - Action action_2 = new SwingAction_2(); - button.setAction(action_2); - - final JButton btnNewButton_2 = new JButton("New button"); - Action action_3 = new SwingAction_3(); - btnNewButton_2.setAction(action_3); - - final JButton btnNewButton_3 = new JButton("New button"); - Action action_4 = new SwingAction_4(); - btnNewButton_3.setAction(action_4); - - final JButton btnNewButton_4 = new JButton("New button"); - Action action_5 = new SwingAction_5(); - btnNewButton_4.setAction(action_5); + MenuPanel() { final GroupLayout groupLayout = new GroupLayout(this); - groupLayout - .setHorizontalGroup(groupLayout - .createParallelGroup(Alignment.LEADING) - .addGroup( - groupLayout - .createSequentialGroup() - .addContainerGap() - .addGroup( - groupLayout - .createParallelGroup( - Alignment.LEADING) - .addGroup( - Alignment.TRAILING, - groupLayout - .createSequentialGroup() - .addComponent( - lblNewLabel, - GroupLayout.PREFERRED_SIZE, - 426, - GroupLayout.PREFERRED_SIZE) - .addContainerGap( - GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE)) - .addGroup( - Alignment.TRAILING, - groupLayout - .createSequentialGroup() - .addGroup( - groupLayout - .createParallelGroup( - Alignment.TRAILING) - .addComponent( - btnNewButton_4, - Alignment.LEADING, - GroupLayout.DEFAULT_SIZE, - 331, - Short.MAX_VALUE) - .addComponent( - btnNewButton_3, - Alignment.LEADING, - GroupLayout.DEFAULT_SIZE, - 331, - Short.MAX_VALUE) - .addComponent( - btnNewButton_2, - Alignment.LEADING, - GroupLayout.DEFAULT_SIZE, - 331, - Short.MAX_VALUE) - .addComponent( - button, - Alignment.LEADING, - GroupLayout.DEFAULT_SIZE, - 331, - Short.MAX_VALUE) - .addComponent( - btnNewButton_1, - Alignment.LEADING, - GroupLayout.DEFAULT_SIZE, - GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent( - btnNewButton, - GroupLayout.DEFAULT_SIZE, - 331, - Short.MAX_VALUE)) - .addGap(107))))); - groupLayout.setVerticalGroup(groupLayout.createParallelGroup( - Alignment.LEADING).addGroup( - groupLayout - .createSequentialGroup() - .addGap(7) - .addComponent(lblNewLabel, GroupLayout.PREFERRED_SIZE, - 58, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(btnNewButton) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(btnNewButton_1) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(button) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(btnNewButton_2) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(btnNewButton_3) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(btnNewButton_4) - .addContainerGap(137, Short.MAX_VALUE))); - setLayout(groupLayout); - + GroupLayout.SequentialGroup sequentialGroup = groupLayout.createSequentialGroup(); + sequentialGroup.addComponent(new JLabel("Choose an example to launch:")); + sequentialGroup.addComponent(new JButton(new ShowOctree())); + sequentialGroup.addComponent(new JButton(new ShowMathGraphs())); + sequentialGroup.addComponent(new JButton(new ShowPointCloud())); + sequentialGroup.addComponent(new JButton(new ShowRain())); + sequentialGroup.addComponent(new JButton(new ShowTextEditors())); + sequentialGroup.addComponent(new JButton(new ShowGameOfLife())); + sequentialGroup.addComponent(new JButton(new ShowRandomPolygons())); } - private class SwingAction extends AbstractAction { - private static final long serialVersionUID = 5197962166765841015L; - - public SwingAction() { + private static class ShowTextEditors extends AbstractAction { + ShowTextEditors() { putValue(NAME, "Text editors"); - putValue(SHORT_DESCRIPTION, "Some short description"); } @Override @@ -154,86 +38,71 @@ class MenuPanel extends JPanel { } } - private class SwingAction_1 extends AbstractAction { - private static final long serialVersionUID = -896479509963403828L; - public SwingAction_1() { - putValue(NAME, "Wireframe sphere and ploygon landscape"); - putValue(SHORT_DESCRIPTION, "Some short description"); + private static class ShowRain extends AbstractAction { + ShowRain() { + putValue(NAME, "Raining numbers"); } @Override public void actionPerformed(final ActionEvent e) { - SphereDemo.main(null); - + RainingNumbersDemo.main(null); } } - private class SwingAction_2 extends AbstractAction { - private static final long serialVersionUID = 8566009849873897321L; - - public SwingAction_2() { - putValue(NAME, "Raining numbers"); - putValue(SHORT_DESCRIPTION, "Some short description"); + private static class ShowPointCloud extends AbstractAction { + ShowPointCloud() { + putValue(NAME, "Pointcloud galaxy"); } @Override public void actionPerformed(final ActionEvent e) { - try { - RainingNumbersDemo.main(null); - } catch (final IOException e1) { - e1.printStackTrace(); - } + PointCloudDemo.main(null); } } - private class SwingAction_3 extends AbstractAction { - private static final long serialVersionUID = -5369105936409884389L; - - public SwingAction_3() { - putValue(NAME, "Pointcloud galaxy"); - putValue(SHORT_DESCRIPTION, "Some short description"); + private static class ShowMathGraphs extends AbstractAction { + ShowMathGraphs() { + putValue(NAME, "Mathematical graphs"); } @Override public void actionPerformed(final ActionEvent e) { - PointCloudDemo.main(null); + GraphDemo.main(null); } } - private class SwingAction_4 extends AbstractAction { - private static final long serialVersionUID = -8486796142555764460L; - - public SwingAction_4() { - putValue(NAME, "Mathematical graphs"); - putValue(SHORT_DESCRIPTION, "Some short description"); + private static class ShowRandomPolygons extends AbstractAction { + ShowRandomPolygons() { + putValue(NAME, "Random polygons"); } @Override public void actionPerformed(final ActionEvent e) { - try { - GraphDemo.main(null); - } catch (final IOException e1) { - e1.printStackTrace(); - } + RandomPolygonsDemo.main(null); } } - private class SwingAction_5 extends AbstractAction { - private static final long serialVersionUID = -6210703594848004946L; - - public SwingAction_5() { + private static class ShowOctree extends AbstractAction { + ShowOctree() { putValue(NAME, "Volumetric Octree"); - putValue(SHORT_DESCRIPTION, "Some short description"); } @Override public void actionPerformed(final ActionEvent e) { - try { - OctreeDemo.main(null); - } catch (final IOException e1) { - e1.printStackTrace(); - } + OctreeDemo.main(null); } } + + private static class ShowGameOfLife extends AbstractAction { + ShowGameOfLife() { + putValue(NAME, "Game of Life"); + } + + @Override + public void actionPerformed(final ActionEvent e) { + eu.svjatoslav.sixth.e3d.examples.life.Main.main(null); + } + } + }