diff options
| author | Paul Buetow <paul@buetow.org> | 2025-06-15 23:30:56 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-06-15 23:30:56 +0300 |
| commit | a568f3f5923e0af77c89e2c8e2bf6b808f29d069 (patch) | |
| tree | 727d6fe7790c556326a561da9c7a24d1e6914c28 | |
| parent | d51c22e7e1f37c527ccd0f929719c39f94c565a4 (diff) | |
Add splash screen functionality and update build documentation
- Add VSSplashScreen component using Java Swing framework
- Display splash.png image for 3 seconds on application startup
- Scale splash screen to 40% of original size (60% reduction)
- Update CLAUDE.md with JAVA_HOME setup instructions for all platforms
- Integrate splash screen into VSMain startup sequence
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
| -rw-r--r-- | CLAUDE.md | 8 | ||||
| -rw-r--r-- | src/main/java/simulator/VSMain.java | 12 | ||||
| -rw-r--r-- | src/main/java/simulator/VSSplashScreen.java | 89 | ||||
| -rw-r--r-- | src/main/resources/splash.png | bin | 0 -> 399548 bytes |
4 files changed, 109 insertions, 0 deletions
@@ -4,6 +4,14 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co ## Build and Development Commands +**Prerequisites:** +```bash +# Set JAVA_HOME if not already configured +export JAVA_HOME=/usr/lib/jvm/java-21-openjdk +# Or on macOS with Homebrew: export JAVA_HOME=$(/usr/libexec/java_home -v 21) +# Or on Windows: set JAVA_HOME=C:\Program Files\Eclipse Adoptium\jdk-21.0.x-hotspot +``` + **Essential Commands:** ```bash # Full build (recommended) diff --git a/src/main/java/simulator/VSMain.java b/src/main/java/simulator/VSMain.java index 46077ec..02f3e20 100644 --- a/src/main/java/simulator/VSMain.java +++ b/src/main/java/simulator/VSMain.java @@ -56,6 +56,10 @@ public class VSMain { * @param args the arguments */ public static void main(String[] args) { + // Show splash screen + VSSplashScreen splash = new VSSplashScreen(); + splash.showSplash(); + try { UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName()); @@ -65,6 +69,14 @@ public class VSMain { javax.swing.JPopupMenu.setDefaultLightWeightPopupEnabled(false); VSPrefs prefs = VSDefaultPrefs.init(); VSRegisteredEvents.init(prefs); + + // Wait for splash screen to finish before showing main window + try { + Thread.sleep(3000); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + new VSMain(prefs); } } diff --git a/src/main/java/simulator/VSSplashScreen.java b/src/main/java/simulator/VSSplashScreen.java new file mode 100644 index 0000000..d8e97d6 --- /dev/null +++ b/src/main/java/simulator/VSSplashScreen.java @@ -0,0 +1,89 @@ +package simulator; + +import javax.swing.*; +import java.awt.*; +import java.awt.image.BufferedImage; +import javax.imageio.ImageIO; +import java.io.IOException; +import java.io.InputStream; + +/** + * Splash screen for the DS-Sim application + * + * @author Paul C. Buetow + */ +public class VSSplashScreen extends JWindow { + private static final int DISPLAY_TIME = 3000; // 3 seconds + + /** + * Creates and shows the splash screen + */ + public VSSplashScreen() { + initSplashScreen(); + } + + /** + * Initialize the splash screen components + */ + private void initSplashScreen() { + try { + // Load the splash image from resources + InputStream imageStream = getClass().getResourceAsStream("/splash.png"); + if (imageStream == null) { + // Fallback if image not found + showTextSplash(); + return; + } + + BufferedImage splashImage = ImageIO.read(imageStream); + + // Reduce size by 60% (scale to 40% of original) + int scaledWidth = (int)(splashImage.getWidth() * 0.4); + int scaledHeight = (int)(splashImage.getHeight() * 0.4); + + Image scaledImage = splashImage.getScaledInstance(scaledWidth, scaledHeight, Image.SCALE_SMOOTH); + ImageIcon splashIcon = new ImageIcon(scaledImage); + + JLabel splashLabel = new JLabel(splashIcon); + splashLabel.setHorizontalAlignment(JLabel.CENTER); + + getContentPane().add(splashLabel, BorderLayout.CENTER); + + // Set window properties + setSize(scaledWidth, scaledHeight); + setLocationRelativeTo(null); // Center on screen + + } catch (IOException e) { + // Fallback to text splash if image loading fails + showTextSplash(); + } + } + + /** + * Fallback text-based splash screen + */ + private void showTextSplash() { + JLabel textLabel = new JLabel("DS-Sim", JLabel.CENTER); + textLabel.setFont(new Font("Arial", Font.BOLD, 24)); + textLabel.setPreferredSize(new Dimension(300, 100)); + + getContentPane().add(textLabel, BorderLayout.CENTER); + setSize(300, 100); + setLocationRelativeTo(null); + } + + /** + * Shows the splash screen for the specified duration + */ + public void showSplash() { + setVisible(true); + + // Use a timer to hide the splash screen after the specified time + Timer timer = new Timer(DISPLAY_TIME, e -> { + setVisible(false); + dispose(); + }); + timer.setRepeats(false); + timer.start(); + } +}
\ No newline at end of file diff --git a/src/main/resources/splash.png b/src/main/resources/splash.png Binary files differnew file mode 100644 index 0000000..c40c314 --- /dev/null +++ b/src/main/resources/splash.png |
