From 393c82f7c5ef091bb2c44dd53c1f7e29f276a2c0 Mon Sep 17 00:00:00 2001 From: Bill Kuker Date: Sun, 24 Oct 2010 23:34:44 +0000 Subject: [PATCH] split hardware tab vertically --- .../motorsim/visual/HardwarePanel.java | 8 ++-- .../visual/workbench/MotorEditor.java | 46 +++++++++++++------ 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/src/com/billkuker/rocketry/motorsim/visual/HardwarePanel.java b/src/com/billkuker/rocketry/motorsim/visual/HardwarePanel.java index 0917010..2c274e0 100644 --- a/src/com/billkuker/rocketry/motorsim/visual/HardwarePanel.java +++ b/src/com/billkuker/rocketry/motorsim/visual/HardwarePanel.java @@ -64,17 +64,19 @@ public class HardwarePanel extends JPanel { h = cb.getHeight() + nb.getHeight(); double mw, mh; - mw = getWidth() - 10; - mh = getHeight() - 10; + mw = getHeight() - 10; + mh = getWidth() - 10; double sw, sh, s; sw = mw / w; sh = mh / h; s = Math.min(sw, sh); + g2d.rotate(-Math.PI / 2); + g2d.translate(0, -cb.getY() - 5); g2d.scale(s, s); - g2d.translate(-cb.getX(), 0); + g2d.translate(cb.getX(), 0); g2d.setStroke(new BasicStroke(1)); g2d.draw( c ); diff --git a/src/com/billkuker/rocketry/motorsim/visual/workbench/MotorEditor.java b/src/com/billkuker/rocketry/motorsim/visual/workbench/MotorEditor.java index 3ce6b11..2e7ecbe 100644 --- a/src/com/billkuker/rocketry/motorsim/visual/workbench/MotorEditor.java +++ b/src/com/billkuker/rocketry/motorsim/visual/workbench/MotorEditor.java @@ -1,6 +1,7 @@ package com.billkuker.rocketry.motorsim.visual.workbench; import java.awt.BorderLayout; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.FocusEvent; @@ -15,6 +16,7 @@ import java.util.Vector; import javax.measure.quantity.Length; import javax.measure.unit.SI; +import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.ComboBoxModel; import javax.swing.JButton; @@ -234,17 +236,23 @@ public class MotorEditor extends JTabbedPane implements PropertyChangeListener { private static final long serialVersionUID = 1L; public CaseEditor(Nozzle n, Chamber c) { - super(JSplitPane.HORIZONTAL_SPLIT); + super(JSplitPane.VERTICAL_SPLIT); setName("General Parameters"); + JPanel parts = new JPanel(); - parts.setLayout(new BoxLayout(parts, BoxLayout.Y_AXIS)); - setLeftComponent(parts); - setRightComponent(new HardwarePanel(n, c)); - - parts.add(new JLabel("Name:")); - parts.add(new JTextField(motor.getName()) { + parts.setLayout(new BoxLayout(parts, BoxLayout.X_AXIS)); + setTopComponent(parts); + setBottomComponent(new HardwarePanel(n, c)); + + JPanel nameAndFuel = new JPanel(); + nameAndFuel.setLayout(new BoxLayout(nameAndFuel, BoxLayout.Y_AXIS)); + + nameAndFuel.add(new JLabel("Name:")); + nameAndFuel.add(new JTextField(motor.getName()) { private static final long serialVersionUID = 1L; { + setMinimumSize(new Dimension(200, 20)); + setMaximumSize(new Dimension(Short.MAX_VALUE, 20)); final JTextField t = this; addFocusListener(new FocusListener() { @@ -266,8 +274,10 @@ public class MotorEditor extends JTabbedPane implements PropertyChangeListener { } }); - parts.add(new JLabel("Fuel:")); - parts.add( new JComboBox(availableFuels){{ + nameAndFuel.add(new JLabel("Fuel:")); + nameAndFuel.add( new JComboBox(availableFuels){{ + setMinimumSize(new Dimension(200, 20)); + setMaximumSize(new Dimension(Short.MAX_VALUE, 20)); addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent e) { @@ -275,10 +285,20 @@ public class MotorEditor extends JTabbedPane implements PropertyChangeListener { System.out.println("FUEL CHANGED"); }}); }}); - parts.add(new JLabel("Casing:")); - parts.add(new Editor(c)); - parts.add(new JLabel("Nozzle:")); - parts.add(new Editor(n)); + nameAndFuel.add(Box.createVerticalGlue()); + parts.add(nameAndFuel); + + JPanel casing = new JPanel(); + casing.setLayout(new BoxLayout(casing, BoxLayout.Y_AXIS)); + casing.add(new JLabel("Casing:")); + casing.add(new Editor(c)); + parts.add(casing); + + JPanel nozzle = new JPanel(); + nozzle.setLayout(new BoxLayout(nozzle, BoxLayout.Y_AXIS)); + nozzle.add(new JLabel("Nozzle:")); + nozzle.add(new Editor(n)); + parts.add(nozzle); if (n instanceof ChangeListening.Subject) { ((ChangeListening.Subject) n) -- 2.47.2