1 package net.sf.openrocket.gui.configdialog;
4 import java.awt.event.ActionEvent;
5 import java.awt.event.ActionListener;
7 import javax.swing.JButton;
8 import javax.swing.JCheckBox;
9 import javax.swing.JComboBox;
10 import javax.swing.JLabel;
11 import javax.swing.JPanel;
12 import javax.swing.JSpinner;
14 import net.miginfocom.swing.MigLayout;
15 import net.sf.openrocket.gui.BasicSlider;
16 import net.sf.openrocket.gui.ResizeLabel;
17 import net.sf.openrocket.gui.SpinnerEditor;
18 import net.sf.openrocket.gui.UnitSelector;
19 import net.sf.openrocket.gui.adaptors.DoubleModel;
20 import net.sf.openrocket.gui.adaptors.EnumModel;
21 import net.sf.openrocket.gui.adaptors.MaterialModel;
22 import net.sf.openrocket.material.Material;
23 import net.sf.openrocket.rocketcomponent.MassComponent;
24 import net.sf.openrocket.rocketcomponent.RocketComponent;
25 import net.sf.openrocket.rocketcomponent.MotorMount.IgnitionEvent;
26 import net.sf.openrocket.unit.UnitGroup;
28 public class StreamerConfig extends RecoveryDeviceConfig {
30 public StreamerConfig(final RocketComponent component) {
33 JPanel primary = new JPanel(new MigLayout());
35 JPanel panel = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::][]",""));
39 panel.add(new JLabel("Strip length:"));
41 DoubleModel m = new DoubleModel(component,"StripLength",UnitGroup.UNITS_LENGTH,0);
43 JSpinner spin = new JSpinner(m.getSpinnerModel());
44 spin.setEditor(new SpinnerEditor(spin));
45 panel.add(spin,"growx");
46 panel.add(new UnitSelector(m),"growx");
47 panel.add(new BasicSlider(m.getSliderModel(0, 0.6, 1.5)),"w 100lp, wrap");
50 panel.add(new JLabel("Strip width:"));
52 m = new DoubleModel(component,"StripWidth",UnitGroup.UNITS_LENGTH,0);
54 spin = new JSpinner(m.getSpinnerModel());
55 spin.setEditor(new SpinnerEditor(spin));
56 panel.add(spin,"growx");
57 panel.add(new UnitSelector(m),"growx");
58 panel.add(new BasicSlider(m.getSliderModel(0, 0.2)),"w 100lp, wrap 20lp");
63 panel.add(new JLabel("Strip area:"));
65 m = new DoubleModel(component,"Area",UnitGroup.UNITS_AREA,0);
67 spin = new JSpinner(m.getSpinnerModel());
68 spin.setEditor(new SpinnerEditor(spin));
69 panel.add(spin,"growx");
70 panel.add(new UnitSelector(m),"growx");
71 panel.add(new BasicSlider(m.getSliderModel(0, 0.04, 0.25)),"w 100lp, wrap");
74 panel.add(new JLabel("Aspect ratio:"));
76 m = new DoubleModel(component,"AspectRatio",UnitGroup.UNITS_NONE,0);
78 spin = new JSpinner(m.getSpinnerModel());
79 spin.setEditor(new SpinnerEditor(spin));
80 panel.add(spin,"growx");
81 // panel.add(new UnitSelector(m),"growx");
82 panel.add(new BasicSlider(m.getSliderModel(2, 15)),"skip, w 100lp, wrap 20lp");
86 panel.add(new JLabel("Material:"));
88 JComboBox combo = new JComboBox(new MaterialModel(component, Material.Type.SURFACE));
89 combo.setToolTipText("The component material affects the weight of the component.");
90 panel.add(combo,"spanx 3, growx, wrap 20lp");
95 JLabel label = new JLabel("<html>Drag coefficient C<sub>D</sub>:");
96 String tip = "<html>The drag coefficient relative to the total area of the streamer.<br>" +
97 "A larger drag coefficient yields a slowed descent rate.";
98 label.setToolTipText(tip);
101 m = new DoubleModel(component,"CD",UnitGroup.UNITS_COEFFICIENT,0);
103 spin = new JSpinner(m.getSpinnerModel());
104 spin.setToolTipText(tip);
105 spin.setEditor(new SpinnerEditor(spin));
106 panel.add(spin,"growx");
108 JCheckBox check = new JCheckBox(m.getAutomaticAction());
109 check.setText("Automatic");
110 panel.add(check,"skip, span, wrap");
112 panel.add(new ResizeLabel("The drag coefficient is relative to the area of the streamer.",
117 primary.add(panel, "grow, gapright 20lp");
118 panel = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::][]",""));
125 panel.add(new JLabel("Position relative to:"));
127 combo = new JComboBox(
128 new EnumModel<RocketComponent.Position>(component, "RelativePosition",
129 new RocketComponent.Position[] {
130 RocketComponent.Position.TOP,
131 RocketComponent.Position.MIDDLE,
132 RocketComponent.Position.BOTTOM,
133 RocketComponent.Position.ABSOLUTE
135 panel.add(combo,"spanx, growx, wrap");
137 panel.add(new JLabel("plus"),"right");
139 m = new DoubleModel(component,"PositionValue",UnitGroup.UNITS_LENGTH);
140 spin = new JSpinner(m.getSpinnerModel());
141 spin.setEditor(new SpinnerEditor(spin));
142 panel.add(spin,"growx");
144 panel.add(new UnitSelector(m),"growx");
145 panel.add(new BasicSlider(m.getSliderModel(
146 new DoubleModel(component.getParent(), "Length", -1.0, UnitGroup.UNITS_NONE),
147 new DoubleModel(component.getParent(), "Length"))),
152 panel.add(new JLabel("Packed length:"));
154 m = new DoubleModel(component,"Length",UnitGroup.UNITS_LENGTH,0);
156 spin = new JSpinner(m.getSpinnerModel());
157 spin.setEditor(new SpinnerEditor(spin));
158 panel.add(spin,"growx");
160 panel.add(new UnitSelector(m),"growx");
161 panel.add(new BasicSlider(m.getSliderModel(0, 0.1, 0.5)),"w 100lp, wrap");
165 panel.add(new JLabel("Packed diameter:"));
167 DoubleModel od = new DoubleModel(component,"Radius",2,UnitGroup.UNITS_LENGTH,0);
168 // Diameter = 2*Radius
170 spin = new JSpinner(od.getSpinnerModel());
171 spin.setEditor(new SpinnerEditor(spin));
172 panel.add(spin,"growx");
174 panel.add(new UnitSelector(od),"growx");
175 panel.add(new BasicSlider(od.getSliderModel(0, 0.04, 0.2)),"w 100lp, wrap 30lp");
180 panel.add(new JLabel("Deploys at:"),"");
182 combo = new JComboBox(new EnumModel<IgnitionEvent>(component, "DeployEvent"));
183 panel.add(combo,"spanx 3, growx, wrap");
186 panel.add(new JLabel("plus"),"right");
188 m = new DoubleModel(component,"DeployDelay",0);
189 spin = new JSpinner(m.getSpinnerModel());
190 spin.setEditor(new SpinnerEditor(spin));
191 panel.add(spin,"spanx, split");
193 panel.add(new JLabel("seconds"),"wrap paragraph");
196 label = new JLabel("Altitude:");
197 altitudeComponents.add(label);
200 m = new DoubleModel(component,"DeployAltitude",UnitGroup.UNITS_DISTANCE,0);
202 spin = new JSpinner(m.getSpinnerModel());
203 spin.setEditor(new SpinnerEditor(spin));
204 altitudeComponents.add(spin);
205 panel.add(spin,"growx");
206 UnitSelector unit = new UnitSelector(m);
207 altitudeComponents.add(unit);
208 panel.add(unit,"growx");
209 BasicSlider slider = new BasicSlider(m.getSliderModel(100, 1000));
210 altitudeComponents.add(slider);
211 panel.add(slider,"w 100lp, wrap");
214 primary.add(panel, "grow");
218 tabbedPane.insertTab("General", null, primary, "General properties", 0);
219 tabbedPane.insertTab("Radial position", null, positionTab(),
220 "Radial position configuration", 1);
221 tabbedPane.setSelectedIndex(0);
228 protected JPanel positionTab() {
229 JPanel panel = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::]",""));
232 panel.add(new JLabel("Radial distance:"));
234 DoubleModel m = new DoubleModel(component,"RadialPosition",UnitGroup.UNITS_LENGTH,0);
236 JSpinner spin = new JSpinner(m.getSpinnerModel());
237 spin.setEditor(new SpinnerEditor(spin));
238 panel.add(spin,"growx");
240 panel.add(new UnitSelector(m),"growx");
241 panel.add(new BasicSlider(m.getSliderModel(0, 0.1, 1.0)),"w 100lp, wrap");
244 //// Radial direction
245 panel.add(new JLabel("Radial direction:"));
247 m = new DoubleModel(component,"RadialDirection",UnitGroup.UNITS_ANGLE,0);
249 spin = new JSpinner(m.getSpinnerModel());
250 spin.setEditor(new SpinnerEditor(spin));
251 panel.add(spin,"growx");
253 panel.add(new UnitSelector(m),"growx");
254 panel.add(new BasicSlider(m.getSliderModel(-Math.PI, Math.PI)),"w 100lp, wrap");
258 JButton button = new JButton("Reset");
259 button.addActionListener(new ActionListener() {
261 public void actionPerformed(ActionEvent e) {
262 ((MassComponent) component).setRadialDirection(0.0);
263 ((MassComponent) component).setRadialPosition(0.0);
266 panel.add(button,"spanx, right");