Split out summary panel
authorBill Kuker <bkuker@billkuker.com>
Sun, 7 Nov 2010 15:54:59 +0000 (15:54 +0000)
committerBill Kuker <bkuker@billkuker.com>
Sun, 7 Nov 2010 15:54:59 +0000 (15:54 +0000)
gui/com/billkuker/rocketry/motorsim/visual/BurnPanel.java
gui/com/billkuker/rocketry/motorsim/visual/SummaryPanel.java [new file with mode: 0644]
gui/com/billkuker/rocketry/motorsim/visual/workbench/MotorEditor.java

index dd40e51ea707b8163d90bb445e2897799fad5f90..6ee32df1f6626df0e1f632be0e65a8fa795c8b53 100644 (file)
@@ -3,8 +3,6 @@ package com.billkuker.rocketry.motorsim.visual;
 import java.awt.BorderLayout;\r
 import java.awt.Color;\r
 import java.awt.Dimension;\r
-import java.awt.GridLayout;\r
-import java.text.DecimalFormat;\r
 import java.text.NumberFormat;\r
 \r
 import javax.measure.quantity.Duration;\r
@@ -13,7 +11,6 @@ import javax.measure.quantity.Pressure;
 import javax.measure.quantity.Velocity;\r
 import javax.measure.unit.SI;\r
 import javax.swing.JFrame;\r
-import javax.swing.JLabel;\r
 import javax.swing.JPanel;\r
 import javax.swing.JSlider;\r
 import javax.swing.JSplitPane;\r
@@ -25,7 +22,6 @@ import org.jscience.physics.amount.Amount;
 \r
 import com.billkuker.rocketry.motorsim.Burn;\r
 import com.billkuker.rocketry.motorsim.BurnSummary;\r
