diff --git a/core/src/net/sf/openrocket/optimization/services/DefaultSimulationModifierService.java b/core/src/net/sf/openrocket/optimization/services/DefaultSimulationModifierService.java index 4880a08c0..e6d72ef25 100644 --- a/core/src/net/sf/openrocket/optimization/services/DefaultSimulationModifierService.java +++ b/core/src/net/sf/openrocket/optimization/services/DefaultSimulationModifierService.java @@ -10,6 +10,7 @@ import java.util.Map; import net.sf.openrocket.document.OpenRocketDocument; import net.sf.openrocket.document.Simulation; import net.sf.openrocket.l10n.Translator; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.optimization.general.OptimizationException; import net.sf.openrocket.optimization.rocketoptimization.SimulationModifier; import net.sf.openrocket.optimization.rocketoptimization.modifiers.FlightConfigurationModifier; @@ -180,7 +181,8 @@ public class DefaultSimulationModifierService implements SimulationModifierServi if (c instanceof MotorMount) { MotorMount mount = (MotorMount) c; if (mount.isMotorMount()) { - + + // Motor overhang SimulationModifier mod = new GenericComponentModifier( trans.get("optimization.modifier.motormount.overhang"), trans.get("optimization.modifier.motormount.overhang.desc"), @@ -188,22 +190,18 @@ public class DefaultSimulationModifierService implements SimulationModifierServi 1.0, c.getClass(), c.getID(), "MotorOverhang"); setDefaultMinMax(mod, simulation); modifiers.add(mod); - -// TODO: reimplement motor ignition optimization -// mod = new FlightConfigurationModifier( -// trans.get("optimization.modifier.motormount.delay"), -// trans.get("optimization.modifier.motormount.delay.desc"), -// c, UnitGroup.UNITS_SHORT_TIME, -// 1.0, -// c.getClass(), -// c.getID(), -// "IgnitionConfiguration", -// IgnitionConfiguration.class, -// "IgnitionDelay"); -// -// mod.setMinValue(0); -// mod.setMaxValue(5); -// modifiers.add(mod); + + // Motor ignition delay + mod = new FlightConfigurationModifier( + trans.get("optimization.modifier.motormount.delay"), + trans.get("optimization.modifier.motormount.delay.desc"), + c, UnitGroup.UNITS_SHORT_TIME, + 1.0, c.getClass(), c.getID(), "MotorConfigurationSet", + MotorConfiguration.class, + "IgnitionDelay"); + mod.setMinValue(0); + mod.setMaxValue(5); + modifiers.add(mod); } } 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 f2c56dc30..f2010d035 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/optimization/SimulationModifierTree.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/optimization/SimulationModifierTree.java @@ -42,6 +42,7 @@ public class SimulationModifierTree extends BasicTree { private static Color textColor; private static Color dimTextColor; + private static Color disabledTextColor; private static Color textSelectionForegroundColor; private static Color textSelectionBackgroundColor; @@ -77,6 +78,7 @@ public class SimulationModifierTree extends BasicTree { private static void updateColors() { textColor = GUIUtil.getUITheme().getTextColor(); dimTextColor = GUIUtil.getUITheme().getDimTextColor(); + disabledTextColor = GUIUtil.getUITheme().getDisabledTextColor(); textSelectionForegroundColor = GUIUtil.getUITheme().getTextSelectionForegroundColor(); textSelectionBackgroundColor = GUIUtil.getUITheme().getTextSelectionBackgroundColor(); } @@ -197,16 +199,18 @@ public class SimulationModifierTree extends BasicTree { setForeground(dimTextColor); setFont(stringFont); } else if (object instanceof SimulationModifier) { + boolean isSelected = tree.getSelectionRows() != null && IntStream.of(tree.getSelectionRows()).anyMatch(r -> r == row); + if (isSelected) { + setBackground(textSelectionBackgroundColor); + setOpaque(true); + } if (selectedModifiers.contains(object)) { - setForeground(dimTextColor); + setForeground(disabledTextColor); setFont(stringFont); } else { - if (tree.getSelectionRows() != null && - IntStream.of(tree.getSelectionRows()).anyMatch(r -> r == row)) { + if (isSelected) { setForeground(textSelectionForegroundColor); - setBackground(textSelectionBackgroundColor); - setOpaque(true); } else { setForeground(textColor); } diff --git a/swing/src/net/sf/openrocket/gui/util/UITheme.java b/swing/src/net/sf/openrocket/gui/util/UITheme.java index c4c9ee84c..45e507102 100644 --- a/swing/src/net/sf/openrocket/gui/util/UITheme.java +++ b/swing/src/net/sf/openrocket/gui/util/UITheme.java @@ -38,6 +38,7 @@ public class UITheme { Color getBorderColor(); Color getTextColor(); Color getDimTextColor(); + Color getDisabledTextColor(); Color getTextSelectionForegroundColor(); Color getTextSelectionBackgroundColor(); Color getWarningColor(); @@ -205,6 +206,11 @@ public class UITheme { return Color.GRAY; } + @Override + public Color getDisabledTextColor() { + return getDimTextColor(); + } + @Override public Color getTextSelectionForegroundColor() { return UIManager.getColor("Tree.selectionForeground"); @@ -567,6 +573,11 @@ public class UITheme { return new Color(182, 182, 182); } + @Override + public Color getDisabledTextColor() { + return new Color(161, 161, 161); + } + @Override public Color getTextSelectionForegroundColor() { return Color.WHITE; @@ -925,6 +936,12 @@ public class UITheme { return new Color(165, 171, 184); } + @Override + public Color getDisabledTextColor() { + return new Color(128, 128, 128); + } + + @Override public Color getTextSelectionForegroundColor() { return Color.WHITE; @@ -1296,6 +1313,11 @@ public class UITheme { return getCurrentTheme().getDimTextColor(); } + @Override + public Color getDisabledTextColor() { + return getCurrentTheme().getDisabledTextColor(); + } + @Override public Color getTextSelectionForegroundColor() { return getCurrentTheme().getTextSelectionForegroundColor();