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.SpinnerEditor;
13 import net.sf.openrocket.gui.adaptors.DoubleModel;
14 import net.sf.openrocket.gui.adaptors.EnumModel;
15 import net.sf.openrocket.gui.adaptors.IntegerModel;
16 import net.sf.openrocket.gui.components.BasicSlider;
17 import net.sf.openrocket.gui.components.UnitSelector;
18 import net.sf.openrocket.l10n.Translator;
19 import net.sf.openrocket.material.Material;
20 import net.sf.openrocket.rocketcomponent.FinSet;
21 import net.sf.openrocket.rocketcomponent.RocketComponent;
22 import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
23 import net.sf.openrocket.startup.Application;
24 import net.sf.openrocket.unit.UnitGroup;
27 public class TrapezoidFinSetConfig extends FinSetConfig {
28 private static final Translator trans = Application.getTranslator();
30 public TrapezoidFinSetConfig(final RocketComponent component) {
37 JPanel mainPanel = new JPanel(new MigLayout());
40 JPanel panel = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::]",""));
43 JLabel label = new JLabel(trans.get("TrapezoidFinSetCfg.lbl.Nbroffins"));
44 //// The number of fins in the fin set.
45 label.setToolTipText(trans.get("TrapezoidFinSetCfg.lbl.ttip.Nbroffins"));
48 IntegerModel im = new IntegerModel(component,"FinCount",1,8);
50 spin = new JSpinner(im.getSpinnerModel());
51 spin.setEditor(new SpinnerEditor(spin));
52 //// The number of fins in the fin set.
53 spin.setToolTipText(trans.get("TrapezoidFinSetCfg.lbl.ttip.Nbroffins"));
54 panel.add(spin,"growx, wrap");
59 label = new JLabel(trans.get("TrapezoidFinSetCfg.lbl.Finrotation"));
60 //// The angle of the first fin in the fin set.
61 label.setToolTipText(trans.get("TrapezoidFinSetCfg.lbl.ttip.Finrotation"));
64 m = new DoubleModel(component, "BaseRotation", UnitGroup.UNITS_ANGLE,-Math.PI,Math.PI);
66 spin = new JSpinner(m.getSpinnerModel());
67 spin.setEditor(new SpinnerEditor(spin));
68 panel.add(spin,"growx");
70 panel.add(new UnitSelector(m),"growx");
71 panel.add(new BasicSlider(m.getSliderModel(-Math.PI,Math.PI)),"w 100lp, wrap");
75 label = new JLabel(trans.get("TrapezoidFinSetCfg.lbl.Fincant"));
76 //// The angle that the fins are canted with respect to the rocket
77 label.setToolTipText(trans.get("TrapezoidFinSetCfg.lbl.ttip.Fincant"));
80 m = new DoubleModel(component, "CantAngle", UnitGroup.UNITS_ANGLE,
81 -FinSet.MAX_CANT, FinSet.MAX_CANT);
83 spin = new JSpinner(m.getSpinnerModel());
84 spin.setEditor(new SpinnerEditor(spin));
85 panel.add(spin,"growx");
87 panel.add(new UnitSelector(m),"growx");
88 panel.add(new BasicSlider(m.getSliderModel(-FinSet.MAX_CANT,FinSet.MAX_CANT)),
93 panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.Rootchord")));
95 m = new DoubleModel(component,"RootChord",UnitGroup.UNITS_LENGTH,0);
97 spin = new JSpinner(m.getSpinnerModel());
98 spin.setEditor(new SpinnerEditor(spin));
99 panel.add(spin,"growx");
101 panel.add(new UnitSelector(m),"growx");
102 panel.add(new BasicSlider(m.getSliderModel(0,0.05,0.2)),"w 100lp, wrap");
107 panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.Tipchord")));
109 m = new DoubleModel(component,"TipChord",UnitGroup.UNITS_LENGTH,0);
111 spin = new JSpinner(m.getSpinnerModel());
112 spin.setEditor(new SpinnerEditor(spin));
113 panel.add(spin,"growx");
115 panel.add(new UnitSelector(m),"growx");
116 panel.add(new BasicSlider(m.getSliderModel(0,0.05,0.2)),"w 100lp, wrap");
120 panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.Height")));
122 m = new DoubleModel(component,"Height",UnitGroup.UNITS_LENGTH,0);
124 spin = new JSpinner(m.getSpinnerModel());
125 spin.setEditor(new SpinnerEditor(spin));
126 panel.add(spin,"growx");
128 panel.add(new UnitSelector(m),"growx");
129 panel.add(new BasicSlider(m.getSliderModel(0,0.05,0.2)),"w 100lp, wrap");
134 panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.Sweeplength")));
136 m = new DoubleModel(component,"Sweep",UnitGroup.UNITS_LENGTH);
138 spin = new JSpinner(m.getSpinnerModel());
139 spin.setEditor(new SpinnerEditor(spin));
140 panel.add(spin,"growx");
142 panel.add(new UnitSelector(m),"growx");
144 // sweep slider from -1.1*TipChord to 1.1*RootChord
145 DoubleModel tc = new DoubleModel(component,"TipChord",-1.1,UnitGroup.UNITS_LENGTH);
146 DoubleModel rc = new DoubleModel(component,"RootChord",1.1,UnitGroup.UNITS_LENGTH);
147 panel.add(new BasicSlider(m.getSliderModel(tc,rc)),"w 100lp, wrap");
151 panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.Sweepangle")));
153 m = new DoubleModel(component, "SweepAngle",UnitGroup.UNITS_ANGLE,
154 -TrapezoidFinSet.MAX_SWEEP_ANGLE,TrapezoidFinSet.MAX_SWEEP_ANGLE);
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(-Math.PI/4,Math.PI/4)),
162 "w 100lp, wrap paragraph");
168 mainPanel.add(panel,"aligny 20%");
170 mainPanel.add(new JSeparator(SwingConstants.VERTICAL),"growy");
174 panel = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::]",""));
178 //// Fin cross section:
179 panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.FincrossSection")));
180 combo = new JComboBox(
181 new EnumModel<FinSet.CrossSection>(component,"CrossSection"));
182 panel.add(combo,"span, growx, wrap");
186 panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.Thickness")));
188 m = new DoubleModel(component,"Thickness",UnitGroup.UNITS_LENGTH,0);
190 spin = new JSpinner(m.getSpinnerModel());
191 spin.setEditor(new SpinnerEditor(spin));
192 panel.add(spin,"growx");
194 panel.add(new UnitSelector(m),"growx");
195 panel.add(new BasicSlider(m.getSliderModel(0,0.01)),"w 100lp, wrap para");
199 //// Position relative to:
200 panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.Posrelativeto")));
202 combo = new JComboBox(
203 new EnumModel<RocketComponent.Position>(component, "RelativePosition",
204 new RocketComponent.Position[] {
205 RocketComponent.Position.TOP,
206 RocketComponent.Position.MIDDLE,
207 RocketComponent.Position.BOTTOM,
208 RocketComponent.Position.ABSOLUTE
210 panel.add(combo,"spanx, growx, wrap");
212 panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.plus")),"right");
214 m = new DoubleModel(component,"PositionValue",UnitGroup.UNITS_LENGTH);
215 spin = new JSpinner(m.getSpinnerModel());
216 spin.setEditor(new SpinnerEditor(spin));
217 panel.add(spin,"growx");
219 panel.add(new UnitSelector(m),"growx");
220 panel.add(new BasicSlider(m.getSliderModel(
221 new DoubleModel(component.getParent(), "Length", -1.0, UnitGroup.UNITS_NONE),
222 new DoubleModel(component.getParent(), "Length"))),
223 "w 100lp, wrap para");
228 materialPanel(panel, Material.Type.BULK);
233 mainPanel.add(panel,"aligny 20%");
235 //// General and General properties
236 tabbedPane.insertTab(trans.get("TrapezoidFinSetCfg.tab.General"), null, mainPanel,
237 trans.get("TrapezoidFinSetCfg.tab.Generalproperties"), 0);
238 tabbedPane.setSelectedIndex(0);