From 3d343528a5bfaab09a3f52c836e511614cc9c0a2 Mon Sep 17 00:00:00 2001 From: SiboVG Date: Fri, 16 Feb 2024 01:02:35 +0100 Subject: [PATCH] Refactor (dark) warning color to (dark) error color --- .../file/wavefrontobj/OBJOptionChooser.java | 6 +-- .../configdialog/RocketComponentConfig.java | 10 ++-- .../gui/dialogs/BugReportDialog.java | 6 +-- .../gui/dialogs/ErrorWarningDialog.java | 8 +-- .../preferences/GeneralPreferencesPanel.java | 2 +- .../preferences/LaunchPreferencesPanel.java | 6 +-- .../SimulationPreferencesPanel.java | 6 +-- .../gui/figureelements/RocketInfo.java | 6 +-- .../gui/plot/SimulationPlotDialog.java | 6 +-- .../gui/simulation/SimulationPlotPanel.java | 6 +-- .../net/sf/openrocket/gui/util/UITheme.java | 54 ++++++++++++++++--- .../extension/impl/JavaCodeConfigurator.java | 6 +-- 12 files changed, 82 insertions(+), 40 deletions(-) diff --git a/swing/src/net/sf/openrocket/file/wavefrontobj/OBJOptionChooser.java b/swing/src/net/sf/openrocket/file/wavefrontobj/OBJOptionChooser.java index ec42ad0a0..604954a8c 100644 --- a/swing/src/net/sf/openrocket/file/wavefrontobj/OBJOptionChooser.java +++ b/swing/src/net/sf/openrocket/file/wavefrontobj/OBJOptionChooser.java @@ -66,7 +66,7 @@ public class OBJOptionChooser extends JPanel { private int totallyNormalCounter = 0; - private static Color darkWarningColor; + private static Color darkErrorColor; static { initColors(); @@ -319,7 +319,7 @@ public class OBJOptionChooser extends JPanel { } private static void updateColors() { - darkWarningColor = GUIUtil.getUITheme().getDarkWarningColor(); + darkErrorColor = GUIUtil.getUITheme().getDarkErrorColor(); } /** @@ -328,7 +328,7 @@ public class OBJOptionChooser extends JPanel { * @param loserButton The button to un-highlight */ private void highlightButton(JButton highlightButton, JButton loserButton) { - highlightButton.setBorder(BorderFactory.createLineBorder(darkWarningColor)); + highlightButton.setBorder(BorderFactory.createLineBorder(darkErrorColor)); loserButton.setBorder(UIManager.getBorder("Button.border")); } diff --git a/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java index 4e7fb85c5..e79687320 100644 --- a/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java +++ b/swing/src/net/sf/openrocket/gui/configdialog/RocketComponentConfig.java @@ -99,7 +99,7 @@ public class RocketComponentConfig extends JPanel implements Invalidatable, Inva 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 darkErrorColor; private static Color multiCompEditColor; private static Border border; @@ -205,7 +205,7 @@ public class RocketComponentConfig extends JPanel implements Invalidatable, Inva } private static void updateColors() { - darkWarningColor = GUIUtil.getUITheme().getDarkWarningColor(); + darkErrorColor = GUIUtil.getUITheme().getDarkErrorColor(); multiCompEditColor = GUIUtil.getUITheme().getMultiCompEditColor(); border = GUIUtil.getUITheme().getBorder(); } @@ -539,7 +539,7 @@ public class RocketComponentConfig extends JPanel implements Invalidatable, Inva StyledLabel labelMassOverriddenBy = new StyledLabel( String.format(trans.get("RocketCompCfg.lbl.MassOverriddenBy"), component.getMassOverriddenBy().getName()), 0, StyledLabel.Style.BOLD); - labelMassOverriddenBy.setFontColor(darkWarningColor); + labelMassOverriddenBy.setFontColor(darkErrorColor); labelMassOverriddenBy.setToolTipText( String.format(trans.get("RocketCompCfg.lbl.MassOverriddenBy.ttip"), component.getMassOverriddenBy().getName())); checkboxes.add(labelMassOverriddenBy, "gapleft 25lp, wrap"); @@ -605,7 +605,7 @@ public class RocketComponentConfig extends JPanel implements Invalidatable, Inva StyledLabel labelCGOverriddenBy = new StyledLabel( String.format(trans.get("RocketCompCfg.lbl.CGOverriddenBy"), component.getCGOverriddenBy().getName()), 0, StyledLabel.Style.BOLD); - labelCGOverriddenBy.setFontColor(darkWarningColor); + labelCGOverriddenBy.setFontColor(darkErrorColor); labelCGOverriddenBy.setToolTipText( String.format(trans.get("RocketCompCfg.lbl.CGOverriddenBy.ttip"), component.getCGOverriddenBy().getName())); checkboxes.add(labelCGOverriddenBy, "gapleft 25lp, wrap"); @@ -702,7 +702,7 @@ public class RocketComponentConfig extends JPanel implements Invalidatable, Inva StyledLabel labelCDOverriddenBy = new StyledLabel( String.format(trans.get("RocketCompCfg.lbl.CDOverriddenBy"), component.getCDOverriddenBy().getName()), 0, StyledLabel.Style.BOLD); - labelCDOverriddenBy.setFontColor(darkWarningColor); + labelCDOverriddenBy.setFontColor(darkErrorColor); labelCDOverriddenBy.setToolTipText( String.format(trans.get("RocketCompCfg.lbl.CDOverriddenBy"), component.getCDOverriddenBy().getName())); checkboxes.add(labelCDOverriddenBy, "gapleft 25lp, wrap"); diff --git a/swing/src/net/sf/openrocket/gui/dialogs/BugReportDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/BugReportDialog.java index 7e9818629..2f6e3c4f6 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/BugReportDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/BugReportDialog.java @@ -49,7 +49,7 @@ public class BugReportDialog extends JDialog { private static final Translator trans = Application.getTranslator(); private static final SwingPreferences preferences = (SwingPreferences) Application.getPreferences(); - private static Color darkWarningColor; + private static Color darkErrorColor; static { initColors(); @@ -117,7 +117,7 @@ public class BugReportDialog extends JDialog { } private static void updateColors() { - darkWarningColor = GUIUtil.getUITheme().getDarkWarningColor(); + darkErrorColor = GUIUtil.getUITheme().getDarkErrorColor(); } /** @@ -194,7 +194,7 @@ public class BugReportDialog extends JDialog { private static void addBugReportInformation(StringBuilder sb) { sb.append("---------- Bug report ----------\n"); sb.append('\n'); - Color color = darkWarningColor; + Color color = darkErrorColor; 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/ErrorWarningDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/ErrorWarningDialog.java index 13e2a8b1f..3fc386d14 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/ErrorWarningDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/ErrorWarningDialog.java @@ -29,7 +29,7 @@ import java.awt.event.MouseEvent; @SuppressWarnings("serial") public abstract class ErrorWarningDialog { private static Border border; - private static Color darkWarningColor; + private static Color darkErrorColor; private static Color textSelectionForegroundColor; static { @@ -43,7 +43,7 @@ public abstract class ErrorWarningDialog { private static void updateColors() { border = GUIUtil.getUITheme().getBorder(); - darkWarningColor = GUIUtil.getUITheme().getDarkWarningColor(); + darkErrorColor = GUIUtil.getUITheme().getDarkErrorColor(); textSelectionForegroundColor = GUIUtil.getUITheme().getTextSelectionForegroundColor(); } @@ -51,7 +51,7 @@ public abstract class ErrorWarningDialog { JPanel content = new JPanel(new MigLayout("ins 0, fillx")); StyledLabel label = new StyledLabel("Errors"); - label.setFontColor(darkWarningColor); + label.setFontColor(darkErrorColor); content.add(label, "wrap, gaptop 15lp"); Error[] e = errors.toArray(new Error[0]); @@ -110,7 +110,7 @@ public abstract class ErrorWarningDialog { if (isSelected) { label.setForeground(textSelectionForegroundColor); } else { - label.setForeground(darkWarningColor); + label.setForeground(darkErrorColor); } return label; diff --git a/swing/src/net/sf/openrocket/gui/dialogs/preferences/GeneralPreferencesPanel.java b/swing/src/net/sf/openrocket/gui/dialogs/preferences/GeneralPreferencesPanel.java index 5506779e5..8f456a9f1 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/preferences/GeneralPreferencesPanel.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/preferences/GeneralPreferencesPanel.java @@ -126,7 +126,7 @@ public class GeneralPreferencesPanel extends PreferencesPanel { //// You need to restart OpenRocket for the theme change to take effect. final JLabel lblRestartORTheme = new JLabel(); - lblRestartORTheme.setForeground(GUIUtil.getUITheme().getDarkWarningColor()); + lblRestartORTheme.setForeground(GUIUtil.getUITheme().getDarkErrorColor()); this.add(lblRestartORTheme, "spanx, wrap para*2, growx"); fontSizeSpinner.addChangeListener(new ChangeListener() { 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 0443c1b8a..b4eaeed33 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/preferences/LaunchPreferencesPanel.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/preferences/LaunchPreferencesPanel.java @@ -11,7 +11,7 @@ import net.sf.openrocket.gui.util.GUIUtil; import net.sf.openrocket.gui.util.UITheme; public class LaunchPreferencesPanel extends PreferencesPanel { - private static Color darkWarningColor; + private static Color darkErrorColor; static { initColors(); @@ -29,7 +29,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(darkWarningColor); + warning.setFontColor(darkErrorColor); warning.setToolTipText(trans.get("pref.dlg.lbl.launchWarning.ttip")); add(warning, "spanx, growx 0, gapbottom para, wrap"); @@ -44,7 +44,7 @@ public class LaunchPreferencesPanel extends PreferencesPanel { } private static void updateColors() { - darkWarningColor = GUIUtil.getUITheme().getDarkWarningColor(); + darkErrorColor = GUIUtil.getUITheme().getDarkErrorColor(); } } 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 36e3c2dda..7a3535e5c 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/preferences/SimulationPreferencesPanel.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/preferences/SimulationPreferencesPanel.java @@ -28,7 +28,7 @@ import net.sf.openrocket.gui.widgets.SelectColorButton; public class SimulationPreferencesPanel extends PreferencesPanel { private static final long serialVersionUID = 7983195730016979888L; - private static Color darkWarningColor; + private static Color darkErrorColor; static { initColors(); @@ -93,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(darkWarningColor); + warning.setFontColor(darkErrorColor); warning.setToolTipText(trans.get("pref.dlg.lbl.launchWarning.ttip")); subsub.add(warning, "spanx, wrap para"); @@ -309,6 +309,6 @@ public class SimulationPreferencesPanel extends PreferencesPanel { } private static void updateColors() { - darkWarningColor = GUIUtil.getUITheme().getDarkWarningColor(); + darkErrorColor = GUIUtil.getUITheme().getDarkErrorColor(); } } diff --git a/swing/src/net/sf/openrocket/gui/figureelements/RocketInfo.java b/swing/src/net/sf/openrocket/gui/figureelements/RocketInfo.java index 83bc688f8..b311e7844 100644 --- a/swing/src/net/sf/openrocket/gui/figureelements/RocketInfo.java +++ b/swing/src/net/sf/openrocket/gui/figureelements/RocketInfo.java @@ -69,7 +69,7 @@ public class RocketInfo implements FigureElement { private static Color textColor; private static Color dimTextColor; - private static Color warningColor; + private static Color darkErrorColor; private static Color flightDataTextActiveColor; private static Color flightDataTextInactiveColor; @@ -91,7 +91,7 @@ public class RocketInfo implements FigureElement { private static void updateColors() { textColor = GUIUtil.getUITheme().getTextColor(); dimTextColor = GUIUtil.getUITheme().getDimTextColor(); - warningColor = GUIUtil.getUITheme().getWarningColor(); + darkErrorColor = GUIUtil.getUITheme().getErrorColor(); flightDataTextActiveColor = GUIUtil.getUITheme().getFlightDataTextActiveColor(); flightDataTextInactiveColor = GUIUtil.getUITheme().getFlightDataTextInactiveColor(); } @@ -435,7 +435,7 @@ public class RocketInfo implements FigureElement { float y = y2 - line * (texts.length-1); - g2.setColor(warningColor); + g2.setColor(darkErrorColor); for (GlyphVector v: texts) { Rectangle2D rect = v.getVisualBounds(); diff --git a/swing/src/net/sf/openrocket/gui/plot/SimulationPlotDialog.java b/swing/src/net/sf/openrocket/gui/plot/SimulationPlotDialog.java index 83096c3cc..292f076cb 100644 --- a/swing/src/net/sf/openrocket/gui/plot/SimulationPlotDialog.java +++ b/swing/src/net/sf/openrocket/gui/plot/SimulationPlotDialog.java @@ -45,7 +45,7 @@ import org.jfree.chart.JFreeChart; public class SimulationPlotDialog extends JDialog { private static final Translator trans = Application.getTranslator(); - private static Color darkWarningColor; + private static Color darkErrorColor; private final JCheckBox checkErrors; static { @@ -82,7 +82,7 @@ public class SimulationPlotDialog extends JDialog { // Add warning if X axis type is not time if (config.getDomainAxisType() != FlightDataType.TYPE_TIME) { JLabel msg = new StyledLabel(trans.get("PlotDialog.lbl.timeSeriesWarning"), -2); - msg.setForeground(darkWarningColor); + msg.setForeground(darkErrorColor); panel.add(msg, "wrap"); } @@ -207,7 +207,7 @@ public class SimulationPlotDialog extends JDialog { } private static void updateColors() { - darkWarningColor = GUIUtil.getUITheme().getDarkWarningColor(); + darkErrorColor = GUIUtil.getUITheme().getDarkErrorColor(); } private boolean doPNGExport(ChartPanel chartPanel, JFreeChart chart){ diff --git a/swing/src/net/sf/openrocket/gui/simulation/SimulationPlotPanel.java b/swing/src/net/sf/openrocket/gui/simulation/SimulationPlotPanel.java index 938f5948d..baba99187 100644 --- a/swing/src/net/sf/openrocket/gui/simulation/SimulationPlotPanel.java +++ b/swing/src/net/sf/openrocket/gui/simulation/SimulationPlotPanel.java @@ -110,7 +110,7 @@ public class SimulationPlotPanel extends JPanel { private DescriptionArea simPlotPanelDesc; - private static java.awt.Color darkWarningColor; + private static java.awt.Color darkErrorColor; private static Border border; static { @@ -213,7 +213,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(darkWarningColor); + simPlotPanelDesc.setForeground(darkErrorColor); simPlotPanelDesc.setViewportBorder(BorderFactory.createEmptyBorder()); this.add(simPlotPanelDesc, "width 1px, growx 1, wrap unrel"); @@ -393,7 +393,7 @@ public class SimulationPlotPanel extends JPanel { } private static void updateColors() { - darkWarningColor = GUIUtil.getUITheme().getDarkWarningColor(); + darkErrorColor = GUIUtil.getUITheme().getDarkErrorColor(); border = GUIUtil.getUITheme().getBorder(); } diff --git a/swing/src/net/sf/openrocket/gui/util/UITheme.java b/swing/src/net/sf/openrocket/gui/util/UITheme.java index 45e507102..33e576106 100644 --- a/swing/src/net/sf/openrocket/gui/util/UITheme.java +++ b/swing/src/net/sf/openrocket/gui/util/UITheme.java @@ -41,8 +41,10 @@ public class UITheme { Color getDisabledTextColor(); Color getTextSelectionForegroundColor(); Color getTextSelectionBackgroundColor(); + Color getInformationColor(); Color getWarningColor(); - Color getDarkWarningColor(); + Color getErrorColor(); + Color getDarkErrorColor(); Color getRowBackgroundLighterColor(); Color getRowBackgroundDarkerColor(); Color getFlightDataTextActiveColor(); @@ -221,13 +223,23 @@ public class UITheme { return UIManager.getColor("Tree.selectionBackground"); } + @Override + public Color getInformationColor() { + return new Color(45, 45, 189); + } + @Override public Color getWarningColor() { + return new Color(180, 90, 17); + } + + @Override + public Color getErrorColor() { return Color.RED; } @Override - public Color getDarkWarningColor() { + public Color getDarkErrorColor() { return new Color(200,0,0); } @@ -588,13 +600,23 @@ public class UITheme { return new Color(75, 110, 175); } + @Override + public Color getInformationColor() { + return new Color(208, 208, 255); + } + @Override public Color getWarningColor() { + return new Color(255, 224, 166); + } + + @Override + public Color getErrorColor() { return new Color(246, 143, 143); } @Override - public Color getDarkWarningColor() { + public Color getDarkErrorColor() { return new Color(229, 103, 103); } @@ -952,13 +974,23 @@ public class UITheme { return new Color(62, 108, 173); } + @Override + public Color getInformationColor() { + return new Color(197, 197, 252); + } + @Override public Color getWarningColor() { + return new Color(255, 233, 187); + } + + @Override + public Color getErrorColor() { return new Color(255, 173, 173); } @Override - public Color getDarkWarningColor() { + public Color getDarkErrorColor() { return new Color(255, 178, 178); } @@ -1328,14 +1360,24 @@ public class UITheme { return getCurrentTheme().getTextSelectionBackgroundColor(); } + @Override + public Color getInformationColor() { + return getCurrentTheme().getInformationColor(); + } + @Override public Color getWarningColor() { return getCurrentTheme().getWarningColor(); } @Override - public Color getDarkWarningColor() { - return getCurrentTheme().getDarkWarningColor(); + public Color getErrorColor() { + return getCurrentTheme().getErrorColor(); + } + + @Override + public Color getDarkErrorColor() { + return getCurrentTheme().getDarkErrorColor(); } @Override 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 6ce79068b..718afe916 100644 --- a/swing/src/net/sf/openrocket/simulation/extension/impl/JavaCodeConfigurator.java +++ b/swing/src/net/sf/openrocket/simulation/extension/impl/JavaCodeConfigurator.java @@ -26,7 +26,7 @@ public class JavaCodeConfigurator extends AbstractSwingSimulationExtensionConfig private static final Translator trans = Application.getTranslator(); - private static Color darkWarningColor; + private static Color darkErrorColor; static { initColors(); @@ -42,7 +42,7 @@ public class JavaCodeConfigurator extends AbstractSwingSimulationExtensionConfig } private static void updateColors() { - darkWarningColor = GUIUtil.getUITheme().getDarkWarningColor(); + darkErrorColor = GUIUtil.getUITheme().getDarkErrorColor(); } @Override @@ -53,7 +53,7 @@ public class JavaCodeConfigurator extends AbstractSwingSimulationExtensionConfig classNameField = new JTextField(extension.getClassName()); panel.add(classNameField, "growx, wrap"); this.errorMsg = new StyledLabel(); - errorMsg.setFontColor(darkWarningColor); + errorMsg.setFontColor(darkErrorColor); errorMsg.setVisible(false); panel.add(errorMsg, "growx, wrap");