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