From: Bill Kuker Date: Mon, 22 Nov 2010 13:47:45 +0000 (+0000) Subject: Rename multiburnchart X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=86a3ca6396a0ff72d8d940486d00d34005cada3e;p=sw%2Fmotorsim Rename multiburnchart --- diff --git a/gui/com/billkuker/rocketry/motorsim/visual/workbench/MotorWorkbench.java b/gui/com/billkuker/rocketry/motorsim/visual/workbench/MotorWorkbench.java index d3a2475..b3c5589 100644 --- a/gui/com/billkuker/rocketry/motorsim/visual/workbench/MotorWorkbench.java +++ b/gui/com/billkuker/rocketry/motorsim/visual/workbench/MotorWorkbench.java @@ -18,7 +18,7 @@ import com.billkuker.rocketry.motorsim.fuel.FuelsEditor; public class MotorWorkbench extends JFrame { private static final long serialVersionUID = 1L; - private MultiBurnChart mb; + private MultiMotorThrustChart mb; private JFrame allBurns; private JFrame fuelEditorFrame = new JFrame(){ @@ -46,7 +46,7 @@ public class MotorWorkbench extends JFrame { addMenu(); - mb = new MultiBurnChart(); + mb = new MultiMotorThrustChart(); allBurns = new JFrame(); allBurns.setTitle("All Burns"); allBurns.setSize(800, 600); diff --git a/gui/com/billkuker/rocketry/motorsim/visual/workbench/MotorsEditor.java b/gui/com/billkuker/rocketry/motorsim/visual/workbench/MotorsEditor.java index f0b2c24..b94aa08 100644 --- a/gui/com/billkuker/rocketry/motorsim/visual/workbench/MotorsEditor.java +++ b/gui/com/billkuker/rocketry/motorsim/visual/workbench/MotorsEditor.java @@ -23,7 +23,7 @@ import com.billkuker.rocketry.motorsim.visual.MultiObjectEditor; public class MotorsEditor extends MultiObjectEditor { private static final long serialVersionUID = 1L; - MultiBurnChart mbc = new MultiBurnChart(); + MultiMotorThrustChart mbc = new MultiMotorThrustChart(); public MotorsEditor(JFrame f) { super(f, "Motor"); diff --git a/gui/com/billkuker/rocketry/motorsim/visual/workbench/MultiBurnChart.java b/gui/com/billkuker/rocketry/motorsim/visual/workbench/MultiBurnChart.java deleted file mode 100644 index 2234029..0000000 --- a/gui/com/billkuker/rocketry/motorsim/visual/workbench/MultiBurnChart.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.billkuker.rocketry.motorsim.visual.workbench; - -import java.awt.BorderLayout; -import java.util.HashMap; - -import javax.measure.quantity.Duration; -import javax.measure.quantity.Force; -import javax.measure.unit.SI; -import javax.measure.unit.Unit; -import javax.swing.JPanel; - -import org.jfree.chart.ChartFactory; -import org.jfree.chart.ChartPanel; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.PlotOrientation; -import org.jfree.data.xy.XYSeries; -import org.jfree.data.xy.XYSeriesCollection; - -import com.billkuker.rocketry.motorsim.Burn; -import com.billkuker.rocketry.motorsim.RocketScience; - -public class MultiBurnChart extends JPanel implements BurnWatcher { - private static final long serialVersionUID = 1L; - - private XYSeriesCollection dataset = new XYSeriesCollection(); - - private HashMap burnToSeries = new HashMap(); - private Unit time; - private Unit force; - - public MultiBurnChart() { - this.setLayout(new BorderLayout()); - time = RocketScience.UnitPreference.getUnitPreference() - .getPreferredUnit(SI.SECOND); - force = RocketScience.UnitPreference.getUnitPreference() - .getPreferredUnit(SI.NEWTON); - JFreeChart chart = ChartFactory.createXYLineChart( - "", // Title - "Time (" + time.toString() + ")", // x-axis Label - "Thrust (" + force.toString() + ")", // y-axis Label - dataset, PlotOrientation.VERTICAL, // Plot Orientation - true, // Show Legend - true, // Use tool tips - false // Configure chart to generate URLs? - ); - add(new ChartPanel(chart)); - } - - public void addBurn(Burn b) { - XYSeries s = createSeries(b); - burnToSeries.put(b, s); - dataset.addSeries(s); - } - - private XYSeries createSeries(Burn b) { - XYSeries s = new XYSeries(b.getMotor().getName()); - for( Burn.Interval i : b.getData().values() ){ - s.add(i.time.doubleValue(time), i.thrust.doubleValue(force)); - } - return s; - } - - public void removeBurn(Burn b) { - XYSeries s = burnToSeries.get(b); - if (s == null) - return; - dataset.removeSeries(s); - } - - @Override - public void replace(Burn oldBurn, Burn newBurn) { - removeBurn(oldBurn); - addBurn(newBurn); - } -} diff --git a/gui/com/billkuker/rocketry/motorsim/visual/workbench/MultiMotorThrustChart.java b/gui/com/billkuker/rocketry/motorsim/visual/workbench/MultiMotorThrustChart.java new file mode 100644 index 0000000..6a9d9fc --- /dev/null +++ b/gui/com/billkuker/rocketry/motorsim/visual/workbench/MultiMotorThrustChart.java @@ -0,0 +1,75 @@ +package com.billkuker.rocketry.motorsim.visual.workbench; + +import java.awt.BorderLayout; +import java.util.HashMap; + +import javax.measure.quantity.Duration; +import javax.measure.quantity.Force; +import javax.measure.unit.SI; +import javax.measure.unit.Unit; +import javax.swing.JPanel; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; + +import com.billkuker.rocketry.motorsim.Burn; +import com.billkuker.rocketry.motorsim.RocketScience; + +public class MultiMotorThrustChart extends JPanel implements BurnWatcher { + private static final long serialVersionUID = 1L; + + private XYSeriesCollection dataset = new XYSeriesCollection(); + + private HashMap burnToSeries = new HashMap(); + private Unit time; + private Unit force; + + public MultiMotorThrustChart() { + this.setLayout(new BorderLayout()); + time = RocketScience.UnitPreference.getUnitPreference() + .getPreferredUnit(SI.SECOND); + force = RocketScience.UnitPreference.getUnitPreference() + .getPreferredUnit(SI.NEWTON); + JFreeChart chart = ChartFactory.createXYLineChart( + "", // Title + "Time (" + time.toString() + ")", // x-axis Label + "Thrust (" + force.toString() + ")", // y-axis Label + dataset, PlotOrientation.VERTICAL, // Plot Orientation + true, // Show Legend + true, // Use tool tips + false // Configure chart to generate URLs? + ); + add(new ChartPanel(chart)); + } + + public void addBurn(Burn b) { + XYSeries s = createSeries(b); + burnToSeries.put(b, s); + dataset.addSeries(s); + } + + private XYSeries createSeries(Burn b) { + XYSeries s = new XYSeries(b.getMotor().getName()); + for( Burn.Interval i : b.getData().values() ){ + s.add(i.time.doubleValue(time), i.thrust.doubleValue(force)); + } + return s; + } + + public void removeBurn(Burn b) { + XYSeries s = burnToSeries.get(b); + if (s == null) + return; + dataset.removeSeries(s); + } + + @Override + public void replace(Burn oldBurn, Burn newBurn) { + removeBurn(oldBurn); + addBurn(newBurn); + } +}