1 package net.sf.openrocket.gui.configdialog;
4 import java.awt.event.ActionEvent;
5 import java.awt.event.ActionListener;
7 import javax.swing.JButton;
8 import javax.swing.JComboBox;
9 import javax.swing.JLabel;
10 import javax.swing.JPanel;
11 import javax.swing.JSeparator;
12 import javax.swing.JSpinner;
13 import javax.swing.SwingConstants;
14 import javax.swing.SwingUtilities;
16 import net.miginfocom.swing.MigLayout;
17 import net.sf.openrocket.gui.BasicSlider;
18 import net.sf.openrocket.gui.SpinnerEditor;
19 import net.sf.openrocket.gui.UnitSelector;
20 import net.sf.openrocket.gui.adaptors.DoubleModel;
21 import net.sf.openrocket.gui.adaptors.EnumModel;
22 import net.sf.openrocket.gui.adaptors.IntegerModel;
23 import net.sf.openrocket.material.Material;
24 import net.sf.openrocket.rocketcomponent.FinSet;
25 import net.sf.openrocket.rocketcomponent.FreeformFinSet;
26 import net.sf.openrocket.rocketcomponent.RocketComponent;
27 import net.sf.openrocket.unit.UnitGroup;
29 public class EllipticalFinSetConfig extends FinSetConfig {
31 public EllipticalFinSetConfig(final RocketComponent component) {
38 JPanel mainPanel = new JPanel(new MigLayout());
42 JPanel panel = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::]",""));
45 panel.add(new JLabel("Number of fins:"));
47 IntegerModel im = new IntegerModel(component,"FinCount",1,8);
49 spin = new JSpinner(im.getSpinnerModel());
50 spin.setEditor(new SpinnerEditor(spin));
51 panel.add(spin,"growx, wrap");
55 panel.add(new JLabel("Rotation:"));
57 m = new DoubleModel(component, "BaseRotation", UnitGroup.UNITS_ANGLE,-Math.PI,Math.PI);
59 spin = new JSpinner(m.getSpinnerModel());
60 spin.setEditor(new SpinnerEditor(spin));
61 panel.add(spin,"growx");
63 panel.add(new UnitSelector(m),"growx");
64 panel.add(new BasicSlider(m.getSliderModel(-Math.PI,Math.PI)),"w 100lp, wrap");
68 panel.add(new JLabel("Root chord:"));
70 m = new DoubleModel(component,"Length",UnitGroup.UNITS_LENGTH,0);
72 spin = new JSpinner(m.getSpinnerModel());
73 spin.setEditor(new SpinnerEditor(spin));
74 panel.add(spin,"growx");
76 panel.add(new UnitSelector(m),"growx");
77 panel.add(new BasicSlider(m.getSliderModel(0,0.05,0.2)),"w 100lp, wrap");
81 panel.add(new JLabel("Height:"));
83 m = new DoubleModel(component,"Height",UnitGroup.UNITS_LENGTH,0);
85 spin = new JSpinner(m.getSpinnerModel());
86 spin.setEditor(new SpinnerEditor(spin));
87 panel.add(spin,"growx");
89 panel.add(new UnitSelector(m),"growx");
90 panel.add(new BasicSlider(m.getSliderModel(0,0.05,0.2)),"w 100lp, wrap");
95 panel.add(new JLabel("Position relative to:"));
97 combo = new JComboBox(
98 new EnumModel<RocketComponent.Position>(component, "RelativePosition",
99 new RocketComponent.Position[] {
100 RocketComponent.Position.TOP,
101 RocketComponent.Position.MIDDLE,
102 RocketComponent.Position.BOTTOM,
103 RocketComponent.Position.ABSOLUTE
105 panel.add(combo,"spanx, growx, wrap");
107 panel.add(new JLabel("plus"),"right");
109 m = new DoubleModel(component,"PositionValue",UnitGroup.UNITS_LENGTH);
110 spin = new JSpinner(m.getSpinnerModel());
111 spin.setEditor(new SpinnerEditor(spin));
112 panel.add(spin,"growx");
114 panel.add(new UnitSelector(m),"growx");
115 panel.add(new BasicSlider(m.getSliderModel(
116 new DoubleModel(component.getParent(), "Length", -1.0, UnitGroup.UNITS_NONE),
117 new DoubleModel(component.getParent(), "Length"))),
123 mainPanel.add(panel,"aligny 20%");
125 mainPanel.add(new JSeparator(SwingConstants.VERTICAL),"growy");
129 panel = new JPanel(new MigLayout("gap rel unrel","[][65lp::][30lp::]",""));
133 panel.add(new JLabel("Fin cross section:"),"span, split");
134 combo = new JComboBox(
135 new EnumModel<FinSet.CrossSection>(component,"CrossSection"));
136 panel.add(combo,"growx, wrap unrel");
140 panel.add(new JLabel("Thickness:"));
142 m = new DoubleModel(component,"Thickness",UnitGroup.UNITS_LENGTH,0);
144 spin = new JSpinner(m.getSpinnerModel());
145 spin.setEditor(new SpinnerEditor(spin));
146 panel.add(spin,"growx");
148 panel.add(new UnitSelector(m),"growx");
149 panel.add(new BasicSlider(m.getSliderModel(0,0.01)),"w 100lp, wrap 30lp");
154 materialPanel(panel, Material.Type.BULK);
160 JButton button = new JButton("Convert to freeform fin set");
161 button.addActionListener(new ActionListener() {
163 public void actionPerformed(ActionEvent e) {
164 // Do change in future for overall safety
165 SwingUtilities.invokeLater(new Runnable() {
168 FreeformFinSet freeform = new FreeformFinSet((FinSet)component);
169 RocketComponent parent = component.getParent();
170 int index = parent.getChildPosition(component);
172 ComponentConfigDialog.addUndoPosition("Convert fin set");
173 parent.removeChild(index);
174 parent.addChild(freeform, index);
175 ComponentConfigDialog.showDialog(freeform);
179 ComponentConfigDialog.hideDialog();
182 panel.add(button,"span, growx, gaptop paragraph");
186 mainPanel.add(panel,"aligny 20%");
191 tabbedPane.insertTab("General", null, mainPanel, "General properties", 0);
192 tabbedPane.setSelectedIndex(0);