summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2011-03-08 07:57:45 +0000
committerJesse Morgan <jesse@jesterpm.net>2011-03-08 07:57:45 +0000
commit83d6f2ea8aaf45203389320a8e7218c23545b818 (patch)
tree3a76b3835a39dec567c3aeaa2495fdad6caf5c4f /src
parentb7cc2e69aa6bf63c0e5c1b7ef1f574536b2de2d7 (diff)
Last Call!
Diffstat (limited to 'src')
-rw-r--r--src/common/Peer.java1
-rw-r--r--src/tesseract/TesseractUI.java6
-rw-r--r--src/tesseract/generators/GeneratorsMenu.java29
-rw-r--r--src/tesseract/generators/MenuItem.java38
-rw-r--r--src/tesseract/generators/ParticleField.java37
-rw-r--r--src/tesseract/generators/SphereField.java43
-rw-r--r--src/tesseract/menuitems/ChainLinkMenuItem.java90
-rw-r--r--src/tesseract/menuitems/DonutMenuItem.java136
-rw-r--r--src/tesseract/menuitems/EllipsoidMenuItem.java81
-rw-r--r--src/tesseract/menuitems/GravityMenuItem.java38
-rw-r--r--src/tesseract/menuitems/IcosahedronMenuItem.java79
-rw-r--r--src/tesseract/menuitems/ParticleEmitterMenuItem.java86
-rw-r--r--src/tesseract/menuitems/ParticleMenuItem.java50
-rw-r--r--src/tesseract/menuitems/PlanarPolygonMenuItem.java80
-rw-r--r--src/tesseract/menuitems/SurfBoardMenuItem.java89
-rw-r--r--src/tesseract/menuitems/TesseractMenuItem.java260
-rw-r--r--src/tesseract/objects/Sphere.java5
17 files changed, 159 insertions, 989 deletions
diff --git a/src/common/Peer.java b/src/common/Peer.java
index f202664..1b57379 100644
--- a/src/common/Peer.java
+++ b/src/common/Peer.java
@@ -283,6 +283,7 @@ public class Peer extends Observable {
try {
serverSocket.close();
} catch (IOException e) {
+ } catch (NullPointerException e) {
}
serverSocket = null;
System.out.println(myInfo + " disconnected");
diff --git a/src/tesseract/TesseractUI.java b/src/tesseract/TesseractUI.java
index 5f947d6..0378f64 100644
--- a/src/tesseract/TesseractUI.java
+++ b/src/tesseract/TesseractUI.java
@@ -38,6 +38,7 @@ import tesseract.forces.Force;
import tesseract.forces.Gravity;
import tesseract.forces.LinearOrigin;
import tesseract.forces.QuadradicOrigin;
+import tesseract.generators.GeneratorsMenu;
import tesseract.newmenu.MenuItem;
import tesseract.newmenu.NewChainLinkMenuItem;
import tesseract.newmenu.NewEllipsoidMenuItem;
@@ -140,6 +141,8 @@ public class TesseractUI extends JFrame {
myChatbox = new Chatbox(myPeer);
myChatbox.setLocationRelativeTo(this);
+ myChatbox.setMyName();
+
myWorld = new World(
new BoundingBox(new Point3d(-UNIT / 2, -UNIT / 2, -UNIT / 2),
new Point3d(UNIT / 2, UNIT / 2, UNIT / 2)),
@@ -346,6 +349,9 @@ public class TesseractUI extends JFrame {
menuBar.add(forcesMenu);
+ // Generators
+ menuBar.add(new GeneratorsMenu(myWorld));
+
// Add reset Simulator menu item
JMenuItem resetSim = new JMenuItem("Reset Simulator");
resetSim.addActionListener(new ActionListener() {
diff --git a/src/tesseract/generators/GeneratorsMenu.java b/src/tesseract/generators/GeneratorsMenu.java
new file mode 100644
index 0000000..0256d8b
--- /dev/null
+++ b/src/tesseract/generators/GeneratorsMenu.java
@@ -0,0 +1,29 @@
+package tesseract.generators;
+
+import javax.swing.JMenu;
+
+import tesseract.World;
+
+/**
+ * A generator menu.
+ *
+ * @author jesse
+ */
+public class GeneratorsMenu extends JMenu {
+
+ /**
+ * Serial UID.
+ */
+ private static final long serialVersionUID = 8994598391451363374L;
+
+ /**
+ * Constructor.
+ */
+ public GeneratorsMenu(final World theWorld) {
+ super("Generators");
+
+ // Build the menu of generators.
+ //add(new SphereField(theWorld));
+ add(new ParticleField(theWorld));
+ }
+}
diff --git a/src/tesseract/generators/MenuItem.java b/src/tesseract/generators/MenuItem.java
new file mode 100644
index 0000000..2990cea
--- /dev/null
+++ b/src/tesseract/generators/MenuItem.java
@@ -0,0 +1,38 @@
+package tesseract.generators;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JMenuItem;
+
+import tesseract.World;
+
+/**
+ * Parent class for generator menus.
+ *
+ * @author jesse
+ */
+public abstract class MenuItem extends JMenuItem {
+
+ /**
+ * Serial UID.
+ */
+ private static final long serialVersionUID = 5591914377175098868L;
+
+ protected MenuItem(final String label, final World theWorld) {
+ super(label);
+
+ addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ generate(theWorld);
+ }
+ });
+ }
+
+ /**
+ * Generate.
+ *
+ * @param World the world to put it in.
+ */
+ public abstract void generate(final World theWorld);
+}
diff --git a/src/tesseract/generators/ParticleField.java b/src/tesseract/generators/ParticleField.java
new file mode 100644
index 0000000..80e5e1d
--- /dev/null
+++ b/src/tesseract/generators/ParticleField.java
@@ -0,0 +1,37 @@
+package tesseract.generators;
+
+import javax.vecmath.Vector3f;
+
+import tesseract.World;
+import tesseract.objects.Particle;
+import tesseract.objects.Sphere;
+
+/**
+ * Generate a field of random particles.
+ *
+ * @author jesse
+ */
+public class ParticleField extends MenuItem {
+
+ private static final int FIELD_SIZE = 100;
+
+ public ParticleField(World theWorld) {
+ super("Particle Field", theWorld);
+ }
+
+ /**
+ * Generate the field.
+ *
+ * @param theWorld Where to put them
+ */
+ public void generate(final World theWorld) {
+ for (int i = 0; i < FIELD_SIZE; i++) {
+ Vector3f position = new Vector3f((float) Math.random() - 0.5f,
+ (float) Math.random() - 0.5f, (float) Math.random() - 0.5f);
+
+ Particle p = new Particle(position, null);
+
+ theWorld.addObject(p);
+ }
+ }
+}
diff --git a/src/tesseract/generators/SphereField.java b/src/tesseract/generators/SphereField.java
new file mode 100644
index 0000000..1bc57ae
--- /dev/null
+++ b/src/tesseract/generators/SphereField.java
@@ -0,0 +1,43 @@
+package tesseract.generators;
+
+import javax.vecmath.Vector3f;
+
+import tesseract.World;
+import tesseract.objects.PhysicalObject;
+import tesseract.objects.Sphere;
+
+/**
+ * Generate a sphere field.
+ *
+ * @author jesse
+ */
+public class SphereField extends MenuItem {
+
+ private static final int FIELD_SIZE = 4;
+
+ private static final float SPHERE_SIZE = 0.15f;
+
+ public SphereField(World theWorld) {
+ super("Sphere Field", theWorld);
+ }
+
+ /**
+ * Generate the field.
+ *
+ * @param theWorld Where to put them
+ */
+ public void generate(final World theWorld) {
+ final float start = 1.1f * 0.5f * FIELD_SIZE * SPHERE_SIZE;
+
+ for (float x = -start; x <= +start; x += SPHERE_SIZE * 1.1f) {
+ for (float y = -start; y <= +start; y += SPHERE_SIZE * 1.1f) {
+ for (float z = -start; z <= +start; z += SPHERE_SIZE * 1.1f) {
+ PhysicalObject s = new Sphere(SPHERE_SIZE, new Vector3f(x, y, z));
+ theWorld.addObject(s);
+
+ }
+ }
+
+ }
+ }
+}
diff --git a/src/tesseract/menuitems/ChainLinkMenuItem.java b/src/tesseract/menuitems/ChainLinkMenuItem.java
deleted file mode 100644
index ca32af7..0000000
--- a/src/tesseract/menuitems/ChainLinkMenuItem.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package tesseract.menuitems;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JFrame;
-import javax.vecmath.Vector3f;
-
-import tesseract.World;
-import tesseract.objects.ChainLink2;
-
-/**
- * Icosahedron Menu Item.
- *
- * @author Steve Bradshaw
- * @deprecated By Phillip Cardon
- */
-public class ChainLinkMenuItem extends TesseractMenuItem {
-
- /**
- * Serial ID.
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * Constructor for the menu item.
- *
- * @param theWorld The world into which we add.
- */
- public ChainLinkMenuItem(final World theWorld) {
- super(theWorld, "ChainLink");
- }
-
- /**
- * Action handler.
- *
- * @param arg0 Unused event info.
- */
- public void actionPerformed(final ActionEvent arg0) {
- createParameterMenu();
-
- final float scale = 0.5f;
- //final float sliceRadius = .06f; //inside whole
- //final int sliceDivisions = 50;
- //final float arcRadius = .08f; //outside whole
- //final int arcDivisions = 30;
-
- //If the default button is checked, the frame will close.
- final JCheckBox defaultButton = getDefaultButton();
- final JFrame params = getParamFrame();
- final JButton enterButton = getEnterButton();
-
- defaultButton.addActionListener(new ActionListener() {
- public void actionPerformed(final ActionEvent e) {
- if (defaultButton.isSelected()) {
- myWorld.addObject(new ChainLink2(getDefaultPosition(), 1, getDefaultRadius()));
- params.dispose();
- /*myWorld.addObject(new ChainLink(getDefaultPosition(), 1, scale,
- sliceRadius, sliceDivisions, arcRadius, arcDivisions));
- params.dispose();*/
- }
- }
- });
-
- enterButton.addActionListener(new ActionListener() {
- public void actionPerformed(final ActionEvent event) {
- String string = getPositionField().getText();
- Vector3f pos = parseVector(string);
- setPosition(pos);
-
- String string2 = getRadiusField().getText();
- float radius = Float.parseFloat(string2);
- setRadius(radius);
-
- String string3 = getMassField().getText();
- float mass = Float.parseFloat(string3);
- setMass(mass);
-
- if (event.getSource() == enterButton) {
- myWorld.addObject(new ChainLink2(getPosition(), getMass(), getRadius()));
- params.dispose();
- }
- }
- });
- }
-}
-
-
diff --git a/src/tesseract/menuitems/DonutMenuItem.java b/src/tesseract/menuitems/DonutMenuItem.java
deleted file mode 100644
index 7fd4470..0000000
--- a/src/tesseract/menuitems/DonutMenuItem.java
+++ /dev/null
@@ -1,136 +0,0 @@
-package tesseract.menuitems;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JTextField;
-import javax.vecmath.Vector3f;
-
-import tesseract.World;
-import tesseract.objects.Toroid;
-
-/**
- * Icosahedron Menu Item.
- *
- * @author Steve Bradshaw
- * @deprecated By Phillip Cardon
- */
-public class DonutMenuItem extends TesseractMenuItem {
-
- /**
- * Serial ID.
- */
- private static final long serialVersionUID = 1L;
-
- private float scale = 1f;
- private float sliceRadius = .06f; //inside whole
- private int sliceDivisions = 25;
- private float arcRadius = .08f; //outside whole
- private int arcDivisions = 30;
-
- /**
- * Constructor for the menu item.
- *
- * @param theWorld The world into which we add.
- */
- public DonutMenuItem(final World theWorld) {
- super(theWorld, "Donut");
- }
-
- /**
- * Action handler.
- *
- * @param arg0 Unused event info.
- */
- public void actionPerformed(final ActionEvent arg0) {
-
- createParameterMenu();
-
- //If the default button is checked, the frame will close.
- final JCheckBox defaultButton = getDefaultButton();
- final JFrame params = getParamFrame();
- /* final JButton enterButton = getEnterButton();
-
- final JTextField scale_input = new JTextField(10);
- scale_input.setText("1");
- final JTextField sliceRadiusInput = new JTextField(10);
- sliceRadiusInput.setText(".06");
- final JTextField sliceDivisionsInput = new JTextField(10);
- sliceDivisionsInput.setText("50");
- final JTextField arcRadiusInput = new JTextField(10);
- arcRadiusInput.setText(".08");
- final JTextField arcDivisionsInput = new JTextField(10);
- arcDivisionsInput.setText("30");
-
- JLabel scale_label = new JLabel("scale: ");
- JLabel slice_radius_label = new JLabel("sliceRadius: ");
- JLabel slice_divs_label = new JLabel("sliceDivs: ");
- JLabel arc_radius_label = new JLabel("arcRadius: ");
- JLabel arc_divs_label = new JLabel("arcDivs: ");
-
- params.add(scale_label);
- params.add(scale_input);
- params.add(slice_radius_label);
- params.add(sliceRadiusInput);
- params.add(slice_divs_label);
- params.add(sliceDivisionsInput);
- params.add(arc_radius_label);
- params.add(arcRadiusInput);
- params.add(arc_divs_label);
- params.add(arcDivisionsInput);
-
-
- params.add(enterButton);*/
-
- defaultButton.addActionListener(new ActionListener() {
- public void actionPerformed(final ActionEvent e) {
- if (defaultButton.isSelected()) {
- myWorld.addObject(new Toroid(getDefaultPosition(), 1, scale,
- sliceRadius, sliceDivisions, arcRadius, arcDivisions));
- params.dispose();
- }
- }
- });
-
- /*enterButton.addActionListener(new ActionListener() {
- public void actionPerformed(final ActionEvent event) {
-
- String string = getPositionField().getText();
- Vector3f pos = parseVector(string);
- setPosition(pos);
-
- String string3 = getMassField().getText();
- float mass = Float.parseFloat(string3);
- setMass(mass);
-
- String string4 = getMassField().getText();
- scale = Float.parseFloat(string4);
-
- String string5 = getMassField().getText();
- sliceRadius = Float.parseFloat(string5);
-
- String string6 = getMassField().getText();
- sliceDivisions = Integer.parseInt(string6);
-
- String string7 = getMassField().getText();
- arcRadius = Float.parseFloat(string7);
-
- String string8 = getMassField().getText();
- arcDivisions = Integer.parseInt(string8);
-
- if (event.getSource() == enterButton) {
- myWorld.addObject(new Toroid(pos, 1, scale,
- sliceRadius, sliceDivisions, arcRadius, arcDivisions));
- params.dispose();
- }
- }
- });*/
- }
-}
-
-
-
diff --git a/src/tesseract/menuitems/EllipsoidMenuItem.java b/src/tesseract/menuitems/EllipsoidMenuItem.java
deleted file mode 100644
index 02d7eb2..0000000
--- a/src/tesseract/menuitems/EllipsoidMenuItem.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package tesseract.menuitems;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JFrame;
-import javax.vecmath.Vector3f;
-
-import tesseract.World;
-import tesseract.objects.Ellipsoid;
-
-/**
- * Ellipsoid Menu Item.
- *
- * @author Steve Bradshaw
- * @deprecated By Phillip Cardon
- */
-public class EllipsoidMenuItem extends TesseractMenuItem {
-
- /**
- * Serial ID.
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * Constructor for the menu item.
- *
- * @param theWorld The world into which we add.
- */
- public EllipsoidMenuItem(final World theWorld) {
- super(theWorld, "Ellipsoid");
- }
-
- /**
- * Action handler.
- *
- * @param arg0 Unused event info.
- */
- public void actionPerformed(final ActionEvent arg0) {
-
- createParameterMenu();
-
- //If the default button is checked, the frame will close.
- final JCheckBox defaultButton = getDefaultButton();
- final JFrame params = getParamFrame();
- final JButton enterButton = getEnterButton();
-
- defaultButton.addActionListener(new ActionListener() {
- public void actionPerformed(final ActionEvent ev) {
- if (defaultButton.isSelected()) {
- myWorld.addObject(new Ellipsoid(getDefaultPosition(), getDefaultRadius()));
- params.dispose();
- }
- }
- });
-
- enterButton.addActionListener(new ActionListener() {
- public void actionPerformed(final ActionEvent event) {
- String string = getPositionField().getText();
- Vector3f pos = parseVector(string);
- setPosition(pos);
-
- String string2 = getRadiusField().getText();
- float radius = Float.parseFloat(string2);
- setRadius(radius);
-
- String string3 = getMassField().getText();
- float mass = Float.parseFloat(string3);
- setMass(mass);
-
- if (event.getSource() == enterButton) {
- myWorld.addObject(new Ellipsoid(getPosition(), getRadius()));
- params.dispose();
- }
- }
- });
-
- }
-}
diff --git a/src/tesseract/menuitems/GravityMenuItem.java b/src/tesseract/menuitems/GravityMenuItem.java
deleted file mode 100644
index 4e11e71..0000000
--- a/src/tesseract/menuitems/GravityMenuItem.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package tesseract.menuitems;
-
-import java.awt.event.ActionEvent;
-
-import tesseract.World;
-import tesseract.forces.Gravity;
-
-/**
- * Gravity Menu Item.
- *
- * @author Steve Bradshaw
- * @deprecated by Phillip Cardon
- */
-public class GravityMenuItem extends TesseractMenuItem {
-
- /**
- * Serial ID.
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * Constructor for the menu item.
- *
- * @param theWorld The world into which we add.
- */
- public GravityMenuItem(final World theWorld) {
- super(theWorld, "Gravity");
- }
-
- /**
- * Action handler.
- *
- * @param arg0 Unused event info.
- */
- public void actionPerformed(final ActionEvent arg0) {
- myWorld.addForce(new Gravity());
- }
-}
diff --git a/src/tesseract/menuitems/IcosahedronMenuItem.java b/src/tesseract/menuitems/IcosahedronMenuItem.java
deleted file mode 100644
index 550f954..0000000
--- a/src/tesseract/menuitems/IcosahedronMenuItem.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package tesseract.menuitems;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JFrame;
-import javax.vecmath.Vector3f;
-
-import tesseract.World;
-import tesseract.objects.Icosahedron;
-
-/**
- * Icosahedron Menu Item.
- *
- * @author Steve Bradshaw
- * @deprecated By Phillip Cardon
- */
-public class IcosahedronMenuItem extends TesseractMenuItem {
-
- /**
- * Serial ID.
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * Constructor for the menu item.
- *
- * @param theWorld The world into which we add.
- */
- public IcosahedronMenuItem(final World theWorld) {
- super(theWorld, "Icosahedron");
- }
-
- /**
- * Action handler.
- *
- * @param arg0 Unused event info.
- */
- public void actionPerformed(final ActionEvent arg0) {
- createParameterMenu();
-
- //If the default button is checked, the frame will close.
- final JCheckBox defaultButton = getDefaultButton();
- final JFrame params = getParamFrame();
- final JButton enterButton = getEnterButton();
-
- defaultButton.addActionListener(new ActionListener() {
- public void actionPerformed(final ActionEvent e) {
- if (defaultButton.isSelected()) {
- myWorld.addObject(new Icosahedron(getDefaultPosition(), 1, getDefaultRadius()));
- params.dispose();
- }
- }
- });
- enterButton.addActionListener(new ActionListener() {
- public void actionPerformed(final ActionEvent event) {
- String string = getPositionField().getText();
- Vector3f pos = parseVector(string);
- setPosition(pos);
-
- String string2 = getRadiusField().getText();
- float radius = Float.parseFloat(string2);
- setRadius(radius);
-
- String string3 = getMassField().getText();
- float mass = Float.parseFloat(string3);
- setMass(mass);
-
- if (event.getSource() == enterButton) {
- myWorld.addObject(new Icosahedron(getPosition(), getMass(), getRadius()));
- params.dispose();
- }
- }
- });
- }
-}
-
diff --git a/src/tesseract/menuitems/ParticleEmitterMenuItem.java b/src/tesseract/menuitems/ParticleEmitterMenuItem.java
deleted file mode 100644
index f8456d2..0000000
--- a/src/tesseract/menuitems/ParticleEmitterMenuItem.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package tesseract.menuitems;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JFrame;
-import javax.vecmath.Color3f;
-import javax.vecmath.Vector3f;
-
-import tesseract.World;
-import tesseract.objects.emitters.ParticleEmitter;
-
-/**
- * Particle Emitter Menu Item.
- *
- * @author Jesse Morgan
- * @deprecated By Phillip Cardon
- */
-public class ParticleEmitterMenuItem extends TesseractMenuItem {
-
- /**
- * Serial ID.
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * Constructor for the menu item.
- *
- * @param theWorld The world into which we add.
- */
- public ParticleEmitterMenuItem(final World theWorld) {
- super(theWorld, "Particle Emitter");
- }
-
- /**
- * Action handler.
- *
- * @param arg0 Unused event info.
- */
- public void actionPerformed(final ActionEvent arg0) {
- createParameterMenu();
-
-
-
- //If the default button is checked, the frame will close.
- final JCheckBox defaultButton = getDefaultButton();
- final JFrame params = getParamFrame();
- final JButton enterButton = getEnterButton();
-
- defaultButton.addActionListener(new ActionListener() {
- public void actionPerformed(final ActionEvent e) {
- if (defaultButton.isSelected()) {
- myWorld.addObject(new ParticleEmitter(
- new Vector3f(0f,.49f, 0f),
- .5f, new Color3f(1f,0f,0f)));
- params.dispose();
- }
- }
- });
-
- enterButton.addActionListener(new ActionListener() {
- public void actionPerformed(final ActionEvent event) {
- String string = getPositionField().getText();
- Vector3f pos = parseVector(string);
- setPosition(pos);
-
- String string2 = getRadiusField().getText();
- float radius = Float.parseFloat(string2);
- setRadius(radius);
-
- String string3 = getMassField().getText();
- float mass = Float.parseFloat(string3);
- setMass(mass);
-
- if (event.getSource() == enterButton) {
- myWorld.addObject(new ParticleEmitter(getPosition(),
- .5f, new Color3f(1f,0f,0f)));
- params.dispose();
- }
- }
- });
- }
-
-}
diff --git a/src/tesseract/menuitems/ParticleMenuItem.java b/src/tesseract/menuitems/ParticleMenuItem.java
deleted file mode 100644
index 822266c..0000000
--- a/src/tesseract/menuitems/ParticleMenuItem.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package tesseract.menuitems;
-
-import java.awt.Color;
-import java.awt.event.ActionEvent;
-
-import javax.swing.JColorChooser;
-import javax.swing.JOptionPane;
-import javax.vecmath.Color3f;
-import javax.vecmath.Vector3f;
-
-import tesseract.World;
-import tesseract.objects.Particle;
-
-/**
- * Particle Menu Item.
- *
- * @author Jesse Morgan
- * @deprecated By Phillip Cardon
- */
-public class ParticleMenuItem extends TesseractMenuItem {
-
- /**
- * Serial ID.
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * Constructor for the menu item.
- *
- * @param theWorld The world into which we add.
- */
- public ParticleMenuItem(final World theWorld) {
- super(theWorld, "Particle");
- }
-
- /**
- * Action handler.
- *
- * @param arg0 Unused event info.
- */
- public void actionPerformed(final ActionEvent arg0) {
- Color c = JColorChooser.showDialog(null, "Particle Color", Color.RED);
-
- Vector3f pos =
- parseVector(JOptionPane.showInputDialog("Enter the position"));
-
- myWorld.addObject(new Particle(pos, new Color3f(c)));
- }
-
-}
diff --git a/src/tesseract/menuitems/PlanarPolygonMenuItem.java b/src/tesseract/menuitems/PlanarPolygonMenuItem.java
deleted file mode 100644
index 5c1f583..0000000
--- a/src/tesseract/menuitems/PlanarPolygonMenuItem.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package tesseract.menuitems;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JFrame;
-import javax.vecmath.Vector3f;
-
-import tesseract.World;
-import tesseract.objects.PlanarPolygon;
-
-/**
- * Planar Polygon Menu Item.
- *
- * @author Steve Bradshaw
- * @deprecated By Phillip Cardon
- */
-public class PlanarPolygonMenuItem extends TesseractMenuItem {
-
- /**
- * Serial ID.
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * Constructor for the menu item.
- *
- * @param theWorld The world into which we add.
- */
- public PlanarPolygonMenuItem(final World theWorld) {
- super(theWorld, "Planar Polygon");
- }
-
- /**
- * Action handler.
- *
- * @param arg0 Unused event info.
- */
- public void actionPerformed(final ActionEvent arg0) {
- createParameterMenu();
-
- //If the default button is checked, the frame will close.
- final JCheckBox defaultButton = getDefaultButton();
- final JFrame params = getParamFrame();
- final JButton enterButton = getEnterButton();
-
- defaultButton.addActionListener(new ActionListener() {
- public void actionPerformed(final ActionEvent ev) {
- if (defaultButton.isSelected()) {
- myWorld.addObject(new PlanarPolygon(getDefaultPosition(), getDefaultRadius()));
- params.dispose();
- }
- }
- });
-
- enterButton.addActionListener(new ActionListener() {
- final int divs = 5;
- public void actionPerformed(final ActionEvent event) {
- String string = getPositionField().getText();
- Vector3f pos = parseVector(string);
- setPosition(pos);
-
- String string2 = getRadiusField().getText();
- float radius = Float.parseFloat(string2);
- setRadius(radius);
-
- String string3 = getMassField().getText();
- float mass = Float.parseFloat(string3);
- setMass(mass);
-
- if (event.getSource() == enterButton) {
- myWorld.addObject(new PlanarPolygon(getPosition(), getMass(), getRadius(), divs));
- params.dispose();
- }
- }
- });
- }
-}
diff --git a/src/tesseract/menuitems/SurfBoardMenuItem.java b/src/tesseract/menuitems/SurfBoardMenuItem.java
deleted file mode 100644
index c96fb3e..0000000
--- a/src/tesseract/menuitems/SurfBoardMenuItem.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package tesseract.menuitems;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.media.j3d.Appearance;
-import javax.media.j3d.ColoringAttributes;
-import javax.media.j3d.Material;
-import javax.swing.JCheckBox;
-import javax.swing.JFrame;
-
-import tesseract.World;
-import tesseract.objects.Ellipsoid;
-
-import com.sun.j3d.utils.geometry.Sphere;
-
-/**
- * Ellipsoid Menu Item.
- *
- * @author Steve Bradshaw
- * @deprecated by Phillip Cardon
- */
-public class SurfBoardMenuItem extends TesseractMenuItem {
-
- /**
- * Serial ID.
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * Constructor for the menu item.
- *
- * @param theWorld The world into which we add.
- */
- public SurfBoardMenuItem(final World theWorld) {
- super(theWorld, "SurfBoard");
- }
-
- /**
- * Action handler.
- *
- * @param arg0 Unused event info.
- */
- public void actionPerformed(final ActionEvent arg0) {
-
- createParameterMenu();
-
- //If the default button is checked, the frame will close.
- final JCheckBox defaultButton = getDefaultButton();
- final JFrame params = getParamFrame();
- //final JButton enterButton = getEnterButton();
-
- defaultButton.addActionListener(new ActionListener() {
- public void actionPerformed(final ActionEvent ev) {
- if (defaultButton.isSelected()) {
- Appearance eApp = new Appearance();
- Material eggMat = new Material();
- eggMat.setDiffuseColor(0f, .5f, 1f);
- eApp.setMaterial(eggMat);
- eApp.setColoringAttributes(new ColoringAttributes(0f, 1f, 1f, ColoringAttributes.ALLOW_COLOR_WRITE));
- myWorld.addObject(new Ellipsoid(getPosition(), 1, 0.05f, new Sphere().getPrimitiveFlags(), 40, eApp, 0.2f, 4.0f));
- params.dispose();
- }
- }
- });
-
- /*enterButton.addActionListener(new ActionListener() {
- public void actionPerformed(final ActionEvent event) {
- String string = getPositionField().getText();
- Vector3f pos = parseVector(string);
- setPosition(pos);
-
- String string2 = getRadiusField().getText();
- float radius = Float.parseFloat(string2);
- setRadius(radius);
-
- String string3 = getMassField().getText();
- float mass = Float.parseFloat(string3);
- setMass(mass);
-
- if (event.getSource() == enterButton) {
- myWorld.addObject(new Ellipsoid(getPosition(), getRadius()));
- params.dispose();
- }
- }
- });*/
-
- }
-}
diff --git a/src/tesseract/menuitems/TesseractMenuItem.java b/src/tesseract/menuitems/TesseractMenuItem.java
deleted file mode 100644
index 97daa0c..0000000
--- a/src/tesseract/menuitems/TesseractMenuItem.java
+++ /dev/null
@@ -1,260 +0,0 @@
-package tesseract.menuitems;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.GridLayout;
-import java.awt.Toolkit;
-import java.awt.event.ActionListener;
-
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JMenuItem;
-import javax.swing.JTextField;
-import javax.vecmath.Vector3f;
-
-import tesseract.World;
-
-/**
- * Abstract class for menu items.
- * USE MENU ITEM IN tesseract.newmenu CLASS.
- * @author Jesse Morgan, Steve Bradshaw
- * @deprecated by Phillip Cardon
- */
-public abstract class TesseractMenuItem
- extends JMenuItem implements ActionListener {
-
- /**
- * Serial ID.
- */
- private static final long serialVersionUID = 1839955501629795920L;
-
- /**
- * A Default radius.
- */
- private static final float DEFAULT_RADIUS = 0.1f;
-
- /**
- * A Default position.
- */
- private static final Vector3f DEFAULT_POSITION = new Vector3f(0, 0, 0);
-
- /**
- * The reference to the world.
- */
- protected World myWorld;
-
- /**
- * The default button
- */
- private JCheckBox my_default_button;
-
- /**
- * A Parameter setting JFrame
- */
- private JFrame my_param_frame;
-
- /**
- * A position.
- */
- private Vector3f my_position;
-
- /**
- * A radius field.
- */
- private float my_radius;
-
- /**
- * A mass field.
- */
- private float my_mass;
-
- /**
- * A position input.
- */
- private JTextField my_position_input;
-
- /**
- * A radius input.
- */
- private JTextField my_radius_input;
-
- /**
- * A mass input.
- */
- private JTextField my_mass_input;
-
- /**
- * The button that get all inputs for shape
- */
- private JButton my_enter_button;
-
- /**
- * Constructor.
- *
- * @param theWorld The world in which to add.
- * @param theLabel The label for the menu item.
- */
- public TesseractMenuItem(final World theWorld, final String theLabel) {
- super(theLabel);
-
- myWorld = theWorld;
-
- my_position = new Vector3f(0,0,0);
- my_radius = 0f;
- my_mass = 1;
-
- addActionListener(this);
- }
-
- /**
- * Utility method to parse a string formatted as x,y,z into a vector3f.
- *
- * @param input A string to parse.
- * @return A vector3f.
- */
- protected Vector3f parseVector(final String input) {
- String[] split = input.split(",");
-
- float x = Float.parseFloat(split[0]);
- float y = Float.parseFloat(split[1]);
- float z = Float.parseFloat(split[2]);
-
- return new Vector3f(x, y, z);
- }
-
- protected void createParameterMenu() {
-
- my_param_frame = new JFrame("Parameters");
- my_param_frame.setBackground(Color.GRAY);
- my_param_frame.setLayout(new GridLayout(5,2));
-
- Toolkit tk = Toolkit.getDefaultToolkit();
- Dimension screenSize = tk.getScreenSize();
- int screenHeight = screenSize.height;
- int screenWidth = screenSize.width;
- my_param_frame.setSize(screenWidth / 4, screenHeight / 4);
- my_param_frame.setLocation(screenWidth / 4, screenHeight / 4);
-
- my_position_input = new JTextField(10);
- my_position_input.setText("0,0,0");
- my_radius_input = new JTextField(10);
- my_radius_input.setText(".1");
- my_mass_input = new JTextField(10);
- my_mass_input.setText("1");
-
- JLabel blank = new JLabel("");
- JLabel position_label = new JLabel("Enter Position: ");
- JLabel radius_label = new JLabel("Enter Radius: ");
- JLabel mass_label = new JLabel("Enter Mass: ");
-
- my_enter_button = new JButton("ENTER");
-
- my_default_button = new JCheckBox("Default Shape ");
-
- my_param_frame.add(my_default_button);
- my_param_frame.add(blank);
- my_param_frame.add(position_label);
- my_param_frame.add(my_position_input);
- my_param_frame.add(radius_label);
- my_param_frame.add(my_radius_input);
- my_param_frame.add(mass_label);
- my_param_frame.add(my_mass_input);
- my_param_frame.add(my_enter_button);
-
- my_param_frame.setAlwaysOnTop(true);
- my_param_frame.pack();
- my_param_frame.setVisible(isVisible());
- }
-
- protected JCheckBox getDefaultButton() {
- return my_default_button;
- }
-
- protected JFrame getParamFrame() {
- return my_param_frame;
- }
-
- protected JButton getEnterButton() {
- return my_enter_button;
- }
-
- /**
- * @return the defaultRadius
- */
- public static float getDefaultRadius() {
- return DEFAULT_RADIUS;
- }
-
- /**
- * @return the defaultPosition
- */
- public static Vector3f getDefaultPosition() {
- return DEFAULT_POSITION;
- }
-
- /**
- * @return the input position.
- */
- public Vector3f getPosition() {
- return my_position;
- }
-
- /**
- * @return the radius.
- */
- public float getRadius() {
- return my_radius;
- }
-
- /**
- * @return the mass.
- */
- public float getMass() {
- return my_mass;
- }
-
- /**
- *
- * @param the_position the new position
- */
- public void setPosition(final Vector3f the_position) {
- my_position = the_position;
- }
-
- /**
- * @param the_radius float sets the radius.
- */
- public void setRadius(final float the_radius) {
- my_radius = the_radius;
- }
-
- /**
- * @param the_mass float sets the mass.
- */
- public void setMass(final float the_mass) {
- my_mass = the_mass;
- }
-
- /**
- * @return the input position input
- */
- public JTextField getPositionField() {
- return my_position_input;
- }
-
- /**
- * @return the radius input.
- */
- public JTextField getRadiusField() {
- return my_radius_input;
- }
-
- /**
- * @return the mass input.
- */
- public JTextField getMassField() {
- return my_mass_input;
- }
-}
diff --git a/src/tesseract/objects/Sphere.java b/src/tesseract/objects/Sphere.java
index 719ecc0..3605fb0 100644
--- a/src/tesseract/objects/Sphere.java
+++ b/src/tesseract/objects/Sphere.java
@@ -14,6 +14,11 @@ import common.CollidableObject;
*/
public class Sphere extends PhysicalObject {
/**
+ *
+ */
+ private static final long serialVersionUID = -8407634448268590714L;
+
+ /**
* Default Object color.
*/
private static final Color3f DEFAULT_COLOR = new Color3f(0.7f, 0.7f, 1);