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