diff --git a/core/resources/pix/componenticons/altimeter_dark-small.png b/core/resources/pix/componenticons/altimeter_dark-small.png
new file mode 100644
index 000000000..3506a26e5
Binary files /dev/null and b/core/resources/pix/componenticons/altimeter_dark-small.png differ
diff --git a/core/resources/pix/componenticons/battery_dark-small.png b/core/resources/pix/componenticons/battery_dark-small.png
new file mode 100644
index 000000000..72b498ebd
Binary files /dev/null and b/core/resources/pix/componenticons/battery_dark-small.png differ
diff --git a/core/resources/pix/componenticons/deployment-charge_dark-small.png b/core/resources/pix/componenticons/deployment-charge_dark-small.png
new file mode 100644
index 000000000..cadf1807c
Binary files /dev/null and b/core/resources/pix/componenticons/deployment-charge_dark-small.png differ
diff --git a/core/resources/pix/componenticons/ellipticalfin_dark-large.png b/core/resources/pix/componenticons/ellipticalfin_dark-large.png
new file mode 100644
index 000000000..cb186f3eb
Binary files /dev/null and b/core/resources/pix/componenticons/ellipticalfin_dark-large.png differ
diff --git a/core/resources/pix/componenticons/ellipticalfin_dark-small.png b/core/resources/pix/componenticons/ellipticalfin_dark-small.png
new file mode 100644
index 000000000..ea25386e4
Binary files /dev/null and b/core/resources/pix/componenticons/ellipticalfin_dark-small.png differ
diff --git a/core/resources/pix/componenticons/flight-comp_dark-small.png b/core/resources/pix/componenticons/flight-comp_dark-small.png
new file mode 100644
index 000000000..658443a1f
Binary files /dev/null and b/core/resources/pix/componenticons/flight-comp_dark-small.png differ
diff --git a/core/resources/pix/componenticons/freeformfin_dark-large.png b/core/resources/pix/componenticons/freeformfin_dark-large.png
new file mode 100644
index 000000000..a1f1e694d
Binary files /dev/null and b/core/resources/pix/componenticons/freeformfin_dark-large.png differ
diff --git a/core/resources/pix/componenticons/freeformfin_dark-small.png b/core/resources/pix/componenticons/freeformfin_dark-small.png
new file mode 100644
index 000000000..ddcb3f2aa
Binary files /dev/null and b/core/resources/pix/componenticons/freeformfin_dark-small.png differ
diff --git a/core/resources/pix/componenticons/launchlug_dark-large.png b/core/resources/pix/componenticons/launchlug_dark-large.png
new file mode 100644
index 000000000..faba92982
Binary files /dev/null and b/core/resources/pix/componenticons/launchlug_dark-large.png differ
diff --git a/core/resources/pix/componenticons/launchlug_dark-small.png b/core/resources/pix/componenticons/launchlug_dark-small.png
new file mode 100644
index 000000000..e3296b66b
Binary files /dev/null and b/core/resources/pix/componenticons/launchlug_dark-small.png differ
diff --git a/core/resources/pix/componenticons/mass_dark-large.png b/core/resources/pix/componenticons/mass_dark-large.png
new file mode 100644
index 000000000..e41e1f590
Binary files /dev/null and b/core/resources/pix/componenticons/mass_dark-large.png differ
diff --git a/core/resources/pix/componenticons/mass_dark-small.png b/core/resources/pix/componenticons/mass_dark-small.png
new file mode 100644
index 000000000..192e767ea
Binary files /dev/null and b/core/resources/pix/componenticons/mass_dark-small.png differ
diff --git a/core/resources/pix/componenticons/parachute_dark-large.png b/core/resources/pix/componenticons/parachute_dark-large.png
new file mode 100644
index 000000000..bcdc3b9d4
Binary files /dev/null and b/core/resources/pix/componenticons/parachute_dark-large.png differ
diff --git a/core/resources/pix/componenticons/parachute_dark-small.png b/core/resources/pix/componenticons/parachute_dark-small.png
new file mode 100644
index 000000000..b837e4ece
Binary files /dev/null and b/core/resources/pix/componenticons/parachute_dark-small.png differ
diff --git a/core/resources/pix/componenticons/pods_dark-large.png b/core/resources/pix/componenticons/pods_dark-large.png
new file mode 100644
index 000000000..a88920e9a
Binary files /dev/null and b/core/resources/pix/componenticons/pods_dark-large.png differ
diff --git a/core/resources/pix/componenticons/pods_dark-small.png b/core/resources/pix/componenticons/pods_dark-small.png
new file mode 100644
index 000000000..8f9ad6d22
Binary files /dev/null and b/core/resources/pix/componenticons/pods_dark-small.png differ
diff --git a/core/resources/pix/componenticons/recovery-hardware_dark-small.png b/core/resources/pix/componenticons/recovery-hardware_dark-small.png
new file mode 100644
index 000000000..b3eb482b9
Binary files /dev/null and b/core/resources/pix/componenticons/recovery-hardware_dark-small.png differ
diff --git a/core/resources/pix/componenticons/shockcord_dark-large.png b/core/resources/pix/componenticons/shockcord_dark-large.png
new file mode 100644
index 000000000..437f56a49
Binary files /dev/null and b/core/resources/pix/componenticons/shockcord_dark-large.png differ
diff --git a/core/resources/pix/componenticons/shockcord_dark-small.png b/core/resources/pix/componenticons/shockcord_dark-small.png
new file mode 100644
index 000000000..c673df524
Binary files /dev/null and b/core/resources/pix/componenticons/shockcord_dark-small.png differ
diff --git a/core/resources/pix/componenticons/streamer_dark-large.png b/core/resources/pix/componenticons/streamer_dark-large.png
new file mode 100644
index 000000000..734c726bc
Binary files /dev/null and b/core/resources/pix/componenticons/streamer_dark-large.png differ
diff --git a/core/resources/pix/componenticons/streamer_dark-small.png b/core/resources/pix/componenticons/streamer_dark-small.png
new file mode 100644
index 000000000..a0ac436d2
Binary files /dev/null and b/core/resources/pix/componenticons/streamer_dark-small.png differ
diff --git a/core/resources/pix/componenticons/tracker_dark-small.png b/core/resources/pix/componenticons/tracker_dark-small.png
new file mode 100644
index 000000000..1af0e0588
Binary files /dev/null and b/core/resources/pix/componenticons/tracker_dark-small.png differ
diff --git a/core/resources/pix/componenticons/tubefin-large.png b/core/resources/pix/componenticons/tubefin-large.png
index 76120e258..5de7272a5 100644
Binary files a/core/resources/pix/componenticons/tubefin-large.png and b/core/resources/pix/componenticons/tubefin-large.png differ
diff --git a/core/resources/pix/componenticons/tubefin-small.png b/core/resources/pix/componenticons/tubefin-small.png
index 334bad233..addf83b3f 100644
Binary files a/core/resources/pix/componenticons/tubefin-small.png and b/core/resources/pix/componenticons/tubefin-small.png differ
diff --git a/install4j/23.09/openrocket-23.09.install4j b/install4j/23.09/openrocket-23.09.install4j
index e609e716c..fd9c9dcc8 100644
--- a/install4j/23.09/openrocket-23.09.install4j
+++ b/install4j/23.09/openrocket-23.09.install4j
@@ -29,7 +29,7 @@
-
+
diff --git a/swing/resources/datafiles/examples/A 3D printable model rocket.ork b/swing/resources/datafiles/examples/A 3D printable model rocket.ork
index 4b3a2bbea..7c1ff65d8 100644
Binary files a/swing/resources/datafiles/examples/A 3D printable model rocket.ork and b/swing/resources/datafiles/examples/A 3D printable model rocket.ork differ
diff --git a/swing/src/net/sf/openrocket/file/wavefrontobj/OBJOptionChooser.java b/swing/src/net/sf/openrocket/file/wavefrontobj/OBJOptionChooser.java
index d23149313..ec42ad0a0 100644
--- a/swing/src/net/sf/openrocket/file/wavefrontobj/OBJOptionChooser.java
+++ b/swing/src/net/sf/openrocket/file/wavefrontobj/OBJOptionChooser.java
@@ -5,6 +5,7 @@ import net.sf.openrocket.file.wavefrontobj.export.OBJExportOptions;
import net.sf.openrocket.gui.SpinnerEditor;
import net.sf.openrocket.gui.adaptors.DoubleModel;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.rocketcomponent.ComponentAssembly;
import net.sf.openrocket.rocketcomponent.Rocket;
@@ -27,6 +28,7 @@ import javax.swing.JToggleButton;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import java.awt.Color;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -64,6 +66,12 @@ public class OBJOptionChooser extends JPanel {
private int totallyNormalCounter = 0;
+ private static Color darkWarningColor;
+
+ static {
+ initColors();
+ }
+
public OBJOptionChooser(JComponent parent, OBJExportOptions opts, List selectedComponents, Rocket rocket) {
super(new MigLayout("hidemode 3"));
@@ -305,13 +313,22 @@ public class OBJOptionChooser extends JPanel {
loadOptions(opts);
}
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(OBJOptionChooser::updateColors);
+ }
+
+ private static void updateColors() {
+ darkWarningColor = GUIUtil.getUITheme().getDarkWarningColor();
+ }
+
/**
* Highlight the given button and un-highlight the other button.
* @param highlightButton The button to highlight
* @param loserButton The button to un-highlight
*/
private void highlightButton(JButton highlightButton, JButton loserButton) {
- highlightButton.setBorder(BorderFactory.createLineBorder(GUIUtil.getUITheme().getDarkWarningColor()));
+ highlightButton.setBorder(BorderFactory.createLineBorder(darkWarningColor));
loserButton.setBorder(UIManager.getBorder("Button.border"));
}
diff --git a/swing/src/net/sf/openrocket/gui/components/BasicTree.java b/swing/src/net/sf/openrocket/gui/components/BasicTree.java
index c3d75231e..6da216522 100644
--- a/swing/src/net/sf/openrocket/gui/components/BasicTree.java
+++ b/swing/src/net/sf/openrocket/gui/components/BasicTree.java
@@ -1,6 +1,7 @@
package net.sf.openrocket.gui.components;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import java.awt.BasicStroke;
import java.awt.Color;
@@ -16,6 +17,12 @@ import javax.swing.tree.TreePath;
@SuppressWarnings("serial")
public class BasicTree extends JTree {
+ private static Color backgroundColor;
+
+ static {
+ initColors();
+ }
+
public BasicTree() {
super();
setDefaultOptions();
@@ -37,10 +44,18 @@ public class BasicTree extends JTree {
plainUI.setLeftChildIndent(15);
- this.setBackground(GUIUtil.getUITheme().getBackgroundColor());
+ this.setBackground(backgroundColor);
this.setShowsRootHandles(false);
}
-
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(BasicTree::updateColors);
+ }
+
+ private static void updateColors() {
+ backgroundColor = GUIUtil.getUITheme().getBackgroundColor();
+ }
/**
* Expand the entire tree structure. All nodes will be visible after the call.
diff --git a/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java b/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java
index 947f70335..edc39f6f7 100644
--- a/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java
+++ b/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java
@@ -1,6 +1,7 @@
package net.sf.openrocket.gui.components;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.gui.util.URLUtil;
import java.awt.Color;
@@ -16,6 +17,7 @@ import java.io.File;
import java.io.FileOutputStream;
import javax.swing.JTextPane;
+import javax.swing.border.Border;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.SimpleAttributeSet;
@@ -33,6 +35,12 @@ public class DescriptionArea extends JScrollPane {
private final JEditorPane editorPane;
private final float size;
+
+ private static Border border;
+
+ static {
+ initColors();
+ }
/**
@@ -177,11 +185,20 @@ public class DescriptionArea extends JScrollPane {
dim.height = lineheight * rows + extraheight + 2;
this.setPreferredSize(dim);
- editorPane.setBorder(GUIUtil.getUITheme().getBorder());
+ editorPane.setBorder(border);
this.setViewportView(editorPane);
this.setText(text);
}
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(DescriptionArea::updateColors);
+ }
+
+ private static void updateColors() {
+ border = GUIUtil.getUITheme().getBorder();
+ }
public void setText(String txt) {
// Set the font size (we can't simply set the font to change the font size, because we're using text/html)
diff --git a/swing/src/net/sf/openrocket/gui/components/URLLabel.java b/swing/src/net/sf/openrocket/gui/components/URLLabel.java
index 3d9a45321..cc64b9b50 100644
--- a/swing/src/net/sf/openrocket/gui/components/URLLabel.java
+++ b/swing/src/net/sf/openrocket/gui/components/URLLabel.java
@@ -1,5 +1,6 @@
package net.sf.openrocket.gui.components;
+import java.awt.Color;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.event.MouseAdapter;
@@ -9,6 +10,7 @@ import java.util.HashMap;
import java.util.Map;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.gui.util.URLUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -22,6 +24,12 @@ import org.slf4j.LoggerFactory;
public class URLLabel extends SelectableLabel {
private static final Logger log = LoggerFactory.getLogger(URLLabel.class);
+ private static Color URLColor;
+
+ static {
+ initColors();
+ }
+
/**
* Create a label showing the url it will direct to.
*
@@ -48,7 +56,7 @@ public class URLLabel extends SelectableLabel {
Map map = new HashMap();
map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
this.setFont(this.getFont().deriveFont(map));
- this.setForeground(GUIUtil.getUITheme().getURLColor());
+ this.setForeground(URLColor);
this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
@@ -66,4 +74,13 @@ public class URLLabel extends SelectableLabel {
}
}
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(URLLabel::updateColors);
+ }
+
+ private static void updateColors() {
+ URLColor = GUIUtil.getUITheme().getURLColor();
+ }
}
diff --git a/swing/src/net/sf/openrocket/gui/configdialog/InnerTubeConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/InnerTubeConfig.java
index 98709e734..d3c267ff1 100644
--- a/swing/src/net/sf/openrocket/gui/configdialog/InnerTubeConfig.java
+++ b/swing/src/net/sf/openrocket/gui/configdialog/InnerTubeConfig.java
@@ -41,6 +41,7 @@ import net.sf.openrocket.gui.components.BasicSlider;
import net.sf.openrocket.gui.components.DescriptionArea;
import net.sf.openrocket.gui.components.UnitSelector;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.gui.widgets.SelectColorButton;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.material.Material;
@@ -467,15 +468,15 @@ class ClusterSelectionPanel extends JPanel {
private static final int MOTOR_DIAMETER = 10;
private static final Color SELECTED_COLOR;
- private static final Color UNSELECTED_COLOR;
+ private static Color UNSELECTED_COLOR;
private static final Color MOTOR_FILL_COLOR;
private static final Color MOTOR_BORDER_COLOR;
static {
SELECTED_COLOR = Color.RED;
- UNSELECTED_COLOR = GUIUtil.getUITheme().getBackgroundColor();
MOTOR_FILL_COLOR = Color.GREEN;
MOTOR_BORDER_COLOR = Color.BLACK;
+ initColors();
}
public ClusterSelectionPanel(Clusterable component) {
@@ -495,6 +496,15 @@ class ClusterSelectionPanel extends JPanel {
}
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(ClusterSelectionPanel::updateColors);
+ }
+
+ private static void updateColors() {
+ UNSELECTED_COLOR = GUIUtil.getUITheme().getBackgroundColor();
+ }
+
private class ClusterButton extends JPanel implements StateChangeListener, MouseListener,
Resettable {
diff --git a/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java
index e5a985341..0239958b8 100644
--- a/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java
+++ b/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java
@@ -30,6 +30,7 @@ import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
+import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@@ -49,6 +50,7 @@ import net.sf.openrocket.gui.components.UnitSelector;
import net.sf.openrocket.gui.dialogs.preset.ComponentPresetChooserDialog;
import net.sf.openrocket.gui.util.GUIUtil;
import net.sf.openrocket.gui.util.Icons;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.gui.widgets.IconToggleButton;
import net.sf.openrocket.gui.widgets.SelectColorButton;
import net.sf.openrocket.l10n.Translator;
@@ -97,6 +99,14 @@ public class RocketComponentConfig extends JPanel {
private boolean allSameType; // Checks whether all listener components are of the same type as
private boolean allMassive; // Checks whether all listener components, and this component, are massive
+ private static Color darkWarningColor;
+ private static Color multiCompEditColor;
+ private static Border border;
+
+ static {
+ initColors();
+ }
+
public RocketComponentConfig(OpenRocketDocument document, RocketComponent component, JDialog parent) {
setLayout(new MigLayout("fill, gap 4!, ins panel, hidemode 3", "[]:5[]", "[growprio 5]5![fill, grow, growprio 500]5![growprio 5]"));
@@ -187,6 +197,17 @@ public class RocketComponentConfig extends JPanel {
updateFields();
}
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(RocketComponentConfig::updateColors);
+ }
+
+ private static void updateColors() {
+ darkWarningColor = GUIUtil.getUITheme().getDarkWarningColor();
+ multiCompEditColor = GUIUtil.getUITheme().getMultiCompEditColor();
+ border = GUIUtil.getUITheme().getBorder();
+ }
+
/**
* Add a section to the component configuration dialog that displays information about the component.
*/
@@ -251,7 +272,7 @@ public class RocketComponentConfig extends JPanel {
//// Multi-comp edit label
multiCompEditLabel = new StyledLabel(" ", -1, Style.BOLD);
- multiCompEditLabel.setFontColor(new Color(170, 0, 100));
+ multiCompEditLabel.setFontColor(multiCompEditColor);
buttonPanel.add(multiCompEditLabel, "split 2");
//// Mass:
@@ -506,7 +527,7 @@ public class RocketComponentConfig extends JPanel {
StyledLabel labelMassOverriddenBy = new StyledLabel(
String.format(trans.get("RocketCompCfg.lbl.MassOverriddenBy"), component.getMassOverriddenBy().getName()),
0, StyledLabel.Style.BOLD);
- labelMassOverriddenBy.setFontColor(GUIUtil.getUITheme().getDarkWarningColor());
+ labelMassOverriddenBy.setFontColor(darkWarningColor);
labelMassOverriddenBy.setToolTipText(
String.format(trans.get("RocketCompCfg.lbl.MassOverriddenBy.ttip"), component.getMassOverriddenBy().getName()));
checkboxes.add(labelMassOverriddenBy, "gapleft 25lp, wrap");
@@ -569,7 +590,7 @@ public class RocketComponentConfig extends JPanel {
StyledLabel labelCGOverriddenBy = new StyledLabel(
String.format(trans.get("RocketCompCfg.lbl.CGOverriddenBy"), component.getCGOverriddenBy().getName()),
0, StyledLabel.Style.BOLD);
- labelCGOverriddenBy.setFontColor(GUIUtil.getUITheme().getDarkWarningColor());
+ labelCGOverriddenBy.setFontColor(darkWarningColor);
labelCGOverriddenBy.setToolTipText(
String.format(trans.get("RocketCompCfg.lbl.CGOverriddenBy.ttip"), component.getCGOverriddenBy().getName()));
checkboxes.add(labelCGOverriddenBy, "gapleft 25lp, wrap");
@@ -663,7 +684,7 @@ public class RocketComponentConfig extends JPanel {
StyledLabel labelCDOverriddenBy = new StyledLabel(
String.format(trans.get("RocketCompCfg.lbl.CDOverriddenBy"), component.getCDOverriddenBy().getName()),
0, StyledLabel.Style.BOLD);
- labelCDOverriddenBy.setFontColor(GUIUtil.getUITheme().getDarkWarningColor());
+ labelCDOverriddenBy.setFontColor(darkWarningColor);
labelCDOverriddenBy.setToolTipText(
String.format(trans.get("RocketCompCfg.lbl.CDOverriddenBy"), component.getCDOverriddenBy().getName()));
checkboxes.add(labelCDOverriddenBy, "gapleft 25lp, wrap");
@@ -719,7 +740,7 @@ public class RocketComponentConfig extends JPanel {
commentTextArea.setLineWrap(true);
commentTextArea.setWrapStyleWord(true);
commentTextArea.setEditable(true);
- commentTextArea.setBorder(GUIUtil.getUITheme().getBorder());
+ commentTextArea.setBorder(border);
GUIUtil.setTabToFocusing(commentTextArea);
commentTextArea.addFocusListener(textFieldListener);
commentTextArea.addKeyListener(new TextComponentSelectionKeyListener(commentTextArea));
diff --git a/swing/src/net/sf/openrocket/gui/configdialog/RocketConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/RocketConfig.java
index 9835778ca..0b7bd3df4 100644
--- a/swing/src/net/sf/openrocket/gui/configdialog/RocketConfig.java
+++ b/swing/src/net/sf/openrocket/gui/configdialog/RocketConfig.java
@@ -16,10 +16,12 @@ import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
+import javax.swing.border.Border;
import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.RocketComponent;
@@ -34,6 +36,12 @@ public class RocketConfig extends RocketComponentConfig {
private JTextArea revisionTextArea;
private final Rocket rocket;
+
+ private static Border border;
+
+ static {
+ initColors();
+ }
public RocketConfig(OpenRocketDocument d, RocketComponent c, JDialog parent) {
super(d, c, parent);
@@ -55,7 +63,7 @@ public class RocketConfig extends RocketComponentConfig {
designerTextArea.setLineWrap(true);
designerTextArea.setWrapStyleWord(true);
designerTextArea.setEditable(true);
- designerTextArea.setBorder(GUIUtil.getUITheme().getBorder());
+ designerTextArea.setBorder(border);
GUIUtil.setTabToFocusing(designerTextArea);
designerTextArea.addFocusListener(textFieldListener);
this.add(new JScrollPane(designerTextArea), "wmin 400lp, height 60lp:60lp:, grow 30, wrap para");
@@ -70,7 +78,7 @@ public class RocketConfig extends RocketComponentConfig {
revisionTextArea.setLineWrap(true);
revisionTextArea.setWrapStyleWord(true);
revisionTextArea.setEditable(true);
- revisionTextArea.setBorder(GUIUtil.getUITheme().getBorder());
+ revisionTextArea.setBorder(border);
GUIUtil.setTabToFocusing(revisionTextArea);
revisionTextArea.addFocusListener(textFieldListener);
@@ -81,6 +89,15 @@ public class RocketConfig extends RocketComponentConfig {
addEasterEgg();
}
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(RocketConfig::updateColors);
+ }
+
+ private static void updateColors() {
+ border = GUIUtil.getUITheme().getBorder();
+ }
+
/**
* Little method that adds a fun easter-egg to the rocket config dialog.
*/
diff --git a/swing/src/net/sf/openrocket/gui/customexpression/CustomExpressionPanel.java b/swing/src/net/sf/openrocket/gui/customexpression/CustomExpressionPanel.java
index c37e8ed2b..8470a6a9a 100644
--- a/swing/src/net/sf/openrocket/gui/customexpression/CustomExpressionPanel.java
+++ b/swing/src/net/sf/openrocket/gui/customexpression/CustomExpressionPanel.java
@@ -1,5 +1,6 @@
package net.sf.openrocket.gui.customexpression;
+import java.awt.Color;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -15,10 +16,12 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
+import javax.swing.border.Border;
import javax.swing.filechooser.FileNameExtensionFilter;
import net.sf.openrocket.gui.util.GUIUtil;
import net.sf.openrocket.gui.util.SwingPreferences;
+import net.sf.openrocket.gui.util.UITheme;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,7 +45,13 @@ public class CustomExpressionPanel extends JPanel {
private JPanel expressionSelectorPanel;
private OpenRocketDocument doc;
-
+
+ private static Border border;
+
+ static {
+ initColors();
+ }
+
public CustomExpressionPanel(final OpenRocketDocument doc, final JDialog parentDialog) {
super(new MigLayout("fill"));
this.doc = doc;
@@ -51,7 +60,7 @@ public class CustomExpressionPanel extends JPanel {
expressionSelectorPanel.setToolTipText(trans.get("customExpressionPanel.lbl.CalcNote"));
JScrollPane scroll = new JScrollPane(expressionSelectorPanel);
- expressionSelectorPanel.setBorder(GUIUtil.getUITheme().getBorder());
+ expressionSelectorPanel.setBorder(border);
//Border bdr = BorderFactory.createTitledBorder(trans.get("customExpressionPanel.lbl.CustomExpressions"));
//scroll.setBorder(bdr);
@@ -131,7 +140,16 @@ public class CustomExpressionPanel extends JPanel {
updateExpressions();
}
-
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(CustomExpressionPanel::updateColors);
+ }
+
+ private static void updateColors() {
+ border = GUIUtil.getUITheme().getBorder();
+ }
+
/*
* Update the expressionSelectorPanel
*/
@@ -171,10 +189,24 @@ public class CustomExpressionPanel extends JPanel {
* A JPanel which configures a single expression
*/
private class SingleExpression extends JPanel {
+ private static Color backgroundColor;
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(SingleExpression::updateColors);
+ }
+
+ static {
+ initColors();
+ }
+
+ private static void updateColors() {
+ backgroundColor = GUIUtil.getUITheme().getBackgroundColor();
+ }
// Convenience method to make the labels consistent
private JLabel setLabelStyle(JLabel l) {
- l.setBackground(GUIUtil.getUITheme().getBackgroundColor());
+ l.setBackground(backgroundColor);
l.setOpaque(true);
l.setBorder(BorderFactory.createRaisedBevelBorder());
l.setText(" " + l.getText() + " ");
@@ -192,7 +224,7 @@ public class CustomExpressionPanel extends JPanel {
JLabel symbolLabel = new JLabel(trans.get("customExpression.Symbol") + " :");
JLabel symbol = new JLabel(expression.getSymbol());
symbol = setLabelStyle(symbol);
- symbol.setBackground(GUIUtil.getUITheme().getBackgroundColor());
+ symbol.setBackground(backgroundColor);
JLabel unitLabel = new JLabel(trans.get("customExpression.Units") + " :");
UnitSelector unitSelector = new UnitSelector(expression.getType().getUnitGroup());
diff --git a/swing/src/net/sf/openrocket/gui/dialogs/BugReportDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/BugReportDialog.java
index 117384b51..7e9818629 100644
--- a/swing/src/net/sf/openrocket/gui/dialogs/BugReportDialog.java
+++ b/swing/src/net/sf/openrocket/gui/dialogs/BugReportDialog.java
@@ -29,6 +29,7 @@ import net.sf.openrocket.gui.components.StyledLabel;
import net.sf.openrocket.gui.components.URLLabel;
import net.sf.openrocket.gui.util.GUIUtil;
import net.sf.openrocket.gui.util.SwingPreferences;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.logging.LogLevelBufferLogger;
import net.sf.openrocket.logging.LogLine;
@@ -47,6 +48,12 @@ public class BugReportDialog extends JDialog {
private static final Translator trans = Application.getTranslator();
private static final SwingPreferences preferences = (SwingPreferences) Application.getPreferences();
+
+ private static Color darkWarningColor;
+
+ static {
+ initColors();
+ }
public BugReportDialog(Window parent, String labelText, final String message, final boolean sendIfUnchanged) {
@@ -103,6 +110,15 @@ public class BugReportDialog extends JDialog {
GUIUtil.setDisposableDialogOptions(this, close);
}
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(BugReportDialog::updateColors);
+ }
+
+ private static void updateColors() {
+ darkWarningColor = GUIUtil.getUITheme().getDarkWarningColor();
+ }
/**
* Show a general bug report dialog allowing the user to input information about
@@ -178,7 +194,7 @@ public class BugReportDialog extends JDialog {
private static void addBugReportInformation(StringBuilder sb) {
sb.append("---------- Bug report ----------\n");
sb.append('\n');
- Color color = GUIUtil.getUITheme().getDarkWarningColor();
+ Color color = darkWarningColor;
sb.append(String.format("Please include a description about what actions you were " +
"performing when the exception occurred:\n", color.getRed(), color.getGreen(), color.getBlue()));
sb.append("(You can edit text directly in this window)\n");
diff --git a/swing/src/net/sf/openrocket/gui/dialogs/ComponentAnalysisDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/ComponentAnalysisDialog.java
index 2a9d598d7..e91a4af75 100644
--- a/swing/src/net/sf/openrocket/gui/dialogs/ComponentAnalysisDialog.java
+++ b/swing/src/net/sf/openrocket/gui/dialogs/ComponentAnalysisDialog.java
@@ -33,6 +33,7 @@ import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
+import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.table.DefaultTableCellRenderer;
@@ -41,6 +42,7 @@ import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.aerodynamics.AerodynamicCalculator;
import net.sf.openrocket.aerodynamics.AerodynamicForces;
import net.sf.openrocket.aerodynamics.FlightConditions;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.logging.Warning;
import net.sf.openrocket.logging.WarningSet;
import net.sf.openrocket.gui.adaptors.Column;
@@ -97,6 +99,12 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
private final List dragData = new ArrayList();
private final List rollData = new ArrayList();
+ private static Border border;
+
+ static {
+ initColors();
+ }
+
public ComponentAnalysisDialog(final RocketPanel rocketPanel) {
////Component analysis
@@ -150,7 +158,7 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
warningList = new JList<>();
JScrollPane scrollPane = new JScrollPane(warningList);
- warningList.setBorder(GUIUtil.getUITheme().getBorder());
+ warningList.setBorder(border);
////Warnings:
scrollPane.setBorder(BorderFactory.createTitledBorder(trans.get("componentanalysisdlg.TitledBorder.warnings")));
panel.add(scrollPane, "gap paragraph, spany 4, w 300lp, grow, height :100lp:, wrap");
@@ -499,6 +507,14 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
}
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(ComponentAnalysisDialog::updateColors);
+ }
+
+ private static void updateColors() {
+ border = GUIUtil.getUITheme().getBorder();
+ }
/**
* Updates the data in the table and fires a table data change event.
@@ -626,6 +642,12 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
private final List> data;
protected final int decimalPlaces;
+ private static Color backgroundColor;
+
+ static {
+ initColors();
+ }
+
public CustomCellRenderer(List> data, int decimalPlaces) {
super();
this.decimalPlaces = decimalPlaces;
@@ -634,6 +656,15 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
this.boldFont = normalFont.deriveFont(Font.BOLD);
}
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(CustomCellRenderer::updateColors);
+ }
+
+ private static void updateColors() {
+ backgroundColor = GUIUtil.getUITheme().getBackgroundColor();
+ }
+
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
@@ -647,7 +678,7 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
}
label.setOpaque(true);
- label.setBackground(GUIUtil.getUITheme().getBackgroundColor());
+ label.setBackground(backgroundColor);
label.setHorizontalAlignment(SwingConstants.LEFT);
if ((row < 0) || (row >= data.size()))
diff --git a/swing/src/net/sf/openrocket/gui/dialogs/DebugLogDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/DebugLogDialog.java
index 26bbd5ddf..9fe13d2d0 100644
--- a/swing/src/net/sf/openrocket/gui/dialogs/DebugLogDialog.java
+++ b/swing/src/net/sf/openrocket/gui/dialogs/DebugLogDialog.java
@@ -32,12 +32,14 @@ import javax.swing.ListSelectionModel;
import javax.swing.RowFilter;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
+import javax.swing.border.Border;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
+import net.sf.openrocket.gui.util.UITheme;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -109,6 +111,12 @@ public class DebugLogDialog extends JDialog {
private final SelectableLabel locationLabel;
private final SelectableLabel messageLabel;
private final JTextArea stackTraceLabel;
+
+ private static Border border;
+
+ static {
+ initColors();
+ }
public DebugLogDialog(Window parent) {
//// OpenRocket debug log
@@ -343,7 +351,7 @@ public class DebugLogDialog extends JDialog {
bottomPanel.add(new JLabel(trans.get("debuglogdlg.lbl.Stacktrace")), "wrap rel");
stackTraceLabel = new JTextArea(8, 80);
stackTraceLabel.setEditable(false);
- stackTraceLabel.setBorder(GUIUtil.getUITheme().getBorder());
+ stackTraceLabel.setBorder(border);
GUIUtil.changeFontSize(stackTraceLabel, -2);
bottomPanel.add(new JScrollPane(stackTraceLabel), "grow, pushy 200, growprioy 200");
@@ -385,7 +393,16 @@ public class DebugLogDialog extends JDialog {
setLocationRelativeTo(parent);
followBox.requestFocus();
}
-
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(DebugLogDialog::updateColors);
+ }
+
+ private static void updateColors() {
+ border = GUIUtil.getUITheme().getBorder();
+ }
+
private void updateSelected(int row) {
if (row < 0) {
diff --git a/swing/src/net/sf/openrocket/gui/dialogs/ErrorWarningDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/ErrorWarningDialog.java
index 29e74dcde..13e2a8b1f 100644
--- a/swing/src/net/sf/openrocket/gui/dialogs/ErrorWarningDialog.java
+++ b/swing/src/net/sf/openrocket/gui/dialogs/ErrorWarningDialog.java
@@ -4,6 +4,7 @@ import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.gui.components.StyledLabel;
import net.sf.openrocket.gui.util.BetterListCellRenderer;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.logging.Error;
import net.sf.openrocket.logging.ErrorSet;
import net.sf.openrocket.logging.Warning;
@@ -16,6 +17,8 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.ListSelectionModel;
+import javax.swing.border.Border;
+import java.awt.Color;
import java.awt.Component;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@@ -25,12 +28,30 @@ import java.awt.event.MouseEvent;
*/
@SuppressWarnings("serial")
public abstract class ErrorWarningDialog {
+ private static Border border;
+ private static Color darkWarningColor;
+ private static Color textSelectionForegroundColor;
+
+ static {
+ initColors();
+ }
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(ErrorWarningDialog::updateColors);
+ }
+
+ private static void updateColors() {
+ border = GUIUtil.getUITheme().getBorder();
+ darkWarningColor = GUIUtil.getUITheme().getDarkWarningColor();
+ textSelectionForegroundColor = GUIUtil.getUITheme().getTextSelectionForegroundColor();
+ }
public static void showErrorsAndWarnings(Component parent, Object message, String title, ErrorSet errors, WarningSet warnings) {
JPanel content = new JPanel(new MigLayout("ins 0, fillx"));
StyledLabel label = new StyledLabel("Errors");
- label.setFontColor(GUIUtil.getUITheme().getDarkWarningColor());
+ label.setFontColor(darkWarningColor);
content.add(label, "wrap, gaptop 15lp");
Error[] e = errors.toArray(new Error[0]);
@@ -38,7 +59,7 @@ public abstract class ErrorWarningDialog {
errorList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
errorList.setCellRenderer(new ErrorListCellRenderer());
JScrollPane errorPane = new JScrollPane(errorList);
- errorList.setBorder(GUIUtil.getUITheme().getBorder());
+ errorList.setBorder(border);
content.add(errorPane, "wrap, growx");
// Deselect items if clicked on blank region
@@ -60,7 +81,7 @@ public abstract class ErrorWarningDialog {
final JList warningList = new JList<>(w);
warningList.setCellRenderer(new BetterListCellRenderer());
JScrollPane warningPane = new JScrollPane(warningList);
- warningList.setBorder(GUIUtil.getUITheme().getBorder());
+ warningList.setBorder(border);
content.add(warningPane, "wrap, growx");
// Deselect items if clicked on blank region
@@ -87,9 +108,9 @@ public abstract class ErrorWarningDialog {
// Text color
if (isSelected) {
- label.setForeground(GUIUtil.getUITheme().getTextSelectionForegroundColor());
+ label.setForeground(textSelectionForegroundColor);
} else {
- label.setForeground(GUIUtil.getUITheme().getDarkWarningColor());
+ label.setForeground(darkWarningColor);
}
return label;
diff --git a/swing/src/net/sf/openrocket/gui/dialogs/UpdateInfoDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/UpdateInfoDialog.java
index cf84659ca..cfcd415d7 100644
--- a/swing/src/net/sf/openrocket/gui/dialogs/UpdateInfoDialog.java
+++ b/swing/src/net/sf/openrocket/gui/dialogs/UpdateInfoDialog.java
@@ -1,5 +1,6 @@
package net.sf.openrocket.gui.dialogs;
+import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Insets;
@@ -32,6 +33,7 @@ import net.sf.openrocket.gui.components.StyledLabel;
import net.sf.openrocket.gui.util.GUIUtil;
import net.sf.openrocket.gui.util.Icons;
import net.sf.openrocket.gui.util.SwingPreferences;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.gui.util.URLUtil;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.startup.Application;
@@ -51,6 +53,12 @@ public class UpdateInfoDialog extends JDialog {
private static final Translator trans = Application.getTranslator();
private final SwingPreferences preferences = (SwingPreferences) Application.getPreferences();
+ private static Color textColor;
+
+ static {
+ initColors();
+ }
+
public UpdateInfoDialog(UpdateInfo info) {
//// OpenRocket update available
super(null, trans.get("update.dlg.updateAvailable.title"), ModalityType.APPLICATION_MODAL);
@@ -74,7 +82,7 @@ public class UpdateInfoDialog extends JDialog {
// Release information box
final JTextPane textPane = new JTextPane();
- textPane.setBorder(BorderFactory.createLineBorder(GUIUtil.getUITheme().getTextColor()));
+ textPane.setBorder(BorderFactory.createLineBorder(textColor));
textPane.setEditable(false);
textPane.setContentType("text/html");
textPane.setMargin(new Insets(10, 10, 40, 10));
@@ -201,6 +209,15 @@ public class UpdateInfoDialog extends JDialog {
GUIUtil.setDisposableDialogOptions(this, btnLater);
}
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(UpdateInfoDialog::updateColors);
+ }
+
+ private static void updateColors() {
+ textColor = GUIUtil.getUITheme().getTextColor();
+ }
+
/**
* ComboBox renderer to display an UpdatePlatform by the platform name
*/
diff --git a/swing/src/net/sf/openrocket/gui/dialogs/WarningDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/WarningDialog.java
index ec2a0a34a..5eb41437c 100644
--- a/swing/src/net/sf/openrocket/gui/dialogs/WarningDialog.java
+++ b/swing/src/net/sf/openrocket/gui/dialogs/WarningDialog.java
@@ -6,21 +6,37 @@ import javax.swing.BorderFactory;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
+import javax.swing.border.Border;
import net.sf.openrocket.gui.util.BetterListCellRenderer;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.logging.Warning;
import net.sf.openrocket.logging.WarningSet;
@SuppressWarnings("serial")
public abstract class WarningDialog {
+ private static Border border;
+
+ static {
+ initColors();
+ }
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(WarningDialog::updateColors);
+ }
+
+ private static void updateColors() {
+ border = GUIUtil.getUITheme().getBorder();
+ }
+
public static void showWarnings(Component parent, Object message, String title, WarningSet warnings) {
-
Warning[] w = warnings.toArray(new Warning[0]);
final JList list = new JList(w);
list.setCellRenderer(new BetterListCellRenderer());
JScrollPane pane = new JScrollPane(list);
- pane.setBorder(GUIUtil.getUITheme().getBorder());
+ pane.setBorder(border);
JOptionPane.showMessageDialog(parent, new Object[] { message, pane },
title, JOptionPane.WARNING_MESSAGE);
diff --git a/swing/src/net/sf/openrocket/gui/dialogs/WelcomeDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/WelcomeDialog.java
index 4d1cfa805..6b8d92d74 100644
--- a/swing/src/net/sf/openrocket/gui/dialogs/WelcomeDialog.java
+++ b/swing/src/net/sf/openrocket/gui/dialogs/WelcomeDialog.java
@@ -4,6 +4,7 @@ import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.gui.components.StyledLabel;
import net.sf.openrocket.gui.util.GUIUtil;
import net.sf.openrocket.gui.util.Icons;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.gui.util.URLUtil;
import net.sf.openrocket.gui.widgets.SelectColorButton;
import net.sf.openrocket.l10n.Translator;
@@ -20,9 +21,9 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
+import javax.swing.border.Border;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
-import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.event.ActionEvent;
@@ -35,6 +36,12 @@ public class WelcomeDialog extends JDialog {
private static final Translator trans = Application.getTranslator();
private static final Logger log = LoggerFactory.getLogger(WelcomeDialog.class);
+ private static Border border;
+
+ static {
+ initColors();
+ }
+
/**
* @param releaseNotes the release notes to display for the current version
*/
@@ -82,7 +89,7 @@ public class WelcomeDialog extends JDialog {
textPane.setCaretPosition(0); // Scroll to the top
JScrollPane scrollPane = new JScrollPane(textPane);
- scrollPane.setBorder(GUIUtil.getUITheme().getBorder());
+ scrollPane.setBorder(border);
panel.add(scrollPane, "skip 1, left, spanx, grow, push, gapbottom 6px, wrap");
// Don't show this dialog again
@@ -114,4 +121,13 @@ public class WelcomeDialog extends JDialog {
this.setLocationRelativeTo(null);
GUIUtil.setDisposableDialogOptions(this, closeBtn);
}
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(WelcomeDialog::updateColors);
+ }
+
+ private static void updateColors() {
+ border = GUIUtil.getUITheme().getBorder();
+ }
}
diff --git a/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/RenameConfigDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/RenameConfigDialog.java
index 7cb232a0b..df94a3ffc 100644
--- a/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/RenameConfigDialog.java
+++ b/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/RenameConfigDialog.java
@@ -1,5 +1,6 @@
package net.sf.openrocket.gui.dialogs.flightconfiguration;
+import java.awt.Color;
import java.awt.Dialog;
import java.awt.Window;
import java.awt.event.ActionEvent;
@@ -15,6 +16,7 @@ import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.gui.components.StyledLabel;
import net.sf.openrocket.gui.configdialog.CommonStrings;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
import net.sf.openrocket.rocketcomponent.Rocket;
@@ -25,6 +27,12 @@ public class RenameConfigDialog extends JDialog {
private static final long serialVersionUID = -5423008694485357248L;
private static final Translator trans = Application.getTranslator();
+ private static Color dimTextColor;
+
+ static {
+ initColors();
+ }
+
public RenameConfigDialog(final Window parent, final Rocket rocket, final FlightConfigurationId fcid) {
super(parent, trans.get("RenameConfigDialog.title"), Dialog.ModalityType.APPLICATION_MODAL);
@@ -73,11 +81,20 @@ public class RenameConfigDialog extends JDialog {
+ trans.get("RenameConfigDialog.lbl.infoCases")
+ trans.get("RenameConfigDialog.lbl.infoCombination");
StyledLabel info = new StyledLabel(text, -2);
- info.setFontColor(GUIUtil.getUITheme().getDimTextColor());
+ info.setFontColor(dimTextColor);
panel.add(info, "spanx, growx, wrap");
this.add(panel);
GUIUtil.setDisposableDialogOptions(this, okButton);
}
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(RenameConfigDialog::updateColors);
+ }
+
+ private static void updateColors() {
+ dimTextColor = GUIUtil.getUITheme().getDimTextColor();
+ }
}
diff --git a/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/MotorFilterPanel.java b/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/MotorFilterPanel.java
index 4e461b983..4d1682adc 100644
--- a/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/MotorFilterPanel.java
+++ b/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/MotorFilterPanel.java
@@ -34,6 +34,7 @@ import net.sf.openrocket.gui.components.UnitSelector;
import net.sf.openrocket.gui.util.CheckList;
import net.sf.openrocket.gui.util.GUIUtil;
import net.sf.openrocket.gui.util.SwingPreferences;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.gui.widgets.MultiSlider;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.motor.Manufacturer;
@@ -118,6 +119,12 @@ public abstract class MotorFilterPanel extends JPanel {
private final MultiSlider lengthSlider;
private final MultiSlider diameterSlider;
+ private static Border border;
+
+ static {
+ initColors();
+ }
+
public MotorFilterPanel(Collection allManufacturers, MotorRowFilter filter ) {
super(new MigLayout("fill", "[grow]"));
this.filter = filter;
@@ -146,7 +153,7 @@ public abstract class MotorFilterPanel extends JPanel {
// Manufacturer selection
JPanel sub = new JPanel(new MigLayout("fill"));
- Border templateBorder = GUIUtil.getUITheme().getBorder();
+ Border templateBorder = border;
TitledBorder border = BorderFactory.createTitledBorder(templateBorder);
border.setTitle(trans.get("TCurveMotorCol.MANUFACTURER"));
GUIUtil.changeFontStyle(border, Font.BOLD);
@@ -186,9 +193,8 @@ public abstract class MotorFilterPanel extends JPanel {
});
JScrollPane scrollPane = new JScrollPane(manufacturerCheckList.getList());
- Border border1 = GUIUtil.getUITheme().getBorder();
- if (border1 != null) {
- scrollPane.setBorder(border1);
+ if (border != null) {
+ scrollPane.setBorder(border);
}
sub.add(scrollPane, "grow, pushy, wrap");
@@ -368,6 +374,15 @@ public abstract class MotorFilterPanel extends JPanel {
}
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(MotorFilterPanel::updateColors);
+ }
+
+ private static void updateColors() {
+ border = GUIUtil.getUITheme().getBorder();
+ }
+
public void setMotorMount( MotorMount mount ) {
filter.setMotorMount(mount);
onSelectionChanged();
diff --git a/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/MotorInformationPanel.java b/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/MotorInformationPanel.java
index 741b61ecd..ddb02dde9 100644
--- a/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/MotorInformationPanel.java
+++ b/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/MotorInformationPanel.java
@@ -15,7 +15,9 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
+import javax.swing.border.Border;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.util.StringUtils;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
@@ -42,8 +44,10 @@ class MotorInformationPanel extends JPanel {
private static final int ZOOM_ICON_POSITION_NEGATIVE_X = 50;
private static final int ZOOM_ICON_POSITION_POSITIVE_Y = 12;
- private static final Color NO_COMMENT_COLOR = GUIUtil.getUITheme().getDimTextColor();
- private static final Color WITH_COMMENT_COLOR = GUIUtil.getUITheme().getTextColor();
+ private static Color NO_COMMENT_COLOR;
+ private static Color WITH_COMMENT_COLOR;
+ private static Color textColor;
+ private static Border border;
// Motors in set
private List selectedMotorSet;
@@ -74,6 +78,10 @@ class MotorInformationPanel extends JPanel {
private final ChartPanel chartPanel;
private final JLabel zoomIcon;
+ static {
+ initColors();
+ }
+
public MotorInformationPanel() {
super(new MigLayout("fill"));
@@ -159,7 +167,7 @@ class MotorInformationPanel extends JPanel {
comment = new JTextArea(5, 5);
- comment.setBorder(GUIUtil.getUITheme().getBorder());
+ comment.setBorder(border);
GUIUtil.changeFontSize(comment, -2);
withCommentFont = comment.getFont();
noCommentFont = withCommentFont.deriveFont(Font.ITALIC);
@@ -191,7 +199,7 @@ class MotorInformationPanel extends JPanel {
//// Thrust curve:
TextTitle title = new TextTitle(trans.get("TCMotorSelPan.title.Thrustcurve"), this.getFont());
- title.setPaint(GUIUtil.getUITheme().getTextColor());
+ title.setPaint(textColor);
chart.setTitle(title);
chart.setBackgroundPaint(this.getBackground());
plot.setBackgroundPaint(Color.WHITE);
@@ -239,6 +247,18 @@ class MotorInformationPanel extends JPanel {
this.add(layer, "width 300:300:, height 180:180:, grow, spanx");
}
}
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(MotorInformationPanel::updateColors);
+ }
+
+ private static void updateColors() {
+ NO_COMMENT_COLOR = GUIUtil.getUITheme().getDimTextColor();
+ WITH_COMMENT_COLOR = GUIUtil.getUITheme().getTextColor();
+ textColor = GUIUtil.getUITheme().getTextColor();
+ border = GUIUtil.getUITheme().getBorder();
+ }
public void clearData() {
selectedMotor = null;
diff --git a/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorSelectionPanel.java b/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorSelectionPanel.java
index 2cc104581..60f4eff46 100644
--- a/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorSelectionPanel.java
+++ b/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorSelectionPanel.java
@@ -111,6 +111,12 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
private ThrustCurveMotorSet selectedMotorSet;
private double selectedDelay;
+ private static Color dimTextColor;
+
+ static {
+ initColors();
+ }
+
public ThrustCurveMotorSelectionPanel( final FlightConfigurationId fcid, MotorMount mount ) {
this();
setMotorMountAndConfig( fcid, mount );
@@ -336,7 +342,7 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
nrOfMotorsLabel = new StyledLabel(-2f, StyledLabel.Style.ITALIC);
nrOfMotorsLabel.setToolTipText(trans.get("TCMotorSelPan.lbl.ttip.nrOfMotors"));
updateNrOfMotors();
- nrOfMotorsLabel.setForeground(GUIUtil.getUITheme().getDimTextColor());
+ nrOfMotorsLabel.setForeground(dimTextColor);
panel.add(nrOfMotorsLabel, "gapleft para, spanx, wrap");
sorter.addRowSorterListener(new RowSorterListener() {
@Override
@@ -400,6 +406,15 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
}
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(ThrustCurveMotorSelectionPanel::updateColors);
+ }
+
+ private static void updateColors() {
+ dimTextColor = GUIUtil.getUITheme().getDimTextColor();
+ }
+
public void setMotorMountAndConfig( final FlightConfigurationId _fcid, MotorMount mountToEdit ) {
if ( null == _fcid ){
throw new NullPointerException(" attempted to set mount with a null FCID. bug. ");
diff --git a/swing/src/net/sf/openrocket/gui/dialogs/optimization/SimulationModifierTree.java b/swing/src/net/sf/openrocket/gui/dialogs/optimization/SimulationModifierTree.java
index 8718a48a6..f2c56dc30 100644
--- a/swing/src/net/sf/openrocket/gui/dialogs/optimization/SimulationModifierTree.java
+++ b/swing/src/net/sf/openrocket/gui/dialogs/optimization/SimulationModifierTree.java
@@ -1,5 +1,6 @@
package net.sf.openrocket.gui.dialogs.optimization;
+import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.util.Enumeration;
@@ -17,6 +18,7 @@ import javax.swing.tree.TreePath;
import net.sf.openrocket.gui.components.BasicTree;
import net.sf.openrocket.gui.main.ComponentIcons;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.optimization.rocketoptimization.SimulationModifier;
import net.sf.openrocket.rocketcomponent.Rocket;
@@ -38,6 +40,15 @@ public class SimulationModifierTree extends BasicTree {
private final List selectedModifiers;
private static final Translator trans = Application.getTranslator();
+ private static Color textColor;
+ private static Color dimTextColor;
+ private static Color textSelectionForegroundColor;
+ private static Color textSelectionBackgroundColor;
+
+ static {
+ initColors();
+ }
+
/**
* Sole constructor.
*
@@ -57,6 +68,18 @@ public class SimulationModifierTree extends BasicTree {
expandComponents();
}
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(SimulationModifierTree::updateColors);
+ }
+
+ private static void updateColors() {
+ textColor = GUIUtil.getUITheme().getTextColor();
+ dimTextColor = GUIUtil.getUITheme().getDimTextColor();
+ textSelectionForegroundColor = GUIUtil.getUITheme().getTextSelectionForegroundColor();
+ textSelectionBackgroundColor = GUIUtil.getUITheme().getTextSelectionBackgroundColor();
+ }
/**
@@ -157,7 +180,7 @@ public class SimulationModifierTree extends BasicTree {
// Set text color/style
if (object instanceof RocketComponent) {
- setForeground(GUIUtil.getUITheme().getDimTextColor());
+ setForeground(dimTextColor);
setFont(componentFont);
// Set tooltip
@@ -171,21 +194,21 @@ public class SimulationModifierTree extends BasicTree {
this.setToolTipText(null);
}
} else if (object instanceof String) {
- setForeground(GUIUtil.getUITheme().getDimTextColor());
+ setForeground(dimTextColor);
setFont(stringFont);
} else if (object instanceof SimulationModifier) {
if (selectedModifiers.contains(object)) {
- setForeground(GUIUtil.getUITheme().getDimTextColor());
+ setForeground(dimTextColor);
setFont(stringFont);
} else {
if (tree.getSelectionRows() != null &&
IntStream.of(tree.getSelectionRows()).anyMatch(r -> r == row)) {
- setForeground(GUIUtil.getUITheme().getTextSelectionForegroundColor());
- setBackground(GUIUtil.getUITheme().getTextSelectionBackgroundColor());
+ setForeground(textSelectionForegroundColor);
+ setBackground(textSelectionBackgroundColor);
setOpaque(true);
} else {
- setForeground(GUIUtil.getUITheme().getTextColor());
+ setForeground(textColor);
}
setFont(modifierFont);
}
diff --git a/swing/src/net/sf/openrocket/gui/dialogs/preferences/LaunchPreferencesPanel.java b/swing/src/net/sf/openrocket/gui/dialogs/preferences/LaunchPreferencesPanel.java
index 2cb386954..50b5d97f7 100644
--- a/swing/src/net/sf/openrocket/gui/dialogs/preferences/LaunchPreferencesPanel.java
+++ b/swing/src/net/sf/openrocket/gui/dialogs/preferences/LaunchPreferencesPanel.java
@@ -1,5 +1,6 @@
package net.sf.openrocket.gui.dialogs.preferences;
+import java.awt.Color;
import java.awt.LayoutManager;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
@@ -24,6 +25,7 @@ import net.sf.openrocket.gui.components.BasicSlider;
import net.sf.openrocket.gui.components.StyledLabel;
import net.sf.openrocket.gui.components.UnitSelector;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.models.atmosphere.ExtendedISAModel;
import net.sf.openrocket.simulation.SimulationOptions;
import net.sf.openrocket.unit.UnitGroup;
@@ -31,6 +33,11 @@ import net.sf.openrocket.util.Chars;
import net.sf.openrocket.util.StateChangeListener;
public class LaunchPreferencesPanel extends PreferencesPanel {
+ private static Color darkWarningColor;
+
+ static {
+ initColors();
+ }
public LaunchPreferencesPanel(JDialog parent, LayoutManager layout) {
super(parent, layout);
@@ -44,7 +51,7 @@ public class LaunchPreferencesPanel extends PreferencesPanel {
StyledLabel warning = new StyledLabel(String.format(
"%s", trans.get("pref.dlg.lbl.launchWarning")),
0.5f, StyledLabel.Style.BOLD);
- warning.setFontColor(GUIUtil.getUITheme().getDarkWarningColor());
+ warning.setFontColor(darkWarningColor);
warning.setToolTipText(trans.get("pref.dlg.lbl.launchWarning.ttip"));
add(warning, "spanx, growx 0, gapbottom para, wrap");
@@ -451,6 +458,15 @@ public class LaunchPreferencesPanel extends PreferencesPanel {
}
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(LaunchPreferencesPanel::updateColors);
+ }
+
+ private static void updateColors() {
+ darkWarningColor = GUIUtil.getUITheme().getDarkWarningColor();
+ }
+
private String getIntensityDescription(double i) {
if (i < 0.001)
// // None
diff --git a/swing/src/net/sf/openrocket/gui/dialogs/preferences/SimulationPreferencesPanel.java b/swing/src/net/sf/openrocket/gui/dialogs/preferences/SimulationPreferencesPanel.java
index 051e312ac..36e3c2dda 100644
--- a/swing/src/net/sf/openrocket/gui/dialogs/preferences/SimulationPreferencesPanel.java
+++ b/swing/src/net/sf/openrocket/gui/dialogs/preferences/SimulationPreferencesPanel.java
@@ -1,5 +1,6 @@
package net.sf.openrocket.gui.dialogs.preferences;
+import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@@ -18,6 +19,7 @@ import net.sf.openrocket.gui.components.BasicSlider;
import net.sf.openrocket.gui.components.StyledLabel;
import net.sf.openrocket.gui.components.UnitSelector;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.simulation.RK4SimulationStepper;
import net.sf.openrocket.unit.UnitGroup;
import net.sf.openrocket.util.GeodeticComputationStrategy;
@@ -26,6 +28,12 @@ import net.sf.openrocket.gui.widgets.SelectColorButton;
public class SimulationPreferencesPanel extends PreferencesPanel {
private static final long serialVersionUID = 7983195730016979888L;
+ private static Color darkWarningColor;
+
+ static {
+ initColors();
+ }
+
/*
* private GeodeticComputationStrategy geodeticComputation =
* GeodeticComputationStrategy.SPHERICAL;
@@ -85,7 +93,7 @@ public class SimulationPreferencesPanel extends PreferencesPanel {
StyledLabel warning = new StyledLabel(String.format(
"%s", trans.get("pref.dlg.lbl.launchWarning")),
0, StyledLabel.Style.BOLD);
- warning.setFontColor(GUIUtil.getUITheme().getDarkWarningColor());
+ warning.setFontColor(darkWarningColor);
warning.setToolTipText(trans.get("pref.dlg.lbl.launchWarning.ttip"));
subsub.add(warning, "spanx, wrap para");
@@ -294,4 +302,13 @@ public class SimulationPreferencesPanel extends PreferencesPanel {
* public void fireContentsChanged() { super.fireContentsChanged(this, 0,
* getSize()); } }
*/
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(SimulationPreferencesPanel::updateColors);
+ }
+
+ private static void updateColors() {
+ darkWarningColor = GUIUtil.getUITheme().getDarkWarningColor();
+ }
}
diff --git a/swing/src/net/sf/openrocket/gui/dialogs/preset/ComponentPresetChooserDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/preset/ComponentPresetChooserDialog.java
index bdc5230a1..8a6203ca9 100644
--- a/swing/src/net/sf/openrocket/gui/dialogs/preset/ComponentPresetChooserDialog.java
+++ b/swing/src/net/sf/openrocket/gui/dialogs/preset/ComponentPresetChooserDialog.java
@@ -22,8 +22,12 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.RowFilter;
+import javax.swing.event.ChangeEvent;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.TableColumnModelEvent;
+import javax.swing.event.TableColumnModelListener;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
@@ -245,12 +249,54 @@ public class ComponentPresetChooserDialog extends JDialog {
panel.add(showLegacyCheckBox, "wrap");
showLegacyCheckBox.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- updateFilters();
- tm.setColumnVisible(legacyColumn, showLegacyCheckBox.isSelected());
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ boolean selected = e != null && e.getStateChange() == ItemEvent.SELECTED;
+ if (tm.isColumnVisible(legacyColumn) == selected) {
+ // No change
+ return;
}
- });
+
+ updateFilters();
+
+ tm.setColumnVisible(legacyColumn, selected);
+
+ if (selected) {
+ // Let's say the optimal width is 100 (you can adjust this as needed)
+ int optimalWidth = 50;
+ legacyColumn.setPreferredWidth(optimalWidth);
+ }
+ }
+ });
+
+ // When the legacy column changes visibility (by right-clicking on the column header and toggling the legacy header checkbox),
+ // update the main legacy checkbox
+ tm.addColumnModelListener(new TableColumnModelListener() {
+ @Override
+ public void columnAdded(TableColumnModelEvent e) {
+ TableColumn column = tm.getColumn(e.getToIndex());
+ if (column == legacyColumn) {
+ showLegacyCheckBox.setSelected(true);
+ }
+ }
+
+ @Override
+ public void columnRemoved(TableColumnModelEvent e) {
+ // Use 'getFromIndex' since the column has been removed
+ if (e.getFromIndex() == legacyColumnIndex) {
+ showLegacyCheckBox.setSelected(false);
+ }
+ }
+
+ @Override
+ public void columnMoved(TableColumnModelEvent e) {}
+
+ @Override
+ public void columnMarginChanged(ChangeEvent e) {}
+
+ @Override
+ public void columnSelectionChanged(ListSelectionEvent e) {}
+ });
if(component instanceof SymmetricComponent) {
final SymmetricComponent curSym = (SymmetricComponent) component;
diff --git a/swing/src/net/sf/openrocket/gui/dialogs/preset/ComponentPresetTable.java b/swing/src/net/sf/openrocket/gui/dialogs/preset/ComponentPresetTable.java
index 469466a31..6b32bd009 100644
--- a/swing/src/net/sf/openrocket/gui/dialogs/preset/ComponentPresetTable.java
+++ b/swing/src/net/sf/openrocket/gui/dialogs/preset/ComponentPresetTable.java
@@ -1,5 +1,7 @@
package net.sf.openrocket.gui.dialogs.preset;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
@@ -10,9 +12,11 @@ import java.util.Comparator;
import java.util.List;
import java.util.Set;
+import javax.swing.ButtonGroup;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenu;
import javax.swing.JPopupMenu;
+import javax.swing.JRadioButtonMenuItem;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.RowFilter;
@@ -45,17 +49,19 @@ public class ComponentPresetTable extends JTable {
private final AbstractTableModel tableModel;
private final XTableColumnModel tableColumnModel;
private final ComponentPresetTableColumn[] columns;
+ private final List hiddenColumns;
public ComponentPresetTable(final ComponentPreset.Type presetType, List presets, List> visibleColumnKeys) {
super();
this.presets = presets;
this.presetType = presetType;
this.favorites = Application.getPreferences().getComponentFavorites(presetType);
- this.columns = new ComponentPresetTableColumn[ComponentPreset.ORDERED_KEY_LIST.size()+1];
+ this.columns = new ComponentPresetTableColumn[ComponentPreset.ORDERED_KEY_LIST.size() + 1];
- tableModel = new AbstractTableModel() {
+ this.tableModel = new AbstractTableModel() {
final ComponentPresetTableColumn[] myColumns = columns;
+
@Override
public int getRowCount() {
return ComponentPresetTable.this.presets.size();
@@ -68,7 +74,7 @@ public class ComponentPresetTable extends JTable {
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
- return myColumns[columnIndex].getValueFromPreset(favorites,ComponentPresetTable.this.presets.get(rowIndex));
+ return myColumns[columnIndex].getValueFromPreset(favorites, ComponentPresetTable.this.presets.get(rowIndex));
}
@Override
@@ -96,38 +102,37 @@ public class ComponentPresetTable extends JTable {
};
- sorter = new TableRowSorter(tableModel);
-
- tableColumnModel = new XTableColumnModel();
+ this.sorter = new TableRowSorter(tableModel);
+ this.tableColumnModel = new XTableColumnModel();
/*
* Set up the Column Table model, and customize the sorting.
*/
- columns[0] = new ComponentPresetTableColumn.Favorite(0);
- tableColumnModel.addColumn(columns[0]);
+ this.columns[0] = new ComponentPresetTableColumn.Favorite(0);
+ this.tableColumnModel.addColumn(columns[0]);
- List hiddenColumns = new ArrayList();
+ this.hiddenColumns = new ArrayList<>();
{
int index = 1;
- for (final TypedKey> key: ComponentPreset.ORDERED_KEY_LIST ) {
- if ( key.getType() == Double.class && key.getUnitGroup() != null ) {
- columns[index] = new ComponentPresetTableColumn.DoubleWithUnit((TypedKey)key,index);
+ for (final TypedKey> key : ComponentPreset.ORDERED_KEY_LIST) {
+ if (key.getType() == Double.class && key.getUnitGroup() != null) {
+ columns[index] = new ComponentPresetTableColumn.DoubleWithUnit((TypedKey) key, index);
} else {
- columns[index] = new ComponentPresetTableColumn.Parameter(key,index);
+ columns[index] = new ComponentPresetTableColumn.Parameter(key, index);
}
tableColumnModel.addColumn(columns[index]);
- if ( key == ComponentPreset.PARTNO ) {
+ if (key == ComponentPreset.PARTNO) {
sorter.setComparator(index, new AlphanumComparator());
- } else if ( key.getType() == Double.class ) {
- sorter.setComparator(index, new Comparator() {
+ } else if (key.getType() == Double.class) {
+ sorter.setComparator(index, new Comparator() {
@Override
public int compare(Value o1, Value o2) {
return Double.compare(o1.getValue(), o2.getValue());
}
-
+
});
- } else if ( key.getType() == Boolean.class ) {
+ } else if (key.getType() == Boolean.class) {
sorter.setComparator(index, new Comparator() {
@Override
@@ -140,42 +145,43 @@ public class ComponentPresetTable extends JTable {
return 0;
}
}
- });
+ });
}
-
- if ( visibleColumnKeys.indexOf(key) < 0 ) {
+
+ if (!visibleColumnKeys.contains(key)) {
hiddenColumns.add(columns[index]);
}
- index ++;
- }
+ index++;
+ }
}
this.setAutoCreateColumnsFromModel(false);
- this.setColumnModel( tableColumnModel );
+ this.setColumnModel(tableColumnModel);
this.setModel(tableModel);
this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
this.setRowSorter(sorter);
- sorter.toggleSortOrder(2); // Sort by the first column (manufacturer) by default
+ this.sorter.toggleSortOrder(2); // Sort by the first column (manufacturer) by default
- for ( TableColumn hiddenColumn : hiddenColumns ) {
- tableColumnModel.setColumnVisible(hiddenColumn, false);
+ for (TableColumn hiddenColumn : this.hiddenColumns) {
+ this.tableColumnModel.setColumnVisible(hiddenColumn, false);
}
JTableHeader header = this.getTableHeader();
-
+
header.setReorderingAllowed(true);
- header.addMouseListener( new MouseAdapter() {
+ header.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
- if ( e.isPopupTrigger() ) {
+ if (e.isPopupTrigger()) {
doPopup(e);
}
}
+
@Override
public void mouseReleased(MouseEvent e) {
- if ( e.isPopupTrigger() ) {
+ if (e.isPopupTrigger()) {
doPopup(e);
}
}
@@ -183,52 +189,55 @@ public class ComponentPresetTable extends JTable {
}
public XTableColumnModel getXColumnModel() {
- return tableColumnModel;
+ return this.tableColumnModel;
}
- public void setRowFilter( RowFilter super TableModel ,? super Integer> filter ) {
- sorter.setRowFilter( filter );
+ public void setRowFilter(RowFilter super TableModel, ? super Integer> filter) {
+ sorter.setRowFilter(filter);
}
- public void updateData( List myPresets ) {
+ public void updateData(List myPresets) {
this.presets = myPresets;
this.favorites = Application.getPreferences().getComponentFavorites(presetType);
this.tableModel.fireTableDataChanged();
}
-
+
public void updateFavorites() {
this.favorites = Application.getPreferences().getComponentFavorites(presetType);
this.tableModel.fireTableDataChanged();
}
- private void doPopup(MouseEvent evt ) {
-
+ private void doPopup(MouseEvent evt) {
+
// Figure out what column header was clicked on.
- int colIndex = tableColumnModel.getColumnIndexAtX( evt.getX() );
+ int colIndex = tableColumnModel.getColumnIndexAtX(evt.getX());
ComponentPresetTableColumn colClicked = null;
- if ( colIndex >=0 ) {
+ if (colIndex >= 0) {
colClicked = (ComponentPresetTableColumn) tableColumnModel.getColumn(colIndex);
}
-
+
JPopupMenu columnMenu = new ColumnPopupMenu(colClicked, colIndex);
- columnMenu.show(evt.getComponent(),evt.getX(),evt.getY());
+ columnMenu.show(evt.getComponent(), evt.getX(), evt.getY());
}
private class ColumnPopupMenu extends JPopupMenu {
ColumnPopupMenu(ComponentPresetTableColumn colClicked, int colClickedIndex) {
- if ( colClickedIndex >= 0 ) {
+ if (colClickedIndex >= 0) {
JCheckBoxMenuItem item = new SortAscColumnMenuItem(colClickedIndex);
this.add(item);
item = new SortDescColumnMenuItem(colClickedIndex);
this.add(item);
this.addSeparator();
- if ( colClicked instanceof ComponentPresetTableColumn.DoubleWithUnit ) {
- this.add( new UnitSelectorMenuItem( (ComponentPresetTableColumn.DoubleWithUnit) colClicked ));
+ if (colClicked instanceof ComponentPresetTableColumn.DoubleWithUnit) {
+ this.add(new UnitSelectorMenuItem((ComponentPresetTableColumn.DoubleWithUnit) colClicked));
this.addSeparator();
}
}
- for( TableColumn c: columns ) {
+ for (TableColumn c : columns) {
+ if (hiddenColumns.contains(c)) {
+ continue;
+ }
JCheckBoxMenuItem item = new ToggleColumnMenuItem(c);
this.add(item);
}
@@ -237,69 +246,81 @@ public class ComponentPresetTable extends JTable {
private class SortAscColumnMenuItem extends JCheckBoxMenuItem implements ItemListener {
private int columnClicked;
+
SortAscColumnMenuItem(int columnClicked) {
- super( trans.get("ComponentPresetChooserDialog.menu.sortAsc") );
+ super(trans.get("ComponentPresetChooserDialog.menu.sortAsc"));
this.addItemListener(this);
this.columnClicked = columnClicked;
}
+
@Override
public void itemStateChanged(ItemEvent e) {
- sorter.setSortKeys( Collections.singletonList( new SortKey(columnClicked, SortOrder.ASCENDING)));
+ sorter.setSortKeys(Collections.singletonList(new SortKey(columnClicked, SortOrder.ASCENDING)));
}
}
-
+
private class SortDescColumnMenuItem extends JCheckBoxMenuItem implements ItemListener {
private int columnClicked;
+
SortDescColumnMenuItem(int columnClicked) {
- super( trans.get("ComponentPresetChooserDialog.menu.sortDesc") );
+ super(trans.get("ComponentPresetChooserDialog.menu.sortDesc"));
this.addItemListener(this);
this.columnClicked = columnClicked;
}
+
@Override
public void itemStateChanged(ItemEvent e) {
- sorter.setSortKeys( Collections.singletonList( new SortKey(columnClicked, SortOrder.DESCENDING)));
+ sorter.setSortKeys(Collections.singletonList(new SortKey(columnClicked, SortOrder.DESCENDING)));
}
}
-
+
private class ToggleColumnMenuItem extends JCheckBoxMenuItem implements ItemListener {
TableColumn col;
- ToggleColumnMenuItem( TableColumn col ) {
- super( String.valueOf(col.getHeaderValue()), tableColumnModel.isColumnVisible(col));
+
+ ToggleColumnMenuItem(TableColumn col) {
+ super(String.valueOf(col.getHeaderValue()), tableColumnModel.isColumnVisible(col));
this.addItemListener(this);
this.col = col;
}
+
@Override
public void itemStateChanged(ItemEvent e) {
tableColumnModel.setColumnVisible(col, !tableColumnModel.isColumnVisible(col));
}
}
-
- private class UnitSelectorMenuItem extends JMenu implements ItemListener {
+
+ private class UnitSelectorMenuItem extends JMenu {
ComponentPresetTableColumn.DoubleWithUnit col;
- UnitSelectorMenuItem( ComponentPresetTableColumn.DoubleWithUnit col ) {
+ ButtonGroup buttonGroup; // To group the radio buttons
+
+ UnitSelectorMenuItem(ComponentPresetTableColumn.DoubleWithUnit col) {
super(trans.get("ComponentPresetChooserDialog.menu.units"));
this.col = col;
+
+ buttonGroup = new ButtonGroup(); // Create a new ButtonGroup to hold the radio buttons
+
UnitGroup group = col.unitGroup;
Unit selectedUnit = col.selectedUnit;
- for( Unit u : group.getUnits() ) {
- JCheckBoxMenuItem item = new JCheckBoxMenuItem( u.toString() );
- if ( u == selectedUnit ) {
+
+ for (Unit u : group.getUnits()) {
+ JRadioButtonMenuItem item = new JRadioButtonMenuItem(u.toString());
+
+ if (u == selectedUnit) {
item.setSelected(true);
}
- item.addItemListener(this);
- this.add(item);
- }
-
- }
- @Override
- public void itemStateChanged(ItemEvent e) {
- JCheckBoxMenuItem item = (JCheckBoxMenuItem) e.getItem();
- String val = item.getText();
- col.selectedUnit = col.unitGroup.findApproximate(val);
- ComponentPresetTable.this.tableModel.fireTableDataChanged();
- return;
- }
+ item.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ col.selectedUnit = u;
+ ComponentPresetTable.this.tableModel.fireTableDataChanged();
+ }
+ });
+
+ buttonGroup.add(item); // Add the radio button to the button group
+ this.add(item); // Add the radio button to the menu
+ }
+ }
}
}
}
diff --git a/swing/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java b/swing/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java
index cc65d95ae..c8a309881 100644
--- a/swing/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java
+++ b/swing/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java
@@ -35,6 +35,7 @@ import javax.swing.SwingUtilities;
import javax.swing.event.MouseInputAdapter;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -98,13 +99,19 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
float[] lightPosition = new float[] { 1, 4, 1, 0 };
RocketRenderer rr = new FigureRenderer();
+
+ private static Color backgroundColor;
+
+ static {
+ initColors();
+ }
public RocketFigure3d(final OpenRocketDocument document) {
this.document = document;
this.rkt = document.getRocket();
this.setLayout(new BorderLayout());
-
- //Only initialize GL if 3d is enabled.
+
+ // Only initialize GL if 3d is enabled.
if (is3dEnabled()) {
//Fixes a linux / X bug: Splash must be closed before GL Init
SplashScreen splash = Splash.getSplashScreen();
@@ -114,6 +121,15 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
initGLCanvas();
}
}
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(RocketFigure3d::updateColors);
+ }
+
+ private static void updateColors() {
+ backgroundColor = GUIUtil.getUITheme().getBackgroundColor();
+ }
public void flushTextureCaches() {
((GLAutoDrawable) canvas).invoke(true, new GLRunnable() {
@@ -289,7 +305,6 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
GL2 gl = drawable.getGL().getGL2();
GLU glu = new GLU();
- Color backgroundColor = GUIUtil.getUITheme().getBackgroundColor();
gl.glClearColor(backgroundColor.getRed()/255f, backgroundColor.getGreen()/255f,
backgroundColor.getBlue()/255f, backgroundColor.getAlpha()/255f);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
diff --git a/swing/src/net/sf/openrocket/gui/figureelements/CGCaret.java b/swing/src/net/sf/openrocket/gui/figureelements/CGCaret.java
index 77361260f..81a413cdb 100644
--- a/swing/src/net/sf/openrocket/gui/figureelements/CGCaret.java
+++ b/swing/src/net/sf/openrocket/gui/figureelements/CGCaret.java
@@ -1,6 +1,7 @@
package net.sf.openrocket.gui.figureelements;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import java.awt.Color;
import java.awt.geom.Area;
@@ -19,6 +20,12 @@ public class CGCaret extends Caret {
private static Area caret = null;
+ private static Color CGColor;
+
+ static {
+ initColors();
+ }
+
/**
* Create a new CGCaret at the specified coordinates.
*/
@@ -26,6 +33,15 @@ public class CGCaret extends Caret {
super(x,y);
}
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(CGCaret::updateColors);
+ }
+
+ private static void updateColors() {
+ CGColor = GUIUtil.getUITheme().getCGColor();
+ }
+
/**
* Returns the Area corresponding to the caret. The Area object is created only once,
* after which the object is cloned for new copies.
@@ -58,7 +74,7 @@ public class CGCaret extends Caret {
*/
@Override
protected Color getColor() {
- return GUIUtil.getUITheme().getCGColor();
+ return CGColor;
}
}
diff --git a/swing/src/net/sf/openrocket/gui/figureelements/CPCaret.java b/swing/src/net/sf/openrocket/gui/figureelements/CPCaret.java
index a5b66a233..17c2aebae 100644
--- a/swing/src/net/sf/openrocket/gui/figureelements/CPCaret.java
+++ b/swing/src/net/sf/openrocket/gui/figureelements/CPCaret.java
@@ -1,6 +1,7 @@
package net.sf.openrocket.gui.figureelements;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import java.awt.Color;
import java.awt.geom.Area;
@@ -18,6 +19,12 @@ public class CPCaret extends Caret {
private static Area caret = null;
+ private static Color CPColor;
+
+ static {
+ initColors();
+ }
+
/**
* Create a new CPCaret at the specified coordinates.
*/
@@ -25,6 +32,15 @@ public class CPCaret extends Caret {
super(x,y);
}
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(CPCaret::updateColors);
+ }
+
+ private static void updateColors() {
+ CPColor = GUIUtil.getUITheme().getCPColor();
+ }
+
/**
* Returns the Area object of the caret. The Area object is created only once,
* after which new copies are cloned from it.
@@ -53,6 +69,6 @@ public class CPCaret extends Caret {
*/
@Override
protected Color getColor() {
- return GUIUtil.getUITheme().getCPColor();
+ return CPColor;
}
}
diff --git a/swing/src/net/sf/openrocket/gui/figureelements/RocketInfo.java b/swing/src/net/sf/openrocket/gui/figureelements/RocketInfo.java
index 1836ae644..83bc688f8 100644
--- a/swing/src/net/sf/openrocket/gui/figureelements/RocketInfo.java
+++ b/swing/src/net/sf/openrocket/gui/figureelements/RocketInfo.java
@@ -3,6 +3,7 @@ package net.sf.openrocket.gui.figureelements;
import static net.sf.openrocket.util.Chars.ALPHA;
import static net.sf.openrocket.util.Chars.THETA;
+import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
@@ -12,6 +13,7 @@ import java.awt.geom.Rectangle2D;
import net.sf.openrocket.gui.util.GUIUtil;
import net.sf.openrocket.gui.util.SwingPreferences;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.logging.Warning;
import net.sf.openrocket.logging.WarningSet;
import net.sf.openrocket.l10n.Translator;
@@ -64,13 +66,35 @@ public class RocketInfo implements FigureElement {
private Graphics2D g2 = null;
private float line = 0;
private float x1, x2, y1, y2;
-
+
+ private static Color textColor;
+ private static Color dimTextColor;
+ private static Color warningColor;
+ private static Color flightDataTextActiveColor;
+ private static Color flightDataTextInactiveColor;
+
+ static {
+ initColors();
+ }
public RocketInfo(FlightConfiguration configuration) {
this.configuration = configuration;
this.stabilityUnits = UnitGroup.stabilityUnits(configuration);
this.secondaryStabilityUnits = UnitGroup.secondaryStabilityUnits(configuration);
}
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(RocketInfo::updateColors);
+ }
+
+ private static void updateColors() {
+ textColor = GUIUtil.getUITheme().getTextColor();
+ dimTextColor = GUIUtil.getUITheme().getDimTextColor();
+ warningColor = GUIUtil.getUITheme().getWarningColor();
+ flightDataTextActiveColor = GUIUtil.getUITheme().getFlightDataTextActiveColor();
+ flightDataTextInactiveColor = GUIUtil.getUITheme().getFlightDataTextInactiveColor();
+ }
@Override
@@ -176,7 +200,7 @@ public class RocketInfo implements FigureElement {
GlyphVector massLineWithoutMotors = createText(massTextWithoutMotors);
- g2.setColor(GUIUtil.getUITheme().getTextColor());
+ g2.setColor(textColor);
g2.drawGlyphVector(name, x1, y1);
g2.drawGlyphVector(lengthLine, x1, y1+line);
@@ -234,7 +258,7 @@ public class RocketInfo implements FigureElement {
unitWidth = unitWidth + spaceWidth;
stabUnitWidth = stabUnitWidth + spaceWidth;
- g2.setColor(GUIUtil.getUITheme().getTextColor());
+ g2.setColor(textColor);
// Draw the stability, CG & CP values (and units)
g2.drawGlyphVector(stabValue, (float)(x2-stabRect.getWidth()), y1);
@@ -261,7 +285,7 @@ public class RocketInfo implements FigureElement {
atPos = (float)(x2 - atTextRect.getWidth());
}
- g2.setColor(GUIUtil.getUITheme().getDimTextColor());
+ g2.setColor(dimTextColor);
g2.drawGlyphVector(atText, atPos, y1 + 3*line);
}
@@ -411,7 +435,7 @@ public class RocketInfo implements FigureElement {
float y = y2 - line * (texts.length-1);
- g2.setColor(GUIUtil.getUITheme().getWarningColor());
+ g2.setColor(warningColor);
for (GlyphVector v: texts) {
Rectangle2D rect = v.getVisualBounds();
@@ -427,7 +451,7 @@ public class RocketInfo implements FigureElement {
if (calculatingData) {
//// Calculating...
GlyphVector calculating = createText(trans.get("RocketInfo.Calculating"));
- g2.setColor(GUIUtil.getUITheme().getTextColor());
+ g2.setColor(textColor);
g2.drawGlyphVector(calculating, x1, (float)(y2-height));
}
}
@@ -485,17 +509,17 @@ public class RocketInfo implements FigureElement {
width += 5;
if (!calculatingData)
- g2.setColor(GUIUtil.getUITheme().getFlightDataTextActiveColor());
+ g2.setColor(flightDataTextActiveColor);
else
- g2.setColor(GUIUtil.getUITheme().getFlightDataTextInactiveColor());
+ g2.setColor(flightDataTextInactiveColor);
- g2.drawGlyphVector(apogee, (float)x1, (float)(y2-2*line));
- g2.drawGlyphVector(maxVelocity, (float)x1, (float)(y2-line));
- g2.drawGlyphVector(maxAcceleration, (float)x1, (float)(y2));
+ g2.drawGlyphVector(apogee, x1, y2-2*line);
+ g2.drawGlyphVector(maxVelocity, x1, y2-line);
+ g2.drawGlyphVector(maxAcceleration, x1, y2);
- g2.drawGlyphVector(apogeeValue, (float)(x1+width), (float)(y2-2*line));
- g2.drawGlyphVector(velocityValue, (float)(x1+width), (float)(y2-line));
- g2.drawGlyphVector(accelerationValue, (float)(x1+width), (float)(y2));
+ g2.drawGlyphVector(apogeeValue, (float)(x1+width), y2-2*line);
+ g2.drawGlyphVector(velocityValue, (float)(x1+width), y2-line);
+ g2.drawGlyphVector(accelerationValue, (float)(x1+width), y2);
return 3*line;
}
diff --git a/swing/src/net/sf/openrocket/gui/help/tours/SlideSetManager.java b/swing/src/net/sf/openrocket/gui/help/tours/SlideSetManager.java
index 7828dfd8d..14e822b36 100644
--- a/swing/src/net/sf/openrocket/gui/help/tours/SlideSetManager.java
+++ b/swing/src/net/sf/openrocket/gui/help/tours/SlideSetManager.java
@@ -13,6 +13,7 @@ import java.util.Map;
import javax.swing.text.html.StyleSheet;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.util.BugException;
/**
@@ -32,7 +33,12 @@ public class SlideSetManager {
private final String baseDir;
private final Map slideSets = new LinkedHashMap();
-
+
+ private static Color textColor;
+
+ static {
+ initColors();
+ }
/**
* Sole constructor.
@@ -45,6 +51,15 @@ public class SlideSetManager {
}
this.baseDir = baseDir;
}
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(SlideSetManager::updateColors);
+ }
+
+ private static void updateColors() {
+ textColor = GUIUtil.getUITheme().getTextColor();
+ }
/**
@@ -132,7 +147,6 @@ public class SlideSetManager {
try {
StyleSheet ss = new StyleSheet();
- Color textColor = GUIUtil.getUITheme().getTextColor();
ss.addRule(String.format("p { color: rgb(%d, %d, %d, %d)",
textColor.getRed(), textColor.getGreen(), textColor.getBlue(), textColor.getAlpha()));
InputStreamReader reader = new InputStreamReader(in, "UTF-8");
diff --git a/swing/src/net/sf/openrocket/gui/help/tours/SlideShowComponent.java b/swing/src/net/sf/openrocket/gui/help/tours/SlideShowComponent.java
index 561ee518b..a7272ec9e 100644
--- a/swing/src/net/sf/openrocket/gui/help/tours/SlideShowComponent.java
+++ b/swing/src/net/sf/openrocket/gui/help/tours/SlideShowComponent.java
@@ -7,12 +7,14 @@ import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextPane;
+import javax.swing.border.Border;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.StyleSheet;
import net.sf.openrocket.gui.components.ImageDisplayComponent;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
/**
* Component that displays a single slide, with the image on top and
@@ -30,10 +32,16 @@ public class SlideShowComponent extends JSplitPane {
private final ImageDisplayComponent imageDisplay;
private final JEditorPane textPane;
+ private static Border border;
+
+ static {
+ initColors();
+ }
+
public SlideShowComponent() {
super(VERTICAL_SPLIT);
-
+
imageDisplay = new ImageDisplayComponent();
imageDisplay.setPreferredSize(new Dimension(WIDTH, HEIGHT_IMAGE));
this.setLeftComponent(imageDisplay);
@@ -45,11 +53,20 @@ public class SlideShowComponent extends JSplitPane {
textPane.setPreferredSize(new Dimension(WIDTH, HEIGHT_TEXT));
JScrollPane scrollPanel = new JScrollPane(textPane);
- textPane.setBorder(GUIUtil.getUITheme().getBorder());
+ textPane.setBorder(border);
this.setRightComponent(scrollPanel);
this.setResizeWeight(((double) HEIGHT_IMAGE) / (HEIGHT_IMAGE + HEIGHT_TEXT));
}
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(SlideShowComponent::updateColors);
+ }
+
+ private static void updateColors() {
+ border = GUIUtil.getUITheme().getBorder();
+ }
diff --git a/swing/src/net/sf/openrocket/gui/main/ComponentIcons.java b/swing/src/net/sf/openrocket/gui/main/ComponentIcons.java
index d5e9b3a28..39dd7ec91 100644
--- a/swing/src/net/sf/openrocket/gui/main/ComponentIcons.java
+++ b/swing/src/net/sf/openrocket/gui/main/ComponentIcons.java
@@ -9,6 +9,8 @@ import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.ImageIcon;
+import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.rocketcomponent.AxialStage;
import net.sf.openrocket.rocketcomponent.BodyTube;
@@ -41,77 +43,138 @@ public class ComponentIcons {
private static final String SMALL_SUFFIX = "-small.png";
private static final String LARGE_SUFFIX = "-large.png";
+ // Component image file keys
+ private static String noseCone;
+ private static String bodyTube;
+ private static String transition;
+ private static String trapezoidFinSet;
+ private static String ellipticalFinSet;
+ private static String freeformFinSet;
+ private static String tubeFinSet;
+ private static String launchLug;
+ private static String railButton;
+ private static String innerTube;
+ private static String tubeCoupler;
+ private static String centeringRing;
+ private static String bulkhead;
+ private static String engineBlock;
+ private static String parachute;
+ private static String streamer;
+ private static String shockCord;
+ private static String mass;
+ private static String stage;
+ private static String boosters;
+ private static String pods;
+
+ private static String mass_altimeter;
+ private static String mass_battery;
+ private static String mass_deployment_charge;
+ private static String mass_payload;
+ private static String mass_flight_comp;
+ private static String mass_recovery_hardware;
+ private static String mass_tracker;
+
private static final HashMap, ImageIcon> SMALL_ICONS = new HashMap, ImageIcon>();
private static final HashMap, ImageIcon> LARGE_ICONS = new HashMap, ImageIcon>();
private static final HashMap, ImageIcon> DISABLED_ICONS = new HashMap, ImageIcon>();
private static final HashMap MASS_COMPONENT_SMALL_ICONS = new HashMap();
static {
+ initColors();
+
// // Nose cone
- load("nosecone", trans.get("ComponentIcons.Nosecone"), NoseCone.class);
+ load(noseCone, trans.get("ComponentIcons.Nosecone"), NoseCone.class);
// // Body tube
- load("bodytube", trans.get("ComponentIcons.Bodytube"), BodyTube.class);
+ load(bodyTube, trans.get("ComponentIcons.Bodytube"), BodyTube.class);
//// Transition
- load("transition", trans.get("ComponentIcons.Transition"), Transition.class);
+ load(transition, trans.get("ComponentIcons.Transition"), Transition.class);
//// Trapezoidal fin set
- load("trapezoidfin", trans.get("ComponentIcons.Trapezoidalfinset"), TrapezoidFinSet.class);
+ load(trapezoidFinSet, trans.get("ComponentIcons.Trapezoidalfinset"), TrapezoidFinSet.class);
//// Elliptical fin set
- load("ellipticalfin", trans.get("ComponentIcons.Ellipticalfinset"), EllipticalFinSet.class);
+ load(ellipticalFinSet, trans.get("ComponentIcons.Ellipticalfinset"), EllipticalFinSet.class);
//// Freeform fin set
- load("freeformfin", trans.get("ComponentIcons.Freeformfinset"), FreeformFinSet.class);
+ load(freeformFinSet, trans.get("ComponentIcons.Freeformfinset"), FreeformFinSet.class);
//// Tube fin set
- load("tubefin", trans.get("ComponentIcons.Tubefinset"), TubeFinSet.class);
+ load(tubeFinSet, trans.get("ComponentIcons.Tubefinset"), TubeFinSet.class);
//// Launch lug
- load("launchlug", trans.get("ComponentIcons.Launchlug"), LaunchLug.class);
+ load(launchLug, trans.get("ComponentIcons.Launchlug"), LaunchLug.class);
//// Rail Button
- load("railbutton", trans.get("ComponentIcons.RailButton"), RailButton.class);
+ load(railButton, trans.get("ComponentIcons.RailButton"), RailButton.class);
//// Inner tube
- load("innertube", trans.get("ComponentIcons.Innertube"), InnerTube.class);
+ load(innerTube, trans.get("ComponentIcons.Innertube"), InnerTube.class);
//// Tube coupler
- load("tubecoupler", trans.get("ComponentIcons.Tubecoupler"), TubeCoupler.class);
+ load(tubeCoupler, trans.get("ComponentIcons.Tubecoupler"), TubeCoupler.class);
//// Centering ring
- load("centeringring", trans.get("ComponentIcons.Centeringring"), CenteringRing.class);
+ load(centeringRing, trans.get("ComponentIcons.Centeringring"), CenteringRing.class);
//// Bulkhead
- load("bulkhead", trans.get("ComponentIcons.Bulkhead"), Bulkhead.class);
+ load(bulkhead, trans.get("ComponentIcons.Bulkhead"), Bulkhead.class);
// // Engine block
- load("engineblock", trans.get("ComponentIcons.Engineblock"),
+ load(engineBlock, trans.get("ComponentIcons.Engineblock"),
EngineBlock.class);
// // Parachute
- load("parachute", trans.get("ComponentIcons.Parachute"),
+ load(parachute, trans.get("ComponentIcons.Parachute"),
Parachute.class);
// // Streamer
- load("streamer", trans.get("ComponentIcons.Streamer"), Streamer.class);
+ load(streamer, trans.get("ComponentIcons.Streamer"), Streamer.class);
// // Shock cord
- load("shockcord", trans.get("ComponentIcons.Shockcord"),
+ load(shockCord, trans.get("ComponentIcons.Shockcord"),
ShockCord.class);
- load("mass", trans.get("ComponentIcons.Masscomponent"),
+ load(mass, trans.get("ComponentIcons.Masscomponent"),
MassComponent.class);
// // Component Assemblies
- load("stage", trans.get("ComponentIcons.Stage"),
+ load(stage, trans.get("ComponentIcons.Stage"),
AxialStage.class);
- load("boosters", trans.get("ComponentIcons.Boosters"),
+ load(boosters, trans.get("ComponentIcons.Boosters"),
ParallelStage.class);
- load("pods", trans.get("ComponentIcons.Pods"),
+ load(pods, trans.get("ComponentIcons.Pods"),
PodSet.class);
// // Mass components
- loadMassTypeIcon("mass", trans.get("ComponentIcons.Masscomponent"),
- MassComponentType.MASSCOMPONENT);
- loadMassTypeIcon("altimeter", trans.get("ComponentIcons.Altimeter"),
- MassComponentType.ALTIMETER);
- loadMassTypeIcon("battery", trans.get("ComponentIcons.Battery"),
- MassComponentType.BATTERY);
- loadMassTypeIcon("deployment-charge",
- trans.get("ComponentIcons.Deploymentcharge"),
+ loadMassTypeIcon(mass, trans.get("ComponentIcons.Masscomponent"), MassComponentType.MASSCOMPONENT);
+ loadMassTypeIcon(mass_altimeter, trans.get("ComponentIcons.Altimeter"), MassComponentType.ALTIMETER);
+ loadMassTypeIcon(mass_battery, trans.get("ComponentIcons.Battery"), MassComponentType.BATTERY);
+ loadMassTypeIcon(mass_deployment_charge, trans.get("ComponentIcons.Deploymentcharge"),
MassComponentType.DEPLOYMENTCHARGE);
- loadMassTypeIcon("payload", trans.get("ComponentIcons.Payload"),
- MassComponentType.PAYLOAD);
- loadMassTypeIcon("flight-comp",
- trans.get("ComponentIcons.Flightcomputer"),
- MassComponentType.FLIGHTCOMPUTER);
- loadMassTypeIcon("recovery-hardware",
- trans.get("ComponentIcons.Recoveryhardware"),
- MassComponentType.RECOVERYHARDWARE);
- loadMassTypeIcon("tracker", trans.get("ComponentIcons.Tracker"),
- MassComponentType.TRACKER);
+ loadMassTypeIcon(mass_payload, trans.get("ComponentIcons.Payload"), MassComponentType.PAYLOAD);
+ loadMassTypeIcon(mass_flight_comp,
+ trans.get("ComponentIcons.Flightcomputer"), MassComponentType.FLIGHTCOMPUTER);
+ loadMassTypeIcon(mass_recovery_hardware,
+ trans.get("ComponentIcons.Recoveryhardware"), MassComponentType.RECOVERYHARDWARE);
+ loadMassTypeIcon(mass_tracker, trans.get("ComponentIcons.Tracker"), MassComponentType.TRACKER);
+ }
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(ComponentIcons::updateColors);
+ }
+
+ private static void updateColors() {
+ noseCone = GUIUtil.getUITheme().getComponentIconNoseCone();
+ bodyTube = GUIUtil.getUITheme().getComponentIconBodyTube();
+ transition = GUIUtil.getUITheme().getComponentIconTransition();
+ trapezoidFinSet = GUIUtil.getUITheme().getComponentIconTrapezoidFinSet();
+ ellipticalFinSet = GUIUtil.getUITheme().getComponentIconEllipticalFinSet();
+ freeformFinSet = GUIUtil.getUITheme().getComponentIconFreeformFinSet();
+ tubeFinSet = GUIUtil.getUITheme().getComponentIconTubeFinSet();
+ launchLug = GUIUtil.getUITheme().getComponentIconLaunchLug();
+ railButton = GUIUtil.getUITheme().getComponentIconRailButton();
+ innerTube = GUIUtil.getUITheme().getComponentIconInnerTube();
+ tubeCoupler = GUIUtil.getUITheme().getComponentIconTubeCoupler();
+ centeringRing = GUIUtil.getUITheme().getComponentIconCenteringRing();
+ bulkhead = GUIUtil.getUITheme().getComponentIconBulkhead();
+ engineBlock = GUIUtil.getUITheme().getComponentIconEngineBlock();
+ parachute = GUIUtil.getUITheme().getComponentIconParachute();
+ streamer = GUIUtil.getUITheme().getComponentIconStreamer();
+ shockCord = GUIUtil.getUITheme().getComponentIconShockCord();
+ mass = GUIUtil.getUITheme().getComponentIconMass();
+ stage = GUIUtil.getUITheme().getComponentIconStage();
+ boosters = GUIUtil.getUITheme().getComponentIconBoosters();
+ pods = GUIUtil.getUITheme().getComponentIconPods();
+ mass_altimeter = GUIUtil.getUITheme().getComponentIconMassAltimeter();
+ mass_battery = GUIUtil.getUITheme().getComponentIconMassBattery();
+ mass_deployment_charge = GUIUtil.getUITheme().getComponentIconMassDeploymentCharge();
+ mass_payload = GUIUtil.getUITheme().getComponentIconMassPayload();
+ mass_flight_comp = GUIUtil.getUITheme().getComponentIconMassFlightComp();
+ mass_recovery_hardware = GUIUtil.getUITheme().getComponentIconMassRecoveryHardware();
+ mass_tracker = GUIUtil.getUITheme().getComponentIconMassTracker();
}
private static void load(String filename, String name,
diff --git a/swing/src/net/sf/openrocket/gui/main/DesignPanel.java b/swing/src/net/sf/openrocket/gui/main/DesignPanel.java
index f4e7c274d..d0c460cde 100644
--- a/swing/src/net/sf/openrocket/gui/main/DesignPanel.java
+++ b/swing/src/net/sf/openrocket/gui/main/DesignPanel.java
@@ -5,6 +5,7 @@ import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.gui.configdialog.ComponentConfigDialog;
import net.sf.openrocket.gui.main.componenttree.ComponentTree;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.gui.widgets.IconButton;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.rocketcomponent.AxialStage;
@@ -24,6 +25,7 @@ import javax.swing.KeyStroke;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
+import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
@@ -51,6 +53,12 @@ public class DesignPanel extends JSplitPane {
private static final Translator trans = Application.getTranslator();
private final Component tree;
+ private static Border border;
+
+ static {
+ initColors();
+ }
+
public DesignPanel(final BasicFrame parent, final OpenRocketDocument document, final ComponentTree tree) {
super(JSplitPane.HORIZONTAL_SPLIT, true);
setResizeWeight(0.5);
@@ -174,7 +182,7 @@ public class DesignPanel extends JSplitPane {
// Place tree inside scroll pane
JScrollPane scroll = new JScrollPane(tree);
- tree.setBorder(GUIUtil.getUITheme().getBorder());
+ tree.setBorder(border);
panel.add(scroll, "spany, wmin 140px, grow, wrap");
@@ -230,6 +238,15 @@ public class DesignPanel extends JSplitPane {
this.setRightComponent(panel);
}
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(DesignPanel::updateColors);
+ }
+
+ private static void updateColors() {
+ border = GUIUtil.getUITheme().getBorder();
+ }
+
/**
* Highlight all child components of a stage/rocket/podset when it is selected
* @param tree the tree in which the component selection took place
diff --git a/swing/src/net/sf/openrocket/gui/main/componenttree/ComponentTreeRenderer.java b/swing/src/net/sf/openrocket/gui/main/componenttree/ComponentTreeRenderer.java
index 742a0c6d2..ec0f2f33c 100644
--- a/swing/src/net/sf/openrocket/gui/main/componenttree/ComponentTreeRenderer.java
+++ b/swing/src/net/sf/openrocket/gui/main/componenttree/ComponentTreeRenderer.java
@@ -1,12 +1,14 @@
package net.sf.openrocket.gui.main.componenttree;
import java.awt.BorderLayout;
+import java.awt.Color;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Font;
import java.util.List;
import javax.swing.BorderFactory;
+import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
@@ -18,6 +20,7 @@ import javax.swing.tree.TreePath;
import net.sf.openrocket.gui.main.ComponentIcons;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.rocketcomponent.MassComponent;
import net.sf.openrocket.rocketcomponent.MassComponent.MassComponentType;
@@ -31,6 +34,21 @@ import net.sf.openrocket.util.TextUtil;
public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
private static final Translator trans = Application.getTranslator();
+
+ private static Color textSelectionBackgroundColor;
+ private static Color textSelectionForegroundColor;
+ private static Color componentTreeBackgroundColor;
+ private static Color componentTreeForegroundColor;
+ private static Icon massOverrideSubcomponentIcon;
+ private static Icon massOverrideIcon;
+ private static Icon CGOverrideSubcomponentIcon;
+ private static Icon CGOverrideIcon;
+ private static Icon CDOverrideSubcomponentIcon;
+ private static Icon CDOverrideIcon;
+
+ static {
+ initColors();
+ }
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value,
@@ -81,12 +99,12 @@ public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
// Set the background and foreground colors of the text JLabel
if (sel) {
textLabel.setOpaque(true);
- textLabel.setBackground(GUIUtil.getUITheme().getTextSelectionBackgroundColor());
- textLabel.setForeground(GUIUtil.getUITheme().getTextSelectionForegroundColor());
+ textLabel.setBackground(textSelectionBackgroundColor);
+ textLabel.setForeground(textSelectionForegroundColor);
} else {
textLabel.setOpaque(true); // Set this to true to allow the background color to be visible
- textLabel.setBackground(GUIUtil.getUITheme().getComponentTreeBackgroundColor());
- textLabel.setForeground(GUIUtil.getUITheme().getComponentTreeForegroundColor());
+ textLabel.setBackground(componentTreeBackgroundColor);
+ textLabel.setForeground(componentTreeForegroundColor);
}
applyToolTipText(components, c, panel);
@@ -99,23 +117,23 @@ public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
c.isCDOverridden() || c.getCDOverriddenBy() != null) {
JPanel p = new JPanel();
p.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 1));
- p.setBackground(GUIUtil.getUITheme().getComponentTreeBackgroundColor());
- p.setForeground(GUIUtil.getUITheme().getComponentTreeForegroundColor());
+ p.setBackground(componentTreeBackgroundColor);
+ p.setForeground(componentTreeForegroundColor);
p.add(comp/* , BorderLayout.WEST */);
if (c.getMassOverriddenBy() != null) {
- p.add(new JLabel(GUIUtil.getUITheme().getMassOverrideSubcomponentIcon()));
+ p.add(new JLabel(massOverrideSubcomponentIcon));
} else if (c.isMassOverridden()) {
- p.add(new JLabel(GUIUtil.getUITheme().getMassOverrideIcon()));
+ p.add(new JLabel(massOverrideIcon));
}
if (c.getCGOverriddenBy() != null) {
- p.add(new JLabel(GUIUtil.getUITheme().getCGOverrideSubcomponentIcon()));
+ p.add(new JLabel(CGOverrideSubcomponentIcon));
} else if (c.isCGOverridden()) {
- p.add(new JLabel(GUIUtil.getUITheme().getCGOverrideIcon()));
+ p.add(new JLabel(CGOverrideIcon));
}
if (c.getCDOverriddenBy() != null) {
- p.add(new JLabel(GUIUtil.getUITheme().getCDOverrideSubcomponentIcon()));
+ p.add(new JLabel(CDOverrideSubcomponentIcon));
} else if (c.isCDOverridden()) {
- p.add(new JLabel(GUIUtil.getUITheme().getCDOverrideIcon()));
+ p.add(new JLabel(CDOverrideIcon));
}
// Make sure the tooltip also works on the override icons
@@ -131,6 +149,25 @@ public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
return comp;
}
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(ComponentTreeRenderer::updateColors);
+ }
+
+ private static void updateColors() {
+ textSelectionBackgroundColor = GUIUtil.getUITheme().getTextSelectionBackgroundColor();
+ textSelectionForegroundColor = GUIUtil.getUITheme().getTextSelectionForegroundColor();
+ componentTreeBackgroundColor = GUIUtil.getUITheme().getComponentTreeBackgroundColor();
+ componentTreeForegroundColor = GUIUtil.getUITheme().getComponentTreeForegroundColor();
+
+ massOverrideSubcomponentIcon = GUIUtil.getUITheme().getMassOverrideSubcomponentIcon();
+ massOverrideIcon = GUIUtil.getUITheme().getMassOverrideIcon();
+ CGOverrideSubcomponentIcon = GUIUtil.getUITheme().getCGOverrideSubcomponentIcon();
+ CGOverrideIcon = GUIUtil.getUITheme().getCGOverrideIcon();
+ CDOverrideSubcomponentIcon = GUIUtil.getUITheme().getCDOverrideSubcomponentIcon();
+ CDOverrideIcon = GUIUtil.getUITheme().getCDOverrideIcon();
+ }
+
private void applyToolTipText(List components, RocketComponent c, JComponent comp) {
String tooltipText;
if (components != null && components.size() > 1 && components.contains(c)) {
diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurablePanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurablePanel.java
index ee6cb3b80..47f3249cb 100644
--- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurablePanel.java
+++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/FlightConfigurablePanel.java
@@ -25,6 +25,7 @@ import javax.swing.table.DefaultTableCellRenderer;
import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.gui.main.FlightConfigurationPanel;
import net.sf.openrocket.gui.util.SwingPreferences;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.util.ArrayList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,6 +56,13 @@ public abstract class FlightConfigurablePanel listeners = new LinkedList();
+
+ private static Color backgroundColor;
+
+ static {
+ initColors();
+ }
public AbstractScaleFigure() {
@@ -70,10 +77,19 @@ public abstract class AbstractScaleFigure extends JPanel {
this.setPreferredSize(new Dimension(100,100));
setSize(100,100);
- setBackground(GUIUtil.getUITheme().getBackgroundColor());
+ setBackground(backgroundColor);
setOpaque(true);
}
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(AbstractScaleFigure::updateColors);
+ }
+
+ private static void updateColors() {
+ backgroundColor = GUIUtil.getUITheme().getBackgroundColor();
+ }
+
public int getBorderHeight(){ return borderThickness_px.height; }
public int getBorderWidth(){ return borderThickness_px.width; }
diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/FinPointFigure.java b/swing/src/net/sf/openrocket/gui/scalefigure/FinPointFigure.java
index cf5662574..dc0ed7c77 100644
--- a/swing/src/net/sf/openrocket/gui/scalefigure/FinPointFigure.java
+++ b/swing/src/net/sf/openrocket/gui/scalefigure/FinPointFigure.java
@@ -1,6 +1,7 @@
package net.sf.openrocket.gui.scalefigure;
import java.awt.BasicStroke;
+import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
@@ -15,6 +16,7 @@ import java.util.LinkedList;
import java.util.List;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.rocketcomponent.FreeformFinSet;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.rocketcomponent.SymmetricComponent;
@@ -56,16 +58,41 @@ public class FinPointFigure extends AbstractScaleFigure {
private Rectangle2D.Double[] finPointHandles = null;
private int selectedIndex = -1;
+
+ private static Color backgroundColor;
+ private static Color finPointBodyLineColor;
+ private static Color finPointGridMajorLineColor;
+ private static Color finPointGridMinorLineColor;
+ private static Color finPointPointColor;
+ private static Color finPointSelectedPointColor;
+
+ static {
+ initColors();
+ }
public FinPointFigure(FreeformFinSet finset) {
this.finset = finset;
- setBackground(GUIUtil.getUITheme().getBackgroundColor());
+ setBackground(backgroundColor);
setOpaque(true);
updateFigure();
}
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(FinPointFigure::updateColors);
+ }
+
+ private static void updateColors() {
+ backgroundColor = GUIUtil.getUITheme().getBackgroundColor();
+ finPointBodyLineColor = GUIUtil.getUITheme().getFinPointBodyLineColor();
+ finPointGridMajorLineColor = GUIUtil.getUITheme().getFinPointGridMajorLineColor();
+ finPointGridMinorLineColor = GUIUtil.getUITheme().getFinPointGridMinorLineColor();
+ finPointPointColor = GUIUtil.getUITheme().getFinPointPointColor();
+ finPointSelectedPointColor = GUIUtil.getUITheme().getFinPointSelectedPointColor();
+ }
+
@Override
public Point getAutoZoomPoint(){
return new Point( Math.max(0, (originLocation_px.x - borderThickness_px.width)), 0);
@@ -122,11 +149,11 @@ public class FinPointFigure extends AbstractScaleFigure {
Line2D.Double line = new Line2D.Double();
for (Tick t : verticalTicks) {
if (t.major) {
- g2.setColor(GUIUtil.getUITheme().getFinPointGridMajorLineColor());
+ g2.setColor(finPointGridMajorLineColor);
line.setLine( t.value, y0, t.value, y1);
g2.draw(line);
}else{
- g2.setColor(GUIUtil.getUITheme().getFinPointGridMinorLineColor());
+ g2.setColor(finPointGridMinorLineColor);
line.setLine( t.value, y0, t.value, y1);
g2.draw(line);
}
@@ -136,11 +163,11 @@ public class FinPointFigure extends AbstractScaleFigure {
Tick[] horizontalTicks = unit.getTicks(y0, y1, MINOR_TICKS / this.scale, MAJOR_TICKS / this.scale);
for (Tick t : horizontalTicks) {
if (t.major) {
- g2.setColor(GUIUtil.getUITheme().getFinPointGridMajorLineColor());
+ g2.setColor(finPointGridMajorLineColor);
line.setLine( x0, t.value, x1, t.value);
g2.draw(line);
}else{
- g2.setColor(GUIUtil.getUITheme().getFinPointGridMinorLineColor());
+ g2.setColor(finPointGridMinorLineColor);
line.setLine( x0, t.value, x1, t.value);
g2.draw(line);
}
@@ -163,7 +190,7 @@ public class FinPointFigure extends AbstractScaleFigure {
// setup lines
final float bodyLineWidth = (float) ( LINE_WIDTH_BODY_PIXELS / scale );
g2.setStroke(new BasicStroke( bodyLineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
- g2.setColor(GUIUtil.getUITheme().getFinPointBodyLineColor());
+ g2.setColor(finPointBodyLineColor);
Transition body = (Transition) finset.getParent();
final float xResolution_m = 0.01f; // distance between draw points, in meters
@@ -213,7 +240,7 @@ public class FinPointFigure extends AbstractScaleFigure {
final float bodyLineWidth = (float) ( LINE_WIDTH_BODY_PIXELS / scale );
g2.setStroke(new BasicStroke( bodyLineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
- g2.setColor(GUIUtil.getUITheme().getFinPointBodyLineColor());
+ g2.setColor(finPointBodyLineColor);
g2.draw(shape);
}
@@ -230,12 +257,12 @@ public class FinPointFigure extends AbstractScaleFigure {
final float finEdgeWidth_m = (float) (LINE_WIDTH_FIN_PIXELS / scale );
g2.setStroke(new BasicStroke( finEdgeWidth_m, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
- g2.setColor(GUIUtil.getUITheme().getFinPointBodyLineColor());
+ g2.setColor(finPointBodyLineColor);
g2.draw(shape);
}
private void paintFinHandles(final Graphics2D g2) {
- // excludes fin tab points
+ // Excludes fin tab points
final Coordinate[] drawPoints = finset.getFinPoints();
// Fin point boxes
@@ -244,7 +271,7 @@ public class FinPointFigure extends AbstractScaleFigure {
final float boxEdgeWidth_m = (float) ( LINE_WIDTH_BOX_PIXELS / scale );
g2.setStroke(new BasicStroke( boxEdgeWidth_m, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
- g2.setColor(GUIUtil.getUITheme().getFinPointPointColor());
+ g2.setColor(finPointPointColor);
finPointHandles = new Rectangle2D.Double[ drawPoints.length];
for (int currentIndex = 0; currentIndex < drawPoints.length; currentIndex++) {
@@ -256,15 +283,15 @@ public class FinPointFigure extends AbstractScaleFigure {
final Rectangle2D.Double selectedPointHighlight = new Rectangle2D.Double(c.x - selBoxHalfWidth, c.y - selBoxHalfWidth, selBoxWidth, selBoxWidth);
- // switch to the highlight color
- g2.setColor(GUIUtil.getUITheme().getFinPointSelectedPointColor());
+ // Switch to the highlight color
+ g2.setColor(finPointSelectedPointColor);
g2.draw(selectedPointHighlight);
- // reset to the normal color
- g2.setColor(GUIUtil.getUITheme().getFinPointPointColor());
+ // Reset to the normal color
+ g2.setColor(finPointPointColor);
}
- // normal boxes
+ // Normal boxes
finPointHandles[currentIndex] = new Rectangle2D.Double(c.x - boxHalfWidth, c.y - boxHalfWidth, boxWidth, boxWidth);
g2.draw(finPointHandles[currentIndex]);
diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java b/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java
index 22f4d8d67..50dd4d1ae 100644
--- a/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java
+++ b/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java
@@ -18,6 +18,7 @@ import java.util.*;
import java.util.Map.Entry;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.rocketcomponent.AxialStage;
import net.sf.openrocket.rocketcomponent.ParallelStage;
import net.sf.openrocket.rocketcomponent.PodSet;
@@ -93,6 +94,13 @@ public class RocketFigure extends AbstractScaleFigure {
private final ArrayList relativeExtra = new ArrayList();
private final ArrayList absoluteExtra = new ArrayList();
+
+ private static Color motorFillColor;
+ private static Color motorBorderColor;
+
+ static {
+ initColors();
+ }
/**
@@ -108,6 +116,16 @@ public class RocketFigure extends AbstractScaleFigure {
updateFigure();
}
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(RocketFigure::updateColors);
+ }
+
+ private static void updateColors() {
+ motorFillColor = GUIUtil.getUITheme().getMotorFillColor();
+ motorBorderColor = GUIUtil.getUITheme().getMotorBorderColor();
+ }
+
public Point getAutoZoomPoint(){
return new Point( Math.max(0, originLocation_px.x - borderThickness_px.width),
Math.max(0, - borderThickness_px.height));
@@ -291,8 +309,8 @@ public class RocketFigure extends AbstractScaleFigure {
RenderingHints.VALUE_STROKE_NORMALIZE);
// Draw motors
- Color fillColor = GUIUtil.getUITheme().getMotorFillColor();
- Color borderColor = GUIUtil.getUITheme().getMotorBorderColor();
+ Color fillColor = motorFillColor;
+ Color borderColor = motorBorderColor;
FlightConfiguration config = rocket.getSelectedConfiguration();
for (MotorConfiguration curInstance : config.getActiveMotors()) {
diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java b/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java
index 7cf764261..72e2fff73 100644
--- a/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java
+++ b/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java
@@ -790,6 +790,11 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
cgy = cg.y * Math.cos(rotation) + cg.z*Math.sin(rotation);
}
+ // We need to flip the y coordinate if we are in top view
+ if (figure.getCurrentViewType() == RocketPanel.VIEW_TYPE.TopView) {
+ cgy = -cgy;
+ }
+
double length = curConfig.getLength();
double diameter = Double.NaN;
diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/ScaleScrollPane.java b/swing/src/net/sf/openrocket/gui/scalefigure/ScaleScrollPane.java
index e30bfe840..bb33d649b 100644
--- a/swing/src/net/sf/openrocket/gui/scalefigure/ScaleScrollPane.java
+++ b/swing/src/net/sf/openrocket/gui/scalefigure/ScaleScrollPane.java
@@ -26,6 +26,7 @@ import javax.swing.event.ChangeListener;
import net.sf.openrocket.gui.adaptors.DoubleModel;
import net.sf.openrocket.gui.components.UnitSelector;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.unit.Tick;
import net.sf.openrocket.unit.Unit;
import net.sf.openrocket.unit.UnitGroup;
@@ -72,6 +73,12 @@ public class ScaleScrollPane extends JScrollPane
private Point2D.Double viewCenter_frac = new Point2D.Double(0.5f, 0.5f);
+ private static Color textColor;
+
+ static {
+ initColors();
+ }
+
/**
* Create a scale scroll pane.
*
@@ -83,7 +90,7 @@ public class ScaleScrollPane extends JScrollPane
if (!(component instanceof AbstractScaleFigure)) {
throw new IllegalArgumentException("component must implement ScaleFigure");
}
-
+
this.component = component;
this.figure = (AbstractScaleFigure) component;
@@ -127,6 +134,15 @@ public class ScaleScrollPane extends JScrollPane
viewport.addMouseMotionListener(this);
viewport.addComponentListener(this);
}
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(ScaleScrollPane::updateColors);
+ }
+
+ private static void updateColors() {
+ textColor = GUIUtil.getUITheme().getTextColor();
+ }
public AbstractScaleFigure getFigure() {
return figure;
@@ -399,7 +415,7 @@ public class ScaleScrollPane extends JScrollPane
}
// Set color & hints
- g2.setColor(GUIUtil.getUITheme().getTextColor());
+ g2.setColor(textColor);
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
RenderingHints.VALUE_STROKE_NORMALIZE);
g2.setRenderingHint(RenderingHints.KEY_RENDERING,
diff --git a/swing/src/net/sf/openrocket/gui/simulation/SimulationEditDialog.java b/swing/src/net/sf/openrocket/gui/simulation/SimulationEditDialog.java
index 096bfc576..51fd38235 100644
--- a/swing/src/net/sf/openrocket/gui/simulation/SimulationEditDialog.java
+++ b/swing/src/net/sf/openrocket/gui/simulation/SimulationEditDialog.java
@@ -33,6 +33,7 @@ import net.sf.openrocket.document.events.DocumentChangeEvent;
import net.sf.openrocket.gui.components.ConfigurationComboBox;
import net.sf.openrocket.gui.components.StyledLabel;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.gui.widgets.SelectColorButton;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
@@ -61,6 +62,12 @@ public class SimulationEditDialog extends JDialog {
private final boolean initialIsSaved; // Whether the document was saved before the dialog was opened
private boolean isModified = false; // Whether the simulation has been modified
private final boolean isNewSimulation; // Whether you are editing a new simulation, or an existing one
+
+ private static Color multiCompEditColor;
+
+ static {
+ initColors();
+ }
public SimulationEditDialog(Window parent, final OpenRocketDocument document, boolean isNewSimulation, Simulation... sims) {
//// Edit simulation
@@ -102,6 +109,15 @@ public class SimulationEditDialog extends JDialog {
GUIUtil.setDisposableDialogOptions(this, null);
}
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(SimulationEditDialog::updateColors);
+ }
+
+ private static void updateColors() {
+ multiCompEditColor = GUIUtil.getUITheme().getMultiCompEditColor();
+ }
private boolean isSingleEdit() {
return simulationList.length == 1;
@@ -247,7 +263,7 @@ public class SimulationEditDialog extends JDialog {
//// Multi-simulation edit
if (simulationList.length > 1) {
StyledLabel multiSimEditLabel = new StyledLabel("", -1, StyledLabel.Style.BOLD);
- multiSimEditLabel.setFontColor(new Color(170, 0, 100));
+ multiSimEditLabel.setFontColor(multiCompEditColor);
multiSimEditLabel.setText(trans.get("simedtdlg.title.MultiSimEdit"));
StringBuilder components = new StringBuilder(trans.get("simedtdlg.title.MultiSimEdit.ttip"));
for (int i = 0; i < simulationList.length; i++) {
diff --git a/swing/src/net/sf/openrocket/gui/simulation/SimulationOptionsPanel.java b/swing/src/net/sf/openrocket/gui/simulation/SimulationOptionsPanel.java
index 82e49ff9a..653d1d80d 100644
--- a/swing/src/net/sf/openrocket/gui/simulation/SimulationOptionsPanel.java
+++ b/swing/src/net/sf/openrocket/gui/simulation/SimulationOptionsPanel.java
@@ -22,6 +22,7 @@ import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.MenuElement;
import javax.swing.SwingUtilities;
+import javax.swing.border.Border;
import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.document.OpenRocketDocument;
@@ -36,6 +37,7 @@ import net.sf.openrocket.gui.components.StyledLabel.Style;
import net.sf.openrocket.gui.components.UnitSelector;
import net.sf.openrocket.gui.util.GUIUtil;
import net.sf.openrocket.gui.util.Icons;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.simulation.RK4SimulationStepper;
import net.sf.openrocket.simulation.SimulationOptions;
@@ -62,12 +64,19 @@ class SimulationOptionsPanel extends JPanel {
private JPanel currentExtensions;
final JPopupMenu extensionMenu;
JMenu extensionMenuCopyExtension;
+
+ private static Color textColor;
+ private static Border border;
+
+ static {
+ initColors();
+ }
SimulationOptionsPanel(OpenRocketDocument document, final Simulation simulation) {
super(new MigLayout("fill"));
this.document = document;
this.simulation = simulation;
-
+
final SimulationOptions conditions = simulation.getOptions();
JPanel sub, subsub;
@@ -207,14 +216,24 @@ class SimulationOptionsPanel extends JPanel {
currentExtensions = new JPanel(new MigLayout("fillx, gap 0 0, ins 0"));
JScrollPane scroll = new JScrollPane(currentExtensions);
- currentExtensions.setBorder(GUIUtil.getUITheme().getBorder());
- scroll.setForeground(GUIUtil.getUITheme().getTextColor());
+ currentExtensions.setBorder(border);
+ scroll.setForeground(textColor);
// $%! scroll pane will not honor "growy"...
sub.add(scroll, "growx, growy, h 100%");
updateCurrentExtensions();
}
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(SimulationOptionsPanel::updateColors);
+ }
+
+ private static void updateColors() {
+ textColor = GUIUtil.getUITheme().getTextColor();
+ border = GUIUtil.getUITheme().getBorder();
+ }
private JPopupMenu getExtensionMenu() {
Set extensions = Application.getInjector().getInstance(new Key>() {
diff --git a/swing/src/net/sf/openrocket/gui/simulation/SimulationPlotPanel.java b/swing/src/net/sf/openrocket/gui/simulation/SimulationPlotPanel.java
index 54d773456..11fcbeb32 100644
--- a/swing/src/net/sf/openrocket/gui/simulation/SimulationPlotPanel.java
+++ b/swing/src/net/sf/openrocket/gui/simulation/SimulationPlotPanel.java
@@ -12,7 +12,6 @@ import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
-import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
@@ -20,6 +19,7 @@ import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
+import javax.swing.border.Border;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
@@ -33,6 +33,7 @@ import net.sf.openrocket.gui.plot.SimulationPlotDialog;
import net.sf.openrocket.gui.util.GUIUtil;
import net.sf.openrocket.gui.util.Icons;
import net.sf.openrocket.gui.util.SwingPreferences;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.simulation.FlightDataBranch;
import net.sf.openrocket.simulation.FlightDataType;
@@ -40,7 +41,6 @@ import net.sf.openrocket.simulation.FlightEvent;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.startup.Preferences;
import net.sf.openrocket.unit.Unit;
-import net.sf.openrocket.util.Color;
import net.sf.openrocket.util.Utils;
import net.sf.openrocket.gui.widgets.SelectColorButton;
@@ -107,11 +107,18 @@ public class SimulationPlotPanel extends JPanel {
private int modifying = 0;
- private DescriptionArea simPlotPanelDesc;
+ private DescriptionArea simPlotPanelDesc;
+
+ private static java.awt.Color darkWarningColor;
+ private static Border border;
+
+ static {
+ initColors();
+ }
public SimulationPlotPanel(final Simulation simulation) {
super(new MigLayout("fill"));
-
+
this.simulation = simulation;
if (simulation.getSimulatedData() == null ||
simulation.getSimulatedData().getBranchCount() == 0) {
@@ -205,7 +212,7 @@ public class SimulationPlotPanel extends JPanel {
//// The data will be plotted in time order even if the X axis type is not time.
simPlotPanelDesc = new DescriptionArea("", 2, -2f, false);
simPlotPanelDesc.setVisible(false);
- simPlotPanelDesc.setForeground(GUIUtil.getUITheme().getDarkWarningColor());
+ simPlotPanelDesc.setForeground(darkWarningColor);
simPlotPanelDesc.setViewportBorder(BorderFactory.createEmptyBorder());
this.add(simPlotPanelDesc, "width 1px, growx 1, wrap unrel");
@@ -220,7 +227,7 @@ public class SimulationPlotPanel extends JPanel {
typeSelectorPanel = new JPanel(new MigLayout("gapy rel"));
JScrollPane scroll = new JScrollPane(typeSelectorPanel);
- scroll.setBorder(GUIUtil.getUITheme().getBorder());
+ scroll.setBorder(border);
this.add(scroll, "spany 3, height 10px, wmin 400lp, grow 100, gapright para");
@@ -379,6 +386,16 @@ public class SimulationPlotPanel extends JPanel {
updatePlots();
}
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(SimulationPlotPanel::updateColors);
+ }
+
+ private static void updateColors() {
+ darkWarningColor = GUIUtil.getUITheme().getDarkWarningColor();
+ border = GUIUtil.getUITheme().getBorder();
+ }
+
private void updateStyleEventWidgets(JLabel styleEventMarker, JRadioButton radioVerticalMarker, JRadioButton radioIcon) {
if (modifying > 0)
return;
diff --git a/swing/src/net/sf/openrocket/gui/util/BetterListCellRenderer.java b/swing/src/net/sf/openrocket/gui/util/BetterListCellRenderer.java
index a91da30c5..dfbb02be0 100644
--- a/swing/src/net/sf/openrocket/gui/util/BetterListCellRenderer.java
+++ b/swing/src/net/sf/openrocket/gui/util/BetterListCellRenderer.java
@@ -4,6 +4,7 @@ package net.sf.openrocket.gui.util;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JLabel;
import javax.swing.JList;
+import java.awt.Color;
import java.awt.Component;
/**
@@ -12,6 +13,14 @@ import java.awt.Component;
* @author Sibo Van Gool
*/
public class BetterListCellRenderer extends DefaultListCellRenderer {
+ private static Color rowBackgroundDarkerColor;
+ private static Color rowBackgroundLighterColor;
+ private static Color textSelectionForegroundColor;
+ private static Color textColor;
+
+ static {
+ initColors();
+ }
@Override
public Component getListCellRendererComponent(JList> list, Object value, int index,
@@ -21,17 +30,29 @@ public class BetterListCellRenderer extends DefaultListCellRenderer {
// Alternating row colors
if (!isSelected) {
if (index % 2 == 0) {
- label.setBackground(GUIUtil.getUITheme().getRowBackgroundDarkerColor());
+ label.setBackground(rowBackgroundDarkerColor);
} else {
- label.setBackground(GUIUtil.getUITheme().getRowBackgroundLighterColor());
+ label.setBackground(rowBackgroundLighterColor);
}
}
// Text color
if (isSelected) {
- label.setForeground(GUIUtil.getUITheme().getTextSelectionForegroundColor());
+ label.setForeground(textSelectionForegroundColor);
} else {
- label.setForeground(GUIUtil.getUITheme().getTextColor());
+ label.setForeground(textColor);
}
return label;
}
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(BetterListCellRenderer::updateColors);
+ }
+
+ private static void updateColors() {
+ rowBackgroundDarkerColor = GUIUtil.getUITheme().getRowBackgroundDarkerColor();
+ rowBackgroundLighterColor = GUIUtil.getUITheme().getRowBackgroundLighterColor();
+ textSelectionForegroundColor = GUIUtil.getUITheme().getTextSelectionForegroundColor();
+ textColor = GUIUtil.getUITheme().getTextColor();
+ }
}
diff --git a/swing/src/net/sf/openrocket/gui/util/GUIUtil.java b/swing/src/net/sf/openrocket/gui/util/GUIUtil.java
index 687eedf53..2becea7c8 100644
--- a/swing/src/net/sf/openrocket/gui/util/GUIUtil.java
+++ b/swing/src/net/sf/openrocket/gui/util/GUIUtil.java
@@ -19,6 +19,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -56,6 +57,7 @@ import javax.swing.event.ChangeListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableColumnModel;
import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel;
import javax.swing.tree.DefaultMutableTreeNode;
@@ -404,23 +406,26 @@ public class GUIUtil {
public static void rememberTableColumnWidths(final JTable table, String keyName) {
final String key = keyName == null ? table.getClass().getName() : keyName;
- for (int i = 0; i < table.getColumnCount(); i++) {
- final int column = i;
- table.getColumnModel().getColumn(i).addPropertyChangeListener(new PropertyChangeListener() {
+ Enumeration columns = table.getColumnModel().getColumns();
+ while (columns.hasMoreElements()) {
+ TableColumn column = columns.nextElement();
+ column.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("width")) {
- log.debug("Storing width of " + table.getName() + "-" + table.getColumnName(column) + ": " + table.getColumnModel().getColumn(column).getWidth());
+ log.debug("Storing width of " + table.getName() + "-" + column + ": " + column.getWidth());
((SwingPreferences) Application.getPreferences()).setTableColumnWidth(
- key, column, table.getColumnModel().getColumn(column).getWidth());
+ key, column.getModelIndex(), column.getWidth());
}
}
});
final Integer width = ((SwingPreferences) Application.getPreferences()).getTableColumnWidth(
- key, column);
+ key, column.getModelIndex());
if (width != null) {
- table.getColumnModel().getColumn(column).setPreferredWidth(width);
+ column.setPreferredWidth(width);
+ } else {
+ column.setPreferredWidth(getOptimalColumnWidth(table, column.getModelIndex()));
}
}
}
@@ -428,6 +433,28 @@ public class GUIUtil {
public static void rememberTableColumnWidths(final JTable table) {
rememberTableColumnWidths(table, null);
}
+
+ public static int getOptimalColumnWidth(JTable table, int columnIndex) {
+ if (columnIndex >= table.getColumnModel().getColumnCount()) {
+ return -1;
+ }
+
+ TableColumn column = table.getColumnModel().getColumn(columnIndex);
+ Component headerRenderer = table.getTableHeader().getDefaultRenderer()
+ .getTableCellRendererComponent(table, column.getHeaderValue(), false, false, 0, columnIndex);
+
+ int maxWidth = headerRenderer.getPreferredSize().width;
+
+ for (int row = 0; row < table.getRowCount(); row++) {
+ Component renderer = table.getCellRenderer(row, columnIndex)
+ .getTableCellRendererComponent(table, table.getValueAt(row, columnIndex), false, false, row, columnIndex);
+ maxWidth = Math.max(maxWidth, renderer.getPreferredSize().width);
+ }
+
+ // Optional: Add some padding
+ int padding = 5; // adjust this value as needed
+ return maxWidth + padding;
+ }
/**
diff --git a/swing/src/net/sf/openrocket/gui/util/UITheme.java b/swing/src/net/sf/openrocket/gui/util/UITheme.java
index 612792f5f..96cb57ac1 100644
--- a/swing/src/net/sf/openrocket/gui/util/UITheme.java
+++ b/swing/src/net/sf/openrocket/gui/util/UITheme.java
@@ -11,17 +11,16 @@ import org.slf4j.LoggerFactory;
import javax.swing.BorderFactory;
import javax.swing.Icon;
-import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.border.Border;
import java.awt.Color;
import java.awt.Font;
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
-import java.util.concurrent.atomic.AtomicReference;
public class UITheme {
private static final Translator trans = Application.getTranslator();
@@ -43,6 +42,7 @@ public class UITheme {
Color getRowBackgroundDarkerColor();
Color getFlightDataTextActiveColor();
Color getFlightDataTextInactiveColor();
+ Color getMultiCompEditColor();
// Component colors
String getDefaultBodyComponentColor();
@@ -83,6 +83,57 @@ public class UITheme {
Border getBorder();
void formatScriptTextArea(RSyntaxTextArea textArea);
+
+ // Rocket component icons
+ String getComponentIconNoseCone();
+ String getComponentIconBodyTube();
+ String getComponentIconTransition();
+ String getComponentIconTrapezoidFinSet();
+ String getComponentIconEllipticalFinSet();
+ String getComponentIconFreeformFinSet();
+ String getComponentIconTubeFinSet();
+ String getComponentIconLaunchLug();
+ String getComponentIconRailButton();
+ String getComponentIconInnerTube();
+ String getComponentIconTubeCoupler();
+ String getComponentIconCenteringRing();
+ String getComponentIconBulkhead();
+ String getComponentIconEngineBlock();
+ String getComponentIconParachute();
+ String getComponentIconStreamer();
+ String getComponentIconShockCord();
+ String getComponentIconMass();
+ String getComponentIconStage();
+ String getComponentIconBoosters();
+ String getComponentIconPods();
+ String getComponentIconMassAltimeter();
+ String getComponentIconMassBattery();
+ String getComponentIconMassDeploymentCharge();
+ String getComponentIconMassPayload();
+ String getComponentIconMassFlightComp();
+ String getComponentIconMassRecoveryHardware();
+ String getComponentIconMassTracker();
+
+ // Static list of listeners
+ static List themeChangeListeners = new ArrayList<>();
+
+ // Static method to add a listener
+ static void addUIThemeChangeListener(Runnable listener) {
+ // TODO: implement this once you have implemented invalidation for each listener so that we don't get memory leaks
+ //themeChangeListeners.add(listener);
+ }
+
+ // Static method to remove a listener
+ static void removeUIThemeChangeListener(Runnable listener) {
+ themeChangeListeners.remove(listener);
+ }
+
+ // Static method to notify all listeners
+ static void notifyUIThemeChangeListeners() {
+ for (Runnable listener : themeChangeListeners) {
+ listener.run();
+ }
+ }
}
public static boolean isLightTheme(Theme theme) {
@@ -115,6 +166,9 @@ public class UITheme {
GUIUtil.setBestLAF();
setGlobalFontSize(prefs.getUIFontSize());
+
+ // After applying the theme settings, notify listeners
+ Theme.notifyUIThemeChangeListeners();
}
@Override
@@ -182,6 +236,11 @@ public class UITheme {
return new Color(0,0,127,127);
}
+ @Override
+ public Color getMultiCompEditColor() {
+ return new Color(170, 0, 100);
+ }
+
@Override
public String getDefaultBodyComponentColor() {
return "0,0,240";
@@ -329,6 +388,119 @@ public class UITheme {
log.warn("Unable to load RSyntaxTextArea theme", ioe);
}
}
+
+ @Override
+ public String getComponentIconNoseCone() {
+ return "nosecone";
+ }
+ @Override
+ public String getComponentIconBodyTube() {
+ return "bodytube";
+ }
+ @Override
+ public String getComponentIconTransition() {
+ return "transition";
+ }
+ @Override
+ public String getComponentIconTrapezoidFinSet() {
+ return "trapezoidfin";
+ }
+ @Override
+ public String getComponentIconEllipticalFinSet() {
+ return "ellipticalfin";
+ }
+ @Override
+ public String getComponentIconFreeformFinSet() {
+ return "freeformfin";
+ }
+ @Override
+ public String getComponentIconTubeFinSet() {
+ return "tubefin";
+ }
+ @Override
+ public String getComponentIconLaunchLug() {
+ return "launchlug";
+ }
+ @Override
+ public String getComponentIconRailButton() {
+ return "railbutton";
+ }
+ @Override
+ public String getComponentIconInnerTube() {
+ return "innertube";
+ }
+ @Override
+ public String getComponentIconTubeCoupler() {
+ return "tubecoupler";
+ }
+ @Override
+ public String getComponentIconCenteringRing() {
+ return "centeringring";
+ }
+ @Override
+ public String getComponentIconBulkhead() {
+ return "bulkhead";
+ }
+ @Override
+ public String getComponentIconEngineBlock() {
+ return "engineblock";
+ }
+ @Override
+ public String getComponentIconParachute() {
+ return "parachute";
+ }
+ @Override
+ public String getComponentIconStreamer() {
+ return "streamer";
+ }
+ @Override
+ public String getComponentIconShockCord() {
+ return "shockcord";
+ }
+ @Override
+ public String getComponentIconMass() {
+ return "mass";
+ }
+ @Override
+ public String getComponentIconStage() {
+ return "stage";
+ }
+ @Override
+ public String getComponentIconBoosters() {
+ return "boosters";
+ }
+ @Override
+ public String getComponentIconPods() {
+ return "pods";
+ }
+ @Override
+ public String getComponentIconMassAltimeter() {
+ return "altimeter";
+ }
+ @Override
+ public String getComponentIconMassBattery() {
+ return "battery";
+ }
+ @Override
+ public String getComponentIconMassDeploymentCharge() {
+ return "deployment-charge";
+ }
+ @Override
+ public String getComponentIconMassPayload() {
+ return "payload";
+ }
+ @Override
+ public String getComponentIconMassFlightComp() {
+ return "flight-comp";
+ }
+ @Override
+ public String getComponentIconMassRecoveryHardware() {
+ return "recovery-hardware";
+ }
+ @Override
+ public String getComponentIconMassTracker() {
+ return "tracker";
+ }
},
DARK {
private final String displayName = trans.get("UITheme.Dark");
@@ -338,6 +510,9 @@ public class UITheme {
LafManager.install(new DarculaTheme());
setGlobalFontSize(prefs.getUIFontSize());
+
+ // After applying the theme settings, notify listeners
+ Theme.notifyUIThemeChangeListeners();
}
@Override
@@ -405,6 +580,11 @@ public class UITheme {
return new Color(128, 166, 230, 127);
}
+ @Override
+ public Color getMultiCompEditColor() {
+ return new Color(222, 146, 176);
+ }
+
@Override
public String getDefaultBodyComponentColor() {
return "150,162,255";
@@ -551,6 +731,119 @@ public class UITheme {
log.warn("Unable to load RSyntaxTextArea theme", ioe);
}
}
+
+ @Override
+ public String getComponentIconNoseCone() {
+ return "nosecone";
+ }
+ @Override
+ public String getComponentIconBodyTube() {
+ return "bodytube";
+ }
+ @Override
+ public String getComponentIconTransition() {
+ return "transition";
+ }
+ @Override
+ public String getComponentIconTrapezoidFinSet() {
+ return "trapezoidfin";
+ }
+ @Override
+ public String getComponentIconEllipticalFinSet() {
+ return "ellipticalfin_dark";
+ }
+ @Override
+ public String getComponentIconFreeformFinSet() {
+ return "freeformfin_dark";
+ }
+ @Override
+ public String getComponentIconTubeFinSet() {
+ return "tubefin";
+ }
+ @Override
+ public String getComponentIconLaunchLug() {
+ return "launchlug_dark";
+ }
+ @Override
+ public String getComponentIconRailButton() {
+ return "railbutton";
+ }
+ @Override
+ public String getComponentIconInnerTube() {
+ return "innertube";
+ }
+ @Override
+ public String getComponentIconTubeCoupler() {
+ return "tubecoupler";
+ }
+ @Override
+ public String getComponentIconCenteringRing() {
+ return "centeringring";
+ }
+ @Override
+ public String getComponentIconBulkhead() {
+ return "bulkhead";
+ }
+ @Override
+ public String getComponentIconEngineBlock() {
+ return "engineblock";
+ }
+ @Override
+ public String getComponentIconParachute() {
+ return "parachute_dark";
+ }
+ @Override
+ public String getComponentIconStreamer() {
+ return "streamer_dark";
+ }
+ @Override
+ public String getComponentIconShockCord() {
+ return "shockcord_dark";
+ }
+ @Override
+ public String getComponentIconMass() {
+ return "mass_dark";
+ }
+ @Override
+ public String getComponentIconStage() {
+ return "stage";
+ }
+ @Override
+ public String getComponentIconBoosters() {
+ return "boosters";
+ }
+ @Override
+ public String getComponentIconPods() {
+ return "pods_dark";
+ }
+ @Override
+ public String getComponentIconMassAltimeter() {
+ return "altimeter_dark";
+ }
+ @Override
+ public String getComponentIconMassBattery() {
+ return "battery_dark";
+ }
+ @Override
+ public String getComponentIconMassDeploymentCharge() {
+ return "deployment-charge_dark";
+ }
+ @Override
+ public String getComponentIconMassPayload() {
+ return "payload";
+ }
+ @Override
+ public String getComponentIconMassFlightComp() {
+ return "flight-comp_dark";
+ }
+ @Override
+ public String getComponentIconMassRecoveryHardware() {
+ return "recovery-hardware_dark";
+ }
+ @Override
+ public String getComponentIconMassTracker() {
+ return "tracker_dark";
+ }
},
AUTO {
private final String displayName = trans.get("UITheme.Auto");
@@ -639,6 +932,11 @@ public class UITheme {
return getCurrentTheme().getFlightDataTextInactiveColor();
}
+ @Override
+ public Color getMultiCompEditColor() {
+ return getCurrentTheme().getMultiCompEditColor();
+ }
+
@Override
public String getDefaultBodyComponentColor() {
return getCurrentTheme().getDefaultBodyComponentColor();
@@ -788,6 +1086,119 @@ public class UITheme {
public void formatScriptTextArea(RSyntaxTextArea textArea) {
getCurrentTheme().formatScriptTextArea(textArea);
}
+
+ @Override
+ public String getComponentIconNoseCone() {
+ return getCurrentTheme().getComponentIconNoseCone();
+ }
+ @Override
+ public String getComponentIconBodyTube() {
+ return getCurrentTheme().getComponentIconBodyTube();
+ }
+ @Override
+ public String getComponentIconTransition() {
+ return getCurrentTheme().getComponentIconTransition();
+ }
+ @Override
+ public String getComponentIconTrapezoidFinSet() {
+ return getCurrentTheme().getComponentIconTrapezoidFinSet();
+ }
+ @Override
+ public String getComponentIconEllipticalFinSet() {
+ return getCurrentTheme().getComponentIconEllipticalFinSet();
+ }
+ @Override
+ public String getComponentIconFreeformFinSet() {
+ return getCurrentTheme().getComponentIconFreeformFinSet();
+ }
+ @Override
+ public String getComponentIconTubeFinSet() {
+ return getCurrentTheme().getComponentIconTubeFinSet();
+ }
+ @Override
+ public String getComponentIconLaunchLug() {
+ return getCurrentTheme().getComponentIconLaunchLug();
+ }
+ @Override
+ public String getComponentIconRailButton() {
+ return getCurrentTheme().getComponentIconRailButton();
+ }
+ @Override
+ public String getComponentIconInnerTube() {
+ return getCurrentTheme().getComponentIconInnerTube();
+ }
+ @Override
+ public String getComponentIconTubeCoupler() {
+ return getCurrentTheme().getComponentIconTubeCoupler();
+ }
+ @Override
+ public String getComponentIconCenteringRing() {
+ return getCurrentTheme().getComponentIconCenteringRing();
+ }
+ @Override
+ public String getComponentIconBulkhead() {
+ return getCurrentTheme().getComponentIconBulkhead();
+ }
+ @Override
+ public String getComponentIconEngineBlock() {
+ return getCurrentTheme().getComponentIconEngineBlock();
+ }
+ @Override
+ public String getComponentIconParachute() {
+ return getCurrentTheme().getComponentIconParachute();
+ }
+ @Override
+ public String getComponentIconStreamer() {
+ return getCurrentTheme().getComponentIconStreamer();
+ }
+ @Override
+ public String getComponentIconShockCord() {
+ return getCurrentTheme().getComponentIconShockCord();
+ }
+ @Override
+ public String getComponentIconMass() {
+ return getCurrentTheme().getComponentIconMass();
+ }
+ @Override
+ public String getComponentIconStage() {
+ return getCurrentTheme().getComponentIconStage();
+ }
+ @Override
+ public String getComponentIconBoosters() {
+ return getCurrentTheme().getComponentIconBoosters();
+ }
+ @Override
+ public String getComponentIconPods() {
+ return getCurrentTheme().getComponentIconPods();
+ }
+ @Override
+ public String getComponentIconMassAltimeter() {
+ return getCurrentTheme().getComponentIconMassAltimeter();
+ }
+ @Override
+ public String getComponentIconMassBattery() {
+ return getCurrentTheme().getComponentIconMassBattery();
+ }
+ @Override
+ public String getComponentIconMassDeploymentCharge() {
+ return getCurrentTheme().getComponentIconMassDeploymentCharge();
+ }
+ @Override
+ public String getComponentIconMassPayload() {
+ return getCurrentTheme().getComponentIconMassPayload();
+ }
+ @Override
+ public String getComponentIconMassFlightComp() {
+ return getCurrentTheme().getComponentIconMassFlightComp();
+ }
+ @Override
+ public String getComponentIconMassRecoveryHardware() {
+ return getCurrentTheme().getComponentIconMassRecoveryHardware();
+ }
+ @Override
+ public String getComponentIconMassTracker() {
+ return getCurrentTheme().getComponentIconMassTracker();
+ }
}
}
diff --git a/swing/src/net/sf/openrocket/simulation/extension/impl/JavaCodeConfigurator.java b/swing/src/net/sf/openrocket/simulation/extension/impl/JavaCodeConfigurator.java
index eea237e11..6ce79068b 100644
--- a/swing/src/net/sf/openrocket/simulation/extension/impl/JavaCodeConfigurator.java
+++ b/swing/src/net/sf/openrocket/simulation/extension/impl/JavaCodeConfigurator.java
@@ -10,11 +10,14 @@ import javax.swing.event.DocumentListener;
import net.sf.openrocket.document.Simulation;
import net.sf.openrocket.gui.components.StyledLabel;
import net.sf.openrocket.gui.util.GUIUtil;
+import net.sf.openrocket.gui.util.UITheme;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.plugin.Plugin;
import net.sf.openrocket.simulation.extension.AbstractSwingSimulationExtensionConfigurator;
import net.sf.openrocket.startup.Application;
+import java.awt.Color;
+
@Plugin
public class JavaCodeConfigurator extends AbstractSwingSimulationExtensionConfigurator {
private JavaCode extension;
@@ -23,9 +26,24 @@ public class JavaCodeConfigurator extends AbstractSwingSimulationExtensionConfig
private static final Translator trans = Application.getTranslator();
+ private static Color darkWarningColor;
+
+ static {
+ initColors();
+ }
+
public JavaCodeConfigurator() {
super(JavaCode.class);
}
+
+ private static void initColors() {
+ updateColors();
+ UITheme.Theme.addUIThemeChangeListener(JavaCodeConfigurator::updateColors);
+ }
+
+ private static void updateColors() {
+ darkWarningColor = GUIUtil.getUITheme().getDarkWarningColor();
+ }
@Override
protected JComponent getConfigurationComponent(final JavaCode extension, Simulation simulation, JPanel panel) {
@@ -35,7 +53,7 @@ public class JavaCodeConfigurator extends AbstractSwingSimulationExtensionConfig
classNameField = new JTextField(extension.getClassName());
panel.add(classNameField, "growx, wrap");
this.errorMsg = new StyledLabel();
- errorMsg.setFontColor(GUIUtil.getUITheme().getDarkWarningColor());
+ errorMsg.setFontColor(darkWarningColor);
errorMsg.setVisible(false);
panel.add(errorMsg, "growx, wrap");