From: Bill Kuker Date: Tue, 1 Sep 2009 00:32:22 +0000 (+0000) Subject: Show percent of motor class X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=304b1d8618339c58ebc61a734e41c8e649b4b1ec;p=sw%2Fmotorsim Show percent of motor class --- diff --git a/src/com/billkuker/rocketry/motorsim/visual/BurnPanel.java b/src/com/billkuker/rocketry/motorsim/visual/BurnPanel.java index 9f95aeb..7cf8ac1 100644 --- a/src/com/billkuker/rocketry/motorsim/visual/BurnPanel.java +++ b/src/com/billkuker/rocketry/motorsim/visual/BurnPanel.java @@ -118,7 +118,10 @@ public class BurnPanel extends JPanel { if ( thrustTime.isGreaterThan(Amount.valueOf(0, SI.SECOND))) averageThrust = ns.divide(thrustTime).to(SI.NEWTON); - int cn = (int)(Math.log(ns.doubleValue(RocketScience.NEWTON_SECOND)/1.25) / Math.log(2)); + float cnf = (float)(Math.log(ns.doubleValue(RocketScience.NEWTON_SECOND)/1.25) / Math.log(2)); + int cn = (int)cnf; + float fraction = cnf - cn; + int percent = (int)(100 * fraction); char cl = (char)((int)'A' + cn); @@ -130,7 +133,7 @@ public class BurnPanel extends JPanel { text.add(new JLabel("Average Thust")); text.add(new JLabel("Max Pressure")); - text.add(new JLabel(new String(new char[]{cl}) + "-" +Math.round(averageThrust.doubleValue(SI.NEWTON)))); + text.add(new JLabel(percent + "% " + new String(new char[]{cl}) + "-" +Math.round(averageThrust.doubleValue(SI.NEWTON)))); text.add(new JLabel(approx(ns))); text.add(new JLabel(approx(maxThrust))); text.add(new JLabel(approx(averageThrust)));