This is an automated email from the ASF dual-hosted git repository. ebakke pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/netbeans.git
commit 437a29d603774e93c4beb3c0eb8dd5caea5e9c49 Author: Eirik Bakke <eba...@ultorg.com> AuthorDate: Sat May 11 05:19:04 2019 +0200 Added the ability to have a version string automatically added to the splash screen. Also added a horizontal alignment setting for the splash screen text box settings. --- platform/core.startup/apichanges.xml | 18 +++++++++++ .../src/org/netbeans/core/startup/Splash.java | 37 ++++++++++++++++++++-- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/platform/core.startup/apichanges.xml b/platform/core.startup/apichanges.xml index 376dde4..ab4d6ed 100644 --- a/platform/core.startup/apichanges.xml +++ b/platform/core.startup/apichanges.xml @@ -32,6 +32,24 @@ <!-- ACTUAL CHANGES BEGIN HERE: --> <changes> + <change id="splash.screen.version.option"> + <summary> + An optional version string can be added to the splash screen. + </summary> + <version major="1" minor="61"/> + <date day="11" month="5" year="2019"/> + <author login="ebakke"/> + <compatibility addition="yes" binary="compatible" source="compatible"/> + <description> + <p> + Branding bundles may now include the SplashVersionTextBounds, + SplashVersionTextFontSize, SplashVersionTextFontType, + SplashVersionTextColor, and SplashVersionTextHorizontalAlignment + properties in order to display the application's product version + and build number in the startup splash screen. + </p> + </description> + </change> <change id="core.base.split"> <api name="bridge"/> <summary> diff --git a/platform/core.startup/src/org/netbeans/core/startup/Splash.java b/platform/core.startup/src/org/netbeans/core/startup/Splash.java index 7bb15ea..8a2e59f 100644 --- a/platform/core.startup/src/org/netbeans/core/startup/Splash.java +++ b/platform/core.startup/src/org/netbeans/core/startup/Splash.java @@ -27,6 +27,7 @@ import java.awt.image.BufferedImage; import java.io.DataOutputStream; import java.io.IOException; import java.util.Arrays; +import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; import java.util.StringTokenizer; @@ -277,17 +278,20 @@ public final class Splash implements Stamps.Updater { final int textSize; final Font font; final FontMetrics fm; + final int horizontalAlignment; // Will be set by SwingUtilities.layoutCompoundLabel. final Rectangle effectiveBounds = new Rectangle(); private TextBox( - Rectangle bounds, Color color, int textSize, Font font, FontMetrics fontMetrics) + Rectangle bounds, Color color, int textSize, Font font, FontMetrics fontMetrics, + int horizontalAlignment) { this.bounds = bounds; this.color = color; this.textSize = textSize; this.font = font; this.fm = fontMetrics; + this.horizontalAlignment = horizontalAlignment; } /** @@ -300,7 +304,7 @@ public final class Splash implements Stamps.Updater { return; } SwingUtilities.layoutCompoundLabel(fm, text, null, - BOTTOM, LEFT, BOTTOM, LEFT, + BOTTOM, horizontalAlignment, BOTTOM, horizontalAlignment, bounds, new Rectangle(), effectiveBounds, 0); if (graphics != null) { graphics.setColor(color); @@ -339,6 +343,26 @@ public final class Splash implements Stamps.Updater { } catch (NumberFormatException nfe) { //ignore - use default size } + int horizontalAlignment = LEFT; + try { + switch (bundle.getString(prefix + "HorizontalAlignment").toLowerCase(Locale.US)) { + case "left": + horizontalAlignment = SwingConstants.LEFT; + break; + case "center": + horizontalAlignment = SwingConstants.CENTER; + break; + case "right": + horizontalAlignment = SwingConstants.RIGHT; + break; + default: + // Ignore; use default + Util.err.warning( + "Invalid horizontal alignment for splash screen text box"); //NOI18N + } + } catch (MissingResourceException e) { + // Ignore; use default + } Font font = new Font(bundle.getString(prefix + "FontType"), Font.PLAIN, size); // NOI18N FontMetrics fontMetrics; if (comp != null) { @@ -346,12 +370,14 @@ public final class Splash implements Stamps.Updater { } else { fontMetrics = graphics.getFontMetrics(font); } - return new TextBox(bounds, color, size, font, fontMetrics); + return new TextBox(bounds, color, size, font, fontMetrics, horizontalAlignment); } } private static class SplashPainter { TextBox statusBox; + // May be null. + TextBox versionBox; Color color_bar; Color color_edge; Color color_corner; @@ -389,6 +415,7 @@ public final class Splash implements Stamps.Updater { ResourceBundle bundle = NbBundle.getBundle(Splash.class); statusBox = TextBox.parse(graphics, comp, bundle, "SplashRunningText", false); + versionBox = TextBox.parse(graphics, comp, bundle, "SplashVersionText", true); StringTokenizer st = new StringTokenizer( bundle.getString("SplashProgressBarBounds"), " ,"); // NOI18N try { @@ -579,6 +606,10 @@ public final class Splash implements Stamps.Updater { g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + if (versionBox != null) { + String buildNumber = System.getProperty("netbeans.buildnumber"); + versionBox.layout(NbBundle.getMessage(TopLogging.class, "currentVersion", buildNumber), graphics); + } if (text != null) { statusBox.layout(text, graphics); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists