Bug fixes and startup checks
[debian/openrocket] / src / net / sf / openrocket / gui / configdialog / ShockCordConfig.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.JSpinner;
8
9 import net.miginfocom.swing.MigLayout;
10 import net.sf.openrocket.gui.SpinnerEditor;
11 import net.sf.openrocket.gui.adaptors.DoubleModel;
12 import net.sf.openrocket.gui.adaptors.EnumModel;
13 import net.sf.openrocket.gui.components.BasicSlider;
14 import net.sf.openrocket.gui.components.UnitSelector;
15 import net.sf.openrocket.material.Material;
16 import net.sf.openrocket.rocketcomponent.RocketComponent;
17 import net.sf.openrocket.unit.UnitGroup;
18
19 public class ShockCordConfig extends RocketComponentConfig {
20
21
22         public ShockCordConfig(RocketComponent component) {
23                 super(component);
24                 
25                 JPanel panel = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::]",""));
26                 JLabel label;
27                 DoubleModel m;
28                 JSpinner spin;
29                 String tip;
30                 
31                 
32                 //////  Left side
33                 
34                 // Cord length
35                 label = new JLabel("Shock cord length");
36                 panel.add(label);
37                 
38                 m = new DoubleModel(component,"CordLength",UnitGroup.UNITS_LENGTH,0);
39                 
40                 spin = new JSpinner(m.getSpinnerModel());
41                 spin.setEditor(new SpinnerEditor(spin));
42                 panel.add(spin,"growx");
43                 
44                 panel.add(new UnitSelector(m),"growx");
45                 panel.add(new BasicSlider(m.getSliderModel(0, 1, 10)),"w 100lp, wrap");
46                 
47
48                 // Material
49                 materialPanel(panel, Material.Type.LINE, "Shock cord material:", null);
50                 
51
52                 
53                 /////  Right side
54                 JPanel panel2 = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::]",""));
55                 panel.add(panel2, "cell 4 0, gapleft paragraph, aligny 0%, spany");
56                 
57                 
58                 ////  Position
59                 
60                 panel2.add(new JLabel("Position relative to:"));
61
62                 JComboBox combo = new JComboBox(
63                                 new EnumModel<RocketComponent.Position>(component, "RelativePosition",
64                                                 new RocketComponent.Position[] {
65                                                 RocketComponent.Position.TOP,
66                                                 RocketComponent.Position.MIDDLE,
67                                                 RocketComponent.Position.BOTTOM,
68                                                 RocketComponent.Position.ABSOLUTE
69                                 }));
70                 panel2.add(combo,"spanx, growx, wrap");
71                 
72                 panel2.add(new JLabel("plus"),"right");
73
74                 m = new DoubleModel(component,"PositionValue",UnitGroup.UNITS_LENGTH);
75                 spin = new JSpinner(m.getSpinnerModel());
76                 spin.setEditor(new SpinnerEditor(spin));
77                 panel2.add(spin,"growx");
78                 
79                 panel2.add(new UnitSelector(m),"growx");
80                 panel2.add(new BasicSlider(m.getSliderModel(
81                                 new DoubleModel(component.getParent(), "Length", -1.0, UnitGroup.UNITS_NONE),
82                                 new DoubleModel(component.getParent(), "Length"))),
83                                 "w 100lp, wrap");
84
85
86                 ////  Spatial length
87                 panel2.add(new JLabel("Packed length:"));
88                 
89                 m = new DoubleModel(component,"Length",UnitGroup.UNITS_LENGTH,0);
90                 
91                 spin = new JSpinner(m.getSpinnerModel());
92                 spin.setEditor(new SpinnerEditor(spin));
93                 panel2.add(spin,"growx");
94                 
95                 panel2.add(new UnitSelector(m),"growx");
96                 panel2.add(new BasicSlider(m.getSliderModel(0, 0.1, 0.5)),"w 100lp, wrap");
97                 
98                 
99                 //// Tube diameter
100                 panel2.add(new JLabel("Packed diameter:"));
101
102                 DoubleModel od  = new DoubleModel(component,"Radius",2,UnitGroup.UNITS_LENGTH,0);
103                 // Diameter = 2*Radius
104
105                 spin = new JSpinner(od.getSpinnerModel());
106                 spin.setEditor(new SpinnerEditor(spin));
107                 panel2.add(spin,"growx");
108                 
109                 panel2.add(new UnitSelector(od),"growx");
110                 panel2.add(new BasicSlider(od.getSliderModel(0, 0.04, 0.2)),"w 100lp, wrap");
111
112                 
113                 
114                 
115                 tabbedPane.insertTab("General", null, panel, "General properties", 0);
116 //              tabbedPane.insertTab("Radial position", null, positionTab(), 
117 //                              "Radial position configuration", 1);
118                 tabbedPane.setSelectedIndex(0);
119         }
120         
121         
122 }