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