1 package net.sf.openrocket.gui.configdialog;
4 import javax.swing.JComboBox;
5 import javax.swing.JLabel;
6 import javax.swing.JPanel;
7 import javax.swing.JSeparator;
8 import javax.swing.JSpinner;
9 import javax.swing.SwingConstants;
11 import net.miginfocom.swing.MigLayout;
12 import net.sf.openrocket.gui.BasicSlider;
13 import net.sf.openrocket.gui.SpinnerEditor;
14 import net.sf.openrocket.gui.UnitSelector;
15 import net.sf.openrocket.gui.adaptors.DoubleModel;
16 import net.sf.openrocket.gui.adaptors.EnumModel;
17 import net.sf.openrocket.gui.adaptors.IntegerModel;
18 import net.sf.openrocket.material.Material;
19 import net.sf.openrocket.rocketcomponent.FinSet;
20 import net.sf.openrocket.rocketcomponent.RocketComponent;
21 import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
22 import net.sf.openrocket.unit.UnitGroup;
25 public class TrapezoidFinSetConfig extends FinSetConfig {
27 public TrapezoidFinSetConfig(final RocketComponent component) {
34 JPanel mainPanel = new JPanel(new MigLayout());
37 JPanel panel = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::]",""));
40 JLabel label = new JLabel("Number of fins:");
41 label.setToolTipText("The number of fins in the fin set.");
44 IntegerModel im = new IntegerModel(component,"FinCount",1,8);
46 spin = new JSpinner(im.getSpinnerModel());
47 spin.setEditor(new SpinnerEditor(spin));
48 spin.setToolTipText("The number of fins in the fin set.");
49 panel.add(spin,"growx, wrap");
53 label = new JLabel("Fin rotation:");
54 label.setToolTipText("The angle of the first fin in the fin set.");
57 m = new DoubleModel(component, "BaseRotation", UnitGroup.UNITS_ANGLE,-Math.PI,Math.PI);
59 spin = new JSpinner(m.getSpinnerModel());
60 spin.setEditor(new SpinnerEditor(spin));
61 panel.add(spin,"growx");
63 panel.add(new UnitSelector(m),"growx");
64 panel.add(new BasicSlider(m.getSliderModel(-Math.PI,Math.PI)),"w 100lp, wrap");
68 label = new JLabel("Fin cant:");
69 label.setToolTipText("The angle that the fins are canted with respect to the rocket " +
73 m = new DoubleModel(component, "CantAngle", UnitGroup.UNITS_ANGLE,
74 -FinSet.MAX_CANT, FinSet.MAX_CANT);
76 spin = new JSpinner(m.getSpinnerModel());
77 spin.setEditor(new SpinnerEditor(spin));
78 panel.add(spin,"growx");
80 panel.add(new UnitSelector(m),"growx");
81 panel.add(new BasicSlider(m.getSliderModel(-FinSet.MAX_CANT,FinSet.MAX_CANT)),
86 panel.add(new JLabel("Root chord:"));
88 m = new DoubleModel(component,"RootChord",UnitGroup.UNITS_LENGTH,0);
90 spin = new JSpinner(m.getSpinnerModel());
91 spin.setEditor(new SpinnerEditor(spin));
92 panel.add(spin,"growx");
94 panel.add(new UnitSelector(m),"growx");
95 panel.add(new BasicSlider(m.getSliderModel(0,0.05,0.2)),"w 100lp, wrap");
100 panel.add(new JLabel("Tip chord:"));
102 m = new DoubleModel(component,"TipChord",UnitGroup.UNITS_LENGTH,0);
104 spin = new JSpinner(m.getSpinnerModel());
105 spin.setEditor(new SpinnerEditor(spin));
106 panel.add(spin,"growx");
108 panel.add(new UnitSelector(m),"growx");
109 panel.add(new BasicSlider(m.getSliderModel(0,0.05,0.2)),"w 100lp, wrap");
113 panel.add(new JLabel("Height:"));
115 m = new DoubleModel(component,"Height",UnitGroup.UNITS_LENGTH,0);
117 spin = new JSpinner(m.getSpinnerModel());
118 spin.setEditor(new SpinnerEditor(spin));
119 panel.add(spin,"growx");
121 panel.add(new UnitSelector(m),"growx");
122 panel.add(new BasicSlider(m.getSliderModel(0,0.05,0.2)),"w 100lp, wrap");
127 panel.add(new JLabel("Sweep length:"));
129 m = new DoubleModel(component,"Sweep",UnitGroup.UNITS_LENGTH);
131 spin = new JSpinner(m.getSpinnerModel());
132 spin.setEditor(new SpinnerEditor(spin));
133 panel.add(spin,"growx");
135 panel.add(new UnitSelector(m),"growx");
137 // sweep slider from -1.1*TipChord to 1.1*RootChord
138 DoubleModel tc = new DoubleModel(component,"TipChord",-1.1,UnitGroup.UNITS_LENGTH);
139 DoubleModel rc = new DoubleModel(component,"RootChord",1.1,UnitGroup.UNITS_LENGTH);
140 panel.add(new BasicSlider(m.getSliderModel(tc,rc)),"w 100lp, wrap");
144 panel.add(new JLabel("Sweep angle:"));
146 m = new DoubleModel(component, "SweepAngle",UnitGroup.UNITS_ANGLE,
147 -TrapezoidFinSet.MAX_SWEEP_ANGLE,TrapezoidFinSet.MAX_SWEEP_ANGLE);
149 spin = new JSpinner(m.getSpinnerModel());
150 spin.setEditor(new SpinnerEditor(spin));
151 panel.add(spin,"growx");
153 panel.add(new UnitSelector(m),"growx");
154 panel.add(new BasicSlider(m.getSliderModel(-Math.PI/4,Math.PI/4)),
155 "w 100lp, wrap paragraph");
161 mainPanel.add(panel,"aligny 20%");
163 mainPanel.add(new JSeparator(SwingConstants.VERTICAL),"growy");
167 panel = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::]",""));
172 panel.add(new JLabel("Fin cross section:"));
173 combo = new JComboBox(
174 new EnumModel<FinSet.CrossSection>(component,"CrossSection"));
175 panel.add(combo,"span, growx, wrap");
179 panel.add(new JLabel("Thickness:"));
181 m = new DoubleModel(component,"Thickness",UnitGroup.UNITS_LENGTH,0);
183 spin = new JSpinner(m.getSpinnerModel());
184 spin.setEditor(new SpinnerEditor(spin));
185 panel.add(spin,"growx");
187 panel.add(new UnitSelector(m),"growx");
188 panel.add(new BasicSlider(m.getSliderModel(0,0.01)),"w 100lp, wrap para");
193 panel.add(new JLabel("Position relative to:"));
195 combo = new JComboBox(
196 new EnumModel<RocketComponent.Position>(component, "RelativePosition",
197 new RocketComponent.Position[] {
198 RocketComponent.Position.TOP,
199 RocketComponent.Position.MIDDLE,
200 RocketComponent.Position.BOTTOM,
201 RocketComponent.Position.ABSOLUTE
203 panel.add(combo,"spanx, growx, wrap");
205 panel.add(new JLabel("plus"),"right");
207 m = new DoubleModel(component,"PositionValue",UnitGroup.UNITS_LENGTH);
208 spin = new JSpinner(m.getSpinnerModel());
209 spin.setEditor(new SpinnerEditor(spin));
210 panel.add(spin,"growx");
212 panel.add(new UnitSelector(m),"growx");
213 panel.add(new BasicSlider(m.getSliderModel(
214 new DoubleModel(component.getParent(), "Length", -1.0, UnitGroup.UNITS_NONE),
215 new DoubleModel(component.getParent(), "Length"))),
216 "w 100lp, wrap para");
221 materialPanel(panel, Material.Type.BULK);
226 mainPanel.add(panel,"aligny 20%");
229 tabbedPane.insertTab("General", null, mainPanel, "General properties", 0);
230 tabbedPane.setSelectedIndex(0);