+2009-07-13 Sampo Niskanen
+
+ * Release 0.9.2
+
+2009-07-12 Sampo Niskanen
+
+ * [BUG] Better DescriptionArea based on JEditorPane
+
2009-07-09 Sampo Niskanen
* [BUG] Fixed imperial unit conversions
-OpenRocket 0.9.2 (future):
----------------------------
+OpenRocket 0.9.2 (2009-07-13):
+-------------------------------
-- a new and enhanced "Edit motor configurations" dialog
-- a search field in the motor selection dialog
+Fixed imperial unit conversions. Significant UI enhancements to the
+motor configuration edit dialog, motor selection dialog and file
+open/save.
OpenRocket 0.9.1 (2009-06-09):
# The OpenRocket build version
-build.version=0.9.2pre
+build.version=0.9.2
# The source of the package. When building a package for a specific
# distribution (Debian, Fedora etc.), this should be changed appropriately!
package net.sf.openrocket.gui.components;
import java.awt.Dimension;
+import java.awt.Font;
import java.awt.Rectangle;
-import javax.swing.JPanel;
+import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
-
-import net.miginfocom.swing.MigLayout;
+import javax.swing.SwingUtilities;
public class DescriptionArea extends JScrollPane {
- private ResizeLabel text;
- private MigLayout layout;
- private JPanel panel;
+ private final JEditorPane editorPane;
public DescriptionArea(int rows) {
- this(rows, -2);
+ this(rows, -1);
}
public DescriptionArea(int rows, float size) {
super(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
- layout = new MigLayout("ins 0 2px, fill");
- panel = new JPanel(layout);
+ editorPane = new JEditorPane("text/html", "");
+ Font font = editorPane.getFont();
+ editorPane.setFont(font.deriveFont(font.getSize2D() + size));
+ editorPane.setEditable(false);
- text = new ResizeLabel(" ",size);
- text.validate();
- Dimension dim = text.getPreferredSize();
- dim.height = (dim.height+2)*rows + 2;
- this.setPreferredSize(dim);
+ // Calculate correct height
+ editorPane.setText("abc");
+ Dimension oneline = editorPane.getPreferredSize();
+ editorPane.setText("abc<br>def");
+ Dimension twolines = editorPane.getPreferredSize();
+ editorPane.setText("");
- panel.add(text, "growx");
+ int lineheight = twolines.height - oneline.height;
+ int extraheight = oneline.height - lineheight;
+
+ Dimension dim = editorPane.getPreferredSize();
+ dim.height = lineheight * rows + extraheight + 2;
+ this.setPreferredSize(dim);
- this.setViewportView(panel);
- this.revalidate();
+ this.setViewportView(editorPane);
}
public void setText(String txt) {
- if (!txt.startsWith("<html>"))
- txt = "<html>" + txt;
- text.setText(txt);
- }
-
-
- @Override
- public void validate() {
-
- Rectangle dim = this.getViewportBorderBounds();
- layout.setComponentConstraints(text, "width "+ dim.width + ", growx");
- super.validate();
- text.validate();
+ editorPane.setText(txt);
+ editorPane.revalidate();
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ editorPane.scrollRectToVisible(new Rectangle(0,0,1,1));
+ }
+
+ });
+ editorPane.scrollRectToVisible(new Rectangle(0,0,1,1));
}
}
private JSlider shapeSlider;
// Prepended to the description from NoseCone.DESCRIPTIONS
- private static final String PREDESC = "<html><p style=\"font-size: x-small\">";
+ private static final String PREDESC = "<html>";
public NoseConeConfig(RocketComponent c) {
super(c);
JPanel sub = materialPanel(new JPanel(new MigLayout()), Material.Type.BULK);
if (component instanceof EngineBlock) {
- DescriptionArea desc = new DescriptionArea(6,-1);
+ final DescriptionArea desc = new DescriptionArea(6);
desc.setText("<html>An <b>engine block</b> stops the motor from moving forwards " +
"in the motor mount tube.<br><br>In order to add a motor, create a " +
"<b>body tube</b> or <b>inner tube</b> and mark it as a motor mount in " +
"the <em>Motor</em> tab.");
- sub.add(desc, "growx");
+ sub.add(desc, "width 1px, growx, wrap");
}
panel.add(sub,"cell 4 0, gapleft paragraph, aligny 0%, spany");
// Prepended to the description from Transition.DESCRIPTIONS
- private static final String PREDESC = "<html><p style=\"font-size: x-small\">";
+ private static final String PREDESC = "<html>";
public TransitionConfig(RocketComponent c) {
-
-
private void updateEnabled() {
boolean e = ((Transition)component).getType().usesParameter();
shapeLabel.setEnabled(e);
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.concurrent.ExecutionException;
}
+ public static void main(final String[] args) {
+
+ // Run the actual startup method in the EDT since it can use dialogs etc.
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ runMain(args);
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ }
+
+ }
- public static void main(String[] args) {
+
+ private static void runMain(String[] args) {
/*
* Set the look-and-feel. On Linux, Motif/Metal is sometimes incorrectly used
* other alternatives.
*/
try {
- UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels();
-// System.out.println("Available look-and-feels:");
-// for (int i=0; i<info.length; i++) {
-// System.out.println(" "+info[i]);
-// }
-
// Set system L&F
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
laf.getName().matches(".*[mM][eE][tT][aA][lL].*")) {
// Search for better LAF
- for (UIManager.LookAndFeelInfo l: info) {
- if (l.getName().matches(".*[gG][tT][kK].*")) {
- UIManager.setLookAndFeel(l.getClassName());
- break;
- }
- if (l.getName().contains(".*[wW][iI][nN].*")) {
- UIManager.setLookAndFeel(l.getClassName());
- break;
- }
- if (l.getName().contains(".*[mM][aA][cC].*")) {
- UIManager.setLookAndFeel(l.getClassName());
- break;
- }
+ UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels();
+ String lafNames[] = {
+ ".*[gG][tT][kK].*",
+ ".*[wW][iI][nN].*",
+ ".*[mM][aA][cC].*",
+ ".*[aA][qQ][uU][aA].*",
+ ".*[nN][iI][mM][bB].*"
+ };
+
+ lf: for (String lafName: lafNames) {
+ for (UIManager.LookAndFeelInfo l: info) {
+ if (l.getName().matches(lafName)) {
+ UIManager.setLookAndFeel(l.getClassName());
+ break lf;
+ }
+ }
}
}
} catch (Exception e) {
panel.add(sub, "growx, growy");
- DescriptionArea desc = new DescriptionArea(5, -1);
+ DescriptionArea desc = new DescriptionArea(5);
desc.setText("<html><p>" +
"<i>Simulation listeners</i> is an advanced feature that allows "+
"user-written code to listen to and interact with the simulation. " +
-/*
- * TODO: CRITICAL: Licensing
- */
-
package net.sf.openrocket.util;
import java.awt.Component;