diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index c1958ea59..32a03ec9e 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -720,6 +720,11 @@ simplotpanel.RIGHT_NAME = Right simplotpanel.CUSTOM = Custom SimulationPlotPanel.error.noPlotSelected = Please add one or more variables to plot on the Y-axis. SimulationPlotPanel.error.noPlotSelected.title = Nothing to plot +simplotpanel.MarkerStyle.lbl.MarkerStyle = Marker style: +simplotpanel.MarkerStyle.lbl.MarkerStyle.ttip = Style of the flight event marker (how it's drawn in the simulation plot) +simplotpanel.MarkerStyle.btn.VerticalMarker = Vertical line +simplotpanel.MarkerStyle.btn.Icon = Icon +simplotpanel.MarkerStyle.OnlyInTime = Only available for time domain, other domains only support icon markers ! Component add buttons compaddbuttons.AxialStage = Stage @@ -1150,6 +1155,8 @@ NoseConeCfg.tab.General = General NoseConeCfg.tab.ttip.General = General properties NoseConeCfg.tab.Shoulder = Shoulder NoseConeCfg.tab.ttip.Shoulder = Shoulder properties +NoseConeCfg.checkbox.Flip = Flip to tail cone +NoseConeCfg.checkbox.Flip.ttip = Flips the nose cone direction to a tail cone. ! ParachuteConfig Parachute.Parachute = Parachute diff --git a/core/src/net/sf/openrocket/startup/Preferences.java b/core/src/net/sf/openrocket/startup/Preferences.java index 26b9b1095..f9c31bd82 100644 --- a/core/src/net/sf/openrocket/startup/Preferences.java +++ b/core/src/net/sf/openrocket/startup/Preferences.java @@ -76,6 +76,7 @@ public abstract class Preferences implements ChangeSource { public static final String PREFERRED_THRUST_CURVE_MOTOR_NODE = "preferredThrustCurveMotors"; private static final String AUTO_OPEN_LAST_DESIGN = "AUTO_OPEN_LAST_DESIGN"; private static final String OPEN_LEFTMOST_DESIGN_TAB = "OPEN_LEFTMOST_DESIGN_TAB"; + public static final String MARKER_STYLE_ICON = "MARKER_STYLE_ICON"; private static final String SHOW_MARKERS = "SHOW_MARKERS"; private static final String SHOW_ROCKSIM_FORMAT_WARNING = "SHOW_ROCKSIM_FORMAT_WARNING"; diff --git a/core/src/net/sf/openrocket/util/LinearInterpolator.java b/core/src/net/sf/openrocket/util/LinearInterpolator.java index e16726bb5..8a9e786ac 100644 --- a/core/src/net/sf/openrocket/util/LinearInterpolator.java +++ b/core/src/net/sf/openrocket/util/LinearInterpolator.java @@ -82,7 +82,7 @@ public class LinearInterpolator implements Cloneable { if ( y1 != null ) { // Wow, x was a key in the map. Such luck. - return y1.doubleValue(); + return y1; } // we now know that x is not in the map, so we need to find the lower and higher keys. @@ -96,16 +96,16 @@ public class LinearInterpolator implements Cloneable { Double firstKey = sortMap.firstKey(); // x is smaller than the first entry in the map. - if ( x < firstKey.doubleValue() ) { + if ( x < firstKey) { y1 = sortMap.get(firstKey); - return y1.doubleValue(); + return y1; } // floor key is the largest key smaller than x - since we have at least one key, // and x>=firstKey, we know that floorKey != null. Double floorKey = sortMap.subMap(firstKey, x).lastKey(); - x1 = floorKey.doubleValue(); + x1 = floorKey; y1 = sortMap.get(floorKey); // Now we need to find the key that is greater or equal to x @@ -113,16 +113,16 @@ public class LinearInterpolator implements Cloneable { // Check if x is bigger than all the entries. if ( tailMap.isEmpty() ) { - return y1.doubleValue(); + return y1; } Double ceilKey = tailMap.firstKey(); // Check if x is bigger than all the entries. if ( ceilKey == null ) { - return y1.doubleValue(); + return y1; } - x2 = ceilKey.doubleValue(); + x2 = ceilKey; y2 = sortMap.get(ceilKey); return (x - x1)/(x2-x1) * (y2-y1) + y1; diff --git a/core/test/net/sf/openrocket/simulation/FlightEventsTest.java b/core/test/net/sf/openrocket/simulation/FlightEventsTest.java index 4aa1df57f..1069d67f5 100644 --- a/core/test/net/sf/openrocket/simulation/FlightEventsTest.java +++ b/core/test/net/sf/openrocket/simulation/FlightEventsTest.java @@ -24,6 +24,8 @@ import static org.junit.Assert.assertSame; * Tests to verify that simulations contain all the expected flight events. */ public class FlightEventsTest extends BaseTestCase { + private static final double EPSILON = 0.005; + /** * Tests for a single stage design. */ @@ -66,7 +68,7 @@ public class FlightEventsTest extends BaseTestCase { // Test that the event times are correct for (int i = 0; i < expectedEventTimes.length; i++) { assertEquals(" Flight type " + expectedEventTypes[i] + " has wrong time", - expectedEventTimes[i], eventList.get(i).getTime(), 0.002); + expectedEventTimes[i], eventList.get(i).getTime(), EPSILON); } @@ -142,7 +144,7 @@ public class FlightEventsTest extends BaseTestCase { // Test that the event times are correct for (int i = 0; i < expectedEventTimes.length; i++) { assertEquals(" Flight type " + expectedEventTypes[i] + " has wrong time", - expectedEventTimes[i], eventList.get(i).getTime(), 0.002); + expectedEventTimes[i], eventList.get(i).getTime(), EPSILON); } // Test that the event sources are correct diff --git a/swing/resources/datafiles/examples/A simple model rocket.ork b/swing/resources/datafiles/examples/A simple model rocket.ork index 3d2fb7bae..e56383db5 100644 Binary files a/swing/resources/datafiles/examples/A simple model rocket.ork and b/swing/resources/datafiles/examples/A simple model rocket.ork differ diff --git a/swing/resources/datafiles/examples/Airstart timing.ork b/swing/resources/datafiles/examples/Airstart timing.ork new file mode 100644 index 000000000..5b58f5bdf Binary files /dev/null and b/swing/resources/datafiles/examples/Airstart timing.ork differ diff --git a/swing/resources/datafiles/examples/Apocalypse with decals.ork b/swing/resources/datafiles/examples/Apocalypse with decals.ork deleted file mode 100644 index e059b4a4e..000000000 Binary files a/swing/resources/datafiles/examples/Apocalypse with decals.ork and /dev/null differ diff --git a/swing/resources/datafiles/examples/Boosted Dart.ork b/swing/resources/datafiles/examples/Boosted Dart.ork deleted file mode 100644 index 056e3e9c5..000000000 Binary files a/swing/resources/datafiles/examples/Boosted Dart.ork and /dev/null differ diff --git a/swing/resources/datafiles/examples/Chute release.ork b/swing/resources/datafiles/examples/Chute release.ork new file mode 100644 index 000000000..aa6705928 Binary files /dev/null and b/swing/resources/datafiles/examples/Chute release.ork differ diff --git a/swing/resources/datafiles/examples/Clustered motors.ork b/swing/resources/datafiles/examples/Clustered motors.ork new file mode 100644 index 000000000..16fdd59a5 Binary files /dev/null and b/swing/resources/datafiles/examples/Clustered motors.ork differ diff --git a/swing/resources/datafiles/examples/Clustered rocket design.ork b/swing/resources/datafiles/examples/Clustered rocket design.ork deleted file mode 100644 index 6cc2f28c9..000000000 Binary files a/swing/resources/datafiles/examples/Clustered rocket design.ork and /dev/null differ diff --git a/swing/resources/datafiles/examples/Dual Deploy.ork b/swing/resources/datafiles/examples/Dual Deploy.ork deleted file mode 100644 index 0d2821e93..000000000 Binary files a/swing/resources/datafiles/examples/Dual Deploy.ork and /dev/null differ diff --git a/swing/resources/datafiles/examples/Dual parachute deployment.ork b/swing/resources/datafiles/examples/Dual parachute deployment.ork new file mode 100644 index 000000000..008270a8e Binary files /dev/null and b/swing/resources/datafiles/examples/Dual parachute deployment.ork differ diff --git a/swing/resources/datafiles/examples/High Power Airstart.ork b/swing/resources/datafiles/examples/High Power Airstart.ork deleted file mode 100644 index 479880efb..000000000 Binary files a/swing/resources/datafiles/examples/High Power Airstart.ork and /dev/null differ diff --git a/swing/resources/datafiles/examples/Hybrid rocket with dual parachute deployment.ork b/swing/resources/datafiles/examples/Hybrid rocket with dual parachute deployment.ork deleted file mode 100644 index 574c89c57..000000000 Binary files a/swing/resources/datafiles/examples/Hybrid rocket with dual parachute deployment.ork and /dev/null differ diff --git a/swing/resources/datafiles/examples/Parallel Staging Example.ork b/swing/resources/datafiles/examples/Parallel Staging Example.ork deleted file mode 100644 index 9b4ea51f1..000000000 Binary files a/swing/resources/datafiles/examples/Parallel Staging Example.ork and /dev/null differ diff --git a/swing/resources/datafiles/examples/Parallel booster staging.ork b/swing/resources/datafiles/examples/Parallel booster staging.ork new file mode 100644 index 000000000..7543c2951 Binary files /dev/null and b/swing/resources/datafiles/examples/Parallel booster staging.ork differ diff --git a/swing/resources/datafiles/examples/Pods Example.ork b/swing/resources/datafiles/examples/Pods Example.ork deleted file mode 100644 index c305c91ba..000000000 Binary files a/swing/resources/datafiles/examples/Pods Example.ork and /dev/null differ diff --git a/swing/resources/datafiles/examples/Pods--airframes and winglets.ork b/swing/resources/datafiles/examples/Pods--airframes and winglets.ork new file mode 100644 index 000000000..381a0d4e4 Binary files /dev/null and b/swing/resources/datafiles/examples/Pods--airframes and winglets.ork differ diff --git a/swing/resources/datafiles/examples/Pods--powered with recovery deployment.ork b/swing/resources/datafiles/examples/Pods--powered with recovery deployment.ork new file mode 100644 index 000000000..35b61c011 Binary files /dev/null and b/swing/resources/datafiles/examples/Pods--powered with recovery deployment.ork differ diff --git a/swing/resources/datafiles/examples/Preset Usage.ork b/swing/resources/datafiles/examples/Preset Usage.ork deleted file mode 100644 index afb1cfb00..000000000 Binary files a/swing/resources/datafiles/examples/Preset Usage.ork and /dev/null differ diff --git a/swing/resources/datafiles/examples/Presets.ork b/swing/resources/datafiles/examples/Presets.ork new file mode 100644 index 000000000..5812e0d38 Binary files /dev/null and b/swing/resources/datafiles/examples/Presets.ork differ diff --git a/swing/resources/datafiles/examples/Simulation Extension.ork b/swing/resources/datafiles/examples/Simulation Extension.ork deleted file mode 100644 index 6f8243e9d..000000000 Binary files a/swing/resources/datafiles/examples/Simulation Extension.ork and /dev/null differ diff --git a/swing/resources/datafiles/examples/Simulation extensions and scripting.ork b/swing/resources/datafiles/examples/Simulation extensions and scripting.ork index e84fc0d9d..dc0d416b1 100644 Binary files a/swing/resources/datafiles/examples/Simulation extensions and scripting.ork and b/swing/resources/datafiles/examples/Simulation extensions and scripting.ork differ diff --git a/swing/resources/datafiles/examples/Simulation extensions.ork b/swing/resources/datafiles/examples/Simulation extensions.ork new file mode 100644 index 000000000..1ba1d3c06 Binary files /dev/null and b/swing/resources/datafiles/examples/Simulation extensions.ork differ diff --git a/swing/resources/datafiles/examples/TARC Payloader.ork b/swing/resources/datafiles/examples/TARC Payloader.ork deleted file mode 100644 index 0482ad09a..000000000 Binary files a/swing/resources/datafiles/examples/TARC Payloader.ork and /dev/null differ diff --git a/swing/resources/datafiles/examples/TARC payload rocket.ork b/swing/resources/datafiles/examples/TARC payload rocket.ork new file mode 100644 index 000000000..f209f2f0c Binary files /dev/null and b/swing/resources/datafiles/examples/TARC payload rocket.ork differ diff --git a/swing/resources/datafiles/examples/Three-stage rocket.ork b/swing/resources/datafiles/examples/Three-stage rocket.ork index e8cb67662..3d90fce6e 100644 Binary files a/swing/resources/datafiles/examples/Three-stage rocket.ork and b/swing/resources/datafiles/examples/Three-stage rocket.ork differ diff --git a/swing/resources/datafiles/examples/Tube Fin.ork b/swing/resources/datafiles/examples/Tube Fin.ork deleted file mode 100644 index c176ce02c..000000000 Binary files a/swing/resources/datafiles/examples/Tube Fin.ork and /dev/null differ diff --git a/swing/resources/datafiles/examples/Tube fin rocket.ork b/swing/resources/datafiles/examples/Tube fin rocket.ork new file mode 100644 index 000000000..e6a56ba32 Binary files /dev/null and b/swing/resources/datafiles/examples/Tube fin rocket.ork differ diff --git a/swing/resources/datafiles/examples/Two-stage rocket.ork b/swing/resources/datafiles/examples/Two-stage rocket.ork new file mode 100644 index 000000000..8871b0e4c Binary files /dev/null and b/swing/resources/datafiles/examples/Two-stage rocket.ork differ diff --git a/swing/src/net/sf/openrocket/gui/main/ExampleDesignFileAction.java b/swing/src/net/sf/openrocket/gui/main/ExampleDesignFileAction.java index 6fc0f39a2..64abf6dc0 100644 --- a/swing/src/net/sf/openrocket/gui/main/ExampleDesignFileAction.java +++ b/swing/src/net/sf/openrocket/gui/main/ExampleDesignFileAction.java @@ -1,6 +1,8 @@ package net.sf.openrocket.gui.main; import java.awt.event.ActionEvent; +import java.util.ArrayList; +import java.util.List; import javax.swing.AbstractAction; import javax.swing.Action; @@ -18,6 +20,35 @@ public final class ExampleDesignFileAction extends JMenu { */ private final BasicFrame parent; + /** + * Order in which the example files should be displayed in the menu. + * A null items means there should be a separator. + *
+ * NOTE: update this list if you add a new example file, or update the name of an existing one!!.
+ */
+ private static final String[] exampleFileOrder = {
+ // Examples of basic rockets
+ "A simple model rocket",
+ "Two-stage rocket",
+ "Three-stage rocket",
+ "TARC payload rocket",
+ "Tube fin rocket",
+ null,
+ // Examples demonstrating complex rocket features
+ "Airstart timing",
+ "Chute release",
+ "Dual parachute deployment",
+ "Clustered motors",
+ "Parallel booster staging",
+ "Pods--airframes and winglets",
+ "Pods--powered with recovery deployment",
+ null,
+ // Examples demonstrating customized functionality
+ "Presets",
+ "Simulation extensions",
+ "Simulation extensions and scripting"
+ };
+
/**
* Constructor.
*
@@ -38,11 +69,37 @@ public final class ExampleDesignFileAction extends JMenu {
private void updateMenu() {
removeAll();
ExampleDesignFile[] examples = ExampleDesignFile.getExampleDesigns();
+ List
" +
- "Y: %s %s
" +
- "X: %s %s
" +
- "%d%s sample" +
- "",
- name, df_y.format(data_y), unit_y,
- df_x.format(data_x), unit_x, item, ord_end);
+ String unitX = domainUnit.getUnit();
+
+ double dataY = dataset.getYValue(series, item);
+ double dataX = dataset.getXValue(series, item);
+
+ return formatSampleTooltip(name, dataX, unitX, dataY, unitY, item);
}
};
@@ -364,6 +356,42 @@ public class SimulationPlot {
return chart;
}
+ private String formatSampleTooltip(String dataName, double dataX, String unitX, double dataY, String unitY, int sampleIdx, boolean addYValue) {
+ String ord_end = "th"; // Ordinal number ending (1'st', 2'nd'...)
+ if (sampleIdx % 10 == 1) {
+ ord_end = "st";
+ } else if (sampleIdx % 10 == 2) {
+ ord_end = "nd";
+ } else if (sampleIdx % 10 == 3) {
+ ord_end = "rd";
+ }
+
+ DecimalFormat df_y = DecimalFormatter.df(dataY, 2, false);
+ DecimalFormat df_x = DecimalFormatter.df(dataX, 2, false);
+
+ StringBuilder sb = new StringBuilder();
+ sb.append(String.format("" +
+ "%s
", dataName));
+
+ if (addYValue) {
+ sb.append(String.format("Y: %s %s
", df_y.format(dataY), unitY));
+ }
+
+ sb.append(String.format("X: %s %s
" +
+ "%d%s sample" +
+ "", df_x.format(dataX), unitX, sampleIdx, ord_end));
+
+ return sb.toString();
+ }
+
+ private String formatSampleTooltip(String dataName, double dataX, String unitX, double dataY, String unitY, int sampleIdx) {
+ return formatSampleTooltip(dataName, dataX, unitX, dataY, unitY, sampleIdx, true);
+ }
+
+ private String formatSampleTooltip(String dataName, double dataX, String unitX, int sampleIdx) {
+ return formatSampleTooltip(dataName, dataX, unitX, 0, "", sampleIdx, false);
+ }
+
private String getLabel(FlightDataType type, Unit unit) {
String name = type.getName();
if (unit != null && !UnitGroup.UNITS_NONE.contains(unit) &&
@@ -372,129 +400,166 @@ public class SimulationPlot {
return name;
}
- private void drawDomainMarkers(int stage) {
+ /**
+ * Draw the domain markers for a certain branch. Draws all the markers if the branch is -1.
+ * @param branch branch to draw, or -1 to draw all
+ */
+ private void drawDomainMarkers(int branch) {
XYPlot plot = chart.getXYPlot();
- FlightDataBranch mainBranch = simulation.getSimulatedData().getBranch(0);
+ FlightDataBranch dataBranch = simulation.getSimulatedData().getBranch(Math.max(branch, 0));
- // Clear existing domain markers
+ // Clear existing domain markers and annotations
plot.clearDomainMarkers();
+ plot.clearAnnotations();
- // Construct domain marker lists collapsing based on time.
+ // Store flight event information
+ List