From 348d4550023dd3960f7d845a685d0370841c6203 Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 14 Feb 2011 23:40:23 +0000 Subject: Change ChainlinK1 to a DonutMenuItem, but the class name is still the same I though Jesse's ChainLink was more of a chainlink --- src/tesseract/TesseractUI.java | 4 +- src/tesseract/menuitems/DonutMenuItem.java | 95 ++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 src/tesseract/menuitems/DonutMenuItem.java (limited to 'src') diff --git a/src/tesseract/TesseractUI.java b/src/tesseract/TesseractUI.java index 7d5877a..15f9f3c 100644 --- a/src/tesseract/TesseractUI.java +++ b/src/tesseract/TesseractUI.java @@ -28,6 +28,7 @@ import tesseract.forces.Circular; import tesseract.forces.Force; import tesseract.forces.Gravity; import tesseract.menuitems.ChainLinkMenuItem; +import tesseract.menuitems.DonutMenuItem; import tesseract.menuitems.EllipsoidMenuItem; import tesseract.menuitems.GravityMenuItem; import tesseract.menuitems.IcosahedronMenuItem; @@ -114,7 +115,8 @@ public class TesseractUI extends JFrame { new PlanarPolygonMenuItem(myWorld), new EllipsoidMenuItem(myWorld), new IcosahedronMenuItem(myWorld), - new ChainLinkMenuItem(myWorld) + new ChainLinkMenuItem(myWorld), + new DonutMenuItem(myWorld) }; createMenu(); setupCanvas(); diff --git a/src/tesseract/menuitems/DonutMenuItem.java b/src/tesseract/menuitems/DonutMenuItem.java new file mode 100644 index 0000000..fb4a79a --- /dev/null +++ b/src/tesseract/menuitems/DonutMenuItem.java @@ -0,0 +1,95 @@ +package tesseract.menuitems; + +import java.awt.Color; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JColorChooser; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.vecmath.Color3f; +import javax.vecmath.Vector3f; + +import tesseract.World; +import tesseract.objects.ChainLink; +import tesseract.objects.ChainLink2; +import tesseract.objects.Icosahedron; +import tesseract.objects.PlanarPolygon; + +/** + * Icosahedron Menu Item. + * + * @author Steve Bradshaw + */ +public class DonutMenuItem extends TesseractMenuItem { + + /** + * Serial ID. + */ + private static final long serialVersionUID = 1L; + + /** + * 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(); + + 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 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 ChainLink(getPosition(), getRadius())); + params.dispose(); + } + } + });*/ + } +} + + + -- cgit v1.2.3