From 59e75d5c83ba7a9cff9122e37ec770c399060e9a Mon Sep 17 00:00:00 2001 From: kruland2607 Date: Wed, 2 Oct 2013 12:51:59 -0500 Subject: [PATCH] Rework BodyTubeConfig and InnerTubeConfig removing the motor configuration stuff. The motormount checkbox and default ignition configuration is now on the General tab. Removed ThicknessRingComponentConfig since that was only used by InnerTubeConfig. Moved the radialPanel from RingComponentConfig to InnerTubeConfig for now. --- .../gui/configdialog/BodyTubeConfig.java | 12 +- .../gui/configdialog/InnerTubeConfig.java | 368 ++++++++++++++---- .../gui/configdialog/LaunchLugConfig.java | 2 - .../gui/configdialog/MotorConfig.java | 136 +------ .../gui/configdialog/RingComponentConfig.java | 74 ---- .../ThicknessRingComponentConfig.java | 34 -- 6 files changed, 295 insertions(+), 331 deletions(-) delete mode 100644 swing/src/net/sf/openrocket/gui/configdialog/ThicknessRingComponentConfig.java diff --git a/swing/src/net/sf/openrocket/gui/configdialog/BodyTubeConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/BodyTubeConfig.java index c91871a1a..2e5dad565 100644 --- a/swing/src/net/sf/openrocket/gui/configdialog/BodyTubeConfig.java +++ b/swing/src/net/sf/openrocket/gui/configdialog/BodyTubeConfig.java @@ -16,13 +16,13 @@ import net.sf.openrocket.gui.components.UnitSelector; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.material.Material; import net.sf.openrocket.rocketcomponent.BodyTube; +import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.startup.Application; import net.sf.openrocket.unit.UnitGroup; public class BodyTubeConfig extends RocketComponentConfig { - private MotorConfig motorConfigPane = null; private DoubleModel maxLength; private static final Translator trans = Application.getTranslator(); @@ -98,7 +98,10 @@ public class BodyTubeConfig extends RocketComponentConfig { check.setText(trans.get("BodyTubecfg.checkbox.Filled")); panel.add(check, "skip, span 2, wrap"); + MotorConfig motorConfig = new MotorConfig((MotorMount)c); + panel.add(motorConfig,"spanx, growx"); + //// Material panel.add(materialPanel(new JPanel(new MigLayout()), Material.Type.BULK), "cell 4 0, gapleft paragraph, aligny 0%, spany"); @@ -106,10 +109,7 @@ public class BodyTubeConfig extends RocketComponentConfig { //// General and General properties tabbedPane.insertTab(trans.get("BodyTubecfg.tab.General"), null, panel, trans.get("BodyTubecfg.tab.Generalproperties"), 0); - motorConfigPane = new MotorConfig((BodyTube) c); - //// Motor and Motor mount configuration - tabbedPane.insertTab(trans.get("BodyTubecfg.tab.Motor"), null, motorConfigPane, - trans.get("BodyTubecfg.tab.Motormountconf"), 1); + tabbedPane.setSelectedIndex(0); @@ -118,8 +118,6 @@ public class BodyTubeConfig extends RocketComponentConfig { @Override public void updateFields() { super.updateFields(); - if (motorConfigPane != null) - motorConfigPane.updateFields(); } } diff --git a/swing/src/net/sf/openrocket/gui/configdialog/InnerTubeConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/InnerTubeConfig.java index b3b96ed61..4d981d7b3 100644 --- a/swing/src/net/sf/openrocket/gui/configdialog/InnerTubeConfig.java +++ b/swing/src/net/sf/openrocket/gui/configdialog/InnerTubeConfig.java @@ -1,28 +1,12 @@ package net.sf.openrocket.gui.configdialog; -import net.miginfocom.swing.MigLayout; -import net.sf.openrocket.document.OpenRocketDocument; -import net.sf.openrocket.gui.Resettable; -import net.sf.openrocket.gui.SpinnerEditor; -import net.sf.openrocket.gui.adaptors.DoubleModel; -import net.sf.openrocket.gui.components.BasicSlider; -import net.sf.openrocket.gui.components.UnitSelector; -import net.sf.openrocket.l10n.Translator; -import net.sf.openrocket.rocketcomponent.ClusterConfiguration; -import net.sf.openrocket.rocketcomponent.Clusterable; -import net.sf.openrocket.rocketcomponent.InnerTube; -import net.sf.openrocket.rocketcomponent.MotorMount; -import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.startup.Application; -import net.sf.openrocket.unit.UnitGroup; -import net.sf.openrocket.util.BugException; -import net.sf.openrocket.util.Coordinate; -import net.sf.openrocket.util.StateChangeListener; - -import javax.swing.*; -import javax.swing.border.BevelBorder; -import java.awt.*; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.RenderingHints; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; @@ -31,40 +15,258 @@ import java.awt.geom.Ellipse2D; import java.util.EventObject; import java.util.List; +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JSpinner; +import javax.swing.SwingUtilities; +import javax.swing.border.BevelBorder; -public class InnerTubeConfig extends ThicknessRingComponentConfig { +import net.miginfocom.swing.MigLayout; +import net.sf.openrocket.document.OpenRocketDocument; +import net.sf.openrocket.gui.Resettable; +import net.sf.openrocket.gui.SpinnerEditor; +import net.sf.openrocket.gui.adaptors.DoubleModel; +import net.sf.openrocket.gui.adaptors.EnumModel; +import net.sf.openrocket.gui.components.BasicSlider; +import net.sf.openrocket.gui.components.DescriptionArea; +import net.sf.openrocket.gui.components.UnitSelector; +import net.sf.openrocket.l10n.Translator; +import net.sf.openrocket.material.Material; +import net.sf.openrocket.rocketcomponent.ClusterConfiguration; +import net.sf.openrocket.rocketcomponent.Clusterable; +import net.sf.openrocket.rocketcomponent.EngineBlock; +import net.sf.openrocket.rocketcomponent.InnerTube; +import net.sf.openrocket.rocketcomponent.MotorMount; +import net.sf.openrocket.rocketcomponent.RingComponent; +import net.sf.openrocket.rocketcomponent.RocketComponent; +import net.sf.openrocket.startup.Application; +import net.sf.openrocket.unit.UnitGroup; +import net.sf.openrocket.util.BugException; +import net.sf.openrocket.util.Coordinate; +import net.sf.openrocket.util.StateChangeListener; + + +public class InnerTubeConfig extends RocketComponentConfig { private static final Translator trans = Application.getTranslator(); - - + + public InnerTubeConfig(OpenRocketDocument d, RocketComponent c) { super(d, c); + + //// General and General properties + JPanel panel = new JPanel(new MigLayout("gap rel unrel", "[][65lp::][30lp::][]", "")); + DoubleModel m; + JSpinner spin; + DoubleModel od = null; + + //// Outer diameter + panel.add(new JLabel(trans.get("ThicknessRingCompCfg.tab.Outerdiam"))); + + //// OuterRadius + od = new DoubleModel(component, "OuterRadius", 2, UnitGroup.UNITS_LENGTH, 0); + // Diameter = 2*Radius + + spin = new JSpinner(od.getSpinnerModel()); + spin.setEditor(new SpinnerEditor(spin)); + panel.add(spin, "growx"); + + panel.add(new UnitSelector(od), "growx"); + panel.add(new BasicSlider(od.getSliderModel(0, 0.04, 0.2)), "w 100lp, wrap"); + + if (od.isAutomaticAvailable()) { + JCheckBox check = new JCheckBox(od.getAutomaticAction()); + //// Automatic + check.setText(trans.get("ringcompcfg.Automatic")); + panel.add(check, "skip, span 2, wrap"); + } + + //// Inner diameter + panel.add(new JLabel(trans.get("ThicknessRingCompCfg.tab.Innerdiam"))); + + //// InnerRadius + m = new DoubleModel(component, "InnerRadius", 2, UnitGroup.UNITS_LENGTH, 0); + + spin = new JSpinner(m.getSpinnerModel()); + spin.setEditor(new SpinnerEditor(spin)); + panel.add(spin, "growx"); + + panel.add(new UnitSelector(m), "growx"); + if (od == null) + panel.add(new BasicSlider(m.getSliderModel(0, 0.04, 0.2)), "w 100lp, wrap"); + else + panel.add(new BasicSlider(m.getSliderModel(new DoubleModel(0), od)), + "w 100lp, wrap"); + + if (m.isAutomaticAvailable()) { + JCheckBox check = new JCheckBox(m.getAutomaticAction()); + //// Automatic + check.setText(trans.get("ringcompcfg.Automatic")); + panel.add(check, "skip, span 2, wrap"); + } + + + //// Wall thickness + panel.add(new JLabel(trans.get("ThicknessRingCompCfg.tab.Wallthickness"))); + + //// Thickness + m = new DoubleModel(component, "Thickness", UnitGroup.UNITS_LENGTH, 0); + + spin = new JSpinner(m.getSpinnerModel()); + spin.setEditor(new SpinnerEditor(spin)); + panel.add(spin, "growx"); + + panel.add(new UnitSelector(m), "growx"); + panel.add(new BasicSlider(m.getSliderModel(0, 0.01)), "w 100lp, wrap"); + + + //// Inner tube length + panel.add(new JLabel(trans.get("ThicknessRingCompCfg.tab.Length"))); + + //// Length + m = new DoubleModel(component, "Length", UnitGroup.UNITS_LENGTH, 0); + + spin = new JSpinner(m.getSpinnerModel()); + spin.setEditor(new SpinnerEditor(spin)); + panel.add(spin, "growx"); + + panel.add(new UnitSelector(m), "growx"); + panel.add(new BasicSlider(m.getSliderModel(0, 0.1, 1.0)), "w 100lp, wrap"); + + + //// Position + + //// Position relative to: + panel.add(new JLabel(trans.get("ringcompcfg.Positionrelativeto"))); + + JComboBox combo = new JComboBox( + new EnumModel(component, "RelativePosition", + new RocketComponent.Position[] { + RocketComponent.Position.TOP, + RocketComponent.Position.MIDDLE, + RocketComponent.Position.BOTTOM, + RocketComponent.Position.ABSOLUTE + })); + panel.add(combo, "spanx 3, growx, wrap"); + + //// plus + panel.add(new JLabel(trans.get("ringcompcfg.plus")), "right"); + + //// PositionValue + m = new DoubleModel(component, "PositionValue", UnitGroup.UNITS_LENGTH); + spin = new JSpinner(m.getSpinnerModel()); + spin.setEditor(new SpinnerEditor(spin)); + panel.add(spin, "growx"); + + panel.add(new UnitSelector(m), "growx"); + panel.add(new BasicSlider(m.getSliderModel( + new DoubleModel(component.getParent(), "Length", -1.0, UnitGroup.UNITS_NONE), + new DoubleModel(component.getParent(), "Length"))), + "w 100lp, wrap"); + + MotorConfig motorConfig = new MotorConfig((MotorMount)c); - JPanel tab; + panel.add(motorConfig,"spanx, growx"); - tab = new MotorConfig((MotorMount) c); - //// Motor and Motor mount configuration - tabbedPane.insertTab(trans.get("InnerTubeCfg.tab.Motor"), null, tab, - trans.get("InnerTubeCfg.tab.ttip.Motor"), 1); - - tab = clusterTab(); + //// Material + panel.add(materialPanel(new JPanel(new MigLayout()), Material.Type.BULK), + "cell 4 0, gapleft paragraph, aligny 0%, spany"); + + tabbedPane.insertTab(trans.get("ThicknessRingCompCfg.tab.General"), null, panel, + trans.get("ThicknessRingCompCfg.tab.Generalprop"), 0); + + JPanel tab = clusterTab(); //// Cluster and Cluster configuration tabbedPane.insertTab(trans.get("InnerTubeCfg.tab.Cluster"), null, tab, trans.get("InnerTubeCfg.tab.ttip.Cluster"), 2); - + tab = positionTab(); //// Radial position tabbedPane.insertTab(trans.get("InnerTubeCfg.tab.Radialpos"), null, tab, trans.get("InnerTubeCfg.tab.ttip.Radialpos"), 3); - + tabbedPane.setSelectedIndex(0); } - - + + protected JPanel positionTab() { + JPanel panel = new JPanel(new MigLayout("align 20% 20%, gap rel unrel", + "[][65lp::][30lp::]", "")); + + //// Radial position + JLabel l = new JLabel(trans.get("ringcompcfg.Radialdistance")); + //// Distance from the rocket centerline + l.setToolTipText(trans.get("ringcompcfg.Distancefrom")); + panel.add(l); + + DoubleModel m = new DoubleModel(component, "RadialPosition", UnitGroup.UNITS_LENGTH, 0); + + JSpinner spin = new JSpinner(m.getSpinnerModel()); + spin.setEditor(new SpinnerEditor(spin)); + //// Distance from the rocket centerline + spin.setToolTipText(trans.get("ringcompcfg.Distancefrom")); + panel.add(spin, "growx"); + + panel.add(new UnitSelector(m), "growx"); + BasicSlider bs = new BasicSlider(m.getSliderModel(0, 0.1, 1.0)); + //// Distance from the rocket centerline + bs.setToolTipText(trans.get("ringcompcfg.Distancefrom")); + panel.add(bs, "w 100lp, wrap"); + + + //// Radial direction + l = new JLabel(trans.get("ringcompcfg.Radialdirection")); + //// The radial direction from the rocket centerline + l.setToolTipText(trans.get("ringcompcfg.radialdirectionfrom")); + panel.add(l); + + m = new DoubleModel(component, "RadialDirection", UnitGroup.UNITS_ANGLE); + + spin = new JSpinner(m.getSpinnerModel()); + spin.setEditor(new SpinnerEditor(spin)); + //// The radial direction from the rocket centerline + spin.setToolTipText(trans.get("ringcompcfg.radialdirectionfrom")); + panel.add(spin, "growx"); + + panel.add(new UnitSelector(m), "growx"); + bs = new BasicSlider(m.getSliderModel(-Math.PI, Math.PI)); + //// The radial direction from the rocket centerline + bs.setToolTipText(trans.get("ringcompcfg.radialdirectionfrom")); + panel.add(bs, "w 100lp, wrap"); + + + //// Reset button + JButton button = new JButton(trans.get("ringcompcfg.but.Reset")); + //// Reset the component to the rocket centerline + button.setToolTipText(trans.get("ringcompcfg.but.Resetcomponant")); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + ((RingComponent) component).setRadialDirection(0.0); + ((RingComponent) component).setRadialPosition(0.0); + } + }); + panel.add(button, "spanx, right, wrap para"); + + + DescriptionArea note = new DescriptionArea(3); + //// Note: An inner tube will not affect the aerodynamics of the rocket even if it is located outside of the body tube. + note.setText(trans.get("ringcompcfg.note.desc")); + panel.add(note, "spanx, growx"); + + + return panel; + } + + private JPanel clusterTab() { JPanel panel = new JPanel(new MigLayout()); - + JPanel subPanel = new JPanel(new MigLayout()); - + // Cluster type selection //// Select cluster configuration: subPanel.add(new JLabel(trans.get("InnerTubeCfg.lbl.Selectclustercfg")), "spanx, wrap"); @@ -72,12 +274,12 @@ public class InnerTubeConfig extends ThicknessRingComponentConfig { // JPanel clusterSelection = new ClusterSelectionPanel((InnerTube)component); // clusterSelection.setBackground(Color.blue); // subPanel.add(clusterSelection); - + panel.add(subPanel); - + subPanel = new JPanel(new MigLayout("gap rel unrel", "[][65lp::][30lp::]")); - + // Tube separation scale //// Tube separation: JLabel l = new JLabel(trans.get("InnerTubeCfg.lbl.TubeSep")); @@ -85,18 +287,18 @@ public class InnerTubeConfig extends ThicknessRingComponentConfig { l.setToolTipText(trans.get("InnerTubeCfg.lbl.ttip.TubeSep")); subPanel.add(l); DoubleModel dm = new DoubleModel(component, "ClusterScale", 1, UnitGroup.UNITS_NONE, 0); - + JSpinner spin = new JSpinner(dm.getSpinnerModel()); spin.setEditor(new SpinnerEditor(spin)); //// The separation of the tubes, 1.0 = touching each other spin.setToolTipText(trans.get("InnerTubeCfg.lbl.ttip.TubeSep")); subPanel.add(spin, "growx"); - + BasicSlider bs = new BasicSlider(dm.getSliderModel(0, 1, 4)); //// The separation of the tubes, 1.0 = touching each other bs.setToolTipText(trans.get("InnerTubeCfg.lbl.ttip.TubeSep")); subPanel.add(bs, "skip,w 100lp, wrap"); - + // Rotation: l = new JLabel(trans.get("InnerTubeCfg.lbl.Rotation")); //// Rotation angle of the cluster configuration @@ -104,19 +306,19 @@ public class InnerTubeConfig extends ThicknessRingComponentConfig { subPanel.add(l); dm = new DoubleModel(component, "ClusterRotation", 1, UnitGroup.UNITS_ANGLE, -Math.PI, Math.PI); - + spin = new JSpinner(dm.getSpinnerModel()); spin.setEditor(new SpinnerEditor(spin)); //// Rotation angle of the cluster configuration spin.setToolTipText(trans.get("InnerTubeCfg.lbl.ttip.Rotation")); subPanel.add(spin, "growx"); - + subPanel.add(new UnitSelector(dm), "growx"); bs = new BasicSlider(dm.getSliderModel(-Math.PI, 0, Math.PI)); //// Rotation angle of the cluster configuration bs.setToolTipText(trans.get("InnerTubeCfg.lbl.ttip.Rotation")); subPanel.add(bs, "w 100lp, wrap para"); - + // Split button @@ -139,19 +341,19 @@ public class InnerTubeConfig extends ThicknessRingComponentConfig { throw new BugException("Inconsistent state: component=" + component + " parent=" + parent + " parent.children=" + parent.getChildren()); } - + InnerTube tube = (InnerTube) component; if (tube.getClusterCount() <= 1) return; - + document.addUndoPosition("Split cluster"); - + Coordinate[] coords = { Coordinate.NUL }; coords = component.shiftCoordinates(coords); parent.removeChild(index); for (int i = 0; i < coords.length; i++) { - InnerTube copy = InnerTube.makeIndividualClusterComponent(coords[i], component.getName() + " #" + (i + 1), component); - + InnerTube copy = InnerTube.makeIndividualClusterComponent(coords[i], component.getName() + " #" + (i + 1), component); + parent.addChild(copy, index + i); } } @@ -159,7 +361,7 @@ public class InnerTubeConfig extends ThicknessRingComponentConfig { } }); subPanel.add(split, "spanx, split 2, gapright para, sizegroup buttons, right"); - + // Reset button ///// Reset settings @@ -174,9 +376,9 @@ public class InnerTubeConfig extends ThicknessRingComponentConfig { } }); subPanel.add(reset, "sizegroup buttons, right"); - + panel.add(subPanel, "grow"); - + return panel; } @@ -188,35 +390,35 @@ public class InnerTubeConfig extends ThicknessRingComponentConfig { class ClusterSelectionPanel extends JPanel { private static final int BUTTON_SIZE = 50; private static final int MOTOR_DIAMETER = 10; - + private static final Color SELECTED_COLOR = Color.RED; private static final Color UNSELECTED_COLOR = Color.WHITE; private static final Color MOTOR_FILL_COLOR = Color.GREEN; private static final Color MOTOR_BORDER_COLOR = Color.BLACK; - + public ClusterSelectionPanel(Clusterable component) { super(new MigLayout("gap 0 0", "[" + BUTTON_SIZE + "!][" + BUTTON_SIZE + "!][" + BUTTON_SIZE + "!][" + BUTTON_SIZE + "!]", "[" + BUTTON_SIZE + "!][" + BUTTON_SIZE + "!][" + BUTTON_SIZE + "!]")); - + for (int i = 0; i < ClusterConfiguration.CONFIGURATIONS.length; i++) { ClusterConfiguration config = ClusterConfiguration.CONFIGURATIONS[i]; - + JComponent button = new ClusterButton(component, config); if (i % 4 == 3) add(button, "wrap"); else add(button); } - + } - - + + private class ClusterButton extends JPanel implements StateChangeListener, MouseListener, - Resettable { + Resettable { private Clusterable component; private ClusterConfiguration config; - + public ClusterButton(Clusterable c, ClusterConfiguration config) { component = c; this.config = config; @@ -228,81 +430,81 @@ class ClusterSelectionPanel extends JPanel { component.addChangeListener(this); addMouseListener(this); } - - + + @Override public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; Rectangle area = g2.getClipBounds(); - + if (component.getClusterConfiguration() == config) g2.setColor(SELECTED_COLOR); else g2.setColor(UNSELECTED_COLOR); - + g2.fillRect(area.x, area.y, area.width, area.height); - + g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - + List points = config.getPoints(); Ellipse2D.Float circle = new Ellipse2D.Float(); for (int i = 0; i < points.size() / 2; i++) { double x = points.get(i * 2); double y = points.get(i * 2 + 1); - + double px = BUTTON_SIZE / 2 + x * MOTOR_DIAMETER; double py = BUTTON_SIZE / 2 - y * MOTOR_DIAMETER; circle.setFrameFromCenter(px, py, px + MOTOR_DIAMETER / 2, py + MOTOR_DIAMETER / 2); - + g2.setColor(MOTOR_FILL_COLOR); g2.fill(circle); g2.setColor(MOTOR_BORDER_COLOR); g2.draw(circle); } } - - + + @Override public void stateChanged(EventObject e) { repaint(); } - - + + @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { component.setClusterConfiguration(config); } } - + @Override public void mouseEntered(MouseEvent e) { } - + @Override public void mouseExited(MouseEvent e) { } - + @Override public void mousePressed(MouseEvent e) { } - + @Override public void mouseReleased(MouseEvent e) { } - - + + @Override public void resetModel() { component.removeChangeListener(this); removeMouseListener(this); } } - + } diff --git a/swing/src/net/sf/openrocket/gui/configdialog/LaunchLugConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/LaunchLugConfig.java index 07248d113..6f6ff0a32 100644 --- a/swing/src/net/sf/openrocket/gui/configdialog/LaunchLugConfig.java +++ b/swing/src/net/sf/openrocket/gui/configdialog/LaunchLugConfig.java @@ -154,8 +154,6 @@ public class LaunchLugConfig extends RocketComponentConfig { @Override public void updateFields() { super.updateFields(); - if (motorConfigPane != null) - motorConfigPane.updateFields(); } } diff --git a/swing/src/net/sf/openrocket/gui/configdialog/MotorConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/MotorConfig.java index 03882cce5..ca4538e38 100644 --- a/swing/src/net/sf/openrocket/gui/configdialog/MotorConfig.java +++ b/swing/src/net/sf/openrocket/gui/configdialog/MotorConfig.java @@ -1,20 +1,16 @@ package net.sf.openrocket.gui.configdialog; +import java.awt.Color; import java.awt.Component; import java.awt.Container; -import java.awt.Font; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import javax.swing.JButton; +import javax.swing.BorderFactory; import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSpinner; -import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -23,40 +19,27 @@ import net.sf.openrocket.gui.SpinnerEditor; import net.sf.openrocket.gui.adaptors.BooleanModel; import net.sf.openrocket.gui.adaptors.DoubleModel; import net.sf.openrocket.gui.adaptors.EnumModel; -import net.sf.openrocket.gui.adaptors.FlightConfigurationModel; import net.sf.openrocket.gui.components.BasicSlider; import net.sf.openrocket.gui.components.StyledLabel; import net.sf.openrocket.gui.components.UnitSelector; -import net.sf.openrocket.gui.dialogs.flightconfiguration.FlightConfigurationDialog; -import net.sf.openrocket.gui.dialogs.motor.MotorChooserDialog; import net.sf.openrocket.l10n.Translator; -import net.sf.openrocket.motor.Motor; -import net.sf.openrocket.motor.ThrustCurveMotor; -import net.sf.openrocket.rocketcomponent.Configuration; import net.sf.openrocket.rocketcomponent.IgnitionConfiguration; -import net.sf.openrocket.rocketcomponent.MotorConfiguration; import net.sf.openrocket.rocketcomponent.MotorMount; -import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.startup.Application; import net.sf.openrocket.unit.UnitGroup; public class MotorConfig extends JPanel { - private final Rocket rocket; private final MotorMount mount; - private final Configuration configuration; - private JPanel panel; - private JLabel motorLabel; private static final Translator trans = Application.getTranslator(); public MotorConfig(MotorMount motorMount) { super(new MigLayout("fill")); - this.rocket = ((RocketComponent) motorMount).getRocket(); this.mount = motorMount; - this.configuration = ((RocketComponent) motorMount).getRocket().getDefaultConfiguration(); + this.setBorder( BorderFactory.createLineBorder(Color.BLACK,1) ); BooleanModel model; model = new BooleanModel(motorMount, "MotorMount"); @@ -65,58 +48,10 @@ public class MotorConfig extends JPanel { check.setText(trans.get("MotorCfg.checkbox.compmotormount")); this.add(check, "wrap"); - - panel = new JPanel(new MigLayout("fill")); + final JPanel panel = new JPanel(new MigLayout("fill")); this.add(panel, "grow, wrap"); - // Motor configuration selector - //// Motor configuration: - panel.add(new JLabel(trans.get("MotorCfg.lbl.Flightcfg")), "shrink"); - - JComboBox combo = new JComboBox(new FlightConfigurationModel(configuration)); - panel.add(combo, "growx"); - combo.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - updateFields(); - } - - }); - - //// New button - JButton button = new JButton(trans.get("MotorCfg.but.New")); - button.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - String id = rocket.newFlightConfigurationID(); - configuration.setFlightConfigurationID(id); - } - }); - panel.add(button, ""); - - //// Edit button - button = new JButton(trans.get("MotorCfg.but.FlightcfgEdit")); - button.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - JDialog configDialog = new FlightConfigurationDialog(rocket, SwingUtilities.windowForComponent(MotorConfig.this)); - configDialog.show(); - } - }); - panel.add(button, "wrap unrel"); - - - // Current motor: - panel.add(new JLabel(trans.get("MotorCfg.lbl.Currentmotor")), "shrink"); - - motorLabel = new JLabel(); - motorLabel.setFont(motorLabel.getFont().deriveFont(Font.BOLD)); - updateFields(); - panel.add(motorLabel, "wrap unrel"); - - - // Overhang //// Motor overhang: panel.add(new JLabel(trans.get("MotorCfg.lbl.Motoroverhang"))); @@ -137,7 +72,7 @@ public class MotorConfig extends JPanel { panel.add(new JLabel(trans.get("MotorCfg.lbl.Ignitionat") + " " + CommonStrings.dagger), ""); IgnitionConfiguration ignitionConfig = mount.getIgnitionConfiguration().getDefault(); - combo = new JComboBox(new EnumModel(ignitionConfig, "IgnitionEvent")); + JComboBox combo = new JComboBox(new EnumModel(ignitionConfig, "IgnitionEvent")); panel.add(combo, "growx, wrap"); // ... and delay @@ -176,51 +111,6 @@ public class MotorConfig extends JPanel { } - // Select etc. buttons - //// Select motor - button = new JButton(trans.get("MotorCfg.but.Selectmotor")); - button.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - String id = configuration.getFlightConfigurationID(); - - MotorChooserDialog dialog = new MotorChooserDialog(mount.getMotor(id), - mount.getMotorDelay(id), mount.getMotorMountDiameter(), - SwingUtilities.getWindowAncestor(MotorConfig.this)); - dialog.setVisible(true); - Motor m = dialog.getSelectedMotor(); - double d = dialog.getSelectedDelay(); - - if (m != null) { - if (id == null) { - id = rocket.newFlightConfigurationID(); - configuration.setFlightConfigurationID(id); - } - MotorConfiguration config = new MotorConfiguration(); - config.setMotor(m); - config.setEjectionDelay(d); - mount.getMotorConfiguration().set(id, config); - } - updateFields(); - } - }); - panel.add(button, "span, split, growx"); - - //// Remove motor - button = new JButton(trans.get("MotorCfg.but.Removemotor")); - button.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - mount.getMotorConfiguration().resetDefault(configuration.getFlightConfigurationID()); - updateFields(); - } - }); - panel.add(button, "growx, wrap"); - - - - - // Set enabled status setDeepEnabled(panel, motorMount.isMotorMount()); @@ -233,22 +123,6 @@ public class MotorConfig extends JPanel { } - public void updateFields() { - String id = configuration.getFlightConfigurationID(); - Motor m = mount.getMotor(id); - if (m == null) { - //// None - motorLabel.setText(trans.get("MotorCfg.lbl.motorLabel")); - } else { - String str = ""; - if (m instanceof ThrustCurveMotor) - str = ((ThrustCurveMotor) m).getManufacturer() + " "; - str += m.getDesignation(mount.getMotorDelay(id)); - motorLabel.setText(str); - } - } - - private static void setDeepEnabled(Component component, boolean enabled) { component.setEnabled(enabled); if (component instanceof Container) { diff --git a/swing/src/net/sf/openrocket/gui/configdialog/RingComponentConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/RingComponentConfig.java index 803633004..10b6e8483 100644 --- a/swing/src/net/sf/openrocket/gui/configdialog/RingComponentConfig.java +++ b/swing/src/net/sf/openrocket/gui/configdialog/RingComponentConfig.java @@ -1,10 +1,6 @@ package net.sf.openrocket.gui.configdialog; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JLabel; @@ -22,7 +18,6 @@ import net.sf.openrocket.gui.components.UnitSelector; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.material.Material; import net.sf.openrocket.rocketcomponent.EngineBlock; -import net.sf.openrocket.rocketcomponent.RingComponent; import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.startup.Application; import net.sf.openrocket.unit.UnitGroup; @@ -171,73 +166,4 @@ public class RingComponentConfig extends RocketComponentConfig { } - protected JPanel positionTab() { - JPanel panel = new JPanel(new MigLayout("align 20% 20%, gap rel unrel", - "[][65lp::][30lp::]", "")); - - //// Radial position - JLabel l = new JLabel(trans.get("ringcompcfg.Radialdistance")); - //// Distance from the rocket centerline - l.setToolTipText(trans.get("ringcompcfg.Distancefrom")); - panel.add(l); - - DoubleModel m = new DoubleModel(component, "RadialPosition", UnitGroup.UNITS_LENGTH, 0); - - JSpinner spin = new JSpinner(m.getSpinnerModel()); - spin.setEditor(new SpinnerEditor(spin)); - //// Distance from the rocket centerline - spin.setToolTipText(trans.get("ringcompcfg.Distancefrom")); - panel.add(spin, "growx"); - - panel.add(new UnitSelector(m), "growx"); - BasicSlider bs = new BasicSlider(m.getSliderModel(0, 0.1, 1.0)); - //// Distance from the rocket centerline - bs.setToolTipText(trans.get("ringcompcfg.Distancefrom")); - panel.add(bs, "w 100lp, wrap"); - - - //// Radial direction - l = new JLabel(trans.get("ringcompcfg.Radialdirection")); - //// The radial direction from the rocket centerline - l.setToolTipText(trans.get("ringcompcfg.radialdirectionfrom")); - panel.add(l); - - m = new DoubleModel(component, "RadialDirection", UnitGroup.UNITS_ANGLE); - - spin = new JSpinner(m.getSpinnerModel()); - spin.setEditor(new SpinnerEditor(spin)); - //// The radial direction from the rocket centerline - spin.setToolTipText(trans.get("ringcompcfg.radialdirectionfrom")); - panel.add(spin, "growx"); - - panel.add(new UnitSelector(m), "growx"); - bs = new BasicSlider(m.getSliderModel(-Math.PI, Math.PI)); - //// The radial direction from the rocket centerline - bs.setToolTipText(trans.get("ringcompcfg.radialdirectionfrom")); - panel.add(bs, "w 100lp, wrap"); - - - //// Reset button - JButton button = new JButton(trans.get("ringcompcfg.but.Reset")); - //// Reset the component to the rocket centerline - button.setToolTipText(trans.get("ringcompcfg.but.Resetcomponant")); - button.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - ((RingComponent) component).setRadialDirection(0.0); - ((RingComponent) component).setRadialPosition(0.0); - } - }); - panel.add(button, "spanx, right, wrap para"); - - - DescriptionArea note = new DescriptionArea(3); - //// Note: An inner tube will not affect the aerodynamics of the rocket even if it is located outside of the body tube. - note.setText(trans.get("ringcompcfg.note.desc")); - panel.add(note, "spanx, growx"); - - - return panel; - } - } diff --git a/swing/src/net/sf/openrocket/gui/configdialog/ThicknessRingComponentConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/ThicknessRingComponentConfig.java deleted file mode 100644 index 3013b7c97..000000000 --- a/swing/src/net/sf/openrocket/gui/configdialog/ThicknessRingComponentConfig.java +++ /dev/null @@ -1,34 +0,0 @@ -package net.sf.openrocket.gui.configdialog; - - -import javax.swing.JPanel; - -import net.sf.openrocket.document.OpenRocketDocument; -import net.sf.openrocket.l10n.Translator; -import net.sf.openrocket.rocketcomponent.RocketComponent; -import net.sf.openrocket.startup.Application; - - - -public class ThicknessRingComponentConfig extends RingComponentConfig { - private static final Translator trans = Application.getTranslator(); - - public ThicknessRingComponentConfig(OpenRocketDocument d, RocketComponent c) { - super(d, c); - - JPanel tab; - - //// Outer diameter: - //// Inner diameter: - //// Wall thickness: - //// Length: - tab = generalTab(trans.get("ThicknessRingCompCfg.tab.Outerdiam"), - trans.get("ThicknessRingCompCfg.tab.Innerdiam"), - trans.get("ThicknessRingCompCfg.tab.Wallthickness"), trans.get("ThicknessRingCompCfg.tab.Length")); - //// General and General properties - tabbedPane.insertTab(trans.get("ThicknessRingCompCfg.tab.General"), null, tab, - trans.get("ThicknessRingCompCfg.tab.Generalprop"), 0); - tabbedPane.setSelectedIndex(0); - } - -} \ No newline at end of file