From 4310cd4b5178b0a0dd83d5ff9d5607e95121e701 Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Sun, 21 Dec 2014 10:11:06 -0700 Subject: [PATCH] RocketInfo font size now configurable in option. Small is 11, medium is 14, large is 17. Corrected spelling on PrefChoiseSelector name, will get the translation keys some other time. Added LineMetrics.descent to the line height for laying out the text in RocketInfo. --- core/resources/l10n/messages.properties | 4 ++++ .../net/sf/openrocket/startup/Preferences.java | 6 ++++++ .../dialogs/preferences/PreferencesDialog.java | 18 ++++++++++++++---- .../gui/figureelements/RocketInfo.java | 10 +++++++--- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index 11ccd3456..c7ff43ba6 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -274,6 +274,10 @@ pref.dlg.ZIParchives = ZIP archives (*.zip) pref.dlg.checkbox.Checkupdates = Check for software updates at startup pref.dlg.ttip.Checkupdatesnow = Check for software updates now pref.dlg.lbl.Selectprefunits = Select your preferred units: +pref.dlg.lbl.Rocketinfofontsize = Size of text in rocket design panel: +pref.dlg.PrefFontSmall = Small +pref.dlg.PrefFontMedium = Medium +pref.dlg.PrefFontLarge = Large pref.dlg.lbl.Rocketdimensions = Rocket dimensions: pref.dlg.lbl.Linedensity = Line density: pref.dlg.lbl.Motordimensions = Motor dimensions: diff --git a/core/src/net/sf/openrocket/startup/Preferences.java b/core/src/net/sf/openrocket/startup/Preferences.java index 07e9d36c5..16d9721d1 100644 --- a/core/src/net/sf/openrocket/startup/Preferences.java +++ b/core/src/net/sf/openrocket/startup/Preferences.java @@ -55,6 +55,8 @@ public abstract class Preferences { public static final String OPENGL_ENABLE_AA = "OpenGL_Antialiasing_Is_Enabled"; public static final String OPENGL_USE_FBO = "OpenGL_Use_FBO"; + public static final String ROCKET_INFO_FONT_SIZE = "RocketInfoFontSize"; + /* * ****************************************************************************************** * @@ -104,6 +106,10 @@ public abstract class Preferences { return 0.3; } + public final float getRocketInfoFontSize() { + return (float) (11.0 + 3 * Application.getPreferences().getChoice(Preferences.ROCKET_INFO_FONT_SIZE, 2, 0)); + } + /** * Enable/Disable the auto-opening of the last edited design file on startup. */ diff --git a/swing/src/net/sf/openrocket/gui/dialogs/preferences/PreferencesDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/preferences/PreferencesDialog.java index c76ad6fe0..f60b54b55 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/preferences/PreferencesDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/preferences/PreferencesDialog.java @@ -164,7 +164,7 @@ public class PreferencesDialog extends JDialog { //// Position to insert new body components: panel.add(new JLabel(trans.get("pref.dlg.lbl.Positiontoinsert")), "gapright para"); - panel.add(new JComboBox(new PrefChoiseSelector(Preferences.BODY_COMPONENT_INSERT_POSITION_KEY, + panel.add(new JComboBox(new PrefChoiceSelector(Preferences.BODY_COMPONENT_INSERT_POSITION_KEY, //// Always ask //// Insert in middle //// Add to end @@ -178,7 +178,17 @@ public class PreferencesDialog extends JDialog { //// Delete //// Confirm trans.get("pref.dlg.PrefBooleanSelector1"), - trans.get("pref.dlg.PrefBooleanSelector2"), true)), "wrap 40lp, growx, sg combos"); + trans.get("pref.dlg.PrefBooleanSelector2"), true)), "wrap, growx, sg combos"); + //// Position to insert new body components: + panel.add(new JLabel(trans.get("pref.dlg.lbl.Rocketinfofontsize")), "gapright para"); + + panel.add(new JComboBox(new PrefChoiceSelector(Preferences.ROCKET_INFO_FONT_SIZE, + //// Small + //// Medium + //// Large + trans.get("pref.dlg.PrefFontSmall"), + trans.get("pref.dlg.PrefFontMedium"), + trans.get("pref.dlg.PrefFontLarge"))), "wrap 40lp, growx, sg combos"); //// User-defined thrust curves: panel.add(new JLabel(trans.get("pref.dlg.lbl.User-definedthrust")), "spanx, wrap"); @@ -673,11 +683,11 @@ public class PreferencesDialog extends JDialog { - private class PrefChoiseSelector extends AbstractListModel implements ComboBoxModel { + private class PrefChoiceSelector extends AbstractListModel implements ComboBoxModel { private final String preference; private final String[] descriptions; - public PrefChoiseSelector(String preference, String... descriptions) { + public PrefChoiceSelector(String preference, String... descriptions) { this.preference = preference; this.descriptions = descriptions; } diff --git a/swing/src/net/sf/openrocket/gui/figureelements/RocketInfo.java b/swing/src/net/sf/openrocket/gui/figureelements/RocketInfo.java index 27849cd2f..16f7cf3f2 100644 --- a/swing/src/net/sf/openrocket/gui/figureelements/RocketInfo.java +++ b/swing/src/net/sf/openrocket/gui/figureelements/RocketInfo.java @@ -77,7 +77,9 @@ public class RocketInfo implements FigureElement { public void paint(Graphics2D myG2, double scale, Rectangle visible) { this.g2 = myG2; this.line = FONT.getLineMetrics("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", - myG2.getFontRenderContext()).getHeight(); + myG2.getFontRenderContext()).getHeight() + + FONT.getLineMetrics("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", + myG2.getFontRenderContext()).getDescent(); x1 = visible.x + MARGIN; x2 = visible.x + visible.width - MARGIN; @@ -429,11 +431,13 @@ public class RocketInfo implements FigureElement { private GlyphVector createText(String text) { - return FONT.createGlyphVector(g2.getFontRenderContext(), text); + float size=Application.getPreferences().getRocketInfoFontSize(); + return (FONT.deriveFont(size)).createGlyphVector(g2.getFontRenderContext(), text); } private GlyphVector createSmallText(String text) { - return SMALLFONT.createGlyphVector(g2.getFontRenderContext(), text); + float size=(float) (Application.getPreferences().getRocketInfoFontSize()-2.0); + return (SMALLFONT.deriveFont(size)).createGlyphVector(g2.getFontRenderContext(), text); } }