Initial commit
[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.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;
23
24
25 public class TrapezoidFinSetConfig extends FinSetConfig {
26
27         public TrapezoidFinSetConfig(final RocketComponent component) {
28                 super(component);
29                 
30                 DoubleModel m;
31                 JSpinner spin;
32                 JComboBox combo;
33                 
34                 JPanel mainPanel = new JPanel(new MigLayout());
35                 
36                 
37                 JPanel panel = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::]",""));
38                 
39                 ////  Number of fins
40                 JLabel label = new JLabel("Number of fins:");
41                 label.setToolTipText("The number of fins in the fin set.");
42                 panel.add(label);
43                 
44                 IntegerModel im = new IntegerModel(component,"FinCount",1,8);
45                 
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");
50                 
51                 
52                 ////  Base rotation
53                 label = new JLabel("Fin rotation:");
54                 label.setToolTipText("The angle of the first fin in the fin set.");
55                 panel.add(label);
56                 
57                 m = new DoubleModel(component, "BaseRotation", UnitGroup.UNITS_ANGLE,-Math.PI,Math.PI);
58                 
59                 spin = new JSpinner(m.getSpinnerModel());
60                 spin.setEditor(new SpinnerEditor(spin));
61                 panel.add(spin,"growx");
62                 
63                 panel.add(new UnitSelector(m),"growx");
64                 panel.add(new BasicSlider(m.getSliderModel(-Math.PI,Math.PI)),"w 100lp, wrap");
65                 
66                 
67                 ////  Fin cant
68                 label = new JLabel("Fin cant:");
69                 label.setToolTipText("The angle that the fins are canted with respect to the rocket " +
70                                 "body.");
71                 panel.add(label);
72                 
73                 m = new DoubleModel(component, "CantAngle", UnitGroup.UNITS_ANGLE,
74                                 -FinSet.MAX_CANT, FinSet.MAX_CANT);
75                 
76                 spin = new JSpinner(m.getSpinnerModel());
77                 spin.setEditor(new SpinnerEditor(spin));
78                 panel.add(spin,"growx");
79                 
80                 panel.add(new UnitSelector(m),"growx");
81                 panel.add(new BasicSlider(m.getSliderModel(-FinSet.MAX_CANT,FinSet.MAX_CANT)),
82                                 "w 100lp, wrap");
83                 
84                 
85                 ////  Root chord
86                 panel.add(new JLabel("Root chord:"));
87                 
88                 m  = new DoubleModel(component,"RootChord",UnitGroup.UNITS_LENGTH,0);
89                 
90                 spin = new JSpinner(m.getSpinnerModel());
91                 spin.setEditor(new SpinnerEditor(spin));
92                 panel.add(spin,"growx");
93                 
94                 panel.add(new UnitSelector(m),"growx");
95                 panel.add(new BasicSlider(m.getSliderModel(0,0.05,0.2)),"w 100lp, wrap");
96
97
98                 
99                 ////  Tip chord
100                 panel.add(new JLabel("Tip chord:"));
101                 
102                 m = new DoubleModel(component,"TipChord",UnitGroup.UNITS_LENGTH,0);
103                 
104                 spin = new JSpinner(m.getSpinnerModel());
105                 spin.setEditor(new SpinnerEditor(spin));
106                 panel.add(spin,"growx");
107                 
108                 panel.add(new UnitSelector(m),"growx");
109                 panel.add(new BasicSlider(m.getSliderModel(0,0.05,0.2)),"w 100lp, wrap");
110
111                 
112                 ////  Height
113                 panel.add(new JLabel("Height:"));
114                 
115                 m = new DoubleModel(component,"Height",UnitGroup.UNITS_LENGTH,0);
116                 
117                 spin = new JSpinner(m.getSpinnerModel());
118                 spin.setEditor(new SpinnerEditor(spin));
119                 panel.add(spin,"growx");
120                 
121                 panel.add(new UnitSelector(m),"growx");
122                 panel.add(new BasicSlider(m.getSliderModel(0,0.05,0.2)),"w 100lp, wrap");
123         
124                 
125                 
126                 ////  Sweep
127                 panel.add(new JLabel("Sweep length:"));
128                 
129                 m = new DoubleModel(component,"Sweep",UnitGroup.UNITS_LENGTH);
130                 
131                 spin = new JSpinner(m.getSpinnerModel());
132                 spin.setEditor(new SpinnerEditor(spin));
133                 panel.add(spin,"growx");
134                 
135                 panel.add(new UnitSelector(m),"growx");
136
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");
141
142                 
143                 ////  Sweep angle
144                 panel.add(new JLabel("Sweep angle:"));
145                 
146                 m = new DoubleModel(component, "SweepAngle",UnitGroup.UNITS_ANGLE,
147                                 -TrapezoidFinSet.MAX_SWEEP_ANGLE,TrapezoidFinSet.MAX_SWEEP_ANGLE);
148                 
149                 spin = new JSpinner(m.getSpinnerModel());
150                 spin.setEditor(new SpinnerEditor(spin));
151                 panel.add(spin,"growx");
152                 
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");
156
157                 
158
159                 
160
161                 mainPanel.add(panel,"aligny 20%");
162                 
163                 mainPanel.add(new JSeparator(SwingConstants.VERTICAL),"growy");
164                 
165                 
166                 
167                 panel = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::]",""));
168
169                 
170                 
171                 ////  Cross section
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");
176                 
177
178                 ////  Thickness
179                 panel.add(new JLabel("Thickness:"));
180                 
181                 m = new DoubleModel(component,"Thickness",UnitGroup.UNITS_LENGTH,0);
182                 
183                 spin = new JSpinner(m.getSpinnerModel());
184                 spin.setEditor(new SpinnerEditor(spin));
185                 panel.add(spin,"growx");
186                 
187                 panel.add(new UnitSelector(m),"growx");
188                 panel.add(new BasicSlider(m.getSliderModel(0,0.01)),"w 100lp, wrap para");
189                 
190                 
191                 ////  Position
192                 
193                 panel.add(new JLabel("Position relative to:"));
194
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
202                                 }));
203                 panel.add(combo,"spanx, growx, wrap");
204                 
205                 panel.add(new JLabel("plus"),"right");
206
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");
211                 
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");
217
218
219
220                 //// Material
221                 materialPanel(panel, Material.Type.BULK);
222                 
223                 
224                 
225                 
226                 mainPanel.add(panel,"aligny 20%");
227                 
228
229                 tabbedPane.insertTab("General", null, mainPanel, "General properties", 0);
230                 tabbedPane.setSelectedIndex(0);
231                 
232                 addFinSetButtons();
233                 
234         }
235 }