Fix unit tests by "abstracting" getUITheme
This commit is contained in:
parent
58b9a2d499
commit
b7e007e1da
@ -118,6 +118,8 @@ public abstract class Preferences implements ChangeSource {
|
|||||||
public static final String SIMULATION_TIME_STEP = "SimulationTimeStep";
|
public static final String SIMULATION_TIME_STEP = "SimulationTimeStep";
|
||||||
public static final String GEODETIC_COMPUTATION = "GeodeticComputationStrategy";
|
public static final String GEODETIC_COMPUTATION = "GeodeticComputationStrategy";
|
||||||
|
|
||||||
|
public static final String UI_THEME = "UITheme";
|
||||||
|
|
||||||
|
|
||||||
private static final AtmosphericModel ISA_ATMOSPHERIC_MODEL = new ExtendedISAModel();
|
private static final AtmosphericModel ISA_ATMOSPHERIC_MODEL = new ExtendedISAModel();
|
||||||
|
|
||||||
@ -975,6 +977,29 @@ public abstract class Preferences implements ChangeSource {
|
|||||||
|
|
||||||
public abstract Set<String> getComponentFavorites(ComponentPreset.Type type);
|
public abstract Set<String> getComponentFavorites(ComponentPreset.Type type);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
NOTE: It is unusual for the UI Theme to be stored in the preferences instead of SwingPreferences. In fact, this code
|
||||||
|
is not pretty. Sometimes I just really hate Java and circular dependencies...
|
||||||
|
But the reason why this is implemented is because it would otherwise be an even bigger nightmare to fix unit tests
|
||||||
|
that use their own preferences... Also wasn't a fan of always casting the preferences to SwingPreferences.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Get the current theme used for the UI.
|
||||||
|
* @return the current theme
|
||||||
|
*/
|
||||||
|
public Object getUITheme() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the theme used for the UI.
|
||||||
|
* @param theme the theme to set
|
||||||
|
*/
|
||||||
|
public void setUITheme(Object theme) {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Within a holder class so they will load only when needed.
|
* Within a holder class so they will load only when needed.
|
||||||
*/
|
*/
|
||||||
|
@ -2,12 +2,10 @@ package net.sf.openrocket.communication;
|
|||||||
|
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.SwingPreferences;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.util.BuildProperties;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class handles assets extracted from a GitHub release page.
|
* This class handles assets extracted from a GitHub release page.
|
||||||
|
@ -3,9 +3,7 @@ package net.sf.openrocket.database;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.sf.openrocket.file.iterator.DirectoryIterator;
|
import net.sf.openrocket.file.iterator.DirectoryIterator;
|
||||||
import net.sf.openrocket.file.iterator.FileIterator;
|
import net.sf.openrocket.file.iterator.FileIterator;
|
||||||
@ -14,7 +12,6 @@ import net.sf.openrocket.gui.util.SwingPreferences;
|
|||||||
import net.sf.openrocket.preset.ComponentPreset;
|
import net.sf.openrocket.preset.ComponentPreset;
|
||||||
import net.sf.openrocket.preset.xml.OpenRocketComponentLoader;
|
import net.sf.openrocket.preset.xml.OpenRocketComponentLoader;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.util.BugException;
|
|
||||||
import net.sf.openrocket.util.Pair;
|
import net.sf.openrocket.util.Pair;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.sf.openrocket.gui.components;
|
package net.sf.openrocket.gui.components;
|
||||||
|
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
|
|
||||||
import java.awt.BasicStroke;
|
import java.awt.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
@ -11,15 +10,12 @@ import java.awt.Graphics2D;
|
|||||||
|
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
import javax.swing.JTree;
|
import javax.swing.JTree;
|
||||||
import javax.swing.UIManager;
|
|
||||||
import javax.swing.tree.TreeModel;
|
import javax.swing.tree.TreeModel;
|
||||||
import javax.swing.tree.TreeNode;
|
import javax.swing.tree.TreeNode;
|
||||||
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreePath;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class BasicTree extends JTree {
|
public class BasicTree extends JTree {
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
public BasicTree() {
|
public BasicTree() {
|
||||||
super();
|
super();
|
||||||
setDefaultOptions();
|
setDefaultOptions();
|
||||||
@ -41,7 +37,7 @@ public class BasicTree extends JTree {
|
|||||||
plainUI.setLeftChildIndent(15);
|
plainUI.setLeftChildIndent(15);
|
||||||
|
|
||||||
|
|
||||||
this.setBackground(prefs.getUITheme().getBackgroundColor());
|
this.setBackground(GUIUtil.getUITheme().getBackgroundColor());
|
||||||
this.setShowsRootHandles(false);
|
this.setShowsRootHandles(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package net.sf.openrocket.gui.components;
|
package net.sf.openrocket.gui.components;
|
||||||
|
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.gui.util.URLUtil;
|
import net.sf.openrocket.gui.util.URLUtil;
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
@ -33,7 +32,6 @@ public class DescriptionArea extends JScrollPane {
|
|||||||
|
|
||||||
private final JEditorPane editorPane;
|
private final JEditorPane editorPane;
|
||||||
|
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
private final float size;
|
private final float size;
|
||||||
|
|
||||||
|
|
||||||
@ -179,7 +177,7 @@ public class DescriptionArea extends JScrollPane {
|
|||||||
dim.height = lineheight * rows + extraheight + 2;
|
dim.height = lineheight * rows + extraheight + 2;
|
||||||
this.setPreferredSize(dim);
|
this.setPreferredSize(dim);
|
||||||
|
|
||||||
editorPane.setBorder(prefs.getUITheme().getBorder());
|
editorPane.setBorder(GUIUtil.getUITheme().getBorder());
|
||||||
|
|
||||||
this.setViewportView(editorPane);
|
this.setViewportView(editorPane);
|
||||||
this.setText(text);
|
this.setText(text);
|
||||||
|
@ -1,25 +1,18 @@
|
|||||||
package net.sf.openrocket.gui.components;
|
package net.sf.openrocket.gui.components;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
import java.awt.Desktop;
|
import java.awt.Desktop;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.font.TextAttribute;
|
import java.awt.font.TextAttribute;
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.gui.util.URLUtil;
|
import net.sf.openrocket.gui.util.URLUtil;
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import net.sf.openrocket.util.BugException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A label of a URL that is clickable. Clicking the URL will launch the URL in
|
* A label of a URL that is clickable. Clicking the URL will launch the URL in
|
||||||
* the default browser if the Desktop class is supported.
|
* the default browser if the Desktop class is supported.
|
||||||
@ -28,7 +21,6 @@ import net.sf.openrocket.util.BugException;
|
|||||||
*/
|
*/
|
||||||
public class URLLabel extends SelectableLabel {
|
public class URLLabel extends SelectableLabel {
|
||||||
private static final Logger log = LoggerFactory.getLogger(URLLabel.class);
|
private static final Logger log = LoggerFactory.getLogger(URLLabel.class);
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a label showing the url it will direct to.
|
* Create a label showing the url it will direct to.
|
||||||
@ -56,7 +48,7 @@ public class URLLabel extends SelectableLabel {
|
|||||||
Map<TextAttribute, Object> map = new HashMap<TextAttribute, Object>();
|
Map<TextAttribute, Object> map = new HashMap<TextAttribute, Object>();
|
||||||
map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
|
map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
|
||||||
this.setFont(this.getFont().deriveFont(map));
|
this.setFont(this.getFont().deriveFont(map));
|
||||||
this.setForeground(prefs.getUITheme().getURLColor());
|
this.setForeground(GUIUtil.getUITheme().getURLColor());
|
||||||
|
|
||||||
this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ public class Tester {
|
|||||||
BasicApplication baseApp = new BasicApplication();
|
BasicApplication baseApp = new BasicApplication();
|
||||||
baseApp.initializeApplication();
|
baseApp.initializeApplication();
|
||||||
|
|
||||||
GUIUtil.setLAF();
|
GUIUtil.applyLAF();
|
||||||
|
|
||||||
SwingUtilities.invokeAndWait(new Runnable() {
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,7 +36,7 @@ import net.sf.openrocket.gui.adaptors.DoubleModel;
|
|||||||
import net.sf.openrocket.gui.components.BasicSlider;
|
import net.sf.openrocket.gui.components.BasicSlider;
|
||||||
import net.sf.openrocket.gui.components.DescriptionArea;
|
import net.sf.openrocket.gui.components.DescriptionArea;
|
||||||
import net.sf.openrocket.gui.components.UnitSelector;
|
import net.sf.openrocket.gui.components.UnitSelector;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.material.Material;
|
import net.sf.openrocket.material.Material;
|
||||||
@ -399,8 +399,6 @@ class ClusterSelectionPanel extends JPanel {
|
|||||||
private static final int BUTTON_SIZE = 50;
|
private static final int BUTTON_SIZE = 50;
|
||||||
private static final int MOTOR_DIAMETER = 10;
|
private static final int MOTOR_DIAMETER = 10;
|
||||||
|
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
private static final Color SELECTED_COLOR;
|
private static final Color SELECTED_COLOR;
|
||||||
private static final Color UNSELECTED_COLOR;
|
private static final Color UNSELECTED_COLOR;
|
||||||
private static final Color MOTOR_FILL_COLOR;
|
private static final Color MOTOR_FILL_COLOR;
|
||||||
@ -408,7 +406,7 @@ class ClusterSelectionPanel extends JPanel {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
SELECTED_COLOR = Color.RED;
|
SELECTED_COLOR = Color.RED;
|
||||||
UNSELECTED_COLOR = prefs.getUITheme().getBackgroundColor();
|
UNSELECTED_COLOR = GUIUtil.getUITheme().getBackgroundColor();
|
||||||
MOTOR_FILL_COLOR = Color.GREEN;
|
MOTOR_FILL_COLOR = Color.GREEN;
|
||||||
MOTOR_BORDER_COLOR = Color.BLACK;
|
MOTOR_BORDER_COLOR = Color.BLACK;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,6 @@ import net.sf.openrocket.gui.components.UnitSelector;
|
|||||||
import net.sf.openrocket.gui.dialogs.preset.ComponentPresetChooserDialog;
|
import net.sf.openrocket.gui.dialogs.preset.ComponentPresetChooserDialog;
|
||||||
import net.sf.openrocket.gui.util.GUIUtil;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.gui.util.Icons;
|
import net.sf.openrocket.gui.util.Icons;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
|
||||||
import net.sf.openrocket.gui.widgets.IconToggleButton;
|
import net.sf.openrocket.gui.widgets.IconToggleButton;
|
||||||
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
@ -65,7 +64,7 @@ public class RocketComponentConfig extends JPanel {
|
|||||||
private static final long serialVersionUID = -2925484062132243982L;
|
private static final long serialVersionUID = -2925484062132243982L;
|
||||||
|
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
private static final SwingPreferences preferences = (SwingPreferences) Application.getPreferences();
|
private static final Preferences preferences = Application.getPreferences();
|
||||||
|
|
||||||
protected final OpenRocketDocument document;
|
protected final OpenRocketDocument document;
|
||||||
protected final RocketComponent component;
|
protected final RocketComponent component;
|
||||||
@ -501,7 +500,7 @@ public class RocketComponentConfig extends JPanel {
|
|||||||
StyledLabel labelMassOverriddenBy = new StyledLabel(
|
StyledLabel labelMassOverriddenBy = new StyledLabel(
|
||||||
String.format(trans.get("RocketCompCfg.lbl.MassOverriddenBy"), component.getMassOverriddenBy().getName()),
|
String.format(trans.get("RocketCompCfg.lbl.MassOverriddenBy"), component.getMassOverriddenBy().getName()),
|
||||||
0, StyledLabel.Style.BOLD);
|
0, StyledLabel.Style.BOLD);
|
||||||
labelMassOverriddenBy.setFontColor(preferences.getUITheme().getDarkWarningColor());
|
labelMassOverriddenBy.setFontColor(GUIUtil.getUITheme().getDarkWarningColor());
|
||||||
labelMassOverriddenBy.setToolTipText(
|
labelMassOverriddenBy.setToolTipText(
|
||||||
String.format(trans.get("RocketCompCfg.lbl.MassOverriddenBy.ttip"), component.getMassOverriddenBy().getName()));
|
String.format(trans.get("RocketCompCfg.lbl.MassOverriddenBy.ttip"), component.getMassOverriddenBy().getName()));
|
||||||
checkboxes.add(labelMassOverriddenBy, "gapleft 25lp, wrap");
|
checkboxes.add(labelMassOverriddenBy, "gapleft 25lp, wrap");
|
||||||
@ -564,7 +563,7 @@ public class RocketComponentConfig extends JPanel {
|
|||||||
StyledLabel labelCGOverriddenBy = new StyledLabel(
|
StyledLabel labelCGOverriddenBy = new StyledLabel(
|
||||||
String.format(trans.get("RocketCompCfg.lbl.CGOverriddenBy"), component.getCGOverriddenBy().getName()),
|
String.format(trans.get("RocketCompCfg.lbl.CGOverriddenBy"), component.getCGOverriddenBy().getName()),
|
||||||
0, StyledLabel.Style.BOLD);
|
0, StyledLabel.Style.BOLD);
|
||||||
labelCGOverriddenBy.setFontColor(preferences.getUITheme().getDarkWarningColor());
|
labelCGOverriddenBy.setFontColor(GUIUtil.getUITheme().getDarkWarningColor());
|
||||||
labelCGOverriddenBy.setToolTipText(
|
labelCGOverriddenBy.setToolTipText(
|
||||||
String.format(trans.get("RocketCompCfg.lbl.CGOverriddenBy.ttip"), component.getCGOverriddenBy().getName()));
|
String.format(trans.get("RocketCompCfg.lbl.CGOverriddenBy.ttip"), component.getCGOverriddenBy().getName()));
|
||||||
checkboxes.add(labelCGOverriddenBy, "gapleft 25lp, wrap");
|
checkboxes.add(labelCGOverriddenBy, "gapleft 25lp, wrap");
|
||||||
@ -658,7 +657,7 @@ public class RocketComponentConfig extends JPanel {
|
|||||||
StyledLabel labelCDOverriddenBy = new StyledLabel(
|
StyledLabel labelCDOverriddenBy = new StyledLabel(
|
||||||
String.format(trans.get("RocketCompCfg.lbl.CDOverriddenBy"), component.getCDOverriddenBy().getName()),
|
String.format(trans.get("RocketCompCfg.lbl.CDOverriddenBy"), component.getCDOverriddenBy().getName()),
|
||||||
0, StyledLabel.Style.BOLD);
|
0, StyledLabel.Style.BOLD);
|
||||||
labelCDOverriddenBy.setFontColor(preferences.getUITheme().getDarkWarningColor());
|
labelCDOverriddenBy.setFontColor(GUIUtil.getUITheme().getDarkWarningColor());
|
||||||
labelCDOverriddenBy.setToolTipText(
|
labelCDOverriddenBy.setToolTipText(
|
||||||
String.format(trans.get("RocketCompCfg.lbl.CDOverriddenBy"), component.getCDOverriddenBy().getName()));
|
String.format(trans.get("RocketCompCfg.lbl.CDOverriddenBy"), component.getCDOverriddenBy().getName()));
|
||||||
checkboxes.add(labelCDOverriddenBy, "gapleft 25lp, wrap");
|
checkboxes.add(labelCDOverriddenBy, "gapleft 25lp, wrap");
|
||||||
@ -714,7 +713,7 @@ public class RocketComponentConfig extends JPanel {
|
|||||||
commentTextArea.setLineWrap(true);
|
commentTextArea.setLineWrap(true);
|
||||||
commentTextArea.setWrapStyleWord(true);
|
commentTextArea.setWrapStyleWord(true);
|
||||||
commentTextArea.setEditable(true);
|
commentTextArea.setEditable(true);
|
||||||
commentTextArea.setBorder(preferences.getUITheme().getBorder());
|
commentTextArea.setBorder(GUIUtil.getUITheme().getBorder());
|
||||||
GUIUtil.setTabToFocusing(commentTextArea);
|
GUIUtil.setTabToFocusing(commentTextArea);
|
||||||
commentTextArea.addFocusListener(textFieldListener);
|
commentTextArea.addFocusListener(textFieldListener);
|
||||||
commentTextArea.addKeyListener(new TextComponentSelectionKeyListener(commentTextArea));
|
commentTextArea.addKeyListener(new TextComponentSelectionKeyListener(commentTextArea));
|
||||||
|
@ -20,7 +20,6 @@ import javax.swing.JTextArea;
|
|||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
import net.sf.openrocket.gui.util.GUIUtil;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
@ -28,7 +27,6 @@ import net.sf.openrocket.startup.Application;
|
|||||||
|
|
||||||
public class RocketConfig extends RocketComponentConfig {
|
public class RocketConfig extends RocketComponentConfig {
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
private TextFieldListener textFieldListener;
|
private TextFieldListener textFieldListener;
|
||||||
|
|
||||||
@ -57,7 +55,7 @@ public class RocketConfig extends RocketComponentConfig {
|
|||||||
designerTextArea.setLineWrap(true);
|
designerTextArea.setLineWrap(true);
|
||||||
designerTextArea.setWrapStyleWord(true);
|
designerTextArea.setWrapStyleWord(true);
|
||||||
designerTextArea.setEditable(true);
|
designerTextArea.setEditable(true);
|
||||||
designerTextArea.setBorder(prefs.getUITheme().getBorder());
|
designerTextArea.setBorder(GUIUtil.getUITheme().getBorder());
|
||||||
GUIUtil.setTabToFocusing(designerTextArea);
|
GUIUtil.setTabToFocusing(designerTextArea);
|
||||||
designerTextArea.addFocusListener(textFieldListener);
|
designerTextArea.addFocusListener(textFieldListener);
|
||||||
this.add(new JScrollPane(designerTextArea), "wmin 400lp, height 60lp:60lp:, grow 30, wrap para");
|
this.add(new JScrollPane(designerTextArea), "wmin 400lp, height 60lp:60lp:, grow 30, wrap para");
|
||||||
@ -72,7 +70,7 @@ public class RocketConfig extends RocketComponentConfig {
|
|||||||
revisionTextArea.setLineWrap(true);
|
revisionTextArea.setLineWrap(true);
|
||||||
revisionTextArea.setWrapStyleWord(true);
|
revisionTextArea.setWrapStyleWord(true);
|
||||||
revisionTextArea.setEditable(true);
|
revisionTextArea.setEditable(true);
|
||||||
revisionTextArea.setBorder(prefs.getUITheme().getBorder());
|
revisionTextArea.setBorder(GUIUtil.getUITheme().getBorder());
|
||||||
GUIUtil.setTabToFocusing(revisionTextArea);
|
GUIUtil.setTabToFocusing(revisionTextArea);
|
||||||
revisionTextArea.addFocusListener(textFieldListener);
|
revisionTextArea.addFocusListener(textFieldListener);
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import javax.swing.JScrollPane;
|
|||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
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.SwingPreferences;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -38,7 +39,6 @@ public class CustomExpressionPanel extends JPanel {
|
|||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(CustomExpressionPanel.class);
|
private static final Logger log = LoggerFactory.getLogger(CustomExpressionPanel.class);
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
private JPanel expressionSelectorPanel;
|
private JPanel expressionSelectorPanel;
|
||||||
private OpenRocketDocument doc;
|
private OpenRocketDocument doc;
|
||||||
@ -51,7 +51,7 @@ public class CustomExpressionPanel extends JPanel {
|
|||||||
expressionSelectorPanel.setToolTipText(trans.get("customExpressionPanel.lbl.CalcNote"));
|
expressionSelectorPanel.setToolTipText(trans.get("customExpressionPanel.lbl.CalcNote"));
|
||||||
|
|
||||||
JScrollPane scroll = new JScrollPane(expressionSelectorPanel);
|
JScrollPane scroll = new JScrollPane(expressionSelectorPanel);
|
||||||
expressionSelectorPanel.setBorder(prefs.getUITheme().getBorder());
|
expressionSelectorPanel.setBorder(GUIUtil.getUITheme().getBorder());
|
||||||
|
|
||||||
//Border bdr = BorderFactory.createTitledBorder(trans.get("customExpressionPanel.lbl.CustomExpressions"));
|
//Border bdr = BorderFactory.createTitledBorder(trans.get("customExpressionPanel.lbl.CustomExpressions"));
|
||||||
//scroll.setBorder(bdr);
|
//scroll.setBorder(bdr);
|
||||||
@ -171,11 +171,10 @@ public class CustomExpressionPanel extends JPanel {
|
|||||||
* A JPanel which configures a single expression
|
* A JPanel which configures a single expression
|
||||||
*/
|
*/
|
||||||
private class SingleExpression extends JPanel {
|
private class SingleExpression extends JPanel {
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
// Convenience method to make the labels consistent
|
// Convenience method to make the labels consistent
|
||||||
private JLabel setLabelStyle(JLabel l) {
|
private JLabel setLabelStyle(JLabel l) {
|
||||||
l.setBackground(prefs.getUITheme().getBackgroundColor());
|
l.setBackground(GUIUtil.getUITheme().getBackgroundColor());
|
||||||
l.setOpaque(true);
|
l.setOpaque(true);
|
||||||
l.setBorder(BorderFactory.createRaisedBevelBorder());
|
l.setBorder(BorderFactory.createRaisedBevelBorder());
|
||||||
l.setText(" " + l.getText() + " ");
|
l.setText(" " + l.getText() + " ");
|
||||||
@ -193,13 +192,13 @@ public class CustomExpressionPanel extends JPanel {
|
|||||||
JLabel symbolLabel = new JLabel(trans.get("customExpression.Symbol") + " :");
|
JLabel symbolLabel = new JLabel(trans.get("customExpression.Symbol") + " :");
|
||||||
JLabel symbol = new JLabel(expression.getSymbol());
|
JLabel symbol = new JLabel(expression.getSymbol());
|
||||||
symbol = setLabelStyle(symbol);
|
symbol = setLabelStyle(symbol);
|
||||||
symbol.setBackground(prefs.getUITheme().getBackgroundColor());
|
symbol.setBackground(GUIUtil.getUITheme().getBackgroundColor());
|
||||||
|
|
||||||
JLabel unitLabel = new JLabel(trans.get("customExpression.Units") + " :");
|
JLabel unitLabel = new JLabel(trans.get("customExpression.Units") + " :");
|
||||||
UnitSelector unitSelector = new UnitSelector(expression.getType().getUnitGroup());
|
UnitSelector unitSelector = new UnitSelector(expression.getType().getUnitGroup());
|
||||||
//JLabel unitSelector = new JLabel ( expression.getUnit() );
|
//JLabel unitSelector = new JLabel ( expression.getUnit() );
|
||||||
//unitSelector = setLabelStyle(unitSelector);
|
//unitSelector = setLabelStyle(unitSelector);
|
||||||
//unitSelector.setBackground(prefs.getUITheme().getBackgroundColor());
|
//unitSelector.setBackground(GUIUtil.getUITheme().getBackgroundColor());
|
||||||
|
|
||||||
JButton editButton = new SelectColorButton(Icons.EDIT_EDIT);
|
JButton editButton = new SelectColorButton(Icons.EDIT_EDIT);
|
||||||
editButton.setToolTipText(trans.get("customExpression.Units.but.ttip.Edit"));
|
editButton.setToolTipText(trans.get("customExpression.Units.but.ttip.Edit"));
|
||||||
|
@ -178,7 +178,7 @@ public class BugReportDialog extends JDialog {
|
|||||||
private static void addBugReportInformation(StringBuilder sb) {
|
private static void addBugReportInformation(StringBuilder sb) {
|
||||||
sb.append("<html>---------- Bug report ----------\n");
|
sb.append("<html>---------- Bug report ----------\n");
|
||||||
sb.append('\n');
|
sb.append('\n');
|
||||||
Color color = preferences.getUITheme().getDarkWarningColor();
|
Color color = GUIUtil.getUITheme().getDarkWarningColor();
|
||||||
sb.append(String.format("<b style='color:rgb(%d, %d, %d)'>Please include a description about what actions you were " +
|
sb.append(String.format("<b style='color:rgb(%d, %d, %d)'>Please include a description about what actions you were " +
|
||||||
"performing when the exception occurred:</b>\n", color.getRed(), color.getGreen(), color.getBlue()));
|
"performing when the exception occurred:</b>\n", color.getRed(), color.getGreen(), color.getBlue()));
|
||||||
sb.append("<i>(You can edit text directly in this window)</i>\n");
|
sb.append("<i>(You can edit text directly in this window)</i>\n");
|
||||||
|
@ -41,7 +41,6 @@ import net.miginfocom.swing.MigLayout;
|
|||||||
import net.sf.openrocket.aerodynamics.AerodynamicCalculator;
|
import net.sf.openrocket.aerodynamics.AerodynamicCalculator;
|
||||||
import net.sf.openrocket.aerodynamics.AerodynamicForces;
|
import net.sf.openrocket.aerodynamics.AerodynamicForces;
|
||||||
import net.sf.openrocket.aerodynamics.FlightConditions;
|
import net.sf.openrocket.aerodynamics.FlightConditions;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
|
||||||
import net.sf.openrocket.logging.Warning;
|
import net.sf.openrocket.logging.Warning;
|
||||||
import net.sf.openrocket.logging.WarningSet;
|
import net.sf.openrocket.logging.WarningSet;
|
||||||
import net.sf.openrocket.gui.adaptors.Column;
|
import net.sf.openrocket.gui.adaptors.Column;
|
||||||
@ -73,7 +72,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
public class ComponentAnalysisDialog extends JDialog implements StateChangeListener {
|
public class ComponentAnalysisDialog extends JDialog implements StateChangeListener {
|
||||||
private static final Logger log = LoggerFactory.getLogger(ComponentAnalysisDialog.class);
|
private static final Logger log = LoggerFactory.getLogger(ComponentAnalysisDialog.class);
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 9131240570600307935L;
|
private static final long serialVersionUID = 9131240570600307935L;
|
||||||
private static ComponentAnalysisDialog singletonDialog = null;
|
private static ComponentAnalysisDialog singletonDialog = null;
|
||||||
@ -152,7 +150,7 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
|||||||
|
|
||||||
warningList = new JList<>();
|
warningList = new JList<>();
|
||||||
JScrollPane scrollPane = new JScrollPane(warningList);
|
JScrollPane scrollPane = new JScrollPane(warningList);
|
||||||
warningList.setBorder(prefs.getUITheme().getBorder());
|
warningList.setBorder(GUIUtil.getUITheme().getBorder());
|
||||||
////Warnings:
|
////Warnings:
|
||||||
scrollPane.setBorder(BorderFactory.createTitledBorder(trans.get("componentanalysisdlg.TitledBorder.warnings")));
|
scrollPane.setBorder(BorderFactory.createTitledBorder(trans.get("componentanalysisdlg.TitledBorder.warnings")));
|
||||||
panel.add(scrollPane, "gap paragraph, spany 4, w 300lp, grow, height :100lp:, wrap");
|
panel.add(scrollPane, "gap paragraph, spany 4, w 300lp, grow, height :100lp:, wrap");
|
||||||
@ -649,7 +647,7 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
|||||||
}
|
}
|
||||||
|
|
||||||
label.setOpaque(true);
|
label.setOpaque(true);
|
||||||
label.setBackground(prefs.getUITheme().getBackgroundColor());
|
label.setBackground(GUIUtil.getUITheme().getBackgroundColor());
|
||||||
label.setHorizontalAlignment(SwingConstants.LEFT);
|
label.setHorizontalAlignment(SwingConstants.LEFT);
|
||||||
|
|
||||||
if ((row < 0) || (row >= data.size()))
|
if ((row < 0) || (row >= data.size()))
|
||||||
@ -696,8 +694,6 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
|||||||
private class DragCellRenderer extends CustomCellRenderer {
|
private class DragCellRenderer extends CustomCellRenderer {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
public DragCellRenderer() {
|
public DragCellRenderer() {
|
||||||
super(dragData, 3);
|
super(dragData, 3);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,6 @@ import javax.swing.table.TableCellRenderer;
|
|||||||
import javax.swing.table.TableModel;
|
import javax.swing.table.TableModel;
|
||||||
import javax.swing.table.TableRowSorter;
|
import javax.swing.table.TableRowSorter;
|
||||||
|
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -68,7 +67,6 @@ public class DebugLogDialog extends JDialog {
|
|||||||
private static final int POLL_TIME = 250;
|
private static final int POLL_TIME = 250;
|
||||||
private static final String STACK_TRACE_MARK = "\uFF01";
|
private static final String STACK_TRACE_MARK = "\uFF01";
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
private static final EnumMap<LogLevel, Color> backgroundColors = new EnumMap<LogLevel, Color>(LogLevel.class);
|
private static final EnumMap<LogLevel, Color> backgroundColors = new EnumMap<LogLevel, Color>(LogLevel.class);
|
||||||
static {
|
static {
|
||||||
@ -345,7 +343,7 @@ public class DebugLogDialog extends JDialog {
|
|||||||
bottomPanel.add(new JLabel(trans.get("debuglogdlg.lbl.Stacktrace")), "wrap rel");
|
bottomPanel.add(new JLabel(trans.get("debuglogdlg.lbl.Stacktrace")), "wrap rel");
|
||||||
stackTraceLabel = new JTextArea(8, 80);
|
stackTraceLabel = new JTextArea(8, 80);
|
||||||
stackTraceLabel.setEditable(false);
|
stackTraceLabel.setEditable(false);
|
||||||
stackTraceLabel.setBorder(prefs.getUITheme().getBorder());
|
stackTraceLabel.setBorder(GUIUtil.getUITheme().getBorder());
|
||||||
GUIUtil.changeFontSize(stackTraceLabel, -2);
|
GUIUtil.changeFontSize(stackTraceLabel, -2);
|
||||||
bottomPanel.add(new JScrollPane(stackTraceLabel), "grow, pushy 200, growprioy 200");
|
bottomPanel.add(new JScrollPane(stackTraceLabel), "grow, pushy 200, growprioy 200");
|
||||||
|
|
||||||
|
@ -3,14 +3,12 @@ package net.sf.openrocket.gui.dialogs;
|
|||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import net.sf.openrocket.gui.components.StyledLabel;
|
import net.sf.openrocket.gui.components.StyledLabel;
|
||||||
import net.sf.openrocket.gui.util.BetterListCellRenderer;
|
import net.sf.openrocket.gui.util.BetterListCellRenderer;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.logging.Error;
|
import net.sf.openrocket.logging.Error;
|
||||||
import net.sf.openrocket.logging.ErrorSet;
|
import net.sf.openrocket.logging.ErrorSet;
|
||||||
import net.sf.openrocket.logging.Warning;
|
import net.sf.openrocket.logging.Warning;
|
||||||
import net.sf.openrocket.logging.WarningSet;
|
import net.sf.openrocket.logging.WarningSet;
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
@ -18,7 +16,6 @@ import javax.swing.JPanel;
|
|||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JSeparator;
|
import javax.swing.JSeparator;
|
||||||
import javax.swing.ListSelectionModel;
|
import javax.swing.ListSelectionModel;
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
@ -28,13 +25,12 @@ import java.awt.event.MouseEvent;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public abstract class ErrorWarningDialog {
|
public abstract class ErrorWarningDialog {
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
public static void showErrorsAndWarnings(Component parent, Object message, String title, ErrorSet errors, WarningSet warnings) {
|
public static void showErrorsAndWarnings(Component parent, Object message, String title, ErrorSet errors, WarningSet warnings) {
|
||||||
JPanel content = new JPanel(new MigLayout("ins 0, fillx"));
|
JPanel content = new JPanel(new MigLayout("ins 0, fillx"));
|
||||||
|
|
||||||
StyledLabel label = new StyledLabel("Errors");
|
StyledLabel label = new StyledLabel("Errors");
|
||||||
label.setFontColor(prefs.getUITheme().getDarkWarningColor());
|
label.setFontColor(GUIUtil.getUITheme().getDarkWarningColor());
|
||||||
content.add(label, "wrap, gaptop 15lp");
|
content.add(label, "wrap, gaptop 15lp");
|
||||||
|
|
||||||
Error[] e = errors.toArray(new Error[0]);
|
Error[] e = errors.toArray(new Error[0]);
|
||||||
@ -42,7 +38,7 @@ public abstract class ErrorWarningDialog {
|
|||||||
errorList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
errorList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
errorList.setCellRenderer(new ErrorListCellRenderer());
|
errorList.setCellRenderer(new ErrorListCellRenderer());
|
||||||
JScrollPane errorPane = new JScrollPane(errorList);
|
JScrollPane errorPane = new JScrollPane(errorList);
|
||||||
errorList.setBorder(prefs.getUITheme().getBorder());
|
errorList.setBorder(GUIUtil.getUITheme().getBorder());
|
||||||
content.add(errorPane, "wrap, growx");
|
content.add(errorPane, "wrap, growx");
|
||||||
|
|
||||||
// Deselect items if clicked on blank region
|
// Deselect items if clicked on blank region
|
||||||
@ -64,7 +60,7 @@ public abstract class ErrorWarningDialog {
|
|||||||
final JList<Warning> warningList = new JList<>(w);
|
final JList<Warning> warningList = new JList<>(w);
|
||||||
warningList.setCellRenderer(new BetterListCellRenderer());
|
warningList.setCellRenderer(new BetterListCellRenderer());
|
||||||
JScrollPane warningPane = new JScrollPane(warningList);
|
JScrollPane warningPane = new JScrollPane(warningList);
|
||||||
warningList.setBorder(prefs.getUITheme().getBorder());
|
warningList.setBorder(GUIUtil.getUITheme().getBorder());
|
||||||
content.add(warningPane, "wrap, growx");
|
content.add(warningPane, "wrap, growx");
|
||||||
|
|
||||||
// Deselect items if clicked on blank region
|
// Deselect items if clicked on blank region
|
||||||
@ -91,9 +87,9 @@ public abstract class ErrorWarningDialog {
|
|||||||
|
|
||||||
// Text color
|
// Text color
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
label.setForeground(prefs.getUITheme().getTextSelectionForegroundColor());
|
label.setForeground(GUIUtil.getUITheme().getTextSelectionForegroundColor());
|
||||||
} else {
|
} else {
|
||||||
label.setForeground(prefs.getUITheme().getDarkWarningColor());
|
label.setForeground(GUIUtil.getUITheme().getDarkWarningColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
return label;
|
return label;
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package net.sf.openrocket.gui.dialogs;
|
package net.sf.openrocket.gui.dialogs;
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Desktop;
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.net.URI;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -76,7 +74,7 @@ public class UpdateInfoDialog extends JDialog {
|
|||||||
|
|
||||||
// Release information box
|
// Release information box
|
||||||
final JTextPane textPane = new JTextPane();
|
final JTextPane textPane = new JTextPane();
|
||||||
textPane.setBorder(BorderFactory.createLineBorder(preferences.getUITheme().getTextColor()));
|
textPane.setBorder(BorderFactory.createLineBorder(GUIUtil.getUITheme().getTextColor()));
|
||||||
textPane.setEditable(false);
|
textPane.setEditable(false);
|
||||||
textPane.setContentType("text/html");
|
textPane.setContentType("text/html");
|
||||||
textPane.setMargin(new Insets(10, 10, 40, 10));
|
textPane.setMargin(new Insets(10, 10, 40, 10));
|
||||||
|
@ -8,22 +8,19 @@ import javax.swing.JOptionPane;
|
|||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
|
||||||
import net.sf.openrocket.gui.util.BetterListCellRenderer;
|
import net.sf.openrocket.gui.util.BetterListCellRenderer;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.logging.Warning;
|
import net.sf.openrocket.logging.Warning;
|
||||||
import net.sf.openrocket.logging.WarningSet;
|
import net.sf.openrocket.logging.WarningSet;
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public abstract class WarningDialog {
|
public abstract class WarningDialog {
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
public static void showWarnings(Component parent, Object message, String title, WarningSet warnings) {
|
public static void showWarnings(Component parent, Object message, String title, WarningSet warnings) {
|
||||||
|
|
||||||
Warning[] w = warnings.toArray(new Warning[0]);
|
Warning[] w = warnings.toArray(new Warning[0]);
|
||||||
final JList<Warning> list = new JList<Warning>(w);
|
final JList<Warning> list = new JList<Warning>(w);
|
||||||
list.setCellRenderer(new BetterListCellRenderer());
|
list.setCellRenderer(new BetterListCellRenderer());
|
||||||
JScrollPane pane = new JScrollPane(list);
|
JScrollPane pane = new JScrollPane(list);
|
||||||
pane.setBorder(prefs.getUITheme().getBorder());
|
pane.setBorder(GUIUtil.getUITheme().getBorder());
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(parent, new Object[] { message, pane },
|
JOptionPane.showMessageDialog(parent, new Object[] { message, pane },
|
||||||
title, JOptionPane.WARNING_MESSAGE);
|
title, JOptionPane.WARNING_MESSAGE);
|
||||||
|
@ -15,7 +15,6 @@ import net.miginfocom.swing.MigLayout;
|
|||||||
import net.sf.openrocket.gui.components.StyledLabel;
|
import net.sf.openrocket.gui.components.StyledLabel;
|
||||||
import net.sf.openrocket.gui.configdialog.CommonStrings;
|
import net.sf.openrocket.gui.configdialog.CommonStrings;
|
||||||
import net.sf.openrocket.gui.util.GUIUtil;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
@ -25,7 +24,6 @@ import net.sf.openrocket.gui.widgets.SelectColorButton;
|
|||||||
public class RenameConfigDialog extends JDialog {
|
public class RenameConfigDialog extends JDialog {
|
||||||
private static final long serialVersionUID = -5423008694485357248L;
|
private static final long serialVersionUID = -5423008694485357248L;
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
public RenameConfigDialog(final Window parent, final Rocket rocket, final FlightConfigurationId fcid) {
|
public RenameConfigDialog(final Window parent, final Rocket rocket, final FlightConfigurationId fcid) {
|
||||||
super(parent, trans.get("RenameConfigDialog.title"), Dialog.ModalityType.APPLICATION_MODAL);
|
super(parent, trans.get("RenameConfigDialog.title"), Dialog.ModalityType.APPLICATION_MODAL);
|
||||||
@ -74,7 +72,7 @@ public class RenameConfigDialog extends JDialog {
|
|||||||
+ trans.get("RenameConfigDialog.lbl.infoManufacturers")
|
+ trans.get("RenameConfigDialog.lbl.infoManufacturers")
|
||||||
+ trans.get("RenameConfigDialog.lbl.infoCombination");
|
+ trans.get("RenameConfigDialog.lbl.infoCombination");
|
||||||
StyledLabel info = new StyledLabel(text, -2);
|
StyledLabel info = new StyledLabel(text, -2);
|
||||||
info.setFontColor(prefs.getUITheme().getDimTextColor());
|
info.setFontColor(GUIUtil.getUITheme().getDimTextColor());
|
||||||
panel.add(info, "spanx, growx, wrap");
|
panel.add(info, "spanx, growx, wrap");
|
||||||
|
|
||||||
this.add(panel);
|
this.add(panel);
|
||||||
|
@ -16,7 +16,6 @@ import javax.swing.JScrollPane;
|
|||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
|
||||||
import net.sf.openrocket.util.StringUtils;
|
import net.sf.openrocket.util.StringUtils;
|
||||||
import org.jfree.chart.ChartFactory;
|
import org.jfree.chart.ChartFactory;
|
||||||
import org.jfree.chart.ChartPanel;
|
import org.jfree.chart.ChartPanel;
|
||||||
@ -39,13 +38,12 @@ import net.sf.openrocket.unit.UnitGroup;
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
class MotorInformationPanel extends JPanel {
|
class MotorInformationPanel extends JPanel {
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
private static final int ZOOM_ICON_POSITION_NEGATIVE_X = 50;
|
private static final int ZOOM_ICON_POSITION_NEGATIVE_X = 50;
|
||||||
private static final int ZOOM_ICON_POSITION_POSITIVE_Y = 12;
|
private static final int ZOOM_ICON_POSITION_POSITIVE_Y = 12;
|
||||||
|
|
||||||
private static final Color NO_COMMENT_COLOR = prefs.getUITheme().getDimTextColor();
|
private static final Color NO_COMMENT_COLOR = GUIUtil.getUITheme().getDimTextColor();
|
||||||
private static final Color WITH_COMMENT_COLOR = prefs.getUITheme().getTextColor();
|
private static final Color WITH_COMMENT_COLOR = GUIUtil.getUITheme().getTextColor();
|
||||||
|
|
||||||
// Motors in set
|
// Motors in set
|
||||||
private List<ThrustCurveMotor> selectedMotorSet;
|
private List<ThrustCurveMotor> selectedMotorSet;
|
||||||
@ -192,7 +190,7 @@ class MotorInformationPanel extends JPanel {
|
|||||||
|
|
||||||
//// Thrust curve:
|
//// Thrust curve:
|
||||||
TextTitle title = new TextTitle(trans.get("TCMotorSelPan.title.Thrustcurve"), this.getFont());
|
TextTitle title = new TextTitle(trans.get("TCMotorSelPan.title.Thrustcurve"), this.getFont());
|
||||||
title.setPaint(prefs.getUITheme().getTextColor());
|
title.setPaint(GUIUtil.getUITheme().getTextColor());
|
||||||
chart.setTitle(title);
|
chart.setTitle(title);
|
||||||
chart.setBackgroundPaint(this.getBackground());
|
chart.setBackgroundPaint(this.getBackground());
|
||||||
plot.setBackgroundPaint(Color.WHITE);
|
plot.setBackgroundPaint(Color.WHITE);
|
||||||
|
@ -16,7 +16,7 @@ import javax.swing.tree.TreePath;
|
|||||||
|
|
||||||
import net.sf.openrocket.gui.components.BasicTree;
|
import net.sf.openrocket.gui.components.BasicTree;
|
||||||
import net.sf.openrocket.gui.main.ComponentIcons;
|
import net.sf.openrocket.gui.main.ComponentIcons;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.optimization.rocketoptimization.SimulationModifier;
|
import net.sf.openrocket.optimization.rocketoptimization.SimulationModifier;
|
||||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||||
@ -37,7 +37,6 @@ public class SimulationModifierTree extends BasicTree {
|
|||||||
|
|
||||||
private final List<SimulationModifier> selectedModifiers;
|
private final List<SimulationModifier> selectedModifiers;
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sole constructor.
|
* Sole constructor.
|
||||||
@ -158,7 +157,7 @@ public class SimulationModifierTree extends BasicTree {
|
|||||||
|
|
||||||
// Set text color/style
|
// Set text color/style
|
||||||
if (object instanceof RocketComponent) {
|
if (object instanceof RocketComponent) {
|
||||||
setForeground(prefs.getUITheme().getDimTextColor());
|
setForeground(GUIUtil.getUITheme().getDimTextColor());
|
||||||
setFont(componentFont);
|
setFont(componentFont);
|
||||||
|
|
||||||
// Set tooltip
|
// Set tooltip
|
||||||
@ -172,21 +171,21 @@ public class SimulationModifierTree extends BasicTree {
|
|||||||
this.setToolTipText(null);
|
this.setToolTipText(null);
|
||||||
}
|
}
|
||||||
} else if (object instanceof String) {
|
} else if (object instanceof String) {
|
||||||
setForeground(prefs.getUITheme().getDimTextColor());
|
setForeground(GUIUtil.getUITheme().getDimTextColor());
|
||||||
setFont(stringFont);
|
setFont(stringFont);
|
||||||
} else if (object instanceof SimulationModifier) {
|
} else if (object instanceof SimulationModifier) {
|
||||||
|
|
||||||
if (selectedModifiers.contains(object)) {
|
if (selectedModifiers.contains(object)) {
|
||||||
setForeground(prefs.getUITheme().getDimTextColor());
|
setForeground(GUIUtil.getUITheme().getDimTextColor());
|
||||||
setFont(stringFont);
|
setFont(stringFont);
|
||||||
} else {
|
} else {
|
||||||
if (tree.getSelectionRows() != null &&
|
if (tree.getSelectionRows() != null &&
|
||||||
IntStream.of(tree.getSelectionRows()).anyMatch(r -> r == row)) {
|
IntStream.of(tree.getSelectionRows()).anyMatch(r -> r == row)) {
|
||||||
setForeground(prefs.getUITheme().getTextSelectionForegroundColor());
|
setForeground(GUIUtil.getUITheme().getTextSelectionForegroundColor());
|
||||||
setBackground(prefs.getUITheme().getTextSelectionBackgroundColor());
|
setBackground(GUIUtil.getUITheme().getTextSelectionBackgroundColor());
|
||||||
setOpaque(true);
|
setOpaque(true);
|
||||||
} else {
|
} else {
|
||||||
setForeground(prefs.getUITheme().getTextColor());
|
setForeground(GUIUtil.getUITheme().getTextColor());
|
||||||
}
|
}
|
||||||
setFont(modifierFont);
|
setFont(modifierFont);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public class GeneralPreferencesPanel extends PreferencesPanel {
|
|||||||
this.add(new StyledLabel(trans.get("generalprefs.lbl.languageEffect"), -3, Style.ITALIC), "span, wrap rel");
|
this.add(new StyledLabel(trans.get("generalprefs.lbl.languageEffect"), -3, Style.ITALIC), "span, wrap rel");
|
||||||
|
|
||||||
//// UI Theme
|
//// UI Theme
|
||||||
UITheme.Theme currentTheme = preferences.getUITheme();
|
UITheme.Theme currentTheme = GUIUtil.getUITheme();
|
||||||
List<Named<UITheme.Theme>> themes = new ArrayList<>();
|
List<Named<UITheme.Theme>> themes = new ArrayList<>();
|
||||||
for (UITheme.Theme t : UITheme.Themes.values()) {
|
for (UITheme.Theme t : UITheme.Themes.values()) {
|
||||||
themes.add(new Named<>(t, t.getDisplayName()));
|
themes.add(new Named<>(t, t.getDisplayName()));
|
||||||
@ -119,7 +119,7 @@ public class GeneralPreferencesPanel extends PreferencesPanel {
|
|||||||
|
|
||||||
//// You need to restart OpenRocket for the theme change to take effect.
|
//// You need to restart OpenRocket for the theme change to take effect.
|
||||||
final JLabel lblRestartORTheme = new JLabel();
|
final JLabel lblRestartORTheme = new JLabel();
|
||||||
lblRestartORTheme.setForeground(preferences.getUITheme().getDarkWarningColor());
|
lblRestartORTheme.setForeground(GUIUtil.getUITheme().getDarkWarningColor());
|
||||||
this.add(lblRestartORTheme, "spanx, wrap para*2, growx");
|
this.add(lblRestartORTheme, "spanx, wrap para*2, growx");
|
||||||
|
|
||||||
themesCombo.addActionListener(new ActionListener() {
|
themesCombo.addActionListener(new ActionListener() {
|
||||||
@ -129,7 +129,7 @@ public class GeneralPreferencesPanel extends PreferencesPanel {
|
|||||||
Named<UITheme.Theme> selection = (Named<UITheme.Theme>) themesCombo.getSelectedItem();
|
Named<UITheme.Theme> selection = (Named<UITheme.Theme>) themesCombo.getSelectedItem();
|
||||||
if (selection == null) return;
|
if (selection == null) return;
|
||||||
UITheme.Theme t = selection.get();
|
UITheme.Theme t = selection.get();
|
||||||
if (t == preferences.getUITheme()) {
|
if (t == GUIUtil.getUITheme()) {
|
||||||
lblRestartORTheme.setText("");
|
lblRestartORTheme.setText("");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -231,8 +231,8 @@ public class GeneralPreferencesPanel extends PreferencesPanel {
|
|||||||
|
|
||||||
//// Add directories, RASP motor files (*.eng), RockSim engine files (*.rse) or ZIP archives separated by a semicolon (;) to load external thrust curves. Changes will take effect the next time you start OpenRocket.
|
//// Add directories, RASP motor files (*.eng), RockSim engine files (*.rse) or ZIP archives separated by a semicolon (;) to load external thrust curves. Changes will take effect the next time you start OpenRocket.
|
||||||
DescriptionArea desc = new DescriptionArea(trans.get("pref.dlg.DescriptionArea.Adddirectories"), 3, -1.5f, false);
|
DescriptionArea desc = new DescriptionArea(trans.get("pref.dlg.DescriptionArea.Adddirectories"), 3, -1.5f, false);
|
||||||
desc.setBackground(preferences.getUITheme().getBackgroundColor());
|
desc.setBackground(GUIUtil.getUITheme().getBackgroundColor());
|
||||||
desc.setForeground(preferences.getUITheme().getTextColor());
|
desc.setForeground(GUIUtil.getUITheme().getTextColor());
|
||||||
this.add(desc, "spanx, growx, wrap 40lp");
|
this.add(desc, "spanx, growx, wrap 40lp");
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,16 +23,14 @@ import net.sf.openrocket.gui.adaptors.DoubleModel;
|
|||||||
import net.sf.openrocket.gui.components.BasicSlider;
|
import net.sf.openrocket.gui.components.BasicSlider;
|
||||||
import net.sf.openrocket.gui.components.StyledLabel;
|
import net.sf.openrocket.gui.components.StyledLabel;
|
||||||
import net.sf.openrocket.gui.components.UnitSelector;
|
import net.sf.openrocket.gui.components.UnitSelector;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.models.atmosphere.ExtendedISAModel;
|
import net.sf.openrocket.models.atmosphere.ExtendedISAModel;
|
||||||
import net.sf.openrocket.simulation.SimulationOptions;
|
import net.sf.openrocket.simulation.SimulationOptions;
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
import net.sf.openrocket.unit.UnitGroup;
|
import net.sf.openrocket.unit.UnitGroup;
|
||||||
import net.sf.openrocket.util.Chars;
|
import net.sf.openrocket.util.Chars;
|
||||||
import net.sf.openrocket.util.StateChangeListener;
|
import net.sf.openrocket.util.StateChangeListener;
|
||||||
|
|
||||||
public class LaunchPreferencesPanel extends PreferencesPanel {
|
public class LaunchPreferencesPanel extends PreferencesPanel {
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
public LaunchPreferencesPanel(JDialog parent, LayoutManager layout) {
|
public LaunchPreferencesPanel(JDialog parent, LayoutManager layout) {
|
||||||
super(parent, layout);
|
super(parent, layout);
|
||||||
@ -46,7 +44,7 @@ public class LaunchPreferencesPanel extends PreferencesPanel {
|
|||||||
StyledLabel warning = new StyledLabel(String.format(
|
StyledLabel warning = new StyledLabel(String.format(
|
||||||
"<html>%s</html>", trans.get("pref.dlg.lbl.launchWarning")),
|
"<html>%s</html>", trans.get("pref.dlg.lbl.launchWarning")),
|
||||||
0.5f, StyledLabel.Style.BOLD);
|
0.5f, StyledLabel.Style.BOLD);
|
||||||
warning.setFontColor(prefs.getUITheme().getDarkWarningColor());
|
warning.setFontColor(GUIUtil.getUITheme().getDarkWarningColor());
|
||||||
warning.setToolTipText(trans.get("pref.dlg.lbl.launchWarning.ttip"));
|
warning.setToolTipText(trans.get("pref.dlg.lbl.launchWarning.ttip"));
|
||||||
add(warning, "spanx, growx 0, gapbottom para, wrap");
|
add(warning, "spanx, growx 0, gapbottom para, wrap");
|
||||||
|
|
||||||
|
@ -17,9 +17,8 @@ import net.sf.openrocket.gui.adaptors.EnumModel;
|
|||||||
import net.sf.openrocket.gui.components.BasicSlider;
|
import net.sf.openrocket.gui.components.BasicSlider;
|
||||||
import net.sf.openrocket.gui.components.StyledLabel;
|
import net.sf.openrocket.gui.components.StyledLabel;
|
||||||
import net.sf.openrocket.gui.components.UnitSelector;
|
import net.sf.openrocket.gui.components.UnitSelector;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.simulation.RK4SimulationStepper;
|
import net.sf.openrocket.simulation.RK4SimulationStepper;
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
import net.sf.openrocket.unit.UnitGroup;
|
import net.sf.openrocket.unit.UnitGroup;
|
||||||
import net.sf.openrocket.util.GeodeticComputationStrategy;
|
import net.sf.openrocket.util.GeodeticComputationStrategy;
|
||||||
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
||||||
@ -27,8 +26,6 @@ import net.sf.openrocket.gui.widgets.SelectColorButton;
|
|||||||
public class SimulationPreferencesPanel extends PreferencesPanel {
|
public class SimulationPreferencesPanel extends PreferencesPanel {
|
||||||
private static final long serialVersionUID = 7983195730016979888L;
|
private static final long serialVersionUID = 7983195730016979888L;
|
||||||
|
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* private GeodeticComputationStrategy geodeticComputation =
|
* private GeodeticComputationStrategy geodeticComputation =
|
||||||
* GeodeticComputationStrategy.SPHERICAL;
|
* GeodeticComputationStrategy.SPHERICAL;
|
||||||
@ -88,7 +85,7 @@ public class SimulationPreferencesPanel extends PreferencesPanel {
|
|||||||
StyledLabel warning = new StyledLabel(String.format(
|
StyledLabel warning = new StyledLabel(String.format(
|
||||||
"<html>%s</html>", trans.get("pref.dlg.lbl.launchWarning")),
|
"<html>%s</html>", trans.get("pref.dlg.lbl.launchWarning")),
|
||||||
0, StyledLabel.Style.BOLD);
|
0, StyledLabel.Style.BOLD);
|
||||||
warning.setFontColor(prefs.getUITheme().getDarkWarningColor());
|
warning.setFontColor(GUIUtil.getUITheme().getDarkWarningColor());
|
||||||
warning.setToolTipText(trans.get("pref.dlg.lbl.launchWarning.ttip"));
|
warning.setToolTipText(trans.get("pref.dlg.lbl.launchWarning.ttip"));
|
||||||
subsub.add(warning, "spanx, wrap para");
|
subsub.add(warning, "spanx, wrap para");
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import javax.swing.JPopupMenu;
|
|||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.event.MouseInputAdapter;
|
import javax.swing.event.MouseInputAdapter;
|
||||||
|
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -65,7 +65,6 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static final Logger log = LoggerFactory.getLogger(RocketFigure3d.class);
|
private static final Logger log = LoggerFactory.getLogger(RocketFigure3d.class);
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
//this allows the GL canvas and things like the motor selection
|
//this allows the GL canvas and things like the motor selection
|
||||||
@ -290,7 +289,7 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
|
|||||||
GL2 gl = drawable.getGL().getGL2();
|
GL2 gl = drawable.getGL().getGL2();
|
||||||
GLU glu = new GLU();
|
GLU glu = new GLU();
|
||||||
|
|
||||||
Color backgroundColor = prefs.getUITheme().getBackgroundColor();
|
Color backgroundColor = GUIUtil.getUITheme().getBackgroundColor();
|
||||||
gl.glClearColor(backgroundColor.getRed()/255f, backgroundColor.getGreen()/255f,
|
gl.glClearColor(backgroundColor.getRed()/255f, backgroundColor.getGreen()/255f,
|
||||||
backgroundColor.getBlue()/255f, backgroundColor.getAlpha()/255f);
|
backgroundColor.getBlue()/255f, backgroundColor.getAlpha()/255f);
|
||||||
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
|
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
|
||||||
|
@ -373,7 +373,7 @@ public class PhotoFrame extends JFrame {
|
|||||||
|
|
||||||
// Set the look-and-feel
|
// Set the look-and-feel
|
||||||
log.info("Setting LAF");
|
log.info("Setting LAF");
|
||||||
GUIUtil.setLAF();
|
GUIUtil.applyLAF();
|
||||||
|
|
||||||
// Load defaults
|
// Load defaults
|
||||||
((SwingPreferences) Application.getPreferences()).loadDefaultUnits();
|
((SwingPreferences) Application.getPreferences()).loadDefaultUnits();
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.sf.openrocket.gui.figureelements;
|
package net.sf.openrocket.gui.figureelements;
|
||||||
|
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
@ -20,8 +19,6 @@ public class CGCaret extends Caret {
|
|||||||
|
|
||||||
private static Area caret = null;
|
private static Area caret = null;
|
||||||
|
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new CGCaret at the specified coordinates.
|
* Create a new CGCaret at the specified coordinates.
|
||||||
*/
|
*/
|
||||||
@ -61,7 +58,7 @@ public class CGCaret extends Caret {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Color getColor() {
|
protected Color getColor() {
|
||||||
return prefs.getUITheme().getCGColor();
|
return GUIUtil.getUITheme().getCGColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.sf.openrocket.gui.figureelements;
|
package net.sf.openrocket.gui.figureelements;
|
||||||
|
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
@ -19,8 +18,6 @@ public class CPCaret extends Caret {
|
|||||||
|
|
||||||
private static Area caret = null;
|
private static Area caret = null;
|
||||||
|
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new CPCaret at the specified coordinates.
|
* Create a new CPCaret at the specified coordinates.
|
||||||
*/
|
*/
|
||||||
@ -56,6 +53,6 @@ public class CPCaret extends Caret {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Color getColor() {
|
protected Color getColor() {
|
||||||
return prefs.getUITheme().getCPColor();
|
return GUIUtil.getUITheme().getCPColor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import java.awt.Rectangle;
|
|||||||
import java.awt.font.GlyphVector;
|
import java.awt.font.GlyphVector;
|
||||||
import java.awt.geom.Rectangle2D;
|
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.SwingPreferences;
|
||||||
import net.sf.openrocket.logging.Warning;
|
import net.sf.openrocket.logging.Warning;
|
||||||
import net.sf.openrocket.logging.WarningSet;
|
import net.sf.openrocket.logging.WarningSet;
|
||||||
@ -175,7 +176,7 @@ public class RocketInfo implements FigureElement {
|
|||||||
|
|
||||||
GlyphVector massLineWithoutMotors = createText(massTextWithoutMotors);
|
GlyphVector massLineWithoutMotors = createText(massTextWithoutMotors);
|
||||||
|
|
||||||
g2.setColor(preferences.getUITheme().getTextColor());
|
g2.setColor(GUIUtil.getUITheme().getTextColor());
|
||||||
|
|
||||||
g2.drawGlyphVector(name, x1, y1);
|
g2.drawGlyphVector(name, x1, y1);
|
||||||
g2.drawGlyphVector(lengthLine, x1, y1+line);
|
g2.drawGlyphVector(lengthLine, x1, y1+line);
|
||||||
@ -231,7 +232,7 @@ public class RocketInfo implements FigureElement {
|
|||||||
// Add an extra space worth of width so the text doesn't run into the values
|
// Add an extra space worth of width so the text doesn't run into the values
|
||||||
unitWidth = unitWidth + spaceWidth;
|
unitWidth = unitWidth + spaceWidth;
|
||||||
|
|
||||||
g2.setColor(preferences.getUITheme().getTextColor());
|
g2.setColor(GUIUtil.getUITheme().getTextColor());
|
||||||
|
|
||||||
g2.drawGlyphVector(stabValue, (float)(x2-stabRect.getWidth()), y1);
|
g2.drawGlyphVector(stabValue, (float)(x2-stabRect.getWidth()), y1);
|
||||||
g2.drawGlyphVector(cgValue, (float)(x2-cgRect.getWidth()), y1+line);
|
g2.drawGlyphVector(cgValue, (float)(x2-cgRect.getWidth()), y1+line);
|
||||||
@ -254,7 +255,7 @@ public class RocketInfo implements FigureElement {
|
|||||||
atPos = (float)(x2 - atTextRect.getWidth());
|
atPos = (float)(x2 - atTextRect.getWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
g2.setColor(preferences.getUITheme().getDimTextColor());
|
g2.setColor(GUIUtil.getUITheme().getDimTextColor());
|
||||||
g2.drawGlyphVector(atText, atPos, y1 + 3*line);
|
g2.drawGlyphVector(atText, atPos, y1 + 3*line);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -404,7 +405,7 @@ public class RocketInfo implements FigureElement {
|
|||||||
|
|
||||||
|
|
||||||
float y = y2 - line * (texts.length-1);
|
float y = y2 - line * (texts.length-1);
|
||||||
g2.setColor(preferences.getUITheme().getWarningColor());
|
g2.setColor(GUIUtil.getUITheme().getWarningColor());
|
||||||
|
|
||||||
for (GlyphVector v: texts) {
|
for (GlyphVector v: texts) {
|
||||||
Rectangle2D rect = v.getVisualBounds();
|
Rectangle2D rect = v.getVisualBounds();
|
||||||
@ -420,7 +421,7 @@ public class RocketInfo implements FigureElement {
|
|||||||
if (calculatingData) {
|
if (calculatingData) {
|
||||||
//// Calculating...
|
//// Calculating...
|
||||||
GlyphVector calculating = createText(trans.get("RocketInfo.Calculating"));
|
GlyphVector calculating = createText(trans.get("RocketInfo.Calculating"));
|
||||||
g2.setColor(preferences.getUITheme().getTextColor());
|
g2.setColor(GUIUtil.getUITheme().getTextColor());
|
||||||
g2.drawGlyphVector(calculating, x1, (float)(y2-height));
|
g2.drawGlyphVector(calculating, x1, (float)(y2-height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -478,9 +479,9 @@ public class RocketInfo implements FigureElement {
|
|||||||
width += 5;
|
width += 5;
|
||||||
|
|
||||||
if (!calculatingData)
|
if (!calculatingData)
|
||||||
g2.setColor(preferences.getUITheme().getFlightDataTextActiveColor());
|
g2.setColor(GUIUtil.getUITheme().getFlightDataTextActiveColor());
|
||||||
else
|
else
|
||||||
g2.setColor(preferences.getUITheme().getFlightDataTextInactiveColor());
|
g2.setColor(GUIUtil.getUITheme().getFlightDataTextInactiveColor());
|
||||||
|
|
||||||
g2.drawGlyphVector(apogee, (float)x1, (float)(y2-2*line));
|
g2.drawGlyphVector(apogee, (float)x1, (float)(y2-2*line));
|
||||||
g2.drawGlyphVector(maxVelocity, (float)x1, (float)(y2-line));
|
g2.drawGlyphVector(maxVelocity, (float)x1, (float)(y2-line));
|
||||||
|
@ -12,8 +12,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import javax.swing.text.html.StyleSheet;
|
import javax.swing.text.html.StyleSheet;
|
||||||
|
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
import net.sf.openrocket.util.BugException;
|
import net.sf.openrocket.util.BugException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,8 +22,6 @@ import net.sf.openrocket.util.BugException;
|
|||||||
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
||||||
*/
|
*/
|
||||||
public class SlideSetManager {
|
public class SlideSetManager {
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
private static final String TOURS_BASE_DIR = "datafiles/tours";
|
private static final String TOURS_BASE_DIR = "datafiles/tours";
|
||||||
|
|
||||||
private static final String TOURS_FILE = "tours.txt";
|
private static final String TOURS_FILE = "tours.txt";
|
||||||
@ -135,7 +132,7 @@ public class SlideSetManager {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
StyleSheet ss = new StyleSheet();
|
StyleSheet ss = new StyleSheet();
|
||||||
Color textColor = prefs.getUITheme().getTextColor();
|
Color textColor = GUIUtil.getUITheme().getTextColor();
|
||||||
ss.addRule(String.format("p { color: rgb(%d, %d, %d, %d)",
|
ss.addRule(String.format("p { color: rgb(%d, %d, %d, %d)",
|
||||||
textColor.getRed(), textColor.getGreen(), textColor.getBlue(), textColor.getAlpha()));
|
textColor.getRed(), textColor.getGreen(), textColor.getBlue(), textColor.getAlpha()));
|
||||||
InputStreamReader reader = new InputStreamReader(in, "UTF-8");
|
InputStreamReader reader = new InputStreamReader(in, "UTF-8");
|
||||||
|
@ -12,8 +12,7 @@ import javax.swing.text.html.HTMLDocument;
|
|||||||
import javax.swing.text.html.StyleSheet;
|
import javax.swing.text.html.StyleSheet;
|
||||||
|
|
||||||
import net.sf.openrocket.gui.components.ImageDisplayComponent;
|
import net.sf.openrocket.gui.components.ImageDisplayComponent;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that displays a single slide, with the image on top and
|
* Component that displays a single slide, with the image on top and
|
||||||
@ -31,8 +30,6 @@ public class SlideShowComponent extends JSplitPane {
|
|||||||
private final ImageDisplayComponent imageDisplay;
|
private final ImageDisplayComponent imageDisplay;
|
||||||
private final JEditorPane textPane;
|
private final JEditorPane textPane;
|
||||||
|
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
|
|
||||||
public SlideShowComponent() {
|
public SlideShowComponent() {
|
||||||
super(VERTICAL_SPLIT);
|
super(VERTICAL_SPLIT);
|
||||||
@ -48,7 +45,7 @@ public class SlideShowComponent extends JSplitPane {
|
|||||||
textPane.setPreferredSize(new Dimension(WIDTH, HEIGHT_TEXT));
|
textPane.setPreferredSize(new Dimension(WIDTH, HEIGHT_TEXT));
|
||||||
|
|
||||||
JScrollPane scrollPanel = new JScrollPane(textPane);
|
JScrollPane scrollPanel = new JScrollPane(textPane);
|
||||||
textPane.setBorder(prefs.getUITheme().getBorder());
|
textPane.setBorder(GUIUtil.getUITheme().getBorder());
|
||||||
this.setRightComponent(scrollPanel);
|
this.setRightComponent(scrollPanel);
|
||||||
|
|
||||||
this.setResizeWeight(((double) HEIGHT_IMAGE) / (HEIGHT_IMAGE + HEIGHT_TEXT));
|
this.setResizeWeight(((double) HEIGHT_IMAGE) / (HEIGHT_IMAGE + HEIGHT_TEXT));
|
||||||
|
@ -5,7 +5,6 @@ import net.sf.openrocket.document.OpenRocketDocument;
|
|||||||
import net.sf.openrocket.gui.configdialog.ComponentConfigDialog;
|
import net.sf.openrocket.gui.configdialog.ComponentConfigDialog;
|
||||||
import net.sf.openrocket.gui.main.componenttree.ComponentTree;
|
import net.sf.openrocket.gui.main.componenttree.ComponentTree;
|
||||||
import net.sf.openrocket.gui.util.GUIUtil;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
|
||||||
import net.sf.openrocket.gui.widgets.IconButton;
|
import net.sf.openrocket.gui.widgets.IconButton;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||||
@ -50,7 +49,6 @@ import static net.sf.openrocket.gui.main.BasicFrame.SHORTCUT_KEY;
|
|||||||
*/
|
*/
|
||||||
public class DesignPanel extends JSplitPane {
|
public class DesignPanel extends JSplitPane {
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
private final Component tree;
|
private final Component tree;
|
||||||
|
|
||||||
public DesignPanel(final BasicFrame parent, final OpenRocketDocument document, final ComponentTree tree) {
|
public DesignPanel(final BasicFrame parent, final OpenRocketDocument document, final ComponentTree tree) {
|
||||||
@ -176,7 +174,7 @@ public class DesignPanel extends JSplitPane {
|
|||||||
|
|
||||||
// Place tree inside scroll pane
|
// Place tree inside scroll pane
|
||||||
JScrollPane scroll = new JScrollPane(tree);
|
JScrollPane scroll = new JScrollPane(tree);
|
||||||
tree.setBorder(prefs.getUITheme().getBorder());
|
tree.setBorder(GUIUtil.getUITheme().getBorder());
|
||||||
panel.add(scroll, "spany, wmin 140px, grow, wrap");
|
panel.add(scroll, "spany, wmin 140px, grow, wrap");
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package net.sf.openrocket.gui.main.componenttree;
|
|||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -17,8 +16,7 @@ import javax.swing.tree.DefaultTreeCellRenderer;
|
|||||||
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreePath;
|
||||||
|
|
||||||
import net.sf.openrocket.gui.main.ComponentIcons;
|
import net.sf.openrocket.gui.main.ComponentIcons;
|
||||||
import net.sf.openrocket.gui.util.Icons;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.rocketcomponent.MassComponent;
|
import net.sf.openrocket.rocketcomponent.MassComponent;
|
||||||
import net.sf.openrocket.rocketcomponent.MassComponent.MassComponentType;
|
import net.sf.openrocket.rocketcomponent.MassComponent.MassComponentType;
|
||||||
@ -32,7 +30,6 @@ import net.sf.openrocket.util.TextUtil;
|
|||||||
public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
|
public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
|
||||||
|
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getTreeCellRendererComponent(JTree tree, Object value,
|
public Component getTreeCellRendererComponent(JTree tree, Object value,
|
||||||
@ -83,12 +80,12 @@ public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
|
|||||||
// Set the background and foreground colors of the text JLabel
|
// Set the background and foreground colors of the text JLabel
|
||||||
if (sel) {
|
if (sel) {
|
||||||
textLabel.setOpaque(true);
|
textLabel.setOpaque(true);
|
||||||
textLabel.setBackground(prefs.getUITheme().getTextSelectionBackgroundColor());
|
textLabel.setBackground(GUIUtil.getUITheme().getTextSelectionBackgroundColor());
|
||||||
textLabel.setForeground(prefs.getUITheme().getTextSelectionForegroundColor());
|
textLabel.setForeground(GUIUtil.getUITheme().getTextSelectionForegroundColor());
|
||||||
} else {
|
} else {
|
||||||
textLabel.setOpaque(true); // Set this to true to allow the background color to be visible
|
textLabel.setOpaque(true); // Set this to true to allow the background color to be visible
|
||||||
textLabel.setBackground(prefs.getUITheme().getComponentTreeBackgroundColor());
|
textLabel.setBackground(GUIUtil.getUITheme().getComponentTreeBackgroundColor());
|
||||||
textLabel.setForeground(prefs.getUITheme().getComponentTreeForegroundColor());
|
textLabel.setForeground(GUIUtil.getUITheme().getComponentTreeForegroundColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
comp = panel;
|
comp = panel;
|
||||||
@ -99,23 +96,23 @@ public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
|
|||||||
c.isCDOverridden() || c.getCDOverriddenBy() != null) {
|
c.isCDOverridden() || c.getCDOverriddenBy() != null) {
|
||||||
JPanel p = new JPanel();
|
JPanel p = new JPanel();
|
||||||
p.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 1));
|
p.setLayout(new FlowLayout(FlowLayout.LEFT, 1, 1));
|
||||||
p.setBackground(prefs.getUITheme().getComponentTreeBackgroundColor());
|
p.setBackground(GUIUtil.getUITheme().getComponentTreeBackgroundColor());
|
||||||
p.setForeground(prefs.getUITheme().getComponentTreeForegroundColor());
|
p.setForeground(GUIUtil.getUITheme().getComponentTreeForegroundColor());
|
||||||
p.add(comp/* , BorderLayout.WEST */);
|
p.add(comp/* , BorderLayout.WEST */);
|
||||||
if (c.getMassOverriddenBy() != null) {
|
if (c.getMassOverriddenBy() != null) {
|
||||||
p.add(new JLabel(prefs.getUITheme().getMassOverrideSubcomponentIcon()));
|
p.add(new JLabel(GUIUtil.getUITheme().getMassOverrideSubcomponentIcon()));
|
||||||
} else if (c.isMassOverridden()) {
|
} else if (c.isMassOverridden()) {
|
||||||
p.add(new JLabel(prefs.getUITheme().getMassOverrideIcon()));
|
p.add(new JLabel(GUIUtil.getUITheme().getMassOverrideIcon()));
|
||||||
}
|
}
|
||||||
if (c.getCGOverriddenBy() != null) {
|
if (c.getCGOverriddenBy() != null) {
|
||||||
p.add(new JLabel(prefs.getUITheme().getCGOverrideSubcomponentIcon()));
|
p.add(new JLabel(GUIUtil.getUITheme().getCGOverrideSubcomponentIcon()));
|
||||||
} else if (c.isCGOverridden()) {
|
} else if (c.isCGOverridden()) {
|
||||||
p.add(new JLabel(prefs.getUITheme().getCGOverrideIcon()));
|
p.add(new JLabel(GUIUtil.getUITheme().getCGOverrideIcon()));
|
||||||
}
|
}
|
||||||
if (c.getCDOverriddenBy() != null) {
|
if (c.getCDOverriddenBy() != null) {
|
||||||
p.add(new JLabel(prefs.getUITheme().getCDOverrideSubcomponentIcon()));
|
p.add(new JLabel(GUIUtil.getUITheme().getCDOverrideSubcomponentIcon()));
|
||||||
} else if (c.isCDOverridden()) {
|
} else if (c.isCDOverridden()) {
|
||||||
p.add(new JLabel(prefs.getUITheme().getCDOverrideIcon()));
|
p.add(new JLabel(GUIUtil.getUITheme().getCDOverrideIcon()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the tooltip also works on the override icons
|
// Make sure the tooltip also works on the override icons
|
||||||
|
@ -390,12 +390,12 @@ public abstract class FlightConfigurablePanel<T extends FlightConfigurableCompon
|
|||||||
|
|
||||||
protected final void shaded(JLabel label) {
|
protected final void shaded(JLabel label) {
|
||||||
GUIUtil.changeFontStyle(label, Font.ITALIC);
|
GUIUtil.changeFontStyle(label, Font.ITALIC);
|
||||||
label.setForeground(prefs.getUITheme().getDimTextColor());
|
label.setForeground(GUIUtil.getUITheme().getDimTextColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void regular(JLabel label) {
|
protected final void regular(JLabel label) {
|
||||||
GUIUtil.changeFontStyle(label, Font.PLAIN);
|
GUIUtil.changeFontStyle(label, Font.PLAIN);
|
||||||
label.setForeground(prefs.getUITheme().getTextColor());
|
label.setForeground(GUIUtil.getUITheme().getTextColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract JLabel format( T component, FlightConfigurationId configId, JLabel label );
|
protected abstract JLabel format( T component, FlightConfigurationId configId, JLabel label );
|
||||||
|
@ -3,8 +3,6 @@ package net.sf.openrocket.gui.plot;
|
|||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.ComponentAdapter;
|
|
||||||
import java.awt.event.ComponentEvent;
|
|
||||||
import java.awt.event.InputEvent;
|
import java.awt.event.InputEvent;
|
||||||
import java.awt.event.ItemEvent;
|
import java.awt.event.ItemEvent;
|
||||||
import java.awt.event.ItemListener;
|
import java.awt.event.ItemListener;
|
||||||
@ -31,7 +29,6 @@ import net.sf.openrocket.l10n.Translator;
|
|||||||
import net.sf.openrocket.simulation.FlightDataType;
|
import net.sf.openrocket.simulation.FlightDataType;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.startup.Preferences;
|
import net.sf.openrocket.startup.Preferences;
|
||||||
import net.sf.openrocket.util.Color;
|
|
||||||
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
||||||
|
|
||||||
import org.jfree.chart.ChartPanel;
|
import org.jfree.chart.ChartPanel;
|
||||||
@ -45,7 +42,6 @@ import org.jfree.chart.JFreeChart;
|
|||||||
*/
|
*/
|
||||||
public class SimulationPlotDialog extends JDialog {
|
public class SimulationPlotDialog extends JDialog {
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
private SimulationPlotDialog(Window parent, Simulation simulation, PlotConfiguration config) {
|
private SimulationPlotDialog(Window parent, Simulation simulation, PlotConfiguration config) {
|
||||||
//// Flight data plot
|
//// Flight data plot
|
||||||
@ -77,7 +73,7 @@ public class SimulationPlotDialog extends JDialog {
|
|||||||
// Add warning if X axis type is not time
|
// Add warning if X axis type is not time
|
||||||
if (config.getDomainAxisType() != FlightDataType.TYPE_TIME) {
|
if (config.getDomainAxisType() != FlightDataType.TYPE_TIME) {
|
||||||
JLabel msg = new StyledLabel(trans.get("PlotDialog.lbl.timeSeriesWarning"), -2);
|
JLabel msg = new StyledLabel(trans.get("PlotDialog.lbl.timeSeriesWarning"), -2);
|
||||||
msg.setForeground(prefs.getUITheme().getDarkWarningColor());
|
msg.setForeground(GUIUtil.getUITheme().getDarkWarningColor());
|
||||||
panel.add(msg, "wrap");
|
panel.add(msg, "wrap");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,8 +12,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -25,7 +23,6 @@ import net.sf.openrocket.util.StateChangeListener;
|
|||||||
public abstract class AbstractScaleFigure extends JPanel {
|
public abstract class AbstractScaleFigure extends JPanel {
|
||||||
|
|
||||||
private final static Logger log = LoggerFactory.getLogger(AbstractScaleFigure.class);
|
private final static Logger log = LoggerFactory.getLogger(AbstractScaleFigure.class);
|
||||||
private final static SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
public static final double INCHES_PER_METER = 39.3701;
|
public static final double INCHES_PER_METER = 39.3701;
|
||||||
public static final double METERS_PER_INCH = 0.0254;
|
public static final double METERS_PER_INCH = 0.0254;
|
||||||
@ -73,7 +70,7 @@ public abstract class AbstractScaleFigure extends JPanel {
|
|||||||
this.setPreferredSize(new Dimension(100,100));
|
this.setPreferredSize(new Dimension(100,100));
|
||||||
setSize(100,100);
|
setSize(100,100);
|
||||||
|
|
||||||
setBackground(prefs.getUITheme().getBackgroundColor());
|
setBackground(GUIUtil.getUITheme().getBackgroundColor());
|
||||||
setOpaque(true);
|
setOpaque(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,13 +14,12 @@ import java.awt.geom.Rectangle2D;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.rocketcomponent.FreeformFinSet;
|
import net.sf.openrocket.rocketcomponent.FreeformFinSet;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
import net.sf.openrocket.rocketcomponent.SymmetricComponent;
|
import net.sf.openrocket.rocketcomponent.SymmetricComponent;
|
||||||
import net.sf.openrocket.rocketcomponent.Transition;
|
import net.sf.openrocket.rocketcomponent.Transition;
|
||||||
import net.sf.openrocket.rocketcomponent.position.AxialMethod;
|
import net.sf.openrocket.rocketcomponent.position.AxialMethod;
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
import net.sf.openrocket.unit.Tick;
|
import net.sf.openrocket.unit.Tick;
|
||||||
import net.sf.openrocket.unit.Unit;
|
import net.sf.openrocket.unit.Unit;
|
||||||
import net.sf.openrocket.unit.UnitGroup;
|
import net.sf.openrocket.unit.UnitGroup;
|
||||||
@ -33,8 +32,6 @@ import net.sf.openrocket.util.StateChangeListener;
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class FinPointFigure extends AbstractScaleFigure {
|
public class FinPointFigure extends AbstractScaleFigure {
|
||||||
|
|
||||||
private final static SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
private static final int GRID_LINE_BASE_WIDTH_PIXELS = 1;
|
private static final int GRID_LINE_BASE_WIDTH_PIXELS = 1;
|
||||||
|
|
||||||
private static final int LINE_WIDTH_FIN_PIXELS = 1;
|
private static final int LINE_WIDTH_FIN_PIXELS = 1;
|
||||||
@ -63,7 +60,7 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
public FinPointFigure(FreeformFinSet finset) {
|
public FinPointFigure(FreeformFinSet finset) {
|
||||||
this.finset = finset;
|
this.finset = finset;
|
||||||
|
|
||||||
setBackground(prefs.getUITheme().getBackgroundColor());
|
setBackground(GUIUtil.getUITheme().getBackgroundColor());
|
||||||
setOpaque(true);
|
setOpaque(true);
|
||||||
|
|
||||||
updateFigure();
|
updateFigure();
|
||||||
@ -125,11 +122,11 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
Line2D.Double line = new Line2D.Double();
|
Line2D.Double line = new Line2D.Double();
|
||||||
for (Tick t : verticalTicks) {
|
for (Tick t : verticalTicks) {
|
||||||
if (t.major) {
|
if (t.major) {
|
||||||
g2.setColor(prefs.getUITheme().getFinPointGridMajorLineColor());
|
g2.setColor(GUIUtil.getUITheme().getFinPointGridMajorLineColor());
|
||||||
line.setLine( t.value, y0, t.value, y1);
|
line.setLine( t.value, y0, t.value, y1);
|
||||||
g2.draw(line);
|
g2.draw(line);
|
||||||
}else{
|
}else{
|
||||||
g2.setColor(prefs.getUITheme().getFinPointGridMinorLineColor());
|
g2.setColor(GUIUtil.getUITheme().getFinPointGridMinorLineColor());
|
||||||
line.setLine( t.value, y0, t.value, y1);
|
line.setLine( t.value, y0, t.value, y1);
|
||||||
g2.draw(line);
|
g2.draw(line);
|
||||||
}
|
}
|
||||||
@ -139,11 +136,11 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
Tick[] horizontalTicks = unit.getTicks(y0, y1, MINOR_TICKS / this.scale, MAJOR_TICKS / this.scale);
|
Tick[] horizontalTicks = unit.getTicks(y0, y1, MINOR_TICKS / this.scale, MAJOR_TICKS / this.scale);
|
||||||
for (Tick t : horizontalTicks) {
|
for (Tick t : horizontalTicks) {
|
||||||
if (t.major) {
|
if (t.major) {
|
||||||
g2.setColor(prefs.getUITheme().getFinPointGridMajorLineColor());
|
g2.setColor(GUIUtil.getUITheme().getFinPointGridMajorLineColor());
|
||||||
line.setLine( x0, t.value, x1, t.value);
|
line.setLine( x0, t.value, x1, t.value);
|
||||||
g2.draw(line);
|
g2.draw(line);
|
||||||
}else{
|
}else{
|
||||||
g2.setColor(prefs.getUITheme().getFinPointGridMinorLineColor());
|
g2.setColor(GUIUtil.getUITheme().getFinPointGridMinorLineColor());
|
||||||
line.setLine( x0, t.value, x1, t.value);
|
line.setLine( x0, t.value, x1, t.value);
|
||||||
g2.draw(line);
|
g2.draw(line);
|
||||||
}
|
}
|
||||||
@ -166,7 +163,7 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
// setup lines
|
// setup lines
|
||||||
final float bodyLineWidth = (float) ( LINE_WIDTH_BODY_PIXELS / scale );
|
final float bodyLineWidth = (float) ( LINE_WIDTH_BODY_PIXELS / scale );
|
||||||
g2.setStroke(new BasicStroke( bodyLineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
g2.setStroke(new BasicStroke( bodyLineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
||||||
g2.setColor(prefs.getUITheme().getFinPointBodyLineColor());
|
g2.setColor(GUIUtil.getUITheme().getFinPointBodyLineColor());
|
||||||
|
|
||||||
Transition body = (Transition) finset.getParent();
|
Transition body = (Transition) finset.getParent();
|
||||||
final float xResolution_m = 0.01f; // distance between draw points, in meters
|
final float xResolution_m = 0.01f; // distance between draw points, in meters
|
||||||
@ -216,7 +213,7 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
|
|
||||||
final float bodyLineWidth = (float) ( LINE_WIDTH_BODY_PIXELS / scale );
|
final float bodyLineWidth = (float) ( LINE_WIDTH_BODY_PIXELS / scale );
|
||||||
g2.setStroke(new BasicStroke( bodyLineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
g2.setStroke(new BasicStroke( bodyLineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
||||||
g2.setColor(prefs.getUITheme().getFinPointBodyLineColor());
|
g2.setColor(GUIUtil.getUITheme().getFinPointBodyLineColor());
|
||||||
g2.draw(shape);
|
g2.draw(shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +230,7 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
|
|
||||||
final float finEdgeWidth_m = (float) (LINE_WIDTH_FIN_PIXELS / scale );
|
final float finEdgeWidth_m = (float) (LINE_WIDTH_FIN_PIXELS / scale );
|
||||||
g2.setStroke(new BasicStroke( finEdgeWidth_m, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
g2.setStroke(new BasicStroke( finEdgeWidth_m, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
||||||
g2.setColor(prefs.getUITheme().getFinPointBodyLineColor());
|
g2.setColor(GUIUtil.getUITheme().getFinPointBodyLineColor());
|
||||||
g2.draw(shape);
|
g2.draw(shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,7 +244,7 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
|
|
||||||
final float boxEdgeWidth_m = (float) ( LINE_WIDTH_BOX_PIXELS / scale );
|
final float boxEdgeWidth_m = (float) ( LINE_WIDTH_BOX_PIXELS / scale );
|
||||||
g2.setStroke(new BasicStroke( boxEdgeWidth_m, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
g2.setStroke(new BasicStroke( boxEdgeWidth_m, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
||||||
g2.setColor(prefs.getUITheme().getFinPointPointColor());
|
g2.setColor(GUIUtil.getUITheme().getFinPointPointColor());
|
||||||
|
|
||||||
finPointHandles = new Rectangle2D.Double[ drawPoints.length];
|
finPointHandles = new Rectangle2D.Double[ drawPoints.length];
|
||||||
for (int currentIndex = 0; currentIndex < drawPoints.length; currentIndex++) {
|
for (int currentIndex = 0; currentIndex < drawPoints.length; currentIndex++) {
|
||||||
@ -260,11 +257,11 @@ public class FinPointFigure extends AbstractScaleFigure {
|
|||||||
final Rectangle2D.Double selectedPointHighlight = new Rectangle2D.Double(c.x - selBoxHalfWidth, c.y - selBoxHalfWidth, selBoxWidth, selBoxWidth);
|
final Rectangle2D.Double selectedPointHighlight = new Rectangle2D.Double(c.x - selBoxHalfWidth, c.y - selBoxHalfWidth, selBoxWidth, selBoxWidth);
|
||||||
|
|
||||||
// switch to the highlight color
|
// switch to the highlight color
|
||||||
g2.setColor(prefs.getUITheme().getFinPointSelectedPointColor());
|
g2.setColor(GUIUtil.getUITheme().getFinPointSelectedPointColor());
|
||||||
g2.draw(selectedPointHighlight);
|
g2.draw(selectedPointHighlight);
|
||||||
|
|
||||||
// reset to the normal color
|
// reset to the normal color
|
||||||
g2.setColor(prefs.getUITheme().getFinPointPointColor());
|
g2.setColor(GUIUtil.getUITheme().getFinPointPointColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
// normal boxes
|
// normal boxes
|
||||||
|
@ -17,6 +17,7 @@ import java.awt.geom.Rectangle2D;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||||
import net.sf.openrocket.rocketcomponent.ParallelStage;
|
import net.sf.openrocket.rocketcomponent.ParallelStage;
|
||||||
import net.sf.openrocket.rocketcomponent.PodSet;
|
import net.sf.openrocket.rocketcomponent.PodSet;
|
||||||
@ -290,8 +291,8 @@ public class RocketFigure extends AbstractScaleFigure {
|
|||||||
RenderingHints.VALUE_STROKE_NORMALIZE);
|
RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||||
|
|
||||||
// Draw motors
|
// Draw motors
|
||||||
Color fillColor = ((SwingPreferences)Application.getPreferences()).getUITheme().getMotorFillColor();
|
Color fillColor = GUIUtil.getUITheme().getMotorFillColor();
|
||||||
Color borderColor = ((SwingPreferences)Application.getPreferences()).getUITheme().getMotorBorderColor();
|
Color borderColor = GUIUtil.getUITheme().getMotorBorderColor();
|
||||||
|
|
||||||
FlightConfiguration config = rocket.getSelectedConfiguration();
|
FlightConfiguration config = rocket.getSelectedConfiguration();
|
||||||
for (MotorConfiguration curInstance : config.getActiveMotors()) {
|
for (MotorConfiguration curInstance : config.getActiveMotors()) {
|
||||||
|
@ -25,8 +25,7 @@ import javax.swing.event.ChangeListener;
|
|||||||
|
|
||||||
import net.sf.openrocket.gui.adaptors.DoubleModel;
|
import net.sf.openrocket.gui.adaptors.DoubleModel;
|
||||||
import net.sf.openrocket.gui.components.UnitSelector;
|
import net.sf.openrocket.gui.components.UnitSelector;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
import net.sf.openrocket.unit.Tick;
|
import net.sf.openrocket.unit.Tick;
|
||||||
import net.sf.openrocket.unit.Unit;
|
import net.sf.openrocket.unit.Unit;
|
||||||
import net.sf.openrocket.unit.UnitGroup;
|
import net.sf.openrocket.unit.UnitGroup;
|
||||||
@ -315,8 +314,6 @@ public class ScaleScrollPane extends JScrollPane
|
|||||||
|
|
||||||
private final int orientation;
|
private final int orientation;
|
||||||
|
|
||||||
private final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
public Ruler(int orientation) {
|
public Ruler(int orientation) {
|
||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
rulerUnit.addChangeListener(this);
|
rulerUnit.addChangeListener(this);
|
||||||
@ -402,7 +399,7 @@ public class ScaleScrollPane extends JScrollPane
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set color & hints
|
// Set color & hints
|
||||||
g2.setColor(prefs.getUITheme().getTextColor());
|
g2.setColor(GUIUtil.getUITheme().getTextColor());
|
||||||
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
|
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
|
||||||
RenderingHints.VALUE_STROKE_NORMALIZE);
|
RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||||
g2.setRenderingHint(RenderingHints.KEY_RENDERING,
|
g2.setRenderingHint(RenderingHints.KEY_RENDERING,
|
||||||
|
@ -36,7 +36,6 @@ import net.sf.openrocket.gui.components.StyledLabel.Style;
|
|||||||
import net.sf.openrocket.gui.components.UnitSelector;
|
import net.sf.openrocket.gui.components.UnitSelector;
|
||||||
import net.sf.openrocket.gui.util.GUIUtil;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.gui.util.Icons;
|
import net.sf.openrocket.gui.util.Icons;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.simulation.RK4SimulationStepper;
|
import net.sf.openrocket.simulation.RK4SimulationStepper;
|
||||||
import net.sf.openrocket.simulation.SimulationOptions;
|
import net.sf.openrocket.simulation.SimulationOptions;
|
||||||
@ -56,7 +55,6 @@ class SimulationOptionsPanel extends JPanel {
|
|||||||
private static final long serialVersionUID = -5251458539346201239L;
|
private static final long serialVersionUID = -5251458539346201239L;
|
||||||
|
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
private OpenRocketDocument document;
|
private OpenRocketDocument document;
|
||||||
final Simulation simulation;
|
final Simulation simulation;
|
||||||
@ -209,8 +207,8 @@ class SimulationOptionsPanel extends JPanel {
|
|||||||
|
|
||||||
currentExtensions = new JPanel(new MigLayout("fillx, gap 0 0, ins 0"));
|
currentExtensions = new JPanel(new MigLayout("fillx, gap 0 0, ins 0"));
|
||||||
JScrollPane scroll = new JScrollPane(currentExtensions);
|
JScrollPane scroll = new JScrollPane(currentExtensions);
|
||||||
currentExtensions.setBorder(prefs.getUITheme().getBorder());
|
currentExtensions.setBorder(GUIUtil.getUITheme().getBorder());
|
||||||
scroll.setForeground(prefs.getUITheme().getTextColor());
|
scroll.setForeground(GUIUtil.getUITheme().getTextColor());
|
||||||
// &#$%! scroll pane will not honor "growy"...
|
// &#$%! scroll pane will not honor "growy"...
|
||||||
sub.add(scroll, "growx, growy, h 100%");
|
sub.add(scroll, "growx, growy, h 100%");
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ public class SimulationPlotPanel extends JPanel {
|
|||||||
//// The data will be plotted in time order even if the X axis type is not time.
|
//// The data will be plotted in time order even if the X axis type is not time.
|
||||||
simPlotPanelDesc = new DescriptionArea("", 2, -2f, false);
|
simPlotPanelDesc = new DescriptionArea("", 2, -2f, false);
|
||||||
simPlotPanelDesc.setVisible(false);
|
simPlotPanelDesc.setVisible(false);
|
||||||
simPlotPanelDesc.setForeground(preferences.getUITheme().getDarkWarningColor());
|
simPlotPanelDesc.setForeground(GUIUtil.getUITheme().getDarkWarningColor());
|
||||||
simPlotPanelDesc.setViewportBorder(BorderFactory.createEmptyBorder());
|
simPlotPanelDesc.setViewportBorder(BorderFactory.createEmptyBorder());
|
||||||
this.add(simPlotPanelDesc, "width 1px, growx 1, wrap unrel");
|
this.add(simPlotPanelDesc, "width 1px, growx 1, wrap unrel");
|
||||||
|
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package net.sf.openrocket.gui.util;
|
package net.sf.openrocket.gui.util;
|
||||||
|
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
|
|
||||||
import javax.swing.DefaultListCellRenderer;
|
import javax.swing.DefaultListCellRenderer;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,7 +12,6 @@ import java.awt.Component;
|
|||||||
* @author Sibo Van Gool <sibo.vangool@hotmail.com>
|
* @author Sibo Van Gool <sibo.vangool@hotmail.com>
|
||||||
*/
|
*/
|
||||||
public class BetterListCellRenderer extends DefaultListCellRenderer {
|
public class BetterListCellRenderer extends DefaultListCellRenderer {
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
|
||||||
@ -24,16 +21,16 @@ public class BetterListCellRenderer extends DefaultListCellRenderer {
|
|||||||
// Alternating row colors
|
// Alternating row colors
|
||||||
if (!isSelected) {
|
if (!isSelected) {
|
||||||
if (index % 2 == 0) {
|
if (index % 2 == 0) {
|
||||||
label.setBackground(prefs.getUITheme().getRowBackgroundDarkerColor());
|
label.setBackground(GUIUtil.getUITheme().getRowBackgroundDarkerColor());
|
||||||
} else {
|
} else {
|
||||||
label.setBackground(prefs.getUITheme().getRowBackgroundLighterColor());
|
label.setBackground(GUIUtil.getUITheme().getRowBackgroundLighterColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Text color
|
// Text color
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
label.setForeground(prefs.getUITheme().getTextSelectionForegroundColor());
|
label.setForeground(GUIUtil.getUITheme().getTextSelectionForegroundColor());
|
||||||
} else {
|
} else {
|
||||||
label.setForeground(prefs.getUITheme().getTextColor());
|
label.setForeground(GUIUtil.getUITheme().getTextColor());
|
||||||
}
|
}
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,7 @@ import net.sf.openrocket.arch.SystemInfo;
|
|||||||
import net.sf.openrocket.gui.Resettable;
|
import net.sf.openrocket.gui.Resettable;
|
||||||
import net.sf.openrocket.logging.Markers;
|
import net.sf.openrocket.logging.Markers;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
|
import net.sf.openrocket.startup.Preferences;
|
||||||
import net.sf.openrocket.util.BugException;
|
import net.sf.openrocket.util.BugException;
|
||||||
import net.sf.openrocket.util.Invalidatable;
|
import net.sf.openrocket.util.Invalidatable;
|
||||||
import net.sf.openrocket.util.MemoryManagement;
|
import net.sf.openrocket.util.MemoryManagement;
|
||||||
@ -79,7 +80,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
public class GUIUtil {
|
public class GUIUtil {
|
||||||
private static final Logger log = LoggerFactory.getLogger(GUIUtil.class);
|
private static final Logger log = LoggerFactory.getLogger(GUIUtil.class);
|
||||||
private static final SwingPreferences preferences = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
private static final KeyStroke ESCAPE = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
|
private static final KeyStroke ESCAPE = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
|
||||||
private static final String CLOSE_ACTION_KEY = "escape:WINDOW_CLOSING";
|
private static final String CLOSE_ACTION_KEY = "escape:WINDOW_CLOSING";
|
||||||
@ -257,8 +257,21 @@ public class GUIUtil {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setLAF() {
|
/**
|
||||||
UITheme.Theme theme = preferences.getUITheme();
|
* Get the current theme used for the UI.
|
||||||
|
* @return the current theme
|
||||||
|
*/
|
||||||
|
public static UITheme.Theme getUITheme() {
|
||||||
|
Preferences prefs = Application.getPreferences();
|
||||||
|
Object theme = prefs.getUITheme();
|
||||||
|
if (theme instanceof UITheme.Theme) {
|
||||||
|
return (UITheme.Theme) theme;
|
||||||
|
}
|
||||||
|
return UITheme.Themes.LIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void applyLAF() {
|
||||||
|
UITheme.Theme theme = getUITheme();
|
||||||
theme.applyTheme();
|
theme.applyTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,6 @@ public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
|
|||||||
|
|
||||||
public static final String NODE_WINDOWS = "windows";
|
public static final String NODE_WINDOWS = "windows";
|
||||||
public static final String NODE_TABLES = "tables";
|
public static final String NODE_TABLES = "tables";
|
||||||
private static final String UI_THEME = "UITheme";
|
|
||||||
private static final String UI_FONT_SIZE = "UIFontSize";
|
private static final String UI_FONT_SIZE = "UIFontSize";
|
||||||
public static final String UPDATE_PLATFORM = "UpdatePlatform";
|
public static final String UPDATE_PLATFORM = "UpdatePlatform";
|
||||||
|
|
||||||
@ -114,16 +113,16 @@ public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void fillDefaultComponentColors() {
|
private void fillDefaultComponentColors() {
|
||||||
DEFAULT_COLORS.put(BodyComponent.class, getUITheme().getDefaultBodyComponentColor());
|
DEFAULT_COLORS.put(BodyComponent.class, getUIThemeAsTheme().getDefaultBodyComponentColor());
|
||||||
DEFAULT_COLORS.put(TubeFinSet.class, getUITheme().getDefaultTubeFinSetColor());
|
DEFAULT_COLORS.put(TubeFinSet.class, getUIThemeAsTheme().getDefaultTubeFinSetColor());
|
||||||
DEFAULT_COLORS.put(FinSet.class, getUITheme().getDefaultFinSetColor());
|
DEFAULT_COLORS.put(FinSet.class, getUIThemeAsTheme().getDefaultFinSetColor());
|
||||||
DEFAULT_COLORS.put(LaunchLug.class, getUITheme().getDefaultLaunchLugColor());
|
DEFAULT_COLORS.put(LaunchLug.class, getUIThemeAsTheme().getDefaultLaunchLugColor());
|
||||||
DEFAULT_COLORS.put(RailButton.class, getUITheme().getDefaultRailButtonColor());
|
DEFAULT_COLORS.put(RailButton.class, getUIThemeAsTheme().getDefaultRailButtonColor());
|
||||||
DEFAULT_COLORS.put(InternalComponent.class, getUITheme().getDefaultInternalComponentColor());
|
DEFAULT_COLORS.put(InternalComponent.class, getUIThemeAsTheme().getDefaultInternalComponentColor());
|
||||||
DEFAULT_COLORS.put(MassObject.class, getUITheme().getDefaultMassObjectColor());
|
DEFAULT_COLORS.put(MassObject.class, getUIThemeAsTheme().getDefaultMassObjectColor());
|
||||||
DEFAULT_COLORS.put(RecoveryDevice.class, getUITheme().getDefaultRecoveryDeviceColor());
|
DEFAULT_COLORS.put(RecoveryDevice.class, getUIThemeAsTheme().getDefaultRecoveryDeviceColor());
|
||||||
DEFAULT_COLORS.put(PodSet.class, getUITheme().getDefaultPodSetColor());
|
DEFAULT_COLORS.put(PodSet.class, getUIThemeAsTheme().getDefaultPodSetColor());
|
||||||
DEFAULT_COLORS.put(ParallelStage.class, getUITheme().getDefaultParallelStageColor());
|
DEFAULT_COLORS.put(ParallelStage.class, getUIThemeAsTheme().getDefaultParallelStageColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNodename() {
|
public String getNodename() {
|
||||||
@ -332,8 +331,13 @@ public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
|
|||||||
* Get the current theme used for the UI.
|
* Get the current theme used for the UI.
|
||||||
* @return the current theme
|
* @return the current theme
|
||||||
*/
|
*/
|
||||||
public UITheme.Theme getUITheme() {
|
@Override
|
||||||
String theme = getString(UI_THEME, UITheme.Themes.LIGHT.name());
|
public Object getUITheme() {
|
||||||
|
return getUIThemeAsTheme();
|
||||||
|
}
|
||||||
|
|
||||||
|
private UITheme.Theme getUIThemeAsTheme() {
|
||||||
|
String theme = getString(net.sf.openrocket.startup.Preferences.UI_THEME, UITheme.Themes.LIGHT.name());
|
||||||
if (theme == null) return UITheme.Themes.LIGHT; // Default theme
|
if (theme == null) return UITheme.Themes.LIGHT; // Default theme
|
||||||
return UITheme.Themes.valueOf(theme);
|
return UITheme.Themes.valueOf(theme);
|
||||||
}
|
}
|
||||||
@ -342,9 +346,10 @@ public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
|
|||||||
* Set the theme used for the UI.
|
* Set the theme used for the UI.
|
||||||
* @param theme the theme to set
|
* @param theme the theme to set
|
||||||
*/
|
*/
|
||||||
public void setUITheme(UITheme.Theme theme) {
|
@Override
|
||||||
if (theme == null) return;
|
public void setUITheme(Object theme) {
|
||||||
putString(UI_THEME, theme.name());
|
if (!(theme instanceof UITheme.Theme)) return;
|
||||||
|
putString(net.sf.openrocket.startup.Preferences.UI_THEME, ((UITheme.Theme) theme).name());
|
||||||
storeVersion();
|
storeVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,13 +387,13 @@ public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
|
|||||||
public net.sf.openrocket.util.Color getDefaultColor(Class<? extends RocketComponent> c) {
|
public net.sf.openrocket.util.Color getDefaultColor(Class<? extends RocketComponent> c) {
|
||||||
String color = get("componentColors", c, DEFAULT_COLORS);
|
String color = get("componentColors", c, DEFAULT_COLORS);
|
||||||
if (color == null)
|
if (color == null)
|
||||||
return net.sf.openrocket.util.Color.fromAWTColor(getUITheme().getTextColor());
|
return net.sf.openrocket.util.Color.fromAWTColor(getUIThemeAsTheme().getTextColor());
|
||||||
|
|
||||||
net.sf.openrocket.util.Color clr = parseColor(color);
|
net.sf.openrocket.util.Color clr = parseColor(color);
|
||||||
if (clr != null) {
|
if (clr != null) {
|
||||||
return clr;
|
return clr;
|
||||||
} else {
|
} else {
|
||||||
return net.sf.openrocket.util.Color.fromAWTColor(getUITheme().getTextColor());
|
return net.sf.openrocket.util.Color.fromAWTColor(getUIThemeAsTheme().getTextColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ import com.github.weisj.darklaf.theme.DarculaTheme;
|
|||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
@ -19,6 +21,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class UITheme {
|
public class UITheme {
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(UITheme.class);
|
||||||
|
|
||||||
public interface Theme {
|
public interface Theme {
|
||||||
void applyTheme();
|
void applyTheme();
|
||||||
@ -299,7 +302,7 @@ public class UITheme {
|
|||||||
theme.apply(textArea);
|
theme.apply(textArea);
|
||||||
textArea.setCurrentLineHighlightColor(new Color(255, 255, 230));
|
textArea.setCurrentLineHighlightColor(new Color(255, 255, 230));
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
ioe.printStackTrace();
|
log.warn("Unable to load RSyntaxTextArea theme", ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -521,7 +524,7 @@ public class UITheme {
|
|||||||
"/org/fife/ui/rsyntaxtextarea/themes/dark.xml"));
|
"/org/fife/ui/rsyntaxtextarea/themes/dark.xml"));
|
||||||
theme.apply(textArea);
|
theme.apply(textArea);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
ioe.printStackTrace();
|
log.warn("Unable to load RSyntaxTextArea theme", ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package net.sf.openrocket.gui.widgets;
|
package net.sf.openrocket.gui.widgets;
|
||||||
|
|
||||||
|
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.util.UITheme;
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
|
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
@ -11,12 +9,10 @@ import javax.swing.JButton;
|
|||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.event.ChangeEvent;
|
import javax.swing.event.ChangeEvent;
|
||||||
import javax.swing.event.ChangeListener;
|
import javax.swing.event.ChangeListener;
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.event.FocusAdapter;
|
import java.awt.event.FocusAdapter;
|
||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
|
|
||||||
public class SelectColorButton extends JButton {
|
public class SelectColorButton extends JButton {
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
public SelectColorButton() {
|
public SelectColorButton() {
|
||||||
addChangeListenerSelectColor();
|
addChangeListenerSelectColor();
|
||||||
@ -43,7 +39,7 @@ public class SelectColorButton extends JButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addChangeListenerSelectColor() {
|
private void addChangeListenerSelectColor() {
|
||||||
if ((prefs.getUITheme() != UITheme.Themes.LIGHT) ||
|
if ((GUIUtil.getUITheme() != UITheme.Themes.LIGHT) ||
|
||||||
(UIManager.getColor("Button.selectForeground") == null) ||
|
(UIManager.getColor("Button.selectForeground") == null) ||
|
||||||
(UIManager.getColor("Button.foreground") == null))
|
(UIManager.getColor("Button.foreground") == null))
|
||||||
return;
|
return;
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package net.sf.openrocket.gui.widgets;
|
package net.sf.openrocket.gui.widgets;
|
||||||
|
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.gui.util.UITheme;
|
import net.sf.openrocket.gui.util.UITheme;
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
|
|
||||||
import javax.swing.JToggleButton;
|
import javax.swing.JToggleButton;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
@ -18,7 +17,6 @@ import java.beans.PropertyChangeListener;
|
|||||||
* @author Sibo Van Gool <sibo.vangool@hotmail.com>
|
* @author Sibo Van Gool <sibo.vangool@hotmail.com>
|
||||||
*/
|
*/
|
||||||
public class SelectColorToggleButton extends JToggleButton {
|
public class SelectColorToggleButton extends JToggleButton {
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
public SelectColorToggleButton(Action a) {
|
public SelectColorToggleButton(Action a) {
|
||||||
super(a);
|
super(a);
|
||||||
@ -66,7 +64,7 @@ public class SelectColorToggleButton extends JToggleButton {
|
|||||||
* This is to fix an issue on OSX devices where the foreground color would be black on blue (hardly readable)
|
* This is to fix an issue on OSX devices where the foreground color would be black on blue (hardly readable)
|
||||||
*/
|
*/
|
||||||
private void addChangeListenerSelectColor() {
|
private void addChangeListenerSelectColor() {
|
||||||
if ((prefs.getUITheme() != UITheme.Themes.LIGHT) ||
|
if ((GUIUtil.getUITheme() != UITheme.Themes.LIGHT) ||
|
||||||
(UIManager.getColor("ToggleButton.selectForeground") == null) ||
|
(UIManager.getColor("ToggleButton.selectForeground") == null) ||
|
||||||
(UIManager.getColor("ToggleButton.foreground") == null))
|
(UIManager.getColor("ToggleButton.foreground") == null))
|
||||||
return;
|
return;
|
||||||
|
@ -9,12 +9,11 @@ import javax.swing.event.DocumentListener;
|
|||||||
|
|
||||||
import net.sf.openrocket.document.Simulation;
|
import net.sf.openrocket.document.Simulation;
|
||||||
import net.sf.openrocket.gui.components.StyledLabel;
|
import net.sf.openrocket.gui.components.StyledLabel;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.plugin.Plugin;
|
import net.sf.openrocket.plugin.Plugin;
|
||||||
import net.sf.openrocket.simulation.extension.AbstractSwingSimulationExtensionConfigurator;
|
import net.sf.openrocket.simulation.extension.AbstractSwingSimulationExtensionConfigurator;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.util.Color;
|
|
||||||
|
|
||||||
@Plugin
|
@Plugin
|
||||||
public class JavaCodeConfigurator extends AbstractSwingSimulationExtensionConfigurator<JavaCode> {
|
public class JavaCodeConfigurator extends AbstractSwingSimulationExtensionConfigurator<JavaCode> {
|
||||||
@ -23,7 +22,6 @@ public class JavaCodeConfigurator extends AbstractSwingSimulationExtensionConfig
|
|||||||
private StyledLabel errorMsg;
|
private StyledLabel errorMsg;
|
||||||
|
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
public JavaCodeConfigurator() {
|
public JavaCodeConfigurator() {
|
||||||
super(JavaCode.class);
|
super(JavaCode.class);
|
||||||
@ -37,7 +35,7 @@ public class JavaCodeConfigurator extends AbstractSwingSimulationExtensionConfig
|
|||||||
classNameField = new JTextField(extension.getClassName());
|
classNameField = new JTextField(extension.getClassName());
|
||||||
panel.add(classNameField, "growx, wrap");
|
panel.add(classNameField, "growx, wrap");
|
||||||
this.errorMsg = new StyledLabel();
|
this.errorMsg = new StyledLabel();
|
||||||
errorMsg.setFontColor(prefs.getUITheme().getDarkWarningColor());
|
errorMsg.setFontColor(GUIUtil.getUITheme().getDarkWarningColor());
|
||||||
errorMsg.setVisible(false);
|
errorMsg.setVisible(false);
|
||||||
panel.add(errorMsg, "growx, wrap");
|
panel.add(errorMsg, "growx, wrap");
|
||||||
|
|
||||||
|
@ -19,12 +19,11 @@ import net.sf.openrocket.document.Simulation;
|
|||||||
import net.sf.openrocket.gui.adaptors.BooleanModel;
|
import net.sf.openrocket.gui.adaptors.BooleanModel;
|
||||||
import net.sf.openrocket.gui.components.StyledLabel;
|
import net.sf.openrocket.gui.components.StyledLabel;
|
||||||
import net.sf.openrocket.gui.components.StyledLabel.Style;
|
import net.sf.openrocket.gui.components.StyledLabel.Style;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.plugin.Plugin;
|
import net.sf.openrocket.plugin.Plugin;
|
||||||
import net.sf.openrocket.simulation.extension.AbstractSwingSimulationExtensionConfigurator;
|
import net.sf.openrocket.simulation.extension.AbstractSwingSimulationExtensionConfigurator;
|
||||||
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
||||||
|
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
||||||
import org.fife.ui.rsyntaxtextarea.TokenMakerFactory;
|
import org.fife.ui.rsyntaxtextarea.TokenMakerFactory;
|
||||||
@ -44,8 +43,6 @@ public class ScriptingConfigurator extends AbstractSwingSimulationExtensionConfi
|
|||||||
private ScriptingExtension extension;
|
private ScriptingExtension extension;
|
||||||
private Simulation simulation;
|
private Simulation simulation;
|
||||||
|
|
||||||
private static final SwingPreferences prefs = (SwingPreferences) Application.getPreferences();
|
|
||||||
|
|
||||||
public ScriptingConfigurator() {
|
public ScriptingConfigurator() {
|
||||||
super(ScriptingExtension.class);
|
super(ScriptingExtension.class);
|
||||||
}
|
}
|
||||||
@ -74,7 +71,7 @@ public class ScriptingConfigurator extends AbstractSwingSimulationExtensionConfi
|
|||||||
text.setLineWrap(true);
|
text.setLineWrap(true);
|
||||||
text.setWrapStyleWord(true);
|
text.setWrapStyleWord(true);
|
||||||
text.setEditable(true);
|
text.setEditable(true);
|
||||||
prefs.getUITheme().formatScriptTextArea(text);
|
GUIUtil.getUITheme().formatScriptTextArea(text);
|
||||||
text.addFocusListener(new FocusListener() {
|
text.addFocusListener(new FocusListener() {
|
||||||
@Override
|
@Override
|
||||||
public void focusGained(FocusEvent event) {
|
public void focusGained(FocusEvent event) {
|
||||||
|
@ -200,7 +200,7 @@ public class SwingStartup {
|
|||||||
|
|
||||||
// Set the look-and-feel
|
// Set the look-and-feel
|
||||||
log.info("Setting LAF");
|
log.info("Setting LAF");
|
||||||
GUIUtil.setLAF();
|
GUIUtil.applyLAF();
|
||||||
|
|
||||||
// Set tooltip delay time. Tooltips are used in MotorChooserDialog extensively.
|
// Set tooltip delay time. Tooltips are used in MotorChooserDialog extensively.
|
||||||
ToolTipManager.sharedInstance().setDismissDelay(30000);
|
ToolTipManager.sharedInstance().setDismissDelay(30000);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user