summaryrefslogtreecommitdiff
path: root/src/tesseract/menuitems/DonutMenuItem.java
blob: 7fd4470d1c319804ea265d4756fa3cf9df3e9e02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
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();
				}
			}
		});*/
	}
}