-import com.billkuker.rocketry.motorsim.RocketScience;\r
 \r
 public class BurnPanel extends JPanel {\r
        private static final long serialVersionUID = 1L;\r
@@ -100,36 +96,17 @@ public class BurnPanel extends JPanel {
                        \r
                        add( new SL(), BorderLayout.SOUTH);\r
                        \r
-                       \r
+                       BurnSummary bi = new BurnSummary(burn);\r
+                       SummaryPanel text = new SummaryPanel(burn);\r
+                       text.setBurnSummary(bi);\r
+                       add(text, BorderLayout.NORTH);\r
                        \r
                        {\r
-                               BurnSummary bi = new BurnSummary(burn);\r
-                               JPanel text = new JPanel(new GridLayout(2, 5));\r
-\r
-                               text.add(new JLabel("Rating"));\r
-                               text.add(new JLabel("Total Impulse"));\r
-                               text.add(new JLabel("ISP"));\r
-                               text.add(new JLabel("Max Thrust"));\r
-                               text.add(new JLabel("Average Thust"));\r
-                               text.add(new JLabel("Max Pressure"));\r
-                               \r
-                               text.add(new JLabel("Safty Factor"));\r
 \r
-                               text.add(new JLabel(bi.getRating()));\r
-                               text.add(new JLabel(RocketScience.ammountToRoundedString(bi.totalImpulse())));\r
-                               text.add(new JLabel(RocketScience.ammountToRoundedString(bi.specificImpulse())));\r
-                               text.add(new JLabel(RocketScience\r
-                                               .ammountToRoundedString(bi.maxThrust())));\r
-                               text.add(new JLabel(RocketScience\r
-                                               .ammountToRoundedString(bi.averageThrust())));\r
-                               text.add(new JLabel(RocketScience\r
-                                               .ammountToRoundedString(bi.maxPressure())));\r
-                               \r
+                               //Color in the Burst marker\r
                                Color saftyColor;\r
                                if ( bi.getSaftyFactor() == null ){\r
-\r
                                        saftyColor = Color.BLACK;\r
-                                       text.add(new JLabel("NA"));\r
                                } else {\r
                                        double d = bi.getSaftyFactor();\r
                                        if ( d >= 1.5 ){\r
@@ -139,25 +116,19 @@ public class BurnPanel extends JPanel {
                                        } else {\r
                                                saftyColor = RED;\r
                                        }\r
-                                       JLabel l = new JLabel( new DecimalFormat("##########.#").format(bi.getSaftyFactor()));\r
-                                       l.setOpaque(true);\r
-                                       l.setBackground(saftyColor);\r
-                                       l.setForeground(Color.WHITE);\r
-                                       text.add(l);\r
+                               }\r
+                               Amount<Pressure> burst = b.getMotor().getChamber().getBurstPressure();\r
+                               if ( burst != null ){\r
+                                       pressure.addRangeMarker(burst, "Burst", saftyColor);\r
                                }\r
                                \r
-\r
-                               add(text, BorderLayout.NORTH);\r
-                               \r
+                               //Add some additional Markers\r
                                thrust.addRangeMarker(bi.maxThrust(), "Max", Color.BLACK);\r
                                thrust.addRangeMarker(bi.averageThrust(), "Average", Color.BLACK);\r
                                pressure.addRangeMarker(bi.maxPressure(), "Max", Color.BLACK);\r
                                burnRate.addDomainMarker(bi.maxPressure(), "Max", RED);\r
                                \r
-                               Amount<Pressure> burst = b.getMotor().getChamber().getBurstPressure();\r
-                               if ( burst != null ){\r
-                                       pressure.addRangeMarker(burst, "Burst", saftyColor);\r
-                               }\r
+\r
                        }\r
                        \r
                        \r
diff --git a/gui/com/billkuker/rocketry/motorsim/visual/SummaryPanel.java b/gui/com/billkuker/rocketry/motorsim/visual/SummaryPanel.java
new file mode 100644 (file)
index 0000000..3d7bb99
--- /dev/null
@@ -0,0 +1,72 @@
+package com.billkuker.rocketry.motorsim.visual;\r
+\r
+import java.awt.Color;\r
+import java.awt.GridLayout;\r
+import java.text.DecimalFormat;\r
+\r
+import javax.swing.JLabel;\r
+import javax.swing.JPanel;\r
+\r
+import com.billkuker.rocketry.motorsim.Burn;\r
+import com.billkuker.rocketry.motorsim.BurnSummary;\r
+import com.billkuker.rocketry.motorsim.RocketScience;\r
+\r
+public class SummaryPanel extends JPanel {\r
+       private static final long serialVersionUID = 1L;\r
+       private static final Color RED = new Color(196, 0, 0);\r
+       private static final Color GREEN = new Color(0, 196, 0);\r
+       private static final Color ORANGE = new Color(160, 96, 0);\r
+\r
+       public SummaryPanel(Burn b) {\r
+               super(new GridLayout(2, 5));\r
+       }\r
+\r
+       public void setBurnSummary(BurnSummary bi) {\r
+               {\r
+                       this.add(new JLabel("Rating"));\r
+                       this.add(new JLabel("Total Impulse"));\r
+                       this.add(new JLabel("ISP"));\r
+                       this.add(new JLabel("Max Thrust"));\r
+                       this.add(new JLabel("Average Thust"));\r
+                       this.add(new JLabel("Max Pressure"));\r
+\r
+                       this.add(new JLabel("Safty Factor"));\r
+\r
+                       this.add(new JLabel(bi.getRating()));\r
+                       this.add(new JLabel(RocketScience.ammountToRoundedString(bi\r
+                                       .totalImpulse())));\r
+                       this.add(new JLabel(RocketScience.ammountToRoundedString(bi\r
+                                       .specificImpulse())));\r
+                       this.add(new JLabel(RocketScience.ammountToRoundedString(bi\r
+                                       .maxThrust())));\r
+                       this.add(new JLabel(RocketScience.ammountToRoundedString(bi\r
+                                       .averageThrust())));\r
+                       this.add(new JLabel(RocketScience.ammountToRoundedString(bi\r
+                                       .maxPressure())));\r
+\r
+                       Color saftyColor;\r
+                       if (bi.getSaftyFactor() == null) {\r
+\r
+                               saftyColor = Color.BLACK;\r
+                               this.add(new JLabel("NA"));\r
+                       } else {\r
+                               double d = bi.getSaftyFactor();\r
+                               if (d >= 1.5) {\r
+                                       saftyColor = GREEN;\r
+                               } else if (d > 1) {\r
+                                       saftyColor = ORANGE;\r
+                               } else {\r
+                                       saftyColor = RED;\r
+                               }\r
+                               JLabel l = new JLabel(\r
+                                               new DecimalFormat("##########.#").format(bi\r
+                                                               .getSaftyFactor()));\r
+                               l.setOpaque(true);\r
+                               l.setBackground(saftyColor);\r
+                               l.setForeground(Color.WHITE);\r
+                               this.add(l);\r
+                       }\r
+\r
+               }\r
+       }\r
+}\r
index 22d2fa4037a5ffccbd5348b27593d73abe887c76..2c863e62b99fbcc1e707c8553501f2b37dc7711c 100644 (file)
@@ -49,6 +49,7 @@ import com.billkuker.rocketry.motorsim.Grain;
 import com.billkuker.rocketry.motorsim.Motor;\r
 import com.billkuker.rocketry.motorsim.Nozzle;\r
 import com.billkuker.rocketry.motorsim.RocketScience;\r
+import com.billkuker.rocketry.motorsim.cases.Schedule40;\r
 import com.billkuker.rocketry.motorsim.fuel.KNSU;\r
 import com.billkuker.rocketry.motorsim.grain.CSlot;\r
 import com.billkuker.rocketry.motorsim.grain.CoredCylindricalGrain;\r
@@ -175,6 +176,7 @@ public class MotorEditor extends JTabbedPane implements PropertyChangeListener {
                                                SwingUtilities.invokeLater(new Thread() {\r
                                                        public void run() {\r
                                                                remove(bar);\r
+                                                               remove(progress);\r
                                                                add(bp, BorderLayout.CENTER);\r
 \r
                                                                for (BurnWatcher bw : burnWatchers)\r
@@ -388,6 +390,10 @@ public class MotorEditor extends JTabbedPane implements PropertyChangeListener {
                c.setID(Amount.valueOf(30, SI.MILLIMETER));\r
                m.setChamber(c);\r
 \r
+               Schedule40 pvc = new Schedule40();\r
+               pvc.setLength(Amount.valueOf(200, SI.MILLIMETER));\r
+               m.setChamber(pvc);\r
+               \r
                CoredCylindricalGrain g = new CoredCylindricalGrain();\r
                try {\r
                        g.setLength(Amount.valueOf(70, SI.MILLIMETER));\r
@@ -396,6 +402,7 @@ public class MotorEditor extends JTabbedPane implements PropertyChangeListener {
                } catch (PropertyVetoException v) {\r
                        throw new Error(v);\r
                }\r
+               \r
 \r
                m.setGrain(new MultiGrain(g, 2));\r
 \r