d4482de14b67569cca82a40f6abef6ed02bb0530
[debian/openrocket] / src / net / sf / openrocket / gui / configdialog / TrapezoidFinSetConfig.java
1 package net.sf.openrocket.gui.configdialog;
2
3
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;
10
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;
25
26
27 public class TrapezoidFinSetConfig extends FinSetConfig {
28         private static final Translator trans = Application.getTranslator();
29         
30         public TrapezoidFinSetConfig(final RocketComponent component) {
31                 super(component);
32                 
33                 DoubleModel m;
34                 JSpinner spin;
35                 JComboBox combo;
36                 
37                 JPanel mainPanel = new JPanel(new MigLayout());
38                 
39                 
40                 JPanel panel = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::]",""));
41                 
42                 ////  Number of fins:
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"));
46                 panel.add(label);
47                 
48                 IntegerModel im = new IntegerModel(component,"FinCount",1,8);
49                 
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");
55                 
56                 
57                 ////  Base rotation
58                 //// Fin rotation:
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"));
62                 panel.add(label);
63                 
64                 m = new DoubleModel(component, "BaseRotation", UnitGroup.UNITS_ANGLE,-Math.PI,Math.PI);
65                 
66                 spin = new JSpinner(m.getSpinnerModel());
67                 spin.setEditor(new SpinnerEditor(spin));
68                 panel.add(spin,"growx");
69                 
70                 panel.add(new UnitSelector(m),"growx");
71                 panel.add(new BasicSlider(m.getSliderModel(-Math.PI,Math.PI)),"w 100lp, wrap");
72                 
73                 
74                 ////  Fin cant:
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"));
78                 panel.add(label);
79                 
80                 m = new DoubleModel(component, "CantAngle", UnitGroup.UNITS_ANGLE,
81                                 -FinSet.MAX_CANT, FinSet.MAX_CANT);
82                 
83                 spin = new JSpinner(m.getSpinnerModel());
84                 spin.setEditor(new SpinnerEditor(spin));
85                 panel.add(spin,"growx");
86                 
87                 panel.add(new UnitSelector(m),"growx");
88                 panel.add(new BasicSlider(m.getSliderModel(-FinSet.MAX_CANT,FinSet.MAX_CANT)),
89                                 "w 100lp, wrap");
90                 
91                 
92                 ////  Root chord:
93                 panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.Rootchord")));
94                 
95                 m  = new DoubleModel(component,"RootChord",UnitGroup.UNITS_LENGTH,0);
96                 
97                 spin = new JSpinner(m.getSpinnerModel());
98                 spin.setEditor(new SpinnerEditor(spin));
99                 panel.add(spin,"growx");
100                 
101                 panel.add(new UnitSelector(m),"growx");
102                 panel.add(new BasicSlider(m.getSliderModel(0,0.05,0.2)),"w 100lp, wrap");
103
104
105                 
106                 ////  Tip chord:
107                 panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.Tipchord")));
108                 
109                 m = new DoubleModel(component,"TipChord",UnitGroup.UNITS_LENGTH,0);
110                 
111                 spin = new JSpinner(m.getSpinnerModel());
112                 spin.setEditor(new SpinnerEditor(spin));
113                 panel.add(spin,"growx");
114                 
115                 panel.add(new UnitSelector(m),"growx");
116                 panel.add(new BasicSlider(m.getSliderModel(0,0.05,0.2)),"w 100lp, wrap");
117
118                 
119                 ////  Height:
120                 panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.Height")));
121                 
122                 m = new DoubleModel(component,"Height",UnitGroup.UNITS_LENGTH,0);
123                 
124                 spin = new JSpinner(m.getSpinnerModel());
125                 spin.setEditor(new SpinnerEditor(spin));
126                 panel.add(spin,"growx");
127                 
128                 panel.add(new UnitSelector(m),"growx");
129                 panel.add(new BasicSlider(m.getSliderModel(0,0.05,0.2)),"w 100lp, wrap");
130         
131                 
132                 
133                 ////  Sweep length:
134                 panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.Sweeplength")));
135                 
136                 m = new DoubleModel(component,"Sweep",UnitGroup.UNITS_LENGTH);
137                 
138                 spin = new JSpinner(m.getSpinnerModel());
139                 spin.setEditor(new SpinnerEditor(spin));
140                 panel.add(spin,"growx");
141                 
142                 panel.add(new UnitSelector(m),"growx");
143
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");
148
149                 
150                 ////  Sweep angle:
151                 panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.Sweepangle")));
152                 
153                 m = new DoubleModel(component, "SweepAngle",UnitGroup.UNITS_ANGLE,
154                                 -TrapezoidFinSet.MAX_SWEEP_ANGLE,TrapezoidFinSet.MAX_SWEEP_ANGLE);
155                 
156                 spin = new JSpinner(m.getSpinnerModel());
157                 spin.setEditor(new SpinnerEditor(spin));
158                 panel.add(spin,"growx");
159                 
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");
163
164                 
165
166                 
167
168                 mainPanel.add(panel,"aligny 20%");
169                 
170                 mainPanel.add(new JSeparator(SwingConstants.VERTICAL),"growy");
171                 
172                 
173                 
174                 panel = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::]",""));
175
176                 
177                 
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");
183                 
184
185                 ////  Thickness:
186                 panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.Thickness")));
187                 
188                 m = new DoubleModel(component,"Thickness",UnitGroup.UNITS_LENGTH,0);
189                 
190                 spin = new JSpinner(m.getSpinnerModel());
191                 spin.setEditor(new SpinnerEditor(spin));
192                 panel.add(spin,"growx");
193                 
194                 panel.add(new UnitSelector(m),"growx");
195                 panel.add(new BasicSlider(m.getSliderModel(0,0.01)),"w 100lp, wrap para");
196                 
197                 
198                 ////  Position
199                 //// Position relative to:
200                 panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.Posrelativeto")));
201
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
209                                 }));
210                 panel.add(combo,"spanx, growx, wrap");
211                 //// plus
212                 panel.add(new JLabel(trans.get("TrapezoidFinSetCfg.lbl.plus")),"right");
213
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");
218                 
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");
224
225
226
227                 //// Material
228                 materialPanel(panel, Material.Type.BULK);
229                 
230                 
231                 
232                 
233                 mainPanel.add(panel,"aligny 20%");
234                 
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);
239                 
240                 addFinSetButtons();
241                 
242         }
243 }