Fixing various issues
This commit is contained in:
parent
b1891e1dc1
commit
88f359c25f
@ -1,3 +1,7 @@
|
|||||||
|
2012-02-16 Sampo Niskanen
|
||||||
|
|
||||||
|
* [BUG] Freeze when dropping component on child component
|
||||||
|
|
||||||
2012-02-10 Sampo Niskanen
|
2012-02-10 Sampo Niskanen
|
||||||
|
|
||||||
* Configurable stage separation events
|
* Configurable stage separation events
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
@ -36,4 +36,5 @@ The following file format versions exist:
|
|||||||
|
|
||||||
1.4: Introduced with OpenRocket 1.1.10. Adds the launchrodvelocity and
|
1.4: Introduced with OpenRocket 1.1.10. Adds the launchrodvelocity and
|
||||||
deploymentvelocity attributes to <flightdata> element. The motor
|
deploymentvelocity attributes to <flightdata> element. The motor
|
||||||
digesting algorithm was changed.
|
digesting algorithm was changed. Adds <separationevent> and
|
||||||
|
<separationdelay> elements to stage components (except sustainer).
|
||||||
|
@ -34,3 +34,4 @@ help-license.png
|
|||||||
help-log.png
|
help-log.png
|
||||||
help-about.png
|
help-about.png
|
||||||
help-bug.png
|
help-bug.png
|
||||||
|
help-tours.png
|
||||||
|
BIN
core/resources/pix/icons/help-tours.png
Normal file
BIN
core/resources/pix/icons/help-tours.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 837 B |
@ -360,7 +360,6 @@ public class RockSimMotorLoader extends AbstractMotorLoader {
|
|||||||
if (!calculateCG) {
|
if (!calculateCG) {
|
||||||
motorDigest.update(DataType.CG_PER_TIME, toArray(cg));
|
motorDigest.update(DataType.CG_PER_TIME, toArray(cg));
|
||||||
}
|
}
|
||||||
// FIXME: Should this use CG_SPECIFIC ???
|
|
||||||
motorDigest.update(DataType.FORCE_PER_TIME, thrustArray);
|
motorDigest.update(DataType.FORCE_PER_TIME, thrustArray);
|
||||||
final String digest = motorDigest.getDigest();
|
final String digest = motorDigest.getDigest();
|
||||||
|
|
||||||
|
@ -1,5 +1,62 @@
|
|||||||
package net.sf.openrocket.gui.main;
|
package net.sf.openrocket.gui.main;
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.Window;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
import javax.swing.Action;
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.InputMap;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JMenu;
|
||||||
|
import javax.swing.JMenuBar;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JSpinner;
|
||||||
|
import javax.swing.JSplitPane;
|
||||||
|
import javax.swing.JTabbedPane;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.KeyStroke;
|
||||||
|
import javax.swing.ListSelectionModel;
|
||||||
|
import javax.swing.ScrollPaneConstants;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.border.BevelBorder;
|
||||||
|
import javax.swing.border.TitledBorder;
|
||||||
|
import javax.swing.event.TreeSelectionEvent;
|
||||||
|
import javax.swing.event.TreeSelectionListener;
|
||||||
|
import javax.swing.tree.DefaultTreeSelectionModel;
|
||||||
|
import javax.swing.tree.TreePath;
|
||||||
|
import javax.swing.tree.TreeSelectionModel;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import net.sf.openrocket.aerodynamics.WarningSet;
|
import net.sf.openrocket.aerodynamics.WarningSet;
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
@ -48,38 +105,6 @@ import net.sf.openrocket.util.MemoryManagement.MemoryData;
|
|||||||
import net.sf.openrocket.util.Reflection;
|
import net.sf.openrocket.util.Reflection;
|
||||||
import net.sf.openrocket.util.TestRockets;
|
import net.sf.openrocket.util.TestRockets;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import javax.swing.border.BevelBorder;
|
|
||||||
import javax.swing.border.TitledBorder;
|
|
||||||
import javax.swing.event.TreeSelectionEvent;
|
|
||||||
import javax.swing.event.TreeSelectionListener;
|
|
||||||
import javax.swing.tree.DefaultTreeSelectionModel;
|
|
||||||
import javax.swing.tree.TreePath;
|
|
||||||
import javax.swing.tree.TreeSelectionModel;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.event.MouseAdapter;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.event.MouseListener;
|
|
||||||
import java.awt.event.WindowAdapter;
|
|
||||||
import java.awt.event.WindowEvent;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLDecoder;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
public class BasicFrame extends JFrame {
|
public class BasicFrame extends JFrame {
|
||||||
private static final LogHelper log = Application.getLogger();
|
private static final LogHelper log = Application.getLogger();
|
||||||
|
|
||||||
@ -652,7 +677,7 @@ public class BasicFrame extends JFrame {
|
|||||||
// Guided tours
|
// Guided tours
|
||||||
|
|
||||||
item = new JMenuItem(trans.get("main.menu.help.tours"), KeyEvent.VK_L);
|
item = new JMenuItem(trans.get("main.menu.help.tours"), KeyEvent.VK_L);
|
||||||
// TODO: Icon
|
item.setIcon(Icons.HELP_TOURS);
|
||||||
item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.help.tours.desc"));
|
item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.help.tours.desc"));
|
||||||
item.addActionListener(new ActionListener() {
|
item.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -666,22 +691,6 @@ public class BasicFrame extends JFrame {
|
|||||||
|
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
|
|
||||||
//// License
|
|
||||||
item = new JMenuItem(trans.get("main.menu.help.license"), KeyEvent.VK_L);
|
|
||||||
item.setIcon(Icons.HELP_LICENSE);
|
|
||||||
item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.help.license.desc"));
|
|
||||||
item.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
log.user("License selected");
|
|
||||||
new LicenseDialog(BasicFrame.this).setVisible(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
menu.add(item);
|
|
||||||
|
|
||||||
menu.addSeparator();
|
|
||||||
|
|
||||||
//// Bug report
|
//// Bug report
|
||||||
item = new JMenuItem(trans.get("main.menu.help.bugReport"), KeyEvent.VK_B);
|
item = new JMenuItem(trans.get("main.menu.help.bugReport"), KeyEvent.VK_B);
|
||||||
item.setIcon(Icons.HELP_BUG_REPORT);
|
item.setIcon(Icons.HELP_BUG_REPORT);
|
||||||
@ -710,6 +719,21 @@ public class BasicFrame extends JFrame {
|
|||||||
|
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
|
|
||||||
|
//// License
|
||||||
|
item = new JMenuItem(trans.get("main.menu.help.license"), KeyEvent.VK_L);
|
||||||
|
item.setIcon(Icons.HELP_LICENSE);
|
||||||
|
item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.help.license.desc"));
|
||||||
|
item.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
log.user("License selected");
|
||||||
|
new LicenseDialog(BasicFrame.this).setVisible(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
menu.add(item);
|
||||||
|
|
||||||
|
|
||||||
//// About
|
//// About
|
||||||
item = new JMenuItem(trans.get("main.menu.help.about"), KeyEvent.VK_A);
|
item = new JMenuItem(trans.get("main.menu.help.about"), KeyEvent.VK_A);
|
||||||
item.setIcon(Icons.HELP_ABOUT);
|
item.setIcon(Icons.HELP_ABOUT);
|
||||||
@ -770,10 +794,10 @@ public class BasicFrame extends JFrame {
|
|||||||
int sel = JOptionPane.showOptionDialog(BasicFrame.this, new Object[] {
|
int sel = JOptionPane.showOptionDialog(BasicFrame.this, new Object[] {
|
||||||
"Input text key to generate random rocket:",
|
"Input text key to generate random rocket:",
|
||||||
field
|
field
|
||||||
}, "Generate random test rocket", JOptionPane.DEFAULT_OPTION,
|
}, "Generate random test rocket", JOptionPane.DEFAULT_OPTION,
|
||||||
JOptionPane.QUESTION_MESSAGE, null, new Object[] {
|
JOptionPane.QUESTION_MESSAGE, null, new Object[] {
|
||||||
"Random", "OK"
|
"Random", "OK"
|
||||||
}, "OK");
|
}, "OK");
|
||||||
|
|
||||||
Rocket r;
|
Rocket r;
|
||||||
if (sel == 0) {
|
if (sel == 0) {
|
||||||
@ -1212,14 +1236,14 @@ public class BasicFrame extends JFrame {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "Save" action. If the design is new, then this is identical to "Save As", with a default file filter for .ork.
|
* "Save" action. If the design is new, then this is identical to "Save As", with a default file filter for .ork.
|
||||||
* If the rocket being edited previously was opened from a .ork file, then it will be saved immediately to the same
|
* If the rocket being edited previously was opened from a .ork file, then it will be saved immediately to the same
|
||||||
* file. But clicking on 'Save' for an existing design file with a .rkt will bring up a confirmation dialog because
|
* file. But clicking on 'Save' for an existing design file with a .rkt will bring up a confirmation dialog because
|
||||||
* it's potentially a destructive write (loss of some fidelity if it's truly an original Rocksim generated file).
|
* it's potentially a destructive write (loss of some fidelity if it's truly an original Rocksim generated file).
|
||||||
*
|
*
|
||||||
* @return true if the file was saved, false otherwise
|
* @return true if the file was saved, false otherwise
|
||||||
*/
|
*/
|
||||||
private boolean saveAction() {
|
private boolean saveAction() {
|
||||||
File file = document.getFile();
|
File file = document.getFile();
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
@ -1229,44 +1253,44 @@ public class BasicFrame extends JFrame {
|
|||||||
log.info("Saving document to " + file);
|
log.info("Saving document to " + file);
|
||||||
|
|
||||||
if (FileHelper.ROCKSIM_DESIGN_FILTER.accept(file)) {
|
if (FileHelper.ROCKSIM_DESIGN_FILTER.accept(file)) {
|
||||||
return saveAsRocksim(file);
|
return saveAsRocksim(file);
|
||||||
}
|
}
|
||||||
return saveAs(file);
|
return saveAs(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "Save As" action.
|
* "Save As" action.
|
||||||
*
|
*
|
||||||
* Never should a .rkt file contain an OpenRocket content, or an .ork file contain a Rocksim design. Regardless of
|
* Never should a .rkt file contain an OpenRocket content, or an .ork file contain a Rocksim design. Regardless of
|
||||||
* what extension the user has chosen, it would violate the Principle of Least Astonishment to do otherwise
|
* what extension the user has chosen, it would violate the Principle of Least Astonishment to do otherwise
|
||||||
* (and we want to make doing the wrong thing really hard to do). So always force the appropriate extension.
|
* (and we want to make doing the wrong thing really hard to do). So always force the appropriate extension.
|
||||||
*
|
*
|
||||||
* This can result in some odd looking filenames (MyDesign.rkt.ork, MyDesign.rkt.ork.rkt, etc.) if the user is
|
* This can result in some odd looking filenames (MyDesign.rkt.ork, MyDesign.rkt.ork.rkt, etc.) if the user is
|
||||||
* not paying attention, but the user can control that by modifying the filename in the dialog.
|
* not paying attention, but the user can control that by modifying the filename in the dialog.
|
||||||
*
|
*
|
||||||
* @return true if the file was saved, false otherwise
|
* @return true if the file was saved, false otherwise
|
||||||
*/
|
*/
|
||||||
private boolean saveAsAction() {
|
private boolean saveAsAction() {
|
||||||
File file = null;
|
File file = null;
|
||||||
|
|
||||||
StorageOptionChooser storageChooser =
|
StorageOptionChooser storageChooser =
|
||||||
new StorageOptionChooser(document, document.getDefaultStorageOptions());
|
new StorageOptionChooser(document, document.getDefaultStorageOptions());
|
||||||
final JFileChooser chooser = new JFileChooser();
|
final JFileChooser chooser = new JFileChooser();
|
||||||
chooser.addChoosableFileFilter(FileHelper.OPENROCKET_DESIGN_FILTER);
|
chooser.addChoosableFileFilter(FileHelper.OPENROCKET_DESIGN_FILTER);
|
||||||
chooser.addChoosableFileFilter(FileHelper.ROCKSIM_DESIGN_FILTER);
|
chooser.addChoosableFileFilter(FileHelper.ROCKSIM_DESIGN_FILTER);
|
||||||
|
|
||||||
//Force the file filter to match the file extension that was opened. Will default to OR if the file is null.
|
//Force the file filter to match the file extension that was opened. Will default to OR if the file is null.
|
||||||
if (FileHelper.ROCKSIM_DESIGN_FILTER.accept(document.getFile())) {
|
if (FileHelper.ROCKSIM_DESIGN_FILTER.accept(document.getFile())) {
|
||||||
chooser.setFileFilter(FileHelper.ROCKSIM_DESIGN_FILTER);
|
chooser.setFileFilter(FileHelper.ROCKSIM_DESIGN_FILTER);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
chooser.setFileFilter(FileHelper.OPENROCKET_DESIGN_FILTER);
|
chooser.setFileFilter(FileHelper.OPENROCKET_DESIGN_FILTER);
|
||||||
}
|
}
|
||||||
chooser.setCurrentDirectory(((SwingPreferences) Application.getPreferences()).getDefaultDirectory());
|
chooser.setCurrentDirectory(((SwingPreferences) Application.getPreferences()).getDefaultDirectory());
|
||||||
chooser.setAccessory(storageChooser);
|
chooser.setAccessory(storageChooser);
|
||||||
if (document.getFile() != null) {
|
if (document.getFile() != null) {
|
||||||
chooser.setSelectedFile(document.getFile());
|
chooser.setSelectedFile(document.getFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
int option = chooser.showSaveDialog(BasicFrame.this);
|
int option = chooser.showSaveDialog(BasicFrame.this);
|
||||||
if (option != JFileChooser.APPROVE_OPTION) {
|
if (option != JFileChooser.APPROVE_OPTION) {
|
||||||
@ -1283,44 +1307,44 @@ public class BasicFrame extends JFrame {
|
|||||||
((SwingPreferences) Application.getPreferences()).setDefaultDirectory(chooser.getCurrentDirectory());
|
((SwingPreferences) Application.getPreferences()).setDefaultDirectory(chooser.getCurrentDirectory());
|
||||||
storageChooser.storeOptions(document.getDefaultStorageOptions());
|
storageChooser.storeOptions(document.getDefaultStorageOptions());
|
||||||
|
|
||||||
if (chooser.getFileFilter().equals(FileHelper.ROCKSIM_DESIGN_FILTER)) {
|
if (chooser.getFileFilter().equals(FileHelper.ROCKSIM_DESIGN_FILTER)) {
|
||||||
return saveAsRocksim(file);
|
return saveAsRocksim(file);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
file = FileHelper.forceExtension(file, "ork");
|
file = FileHelper.forceExtension(file, "ork");
|
||||||
return FileHelper.confirmWrite(file, this) && saveAs(file);
|
return FileHelper.confirmWrite(file, this) && saveAs(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform the writing of the design to the given file in Rocksim format.
|
* Perform the writing of the design to the given file in Rocksim format.
|
||||||
*
|
*
|
||||||
* @param file the chosen file
|
* @param file the chosen file
|
||||||
*
|
*
|
||||||
* @return true if the file was written
|
* @return true if the file was written
|
||||||
*/
|
*/
|
||||||
private boolean saveAsRocksim(File file) {
|
private boolean saveAsRocksim(File file) {
|
||||||
file = FileHelper.forceExtension(file, "rkt");
|
file = FileHelper.forceExtension(file, "rkt");
|
||||||
if (!FileHelper.confirmWrite(file, this)) {
|
if (!FileHelper.confirmWrite(file, this)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new RocksimSaver().save(file, document);
|
new RocksimSaver().save(file, document);
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform the writing of the design to the given file in OpenRocket format.
|
* Perform the writing of the design to the given file in OpenRocket format.
|
||||||
*
|
*
|
||||||
* @param file the chosen file
|
* @param file the chosen file
|
||||||
*
|
*
|
||||||
* @return true if the file was written
|
* @return true if the file was written
|
||||||
*/
|
*/
|
||||||
private boolean saveAs(File file) {
|
private boolean saveAs(File file) {
|
||||||
log.info("Saving document as " + file);
|
log.info("Saving document as " + file);
|
||||||
boolean saved = false;
|
boolean saved = false;
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ public class ComponentTreeTransferHandler extends TransferHandler {
|
|||||||
|
|
||||||
private final OpenRocketDocument document;
|
private final OpenRocketDocument document;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sole constructor.
|
* Sole constructor.
|
||||||
*
|
*
|
||||||
@ -89,6 +90,17 @@ public class ComponentTreeTransferHandler extends TransferHandler {
|
|||||||
boolean allowed = data.destParent.isCompatible(data.child);
|
boolean allowed = data.destParent.isCompatible(data.child);
|
||||||
log.verbose("Checking validity of drag-drop " + data.toString() + " allowed:" + allowed);
|
log.verbose("Checking validity of drag-drop " + data.toString() + " allowed:" + allowed);
|
||||||
|
|
||||||
|
// Ensure we're not dropping a component onto a child component
|
||||||
|
RocketComponent path = data.destParent;
|
||||||
|
while (path != null) {
|
||||||
|
if (path.equals(data.child)) {
|
||||||
|
log.verbose("Drop would cause cycle in tree, disallowing.");
|
||||||
|
allowed = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
path = path.getParent();
|
||||||
|
}
|
||||||
|
|
||||||
// If drag-dropping to another rocket always copy
|
// If drag-dropping to another rocket always copy
|
||||||
if (support.getDropAction() == MOVE && data.srcParent.getRoot() != data.destParent.getRoot()) {
|
if (support.getDropAction() == MOVE && data.srcParent.getRoot() != data.destParent.getRoot()) {
|
||||||
support.setDropAction(COPY);
|
support.setDropAction(COPY);
|
||||||
@ -98,7 +110,6 @@ public class ComponentTreeTransferHandler extends TransferHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean importData(TransferHandler.TransferSupport support) {
|
public boolean importData(TransferHandler.TransferSupport support) {
|
||||||
|
|
||||||
|
@ -62,9 +62,10 @@ public class Icons {
|
|||||||
public static final Icon EDIT_SCALE = loadImageIcon("pix/icons/edit-scale.png", "Scale");
|
public static final Icon EDIT_SCALE = loadImageIcon("pix/icons/edit-scale.png", "Scale");
|
||||||
|
|
||||||
public static final Icon HELP_ABOUT = loadImageIcon("pix/icons/help-about.png", "About");
|
public static final Icon HELP_ABOUT = loadImageIcon("pix/icons/help-about.png", "About");
|
||||||
|
public static final Icon HELP_LICENSE = loadImageIcon("pix/icons/help-license.png", "License");
|
||||||
public static final Icon HELP_BUG_REPORT = loadImageIcon("pix/icons/help-bug.png", "Bug report");
|
public static final Icon HELP_BUG_REPORT = loadImageIcon("pix/icons/help-bug.png", "Bug report");
|
||||||
public static final Icon HELP_DEBUG_LOG = loadImageIcon("pix/icons/help-log.png", "Debug log");
|
public static final Icon HELP_DEBUG_LOG = loadImageIcon("pix/icons/help-log.png", "Debug log");
|
||||||
public static final Icon HELP_LICENSE = loadImageIcon("pix/icons/help-license.png", "License");
|
public static final Icon HELP_TOURS = loadImageIcon("pix/icons/help-tours.png", "Guided tours");
|
||||||
|
|
||||||
public static final Icon ZOOM_IN = loadImageIcon("pix/icons/zoom-in.png", "Zoom in");
|
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 ZOOM_OUT = loadImageIcon("pix/icons/zoom-out.png", "Zoom out");
|
||||||
|
@ -690,7 +690,7 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
|
|
||||||
if (preset.getComponentClass() != this.getClass()) {
|
if (preset.getComponentClass() != this.getClass()) {
|
||||||
throw new IllegalArgumentException("Attempting to load preset of type " + preset.getComponentClass()
|
throw new IllegalArgumentException("Attempting to load preset of type " + preset.getComponentClass()
|
||||||
+ " into component of type " + this.getClass());
|
+ " into component of type " + this.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
RocketComponent root = getRoot();
|
RocketComponent root = getRoot();
|
||||||
@ -840,39 +840,39 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine position relative to given position argument. Note: This is a side-effect free method. No state
|
* Determine position relative to given position argument. Note: This is a side-effect free method. No state
|
||||||
* is modified.
|
* is modified.
|
||||||
*
|
*
|
||||||
* @param thePosition the relative position to be used as the basis for the computation
|
* @param thePosition the relative position to be used as the basis for the computation
|
||||||
* @param relativeTo the position is computed relative the the given component
|
* @param relativeTo the position is computed relative the the given component
|
||||||
*
|
*
|
||||||
* @return double position of the component relative to the parent, with respect to <code>position</code>
|
* @return double position of the component relative to the parent, with respect to <code>position</code>
|
||||||
*/
|
*/
|
||||||
public double asPositionValue (Position thePosition, RocketComponent relativeTo) {
|
public double asPositionValue(Position thePosition, RocketComponent relativeTo) {
|
||||||
double result = this.position;
|
double result = this.position;
|
||||||
if (relativeTo != null) {
|
if (relativeTo != null) {
|
||||||
double thisPos = this.toRelative(Coordinate.NUL, relativeTo)[0].x;
|
double thisPos = this.toRelative(Coordinate.NUL, relativeTo)[0].x;
|
||||||
|
|
||||||
switch (thePosition) {
|
switch (thePosition) {
|
||||||
case ABSOLUTE:
|
case ABSOLUTE:
|
||||||
result = this.toAbsolute(Coordinate.NUL)[0].x;
|
result = this.toAbsolute(Coordinate.NUL)[0].x;
|
||||||
break;
|
break;
|
||||||
case TOP:
|
case TOP:
|
||||||
result = thisPos;
|
result = thisPos;
|
||||||
break;
|
break;
|
||||||
case MIDDLE:
|
case MIDDLE:
|
||||||
result = thisPos - (relativeTo.length - this.length) / 2;
|
result = thisPos - (relativeTo.length - this.length) / 2;
|
||||||
break;
|
break;
|
||||||
case BOTTOM:
|
case BOTTOM:
|
||||||
result = thisPos - (relativeTo.length - this.length);
|
result = thisPos - (relativeTo.length - this.length);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new BugException("Unknown position type: " + thePosition);
|
throw new BugException("Unknown position type: " + thePosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the position value of the component. The exact meaning of the value is
|
* Get the position value of the component. The exact meaning of the value is
|
||||||
@ -1138,10 +1138,18 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
*/
|
*/
|
||||||
public void addChild(RocketComponent component, int index) {
|
public void addChild(RocketComponent component, int index) {
|
||||||
checkState();
|
checkState();
|
||||||
|
|
||||||
if (component.parent != null) {
|
if (component.parent != null) {
|
||||||
throw new IllegalArgumentException("component " + component.getComponentName() +
|
throw new IllegalArgumentException("component " + component.getComponentName() +
|
||||||
" is already in a tree");
|
" is already in a tree");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure that the no loops are created in component tree [A -> X -> Y -> B, B.addChild(A)]
|
||||||
|
if (this.getRoot().equals(component)) {
|
||||||
|
throw new IllegalStateException("Component " + component.getComponentName() +
|
||||||
|
" is a parent of " + this.getComponentName() + ", attempting to create cycle in tree.");
|
||||||
|
}
|
||||||
|
|
||||||
if (!isCompatible(component)) {
|
if (!isCompatible(component)) {
|
||||||
throw new IllegalStateException("Component " + component.getComponentName() +
|
throw new IllegalStateException("Component " + component.getComponentName() +
|
||||||
" not currently compatible with component " + getComponentName());
|
" not currently compatible with component " + getComponentName());
|
||||||
@ -1156,7 +1164,6 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
fireAddRemoveEvent(component);
|
fireAddRemoveEvent(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a child from the rocket component tree.
|
* Removes a child from the rocket component tree.
|
||||||
*
|
*
|
||||||
@ -1703,7 +1710,7 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
protected static final double ringMass(double outerRadius, double innerRadius,
|
protected static final double ringMass(double outerRadius, double innerRadius,
|
||||||
double length, double density) {
|
double length, double density) {
|
||||||
return Math.PI * (MathUtil.pow2(outerRadius) - MathUtil.pow2(innerRadius)) *
|
return Math.PI * (MathUtil.pow2(outerRadius) - MathUtil.pow2(innerRadius)) *
|
||||||
length * density;
|
length * density;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static final double ringLongitudinalUnitInertia(double outerRadius,
|
protected static final double ringLongitudinalUnitInertia(double outerRadius,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user