reset
is true
- * then sets the selected value as the value closest to selectedDelay, otherwise
- * leaves selection alone.
- */
- private void setDelays(boolean reset) {
- if (selectedMotor == null) {
-
- delayBox.setModel(new DefaultComboBoxModel(new String[] { "None" }));
- delayBox.setSelectedIndex(0);
-
- } else {
-
- double[] delays = selectedMotor.getStandardDelays();
- String[] delayStrings = new String[delays.length];
- double currentDelay = selectedDelay; // Store current setting locally
-
- for (int i = 0; i < delays.length; i++) {
- delayStrings[i] = ThrustCurveMotor.getDelayString(delays[i], "None");
- }
- delayBox.setModel(new DefaultComboBoxModel(delayStrings));
-
- if (reset) {
-
- // Find and set the closest value
- double closest = Double.NaN;
- for (int i = 0; i < delays.length; i++) {
- // if-condition to always become true for NaN
- if (!(Math.abs(delays[i] - currentDelay) > Math.abs(closest - currentDelay))) {
- closest = delays[i];
- }
- }
- if (!Double.isNaN(closest)) {
- selectedDelay = closest;
- delayBox.setSelectedItem(ThrustCurveMotor.getDelayString(closest, "None"));
- } else {
- delayBox.setSelectedItem("None");
- }
-
- } else {
-
- selectedDelay = currentDelay;
- delayBox.setSelectedItem(ThrustCurveMotor.getDelayString(currentDelay, "None"));
-
- }
-
- }
- }
-
-
-
- public ThrustCurveMotor getSelectedMotor() {
- if (!okClicked)
- return null;
- return selectedMotor;
- }
-
-
- public double getSelectedDelay() {
- return selectedDelay;
- }
-
-
-
-
- //////////////// JTable elements ////////////////
-
-
- /**
- * Enum defining the table columns.
- */
- private enum MotorColumns {
- MANUFACTURER("Manufacturer", 100) {
- @Override
- public String getValue(ThrustCurveMotor m) {
- return m.getManufacturer().getDisplayName();
- }
-
- @Override
- public Comparator> getComparator() {
- return Collator.getInstance();
- }
- },
- DESIGNATION("Designation") {
- @Override
- public String getValue(ThrustCurveMotor m) {
- return m.getDesignation();
- }
-
- @Override
- public Comparator> getComparator() {
- return new DesignationComparator();
- }
- },
- TYPE("Type") {
- @Override
- public String getValue(ThrustCurveMotor m) {
- return m.getMotorType().getName();
- }
-
- @Override
- public Comparator> getComparator() {
- return Collator.getInstance();
- }
- },
- DIAMETER("Diameter") {
- @Override
- public Object getValue(ThrustCurveMotor m) {
- return new Value(m.getDiameter(), UnitGroup.UNITS_MOTOR_DIMENSIONS);
- }
-
- @Override
- public Comparator> getComparator() {
- return ValueComparator.INSTANCE;
- }
- },
- LENGTH("Length") {
- @Override
- public Object getValue(ThrustCurveMotor m) {
- return new Value(m.getLength(), UnitGroup.UNITS_MOTOR_DIMENSIONS);
- }
-
- @Override
- public Comparator> getComparator() {
- return ValueComparator.INSTANCE;
- }
- },
- IMPULSE("Impulse") {
- @Override
- public Object getValue(ThrustCurveMotor m) {
- return new Value(m.getTotalImpulseEstimate(), UnitGroup.UNITS_IMPULSE);
- }
-
- @Override
- public Comparator> getComparator() {
- return ValueComparator.INSTANCE;
- }
- },
- TIME("Burn time") {
- @Override
- public Object getValue(ThrustCurveMotor m) {
- return new Value(m.getBurnTimeEstimate(), UnitGroup.UNITS_SHORT_TIME);
- }
-
- @Override
- public Comparator> getComparator() {
- return ValueComparator.INSTANCE;
- }
- };
-
-
- private final String title;
- private final int width;
-
- MotorColumns(String title) {
- this(title, 50);
- }
-
- MotorColumns(String title, int width) {
- this.title = title;
- this.width = width;
- }
-
-
- public abstract Object getValue(ThrustCurveMotor m);
-
- public abstract Comparator> getComparator();
-
- public String getTitle() {
- return title;
- }
-
- public int getWidth() {
- return width;
- }
-
- public String getToolTipText(ThrustCurveMotor m) {
- String tip = "";
- tip += "" + m.toString() + "";
- tip += " (" + m.getMotorType().getDescription() + ")null
+ */
+ public static void check(Window parent) {
+ final ThrustCurveMotorSetDatabase db = Application.getMotorSetDatabase();
+ if (db.isLoaded())
+ return;
+
+ log.info(1, "Motor database not loaded yet, displaying dialog");
+
+ final MotorDatabaseLoadingDialog dialog = new MotorDatabaseLoadingDialog(parent);
+
+ final Timer timer = new Timer(100, new ActionListener() {
+ private int count = 0;
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ count++;
+ if (db.isLoaded()) {
+ log.debug("Database loaded, closing dialog");
+ dialog.setVisible(false);
+ } else if (count % 10 == 0) {
+ log.debug("Database not loaded, count=" + count);
+ }
+ }
+ });
+
+ db.setInUse();
+ timer.start();
+ dialog.setVisible(true);
+ timer.stop();
+
+ log.debug("Motor database now loaded");
+ }
+
+}
diff --git a/src/net/sf/openrocket/gui/dialogs/motor/CloseableDialog.java b/src/net/sf/openrocket/gui/dialogs/motor/CloseableDialog.java
new file mode 100644
index 000000000..48e58a0fe
--- /dev/null
+++ b/src/net/sf/openrocket/gui/dialogs/motor/CloseableDialog.java
@@ -0,0 +1,12 @@
+package net.sf.openrocket.gui.dialogs.motor;
+
+public interface CloseableDialog {
+
+ /**
+ * Close this dialog.
+ *
+ * @param ok whether "OK" should be considered to have been clicked.
+ */
+ public void close(boolean ok);
+
+}
diff --git a/src/net/sf/openrocket/gui/dialogs/motor/MotorChooserDialog.java b/src/net/sf/openrocket/gui/dialogs/motor/MotorChooserDialog.java
new file mode 100644
index 000000000..2258251f4
--- /dev/null
+++ b/src/net/sf/openrocket/gui/dialogs/motor/MotorChooserDialog.java
@@ -0,0 +1,112 @@
+package net.sf.openrocket.gui.dialogs.motor;
+
+
+import java.awt.Dialog;
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JPanel;
+
+import net.miginfocom.swing.MigLayout;
+import net.sf.openrocket.gui.dialogs.MotorDatabaseLoadingDialog;
+import net.sf.openrocket.gui.dialogs.motor.thrustcurve.ThrustCurveMotorSelectionPanel;
+import net.sf.openrocket.motor.Motor;
+import net.sf.openrocket.motor.ThrustCurveMotor;
+import net.sf.openrocket.util.GUIUtil;
+
+public class MotorChooserDialog extends JDialog implements CloseableDialog {
+
+ private final ThrustCurveMotorSelectionPanel selectionPanel;
+
+ private boolean okClicked = false;
+
+
+ public MotorChooserDialog(Motor current, double delay, double diameter, Window owner) {
+ super(owner, "Select a rocket motor", Dialog.ModalityType.APPLICATION_MODAL);
+
+ // Check that the motor database has been loaded properly
+ MotorDatabaseLoadingDialog.check(null);
+
+
+ JPanel panel = new JPanel(new MigLayout("fill"));
+
+ selectionPanel = new ThrustCurveMotorSelectionPanel((ThrustCurveMotor) current, delay, diameter);
+
+ panel.add(selectionPanel, "grow, wrap para");
+
+
+ // OK / Cancel buttons
+
+ JButton okButton = new JButton("OK");
+ okButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ close(true);
+ }
+ });
+ panel.add(okButton, "tag ok, spanx, split");
+
+ JButton cancelButton = new JButton("Cancel");
+ cancelButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ close(false);
+ }
+ });
+ panel.add(cancelButton, "tag cancel");
+
+ this.add(panel);
+
+ this.setModal(true);
+ this.pack();
+ this.setLocationByPlatform(true);
+ GUIUtil.setDisposableDialogOptions(this, okButton);
+
+ JComponent focus = selectionPanel.getDefaultFocus();
+ if (focus != null) {
+ focus.grabFocus();
+ }
+
+ // Set the closeable dialog after all initialization
+ selectionPanel.setCloseableDialog(this);
+ }
+
+
+ /**
+ * Return the motor selected by this chooser dialog, or null
if the selection has been aborted.
+ *
+ * @return the selected motor, or null
if no motor has been selected or the selection was canceled.
+ */
+ public Motor getSelectedMotor() {
+ if (!okClicked)
+ return null;
+ return selectionPanel.getSelectedMotor();
+ }
+
+ /**
+ * Return the selected ejection charge delay.
+ *
+ * @return the selected ejection charge delay.
+ */
+ public double getSelectedDelay() {
+ return selectionPanel.getSelectedDelay();
+ }
+
+
+
+ @Override
+ public void close(boolean ok) {
+ okClicked = ok;
+ this.setVisible(false);
+
+ Motor selected = getSelectedMotor();
+ if (okClicked && selected != null) {
+ selectionPanel.selectedMotor(selected);
+ }
+ }
+
+}
diff --git a/src/net/sf/openrocket/gui/dialogs/motor/MotorSelector.java b/src/net/sf/openrocket/gui/dialogs/motor/MotorSelector.java
new file mode 100644
index 000000000..23bd9984c
--- /dev/null
+++ b/src/net/sf/openrocket/gui/dialogs/motor/MotorSelector.java
@@ -0,0 +1,38 @@
+package net.sf.openrocket.gui.dialogs.motor;
+
+import javax.swing.JComponent;
+
+import net.sf.openrocket.motor.Motor;
+
+public interface MotorSelector {
+
+ /**
+ * Return the currently selected motor.
+ *
+ * @return the currently selected motor, or null
if no motor is selected.
+ */
+ public Motor getSelectedMotor();
+
+ /**
+ * Return the currently selected ejection charge delay.
+ *
+ * @return the currently selected ejection charge delay.
+ */
+ public double getSelectedDelay();
+
+ /**
+ * Return the component that should have the default focus in this motor selector panel.
+ *
+ * @return the component that should have default focus, or null
for none.
+ */
+ public JComponent getDefaultFocus();
+
+ /**
+ * Notify that the provided motor has been selected. This can be used to store preference
+ * data for later usage.
+ *
+ * @param m the motor that was selected.
+ */
+ public void selectedMotor(Motor m);
+
+}
diff --git a/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/MotorHolder.java b/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/MotorHolder.java
new file mode 100644
index 000000000..bb8113331
--- /dev/null
+++ b/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/MotorHolder.java
@@ -0,0 +1,40 @@
+package net.sf.openrocket.gui.dialogs.motor.thrustcurve;
+
+import net.sf.openrocket.motor.ThrustCurveMotor;
+
+class MotorHolder {
+
+ private final ThrustCurveMotor motor;
+ private final int index;
+
+ public MotorHolder(ThrustCurveMotor motor, int index) {
+ this.motor = motor;
+ this.index = index;
+ }
+
+ public ThrustCurveMotor getMotor() {
+ return motor;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ @Override
+ public String toString() {
+ return motor.getDesignation();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof MotorHolder))
+ return false;
+ MotorHolder other = (MotorHolder) obj;
+ return this.motor.equals(other.motor);
+ }
+
+ @Override
+ public int hashCode() {
+ return motor.hashCode();
+ }
+}
diff --git a/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorColumns.java b/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorColumns.java
new file mode 100644
index 000000000..145a9956e
--- /dev/null
+++ b/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorColumns.java
@@ -0,0 +1,136 @@
+package net.sf.openrocket.gui.dialogs.motor.thrustcurve;
+
+import java.text.Collator;
+import java.util.Comparator;
+
+import net.sf.openrocket.database.ThrustCurveMotorSet;
+import net.sf.openrocket.motor.DesignationComparator;
+import net.sf.openrocket.motor.ThrustCurveMotor;
+import net.sf.openrocket.unit.UnitGroup;
+import net.sf.openrocket.unit.Value;
+import net.sf.openrocket.unit.ValueComparator;
+
+/**
+ * Enum defining the table columns.
+ */
+enum ThrustCurveMotorColumns {
+ MANUFACTURER("Manufacturer", 100) {
+ @Override
+ public String getValue(ThrustCurveMotorSet m) {
+ return m.getManufacturer().getDisplayName();
+ }
+
+ @Override
+ public Comparator> getComparator() {
+ return Collator.getInstance();
+ }
+ },
+ DESIGNATION("Designation") {
+ @Override
+ public String getValue(ThrustCurveMotorSet m) {
+ return m.getDesignation();
+ }
+
+ @Override
+ public Comparator> getComparator() {
+ return new DesignationComparator();
+ }
+ },
+ TYPE("Type") {
+ @Override
+ public String getValue(ThrustCurveMotorSet m) {
+ return m.getType().getName();
+ }
+
+ @Override
+ public Comparator> getComparator() {
+ return Collator.getInstance();
+ }
+ },
+ DIAMETER("Diameter") {
+ @Override
+ public Object getValue(ThrustCurveMotorSet m) {
+ return new Value(m.getDiameter(), UnitGroup.UNITS_MOTOR_DIMENSIONS);
+ }
+
+ @Override
+ public Comparator> getComparator() {
+ return ValueComparator.INSTANCE;
+ }
+ },
+ LENGTH("Length") {
+ @Override
+ public Object getValue(ThrustCurveMotorSet m) {
+ return new Value(m.getLength(), UnitGroup.UNITS_MOTOR_DIMENSIONS);
+ }
+
+ @Override
+ public Comparator> getComparator() {
+ return ValueComparator.INSTANCE;
+ }
+ };
+
+
+ private final String title;
+ private final int width;
+
+ ThrustCurveMotorColumns(String title) {
+ this(title, 50);
+ }
+
+ ThrustCurveMotorColumns(String title, int width) {
+ this.title = title;
+ this.width = width;
+ }
+
+
+ public abstract Object getValue(ThrustCurveMotorSet m);
+
+ public abstract Comparator> getComparator();
+
+ public String getTitle() {
+ return title;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
+ public String getToolTipText(ThrustCurveMotor m) {
+ String tip = "";
+ tip += "" + m.toString() + "";
+ tip += " (" + m.getMotorType().getDescription() + ")null
for none.
+ * @param delay the currently selected ejection charge delay.
+ * @param diameter the diameter of the motor mount.
+ */
+ public ThrustCurveMotorSelectionPanel(ThrustCurveMotor current, double delay, double diameter) {
+ super(new MigLayout("fill", "[grow][]"));
+
+ this.diameter = diameter;
+
+
+ // Construct the database (adding the current motor if not in the db already)
+ Listreset
is true
+ * then sets the selected value as the value closest to selectedDelay, otherwise
+ * leaves selection alone.
+ */
+ private void setDelays(boolean reset) {
+ if (selectedMotor == null) {
+
+ delayBox.setModel(new DefaultComboBoxModel(new String[] { "None" }));
+ delayBox.setSelectedIndex(0);
+
+ } else {
+
+ Listfalse
is returned.
@@ -856,7 +866,7 @@ public class BasicFrame extends JFrame {
return open(worker, file.getName(), file, parent);
}
-
+
/**
* Open the specified file using the provided worker.
*
@@ -866,49 +876,51 @@ public class BasicFrame extends JFrame {
* @param parent
* @return
*/
- private static boolean open(OpenFileWorker worker, String filename, File file,
+ private static boolean open(OpenFileWorker worker, String filename, File file,
Window parent) {
-
+
+ MotorDatabaseLoadingDialog.check(null);
+
// Open the file in a Swing worker thread
- if (!SwingWorkerDialog.runWorker(parent, "Opening file",
+ if (!SwingWorkerDialog.runWorker(parent, "Opening file",
"Reading " + filename + "...", worker)) {
-
+
// User cancelled the operation
return false;
}
-
+
// Handle the document
OpenRocketDocument doc = null;
try {
-
+
doc = worker.get();
-
+
} catch (ExecutionException e) {
-
+
Throwable cause = e.getCause();
-
+
if (cause instanceof FileNotFoundException) {
-
- JOptionPane.showMessageDialog(parent,
+
+ JOptionPane.showMessageDialog(parent,
"File not found: " + filename,
"Error opening file", JOptionPane.ERROR_MESSAGE);
return false;
-
+
} else if (cause instanceof RocketLoadException) {
-
- JOptionPane.showMessageDialog(parent,
- "Unable to open file '" + filename +"': "
- + cause.getMessage(),
+
+ JOptionPane.showMessageDialog(parent,
+ "Unable to open file '" + filename + "': "
+ + cause.getMessage(),
"Error opening file", JOptionPane.ERROR_MESSAGE);
return false;
-
+
} else {
-
+
throw new BugException("Unknown error when opening file", e);
-
+
}
-
+
} catch (InterruptedException e) {
throw new BugException("EDT was interrupted", e);
}
@@ -917,59 +929,55 @@ public class BasicFrame extends JFrame {
throw new BugException("BUG: Document loader returned null");
}
-
- // Show warnings
+
+ // Show warnings
WarningSet warnings = worker.getRocketLoader().getWarnings();
if (!warnings.isEmpty()) {
WarningDialog.showWarnings(parent,
new Object[] {
- "The following problems were encountered while opening " + filename + ".",
- "Some design features may not have been loaded correctly."
+ "The following problems were encountered while opening " + filename + ".",
+ "Some design features may not have been loaded correctly."
},
"Warnings while opening file", warnings);
}
-
- // Set document state
- doc.setFile(file);
- doc.setSaved(true);
- // Open the frame
- BasicFrame frame = new BasicFrame(doc);
- frame.setVisible(true);
-
- return true;
+ // Set document state
+ doc.setFile(file);
+ doc.setSaved(true);
+
+ // Open the frame
+ BasicFrame frame = new BasicFrame(doc);
+ frame.setVisible(true);
+
+ return true;
}
-
-
-
-
-
-
-
+
+
+
private boolean saveAction() {
File file = document.getFile();
- if (file==null) {
+ if (file == null) {
return saveAsAction();
}
// Saving RockSim designs is not supported
if (ROCKSIM_DESIGN_FILTER.accept(file)) {
- file = new File(file.getAbsolutePath().replaceAll(".[rR][kK][tT](.[gG][zZ])?$",
+ file = new File(file.getAbsolutePath().replaceAll(".[rR][kK][tT](.[gG][zZ])?$",
".ork"));
-
+
int option = JOptionPane.showConfirmDialog(this, new Object[] {
"Saving designs in RockSim format is not supported.",
- "Save in OpenRocket format instead ("+file.getName()+")?"
- }, "Save "+file.getName(), JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE, null);
+ "Save in OpenRocket format instead (" + file.getName() + ")?"
+ }, "Save " + file.getName(), JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE, null);
if (option != JOptionPane.YES_OPTION)
return false;
document.setFile(file);
- }
+ }
return saveAs(file);
}
@@ -978,8 +986,8 @@ public class BasicFrame extends JFrame {
File file = null;
while (file == null) {
// TODO: HIGH: what if *.rkt chosen?
- StorageOptionChooser storageChooser =
- new StorageOptionChooser(document, document.getDefaultStorageOptions());
+ StorageOptionChooser storageChooser =
+ new StorageOptionChooser(document, document.getDefaultStorageOptions());
JFileChooser chooser = new JFileChooser();
chooser.setFileFilter(OPENROCKET_DESIGN_FILTER);
chooser.setCurrentDirectory(Prefs.getDefaultDirectory());
@@ -993,7 +1001,7 @@ public class BasicFrame extends JFrame {
file = chooser.getSelectedFile();
if (file == null)
return false;
-
+
Prefs.setDefaultDirectory(chooser.getCurrentDirectory());
storageChooser.storeOptions(document.getDefaultStorageOptions());
@@ -1004,53 +1012,53 @@ public class BasicFrame extends JFrame {
}
if (file.exists()) {
- int result = JOptionPane.showConfirmDialog(this,
- "File '"+file.getName()+"' exists. Do you want to overwrite it?",
+ int result = JOptionPane.showConfirmDialog(this,
+ "File '" + file.getName() + "' exists. Do you want to overwrite it?",
"File exists", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (result != JOptionPane.YES_OPTION)
return false;
}
}
- saveAs(file);
- return true;
+ saveAs(file);
+ return true;
}
private boolean saveAs(File file) {
- System.out.println("Saving to file: " + file.getName());
- boolean saved = false;
-
- if (!StorageOptionChooser.verifyStorageOptions(document, this)) {
- // User cancelled the dialog
- return false;
- }
+ System.out.println("Saving to file: " + file.getName());
+ boolean saved = false;
+
+ if (!StorageOptionChooser.verifyStorageOptions(document, this)) {
+ // User cancelled the dialog
+ return false;
+ }
+
-
- SaveFileWorker worker = new SaveFileWorker(document, file, ROCKET_SAVER);
-
- if (!SwingWorkerDialog.runWorker(this, "Saving file",
- "Writing " + file.getName() + "...", worker)) {
-
- // User cancelled the save
- file.delete();
- return false;
- }
-
- try {
+ SaveFileWorker worker = new SaveFileWorker(document, file, ROCKET_SAVER);
+
+ if (!SwingWorkerDialog.runWorker(this, "Saving file",
+ "Writing " + file.getName() + "...", worker)) {
+
+ // User cancelled the save
+ file.delete();
+ return false;
+ }
+
+ try {
worker.get();
document.setFile(file);
document.setSaved(true);
saved = true;
- setTitle();
+ setTitle();
} catch (ExecutionException e) {
-
+
Throwable cause = e.getCause();
if (cause instanceof IOException) {
- JOptionPane.showMessageDialog(this, new String[] {
- "An I/O error occurred while saving:",
- e.getMessage() }, "Saving failed", JOptionPane.ERROR_MESSAGE);
- return false;
+ JOptionPane.showMessageDialog(this, new String[] {
+ "An I/O error occurred while saving:",
+ e.getMessage() }, "Saving failed", JOptionPane.ERROR_MESSAGE);
+ return false;
} else {
Reflection.handleWrappedException(e);
}
@@ -1058,23 +1066,23 @@ public class BasicFrame extends JFrame {
} catch (InterruptedException e) {
throw new BugException("EDT was interrupted", e);
}
-
- return saved;
+
+ return saved;
}
private boolean closeAction() {
if (!document.isSaved()) {
ComponentConfigDialog.hideDialog();
- int result = JOptionPane.showConfirmDialog(this,
- "Design '"+rocket.getName()+"' has not been saved. " +
- "Do you want to save it?",
- "Design not saved", JOptionPane.YES_NO_CANCEL_OPTION,
+ int result = JOptionPane.showConfirmDialog(this,
+ "Design '" + rocket.getName() + "' has not been saved. " +
+ "Do you want to save it?",
+ "Design not saved", JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (result == JOptionPane.YES_OPTION) {
// Save
if (!saveAction())
- return false; // If save was interrupted
+ return false; // If save was interrupted
} else if (result == JOptionPane.NO_OPTION) {
// Don't save: No-op
} else {
@@ -1085,7 +1093,7 @@ public class BasicFrame extends JFrame {
// Rocket has been saved or discarded
this.dispose();
-
+
// TODO: LOW: Close only dialogs that have this frame as their parent
ComponentConfigDialog.hideDialog();
ComponentAnalysisDialog.hideDialog();
@@ -1110,6 +1118,7 @@ public class BasicFrame extends JFrame {
* Open a new design window with a basic rocket+stage.
*/
public static void newAction() {
+ log.debug("New action initiated");
Rocket rocket = new Rocket();
Stage stage = new Stage();
stage.setName("Sustainer");
@@ -1127,7 +1136,7 @@ public class BasicFrame extends JFrame {
* Quit the application. Confirms saving unsaved designs. The action of File->Quit.
*/
public static void quitAction() {
- for (int i=frames.size()-1; i>=0; i--) {
+ for (int i = frames.size() - 1; i >= 0; i--) {
if (!frames.get(i).closeAction()) {
// Close canceled
return;
@@ -1148,8 +1157,8 @@ public class BasicFrame extends JFrame {
String title;
title = rocket.getName();
- if (file!=null) {
- title = title + " ("+file.getName()+")";
+ if (file != null) {
+ title = title + " (" + file.getName() + ")";
}
if (!saved)
title = "*" + title;
@@ -1158,7 +1167,7 @@ public class BasicFrame extends JFrame {
}
-
+
/**
* Find a currently open BasicFrame containing the specified rocket. This method
* can be used to map a Rocket to a BasicFrame from GUI methods.
@@ -1167,7 +1176,7 @@ public class BasicFrame extends JFrame {
* @return the corresponding BasicFrame, or null
if none found.
*/
public static BasicFrame findFrame(Rocket rocket) {
- for (BasicFrame f: frames) {
+ for (BasicFrame f : frames) {
if (f.rocket == rocket)
return f;
}
@@ -1182,7 +1191,7 @@ public class BasicFrame extends JFrame {
* @return the corresponding OpenRocketDocument, or null
if not found.
*/
public static OpenRocketDocument findDocument(Rocket rocket) {
- for (BasicFrame f: frames) {
+ for (BasicFrame f : frames) {
if (f.rocket == rocket)
return f.document;
}
@@ -1214,7 +1223,7 @@ public class BasicFrame extends JFrame {
// Initialize the splash screen with version info
Splash.init();
-
+
// Start update info fetching
final UpdateInfoRetriever updateInfo;
if (Prefs.getCheckUpdates()) {
@@ -1224,18 +1233,18 @@ public class BasicFrame extends JFrame {
updateInfo = null;
}
-
+
// Set the best available look-and-feel
GUIUtil.setBestLAF();
-
+
// Set tooltip delay time. Tooltips are used in MotorChooserDialog extensively.
ToolTipManager.sharedInstance().setDismissDelay(30000);
-
+
// Setup the uncaught exception handler
ExceptionHandler.registerExceptionHandler();
-
+
// Load defaults
Prefs.loadDefaultUnits();
@@ -1248,7 +1257,7 @@ public class BasicFrame extends JFrame {
newAction();
}
-
+
// Check whether update info has been fetched or whether it needs more time
checkUpdateStatus(updateInfo);
}
@@ -1257,15 +1266,16 @@ public class BasicFrame extends JFrame {
private static void checkUpdateStatus(final UpdateInfoRetriever updateInfo) {
if (updateInfo == null)
return;
-
+
int delay = 1000;
if (!updateInfo.isRunning())
delay = 100;
-
+
final Timer timer = new Timer(delay, null);
-
+
ActionListener listener = new ActionListener() {
private int count = 5;
+
@Override
public void actionPerformed(ActionEvent e) {
if (!updateInfo.isRunning()) {
@@ -1273,7 +1283,7 @@ public class BasicFrame extends JFrame {
String current = Prefs.getVersion();
String last = Prefs.getString(Prefs.LAST_UPDATE, "");
-
+
UpdateInfo info = updateInfo.getUpdateInfo();
if (info != null && info.getLatestVersion() != null &&
!current.equals(info.getLatestVersion()) &&
@@ -1311,12 +1321,12 @@ public class BasicFrame extends JFrame {
// Check command-line for files
boolean opened = false;
- for (String file: args) {
+ for (String file : args) {
if (open(new File(file), null)) {
opened = true;
}
}
return opened;
}
-
+
}
diff --git a/src/net/sf/openrocket/gui/plot/PlotDialog.java b/src/net/sf/openrocket/gui/plot/PlotDialog.java
index ad6e34a58..77d5338e3 100644
--- a/src/net/sf/openrocket/gui/plot/PlotDialog.java
+++ b/src/net/sf/openrocket/gui/plot/PlotDialog.java
@@ -1,6 +1,7 @@
package net.sf.openrocket.gui.plot;
import java.awt.AlphaComposite;
+import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Font;
@@ -62,6 +63,8 @@ import org.jfree.ui.TextAnchor;
public class PlotDialog extends JDialog {
+ private static final float PLOT_STROKE_WIDTH = 1.5f;
+
private static final Color DEFAULT_EVENT_COLOR = new Color(0, 0, 0);
private static final Map
+ * NOTE: In most cases you want to examine the motor type of the ThrustCurveMotorSet,
+ * not the ThrustCurveMotor itself.
+ */
@Override
public Type getMotorType() {
return type;
@@ -391,6 +399,7 @@ public class ThrustCurveMotor implements Motor, Comparable
* The default button must be already attached to the dialog.
*
@@ -108,6 +110,7 @@ public class GUIUtil {
installEscapeCloseOperation(dialog);
setWindowIcons(dialog);
addModelNullingListener(dialog);
+ dialog.setLocationByPlatform(true);
if (defaultButton != null) {
setDefaultButton(defaultButton);
}
@@ -238,6 +241,19 @@ public class GUIUtil {
}
+ /**
+ * Changes the size of the font of the specified component by the given amount.
+ *
+ * @param component the component for which to change the font
+ * @param size the change in the font size
+ */
+ public static void changeFontSize(JComponent component, float size) {
+ Font font = component.getFont();
+ font = font.deriveFont(font.getSize2D() + size);
+ component.setFont(font);
+ }
+
+
/**
* Traverses recursively the component tree, and sets all applicable component
* models to null, so as to remove the listener connections. After calling this
diff --git a/src/net/sf/openrocket/util/Icons.java b/src/net/sf/openrocket/util/Icons.java
index a447009f1..52153e148 100644
--- a/src/net/sf/openrocket/util/Icons.java
+++ b/src/net/sf/openrocket/util/Icons.java
@@ -10,10 +10,17 @@ import javax.swing.ImageIcon;
import net.sf.openrocket.document.Simulation;
import net.sf.openrocket.gui.main.ExceptionHandler;
+import net.sf.openrocket.logging.LogHelper;
+import net.sf.openrocket.startup.Application;
public class Icons {
-
+ private static final LogHelper log = Application.getLogger();
+
+ static {
+ log.debug("Starting to load icons");
+ }
+
/**
* Icons used for showing the status of a simulation (up to date, out of date, etc).
*/
@@ -34,7 +41,7 @@ public class Icons {
SIMULATION_LISTENER_OK = SIMULATION_STATUS_ICON_MAP.get(Simulation.Status.UPTODATE);
SIMULATION_LISTENER_ERROR = SIMULATION_STATUS_ICON_MAP.get(Simulation.Status.OUTDATED);
}
-
+
public static final Icon FILE_NEW = loadImageIcon("pix/icons/document-new.png", "New document");
public static final Icon FILE_OPEN = loadImageIcon("pix/icons/document-open.png", "Open document");
@@ -50,15 +57,17 @@ public class Icons {
public static final Icon EDIT_COPY = loadImageIcon("pix/icons/edit-copy.png", "Copy");
public static final Icon EDIT_PASTE = loadImageIcon("pix/icons/edit-paste.png", "Paste");
public static final Icon EDIT_DELETE = loadImageIcon("pix/icons/edit-delete.png", "Delete");
-
+
public static final Icon ZOOM_IN = loadImageIcon("pix/icons/zoom-in.png", "Zoom in");
public static final Icon ZOOM_OUT = loadImageIcon("pix/icons/zoom-out.png", "Zoom out");
-
+
public static final Icon PREFERENCES = loadImageIcon("pix/icons/preferences.png", "Preferences");
-
+
public static final Icon DELETE = loadImageIcon("pix/icons/delete.png", "Delete");
-
+ static {
+ log.debug("Icons loaded");
+ }
/**
* Load an ImageIcon from the specified file. The file is obtained as a system
diff --git a/src/net/sf/openrocket/util/Prefs.java b/src/net/sf/openrocket/util/Prefs.java
index c8ed58b92..8f5a75ec5 100644
--- a/src/net/sf/openrocket/util/Prefs.java
+++ b/src/net/sf/openrocket/util/Prefs.java
@@ -42,21 +42,21 @@ public class Prefs {
/**
* Whether to use the debug-node instead of the normal node.
*/
- public static final boolean DEBUG = false;
+ private static final boolean DEBUG;
+ static {
+ DEBUG = (System.getProperty("openrocket.debug.prefs") != null);
+ }
/**
* Whether to clear all preferences at application startup. This has an effect only
* if DEBUG is true.
*/
- public static final boolean CLEARPREFS = true;
+ private static final boolean CLEARPREFS = true;
/**
* The node name to use in the Java preferences storage.
*/
- public static final String NODENAME = (DEBUG ? "OpenRocket-debug" : "OpenRocket");
-
-
- public static final String DEFAULT_BUILD_SOURCE = "default";
+ private static final String NODENAME = (DEBUG ? "OpenRocket-debug" : "OpenRocket");
/*
@@ -128,6 +128,11 @@ public class Prefs {
private static final String CHECK_UPDATES = "CheckUpdates";
public static final String LAST_UPDATE = "LastUpdateVersion";
+
+ // Node names
+ public static final String PREFERRED_THRUST_CURVE_MOTOR_NODE = "preferredThrustCurveMotors";
+
+
/**
* Node to this application's preferences.
* @deprecated Use the static methods instead.
@@ -137,6 +142,7 @@ public class Prefs {
private static final Preferences PREFNODE;
+ // Clear the preferences if debug mode and clearprefs is defined
static {
Preferences root = Preferences.userRoot();
if (DEBUG && CLEARPREFS) {
@@ -193,16 +199,27 @@ public class Prefs {
//////////////////////
+ /**
+ * Return the OpenRocket version number.
+ */
public static String getVersion() {
return BuildPropertyHolder.BUILD_VERSION;
}
+ /**
+ * Return the OpenRocket build source (e.g. "default" or "Debian")
+ */
public static String getBuildSource() {
return BuildPropertyHolder.BUILD_SOURCE;
}
+ /**
+ * Return the OpenRocket unique ID.
+ *
+ * @return a random ID string that stays constant between OpenRocket executions
+ */
public static String getUniqueID() {
String id = PREFNODE.get("id", null);
if (id == null) {
@@ -214,7 +231,10 @@ public class Prefs {
- public static void storeVersion() {
+ /**
+ * Store the current OpenRocket version into the preferences to allow for preferences migration.
+ */
+ private static void storeVersion() {
PREFNODE.put("OpenRocketVersion", getVersion());
}
@@ -249,27 +269,66 @@ public class Prefs {
}
-
+ /**
+ * Return a string preference.
+ *
+ * @param key the preference key.
+ * @param def the default if no preference is stored
+ * @return the preference value
+ */
public static String getString(String key, String def) {
return PREFNODE.get(key, def);
}
+ /**
+ * Set a string preference.
+ *
+ * @param key the preference key
+ * @param value the value to set
+ */
public static void putString(String key, String value) {
PREFNODE.put(key, value);
storeVersion();
}
-
+ /**
+ * Return a boolean preference.
+ *
+ * @param key the preference key
+ * @param def the default if no preference is stored
+ * @return the preference value
+ */
public static boolean getBoolean(String key, boolean def) {
return PREFNODE.getBoolean(key, def);
}
+ /**
+ * Set a boolean preference.
+ *
+ * @param key the preference key
+ * @param value the value to set
+ */
public static void putBoolean(String key, boolean value) {
PREFNODE.putBoolean(key, value);
storeVersion();
}
+ /**
+ * Return a preferences object for the specified node name.
+ *
+ * @param nodeName the node name
+ * @return the preferences object for that node
+ */
+ public static Preferences getNode(String nodeName) {
+ return PREFNODE.node(nodeName);
+ }
+
+
+ //////////////////
+
+
+
public static boolean getCheckUpdates() {
return PREFNODE.getBoolean(CHECK_UPDATES, BuildPropertyHolder.DEFAULT_CHECK_UPDATES);
@@ -280,9 +339,6 @@ public class Prefs {
storeVersion();
}
-
- //////////////////
-
public static File getDefaultDirectory() {
String file = PREFNODE.get("defaultDirectory", null);
if (file == null)
diff --git a/src/net/sf/openrocket/util/TestRockets.java b/src/net/sf/openrocket/util/TestRockets.java
index 6b5b83f70..cf6b2787a 100644
--- a/src/net/sf/openrocket/util/TestRockets.java
+++ b/src/net/sf/openrocket/util/TestRockets.java
@@ -3,7 +3,6 @@ package net.sf.openrocket.util;
import java.awt.Color;
import java.util.Random;
-import net.sf.openrocket.database.Databases;
import net.sf.openrocket.material.Material;
import net.sf.openrocket.material.Material.Type;
import net.sf.openrocket.motor.Motor;
@@ -30,6 +29,7 @@ import net.sf.openrocket.rocketcomponent.FinSet.CrossSection;
import net.sf.openrocket.rocketcomponent.MotorMount.IgnitionEvent;
import net.sf.openrocket.rocketcomponent.RocketComponent.Position;
import net.sf.openrocket.rocketcomponent.Transition.Shape;
+import net.sf.openrocket.startup.Application;
public class TestRockets {
@@ -38,18 +38,18 @@ public class TestRockets {
public TestRockets(String key) {
-
+
if (key == null) {
Random rnd = new Random();
StringBuilder sb = new StringBuilder();
- for (int i=0; i<6; i++) {
+ for (int i = 0; i < 6; i++) {
int n = rnd.nextInt(62);
if (n < 10) {
- sb.append((char)('0'+n));
+ sb.append((char) ('0' + n));
} else if (n < 36) {
- sb.append((char)('A'+n-10));
+ sb.append((char) ('A' + n - 10));
} else {
- sb.append((char)('a'+n-36));
+ sb.append((char) ('a' + n - 36));
}
}
key = sb.toString();
@@ -57,10 +57,10 @@ public class TestRockets {
this.key = key;
this.rnd = new Random(key.hashCode());
-
+
}
-
-
+
+
/**
* Create a new test rocket based on the value 'key'. The rocket utilizes most of the
* properties and features available. The same key always returns the same rocket,
@@ -82,12 +82,12 @@ public class TestRockets {
rocket.setRevision("Rocket revision " + key);
rocket.setName(key);
-
+
Stage stage = new Stage();
setBasics(stage);
rocket.addChild(stage);
-
+
NoseCone nose = new NoseCone();
setBasics(stage);
nose.setAftRadius(rnd(0.03));
@@ -99,13 +99,13 @@ public class TestRockets {
nose.setClipped(rnd.nextBoolean());
nose.setThickness(rnd(0.002));
nose.setFilled(rnd.nextBoolean());
- nose.setForeRadius(rnd(0.1)); // Unset
+ nose.setForeRadius(rnd(0.1)); // Unset
nose.setLength(rnd(0.15));
nose.setShapeParameter(rnd(0.5));
nose.setType((Shape) randomEnum(Shape.class));
stage.addChild(nose);
-
+
Transition shoulder = new Transition();
setBasics(shoulder);
shoulder.setAftRadius(rnd(0.06));
@@ -129,21 +129,21 @@ public class TestRockets {
shoulder.setType((Shape) randomEnum(Shape.class));
stage.addChild(shoulder);
-
+
BodyTube body = new BodyTube();
setBasics(body);
body.setThickness(rnd(0.002));
body.setFilled(rnd.nextBoolean());
- body.setIgnitionDelay(rnd.nextDouble()*3);
+ body.setIgnitionDelay(rnd.nextDouble() * 3);
body.setIgnitionEvent((IgnitionEvent) randomEnum(IgnitionEvent.class));
body.setLength(rnd(0.3));
body.setMotorMount(rnd.nextBoolean());
- body.setMotorOverhang(rnd.nextGaussian()*0.03);
+ body.setMotorOverhang(rnd.nextGaussian() * 0.03);
body.setRadius(rnd(0.06));
body.setRadiusAutomatic(rnd.nextBoolean());
stage.addChild(body);
-
+
Transition boattail = new Transition();
setBasics(boattail);
boattail.setAftRadius(rnd(0.03));
@@ -177,9 +177,9 @@ public class TestRockets {
mass.setRadius(rnd(0.05));
nose.addChild(mass);
-
-
-
+
+
+
return rocket;
}
@@ -187,13 +187,13 @@ public class TestRockets {
private void setBasics(RocketComponent c) {
c.setComment(c.getComponentName() + " comment " + key);
c.setName(c.getComponentName() + " name " + key);
-
+
c.setCGOverridden(rnd.nextBoolean());
c.setMassOverridden(rnd.nextBoolean());
c.setOverrideCGX(rnd(0.2));
c.setOverrideMass(rnd(0.05));
c.setOverrideSubcomponents(rnd.nextBoolean());
-
+
if (c.isMassive()) {
// Only massive components are drawn
c.setColor(randomColor());
@@ -201,23 +201,23 @@ public class TestRockets {
}
if (c instanceof ExternalComponent) {
- ExternalComponent e = (ExternalComponent)c;
+ ExternalComponent e = (ExternalComponent) c;
e.setFinish((Finish) randomEnum(Finish.class));
double d = rnd(100);
- e.setMaterial(Material.newMaterial(Type.BULK, "Testmat "+d, d, rnd.nextBoolean()));
+ e.setMaterial(Material.newMaterial(Type.BULK, "Testmat " + d, d, rnd.nextBoolean()));
}
if (c instanceof InternalComponent) {
- InternalComponent i = (InternalComponent)c;
+ InternalComponent i = (InternalComponent) c;
i.setRelativePosition((Position) randomEnum(Position.class));
i.setPositionValue(rnd(0.3));
}
}
-
+
private double rnd(double scale) {
- return (rnd.nextDouble()*0.2+0.9) * scale;
+ return (rnd.nextDouble() * 0.2 + 0.9) * scale;
}
private Color randomColor() {
@@ -231,20 +231,19 @@ public class TestRockets {
return values[rnd.nextInt(values.length)];
}
+
+
+
+
-
-
-
-
-
public Rocket makeSmallFlyable() {
- double noseconeLength=0.10,noseconeRadius=0.01;
- double bodytubeLength=0.20,bodytubeRadius=0.01,bodytubeThickness=0.001;
-
- int finCount=3;
- double finRootChord=0.04,finTipChord=0.05,finSweep=0.01,finThickness=0.003, finHeight=0.03;
+ double noseconeLength = 0.10, noseconeRadius = 0.01;
+ double bodytubeLength = 0.20, bodytubeRadius = 0.01, bodytubeThickness = 0.001;
+ int finCount = 3;
+ double finRootChord = 0.04, finTipChord = 0.05, finSweep = 0.01, finThickness = 0.003, finHeight = 0.03;
+
Rocket rocket;
Stage stage;
NoseCone nosecone;
@@ -254,21 +253,21 @@ public class TestRockets {
rocket = new Rocket();
stage = new Stage();
stage.setName("Stage1");
-
- nosecone = new NoseCone(Transition.Shape.ELLIPSOID,noseconeLength,noseconeRadius);
- bodytube = new BodyTube(bodytubeLength,bodytubeRadius,bodytubeThickness);
-
- finset = new TrapezoidFinSet(finCount,finRootChord,finTipChord,finSweep,finHeight);
+ nosecone = new NoseCone(Transition.Shape.ELLIPSOID, noseconeLength, noseconeRadius);
+ bodytube = new BodyTube(bodytubeLength, bodytubeRadius, bodytubeThickness);
+ finset = new TrapezoidFinSet(finCount, finRootChord, finTipChord, finSweep, finHeight);
+
+
// Stage construction
rocket.addChild(stage);
-
+
// Component construction
stage.addChild(nosecone);
stage.addChild(bodytube);
-
+
bodytube.addChild(finset);
Material material = Prefs.getDefaultComponentMaterial(null, Material.Type.BULK);
@@ -279,22 +278,18 @@ public class TestRockets {
String id = rocket.newMotorConfigurationID();
bodytube.setMotorMount(true);
- for (Motor m: Databases.MOTOR) {
- if (m.getDesignation().equals("B4")) {
- bodytube.setMotor(id, m);
- break;
- }
- }
+ Motor m = Application.getMotorSetDatabase().findMotors(null, null, "B4", Double.NaN, Double.NaN).get(0);
+ bodytube.setMotor(id, m);
bodytube.setMotorOverhang(0.005);
rocket.getDefaultConfiguration().setMotorConfigurationID(id);
rocket.getDefaultConfiguration().setAllStages();
-
+
return rocket;
}
-
-
+
+
public static Rocket makeBigBlue() {
Rocket rocket;
Stage stage;
@@ -306,11 +301,11 @@ public class TestRockets {
rocket = new Rocket();
stage = new Stage();
stage.setName("Stage1");
-
- nosecone = new NoseCone(Transition.Shape.ELLIPSOID,0.105,0.033);
+
+ nosecone = new NoseCone(Transition.Shape.ELLIPSOID, 0.105, 0.033);
nosecone.setThickness(0.001);
- bodytube = new BodyTube(0.69,0.033,0.001);
-
+ bodytube = new BodyTube(0.69, 0.033, 0.001);
+
finset = new FreeformFinSet();
try {
finset.setPoints(new Coordinate[] {
@@ -326,46 +321,42 @@ public class TestRockets {
finset.setThickness(0.003);
finset.setFinCount(4);
- finset.setCantAngle(0*Math.PI/180);
- System.err.println("Fin cant angle: "+(finset.getCantAngle() * 180/Math.PI));
+ finset.setCantAngle(0 * Math.PI / 180);
+ System.err.println("Fin cant angle: " + (finset.getCantAngle() * 180 / Math.PI));
- mcomp = new MassComponent(0.2,0.03,0.045 + 0.060);
+ mcomp = new MassComponent(0.2, 0.03, 0.045 + 0.060);
mcomp.setRelativePosition(Position.TOP);
mcomp.setPositionValue(0);
// Stage construction
rocket.addChild(stage);
rocket.setPerfectFinish(false);
-
+
// Component construction
stage.addChild(nosecone);
stage.addChild(bodytube);
-
+
bodytube.addChild(finset);
bodytube.addChild(mcomp);
-// Material material = new Material("Test material", 500);
-// nosecone.setMaterial(material);
-// bodytube.setMaterial(material);
-// finset.setMaterial(material);
+ // Material material = new Material("Test material", 500);
+ // nosecone.setMaterial(material);
+ // bodytube.setMaterial(material);
+ // finset.setMaterial(material);
String id = rocket.newMotorConfigurationID();
bodytube.setMotorMount(true);
- for (Motor m: Databases.MOTOR) {
- if (m.getDesignation().equals("F12J")) {
- bodytube.setMotor(id, m);
- break;
- }
- }
+ Motor m = Application.getMotorSetDatabase().findMotors(null, null, "F12J", Double.NaN, Double.NaN).get(0);
+ bodytube.setMotor(id, m);
bodytube.setMotorOverhang(0.005);
rocket.getDefaultConfiguration().setMotorConfigurationID(id);
rocket.getDefaultConfiguration().setAllStages();
-
+
return rocket;
}
@@ -385,29 +376,29 @@ public class TestRockets {
rocket = new Rocket();
stage = new Stage();
stage.setName("Stage1");
-
- nosecone = new NoseCone(Transition.Shape.OGIVE,0.53,R);
+
+ nosecone = new NoseCone(Transition.Shape.OGIVE, 0.53, R);
nosecone.setThickness(0.005);
nosecone.setMassOverridden(true);
nosecone.setOverrideMass(0.588);
stage.addChild(nosecone);
- tube1 = new BodyTube(0.505,R,0.005);
+ tube1 = new BodyTube(0.505, R, 0.005);
tube1.setMassOverridden(true);
tube1.setOverrideMass(0.366);
stage.addChild(tube1);
- tube2 = new BodyTube(0.605,R,0.005);
+ tube2 = new BodyTube(0.605, R, 0.005);
tube2.setMassOverridden(true);
tube2.setOverrideMass(0.427);
stage.addChild(tube2);
- tube3 = new BodyTube(1.065,R,0.005);
+ tube3 = new BodyTube(1.065, R, 0.005);
tube3.setMassOverridden(true);
tube3.setOverrideMass(0.730);
stage.addChild(tube3);
-
+
LaunchLug lug = new LaunchLug();
tube1.addChild(lug);
@@ -421,7 +412,7 @@ public class TestRockets {
coupler.setPositionValue(-0.14);
tube1.addChild(coupler);
-
+
// Parachute
MassComponent mass = new MassComponent(0.05, 0.05, 0.280);
mass.setRelativePosition(Position.TOP);
@@ -440,7 +431,7 @@ public class TestRockets {
mass.setPositionValue(0.25);
tube1.addChild(mass);
-
+
auxfinset = new TrapezoidFinSet();
auxfinset.setName("CONTROL");
auxfinset.setFinCount(2);
@@ -452,12 +443,12 @@ public class TestRockets {
auxfinset.setCrossSection(CrossSection.AIRFOIL);
auxfinset.setRelativePosition(Position.TOP);
auxfinset.setPositionValue(0.28);
- auxfinset.setBaseRotation(Math.PI/2);
+ auxfinset.setBaseRotation(Math.PI / 2);
tube1.addChild(auxfinset);
-
-
-
+
+
+
coupler = new TubeCoupler();
coupler.setOuterRadiusAutomatic(true);
coupler.setLength(0.28);
@@ -467,8 +458,8 @@ public class TestRockets {
coupler.setOverrideMass(0.360);
tube2.addChild(coupler);
-
-
+
+
// Parachute
mass = new MassComponent(0.1, 0.05, 0.028);
mass.setRelativePosition(Position.TOP);
@@ -489,17 +480,17 @@ public class TestRockets {
mass.setPositionValue(0.19);
tube2.addChild(mass);
-
-
+
+
InnerTube inner = new InnerTube();
- inner.setOuterRadius(0.08/2);
- inner.setInnerRadius(0.0762/2);
+ inner.setOuterRadius(0.08 / 2);
+ inner.setInnerRadius(0.0762 / 2);
inner.setLength(0.86);
inner.setMassOverridden(true);
inner.setOverrideMass(0.388);
tube3.addChild(inner);
-
+
CenteringRing center = new CenteringRing();
center.setInnerRadiusAutomatic(true);
center.setOuterRadiusAutomatic(true);
@@ -510,7 +501,7 @@ public class TestRockets {
center.setPositionValue(0);
tube3.addChild(center);
-
+
center = new CenteringRing();
center.setInnerRadiusAutomatic(true);
center.setOuterRadiusAutomatic(true);
@@ -521,7 +512,7 @@ public class TestRockets {
center.setPositionValue(0.28);
tube3.addChild(center);
-
+
center = new CenteringRing();
center.setInnerRadiusAutomatic(true);
center.setOuterRadiusAutomatic(true);
@@ -532,10 +523,10 @@ public class TestRockets {
center.setPositionValue(0.83);
tube3.addChild(center);
-
-
-
-
+
+
+
+
finset = new TrapezoidFinSet();
finset.setRootChord(0.495);
finset.setTipChord(0.1);
@@ -544,40 +535,36 @@ public class TestRockets {
finset.setSweep(0.3);
finset.setRelativePosition(Position.BOTTOM);
finset.setPositionValue(-0.03);
- finset.setBaseRotation(Math.PI/2);
+ finset.setBaseRotation(Math.PI / 2);
tube3.addChild(finset);
+
+ finset.setCantAngle(0 * Math.PI / 180);
+ System.err.println("Fin cant angle: " + (finset.getCantAngle() * 180 / Math.PI));
- finset.setCantAngle(0*Math.PI/180);
- System.err.println("Fin cant angle: "+(finset.getCantAngle() * 180/Math.PI));
-
-
+
// Stage construction
rocket.addChild(stage);
rocket.setPerfectFinish(false);
+
+
-
-
String id = rocket.newMotorConfigurationID();
tube3.setMotorMount(true);
- for (Motor m: Databases.MOTOR) {
- if (m.getDesignation().equals("L540")) {
- tube3.setMotor(id, m);
- break;
- }
- }
+ Motor m = Application.getMotorSetDatabase().findMotors(null, null, "L540", Double.NaN, Double.NaN).get(0);
+ tube3.setMotor(id, m);
tube3.setMotorOverhang(0.02);
rocket.getDefaultConfiguration().setMotorConfigurationID(id);
-
-// tube3.setIgnitionEvent(MotorMount.IgnitionEvent.NEVER);
+
+ // tube3.setIgnitionEvent(MotorMount.IgnitionEvent.NEVER);
rocket.getDefaultConfiguration().setAllStages();
-
+
return rocket;
}
-
-
+
+
}
diff --git a/test/net/sf/openrocket/database/MotorSetDatabaseTest.java b/test/net/sf/openrocket/database/MotorSetDatabaseTest.java
index 663340f8c..33ced0c8e 100644
--- a/test/net/sf/openrocket/database/MotorSetDatabaseTest.java
+++ b/test/net/sf/openrocket/database/MotorSetDatabaseTest.java
@@ -17,7 +17,7 @@ public class MotorSetDatabaseTest {
@Test
public void testMotorLoading() {
- MotorSetDatabase db = new MotorSetDatabase(true) {
+ ThrustCurveMotorSetDatabase db = new ThrustCurveMotorSetDatabase(true) {
@Override
protected void loadMotors() {
try {