updates for 0.9.3
[debian/openrocket] / src / net / sf / openrocket / gui / configdialog / EllipticalFinSetConfig.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.material.Material;
19 import net.sf.openrocket.rocketcomponent.FinSet;
20 import net.sf.openrocket.rocketcomponent.RocketComponent;
21 import net.sf.openrocket.unit.UnitGroup;
22
23 public class EllipticalFinSetConfig extends FinSetConfig {
24
25         public EllipticalFinSetConfig(final RocketComponent component) {
26                 super(component);
27
28                 DoubleModel m;
29                 JSpinner spin;
30                 JComboBox combo;
31                 
32                 JPanel mainPanel = new JPanel(new MigLayout());
33                 
34                 
35                 
36                 JPanel panel = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::]",""));
37                 
38                 ////  Number of fins
39                 panel.add(new JLabel("Number of fins:"));
40                 
41                 IntegerModel im = new IntegerModel(component,"FinCount",1,8);
42                 
43                 spin = new JSpinner(im.getSpinnerModel());
44                 spin.setEditor(new SpinnerEditor(spin));
45                 panel.add(spin,"growx, wrap");
46                 
47                 
48                 ////  Base rotation
49                 panel.add(new JLabel("Rotation:"));
50                 
51                 m = new DoubleModel(component, "BaseRotation", UnitGroup.UNITS_ANGLE,-Math.PI,Math.PI);
52                 
53                 spin = new JSpinner(m.getSpinnerModel());
54                 spin.setEditor(new SpinnerEditor(spin));
55                 panel.add(spin,"growx");
56                 
57                 panel.add(new UnitSelector(m),"growx");
58                 panel.add(new BasicSlider(m.getSliderModel(-Math.PI,Math.PI)),"w 100lp, wrap");
59                 
60                 
61                 ////  Fin cant
62                 JLabel label = new JLabel("Fin cant:");
63                 label.setToolTipText("The angle that the fins are canted with respect to the rocket " +
64                                 "body.");
65                 panel.add(label);
66                 
67                 m = new DoubleModel(component, "CantAngle", UnitGroup.UNITS_ANGLE,
68                                 -FinSet.MAX_CANT, FinSet.MAX_CANT);
69                 
70                 spin = new JSpinner(m.getSpinnerModel());
71                 spin.setEditor(new SpinnerEditor(spin));
72                 panel.add(spin,"growx");
73                 
74                 panel.add(new UnitSelector(m),"growx");
75                 panel.add(new BasicSlider(m.getSliderModel(-FinSet.MAX_CANT,FinSet.MAX_CANT)),
76                                 "w 100lp, wrap");
77                 
78
79                 
80                 ////  Root chord
81                 panel.add(new JLabel("Root chord:"));
82                 
83                 m  = new DoubleModel(component,"Length",UnitGroup.UNITS_LENGTH,0);
84                 
85                 spin = new JSpinner(m.getSpinnerModel());
86                 spin.setEditor(new SpinnerEditor(spin));
87                 panel.add(spin,"growx");
88                 
89                 panel.add(new UnitSelector(m),"growx");
90                 panel.add(new BasicSlider(m.getSliderModel(0,0.05,0.2)),"w 100lp, wrap");
91
92
93                 ////  Height
94                 panel.add(new JLabel("Height:"));
95                 
96                 m = new DoubleModel(component,"Height",UnitGroup.UNITS_LENGTH,0);
97                 
98                 spin = new JSpinner(m.getSpinnerModel());
99                 spin.setEditor(new SpinnerEditor(spin));
100                 panel.add(spin,"growx");
101                 
102                 panel.add(new UnitSelector(m),"growx");
103                 panel.add(new BasicSlider(m.getSliderModel(0,0.05,0.2)),"w 100lp, wrap");
104         
105                 
106                 ////  Position
107                 
108                 panel.add(new JLabel("Position relative to:"));
109
110                 combo = new JComboBox(
111                                 new EnumModel<RocketComponent.Position>(component, "RelativePosition",
112                                                 new RocketComponent.Position[] {
113                                                 RocketComponent.Position.TOP,
114                                                 RocketComponent.Position.MIDDLE,
115                                                 RocketComponent.Position.BOTTOM,
116                                                 RocketComponent.Position.ABSOLUTE
117                                 }));
118                 panel.add(combo,"spanx, growx, wrap");
119                 
120                 panel.add(new JLabel("plus"),"right");
121
122                 m = new DoubleModel(component,"PositionValue",UnitGroup.UNITS_LENGTH);
123                 spin = new JSpinner(m.getSpinnerModel());
124                 spin.setEditor(new SpinnerEditor(spin));
125                 panel.add(spin,"growx");
126                 
127                 panel.add(new UnitSelector(m),"growx");
128                 panel.add(new BasicSlider(m.getSliderModel(
129                                 new DoubleModel(component.getParent(), "Length", -1.0, UnitGroup.UNITS_NONE),
130                                 new DoubleModel(component.getParent(), "Length"))),
131                                 "w 100lp, wrap");
132
133
134                 
135                 //// Right portion
136                 mainPanel.add(panel,"aligny 20%");
137                 
138                 mainPanel.add(new JSeparator(SwingConstants.VERTICAL),"growy");
139                 
140                 
141                 
142                 panel = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::]",""));
143
144
145                 ////  Cross section
146                 panel.add(new JLabel("Fin cross section:"),"span, split");
147                 combo = new JComboBox(
148                                 new EnumModel<FinSet.CrossSection>(component,"CrossSection"));
149                 panel.add(combo,"growx, wrap unrel");
150                 
151
152                 ////  Thickness
153                 panel.add(new JLabel("Thickness:"));
154                 
155                 m = new DoubleModel(component,"Thickness",UnitGroup.UNITS_LENGTH,0);
156                 
157                 spin = new JSpinner(m.getSpinnerModel());
158                 spin.setEditor(new SpinnerEditor(spin));
159                 panel.add(spin,"growx");
160                 
161                 panel.add(new UnitSelector(m),"growx");
162                 panel.add(new BasicSlider(m.getSliderModel(0,0.01)),"w 100lp, wrap 30lp");
163                 
164                 
165
166                 //// Material
167                 materialPanel(panel, Material.Type.BULK);
168                 
169                 
170                 
171                 
172                 
173                 mainPanel.add(panel,"aligny 20%");
174                 
175                 addFinSetButtons();
176
177
178                 tabbedPane.insertTab("General", null, mainPanel, "General properties", 0);
179                 tabbedPane.setSelectedIndex(0);
180         }
181
182 }