move the splash screen to a separate bundle

cusax-fix
Yana Stamcheva 19 years ago
parent 190951a86f
commit c5f27fb1c6

@ -725,7 +725,7 @@
bundle-plugin-msnaccregwizz,bundle-plugin-sipaccregwizz,
bundle-plugin-yahooaccregwizz,
bundle-version,bundle-version-impl,bundle-shutdown,
bundle-growlnotification,bundle-audionotifier"/>
bundle-growlnotification,bundle-audionotifier,bundle-plugin-splashscreen"/>
<!--BUNDLE-HISTORY-->
<target name="bundle-history">
@ -1259,4 +1259,14 @@ javax.swing.event, javax.swing.border"/>
prefix="net/java/sip/communicator/plugin/exampleplugin"/>
</jar>
</target>
<!-- BUNDLE-PLUGIN-SPLASH SCREEN -->
<target name="bundle-plugin-splashscreen">
<!-- Creates a bundle for the Splash Screen plugin.-->
<jar compress="false" destfile="${bundles.dest}/splashscreen.jar"
manifest="src/net/java/sip/communicator/plugin/splashscreen/splashscreen.manifest.mf">
<zipfileset dir="${dest}/net/java/sip/communicator/plugin/exampleplugin"
prefix="net/java/sip/communicator/plugin/exampleplugin"/>
</jar>
</target>
</project>

@ -45,10 +45,12 @@ felix.auto.start.1= reference:file:lib/bundle/org.apache.felix.servicebinder-0.8
felix.auto.start.2= \
reference:file:sc-bundles/util.jar
felix.auto.start.3= \
felix.auto.start.4= \
reference:file:sc-bundles/configuration.jar \
reference:file:sc-bundles/version.jar \
reference:file:sc-bundles/version-impl.jar \
reference:file:sc-bundles/splashscreen.jar \
reference:file:sc-bundles/fileaccess.jar \
reference:file:sc-bundles/protocol.jar \
reference:file:sc-bundles/contactlist.jar \
@ -61,7 +63,7 @@ felix.auto.start.3= \
reference:file:sc-bundles/netaddr.jar \
reference:file:sc-bundles/meta-cl.jar
felix.auto.start.4= \
felix.auto.start.5= \
reference:file:sc-bundles/history.jar \
reference:file:sc-bundles/msghistory.jar \
reference:file:sc-bundles/callhistory.jar \

@ -10,11 +10,8 @@
import javax.swing.*;
import org.osgi.framework.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.main.login.*;
import net.java.sip.communicator.launcher.*;
import net.java.sip.communicator.launcher.WelcomeWindow.*;
import net.java.sip.communicator.service.audionotifier.*;
import net.java.sip.communicator.service.callhistory.*;
import net.java.sip.communicator.service.configuration.*;
@ -24,6 +21,8 @@
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
import org.osgi.framework.*;
/**
* The GUI Activator class.
*
@ -88,9 +87,6 @@ public void start(BundleContext bundleContext) throws Exception {
logger.info("UI Service ...[REGISTERED]");
//used by the splash screen to determine when the ui service is started
System.setProperty("uiService", "started");
communicatorMain.showCommunicator(true);
SwingUtilities.invokeLater(new RunLogin());
}

@ -22,12 +22,7 @@ public class SIPCommunicator
*/
public static void main(String[] args)
throws Exception
{
WelcomeWindow welcomeWindow = new WelcomeWindow();
welcomeWindow.pack();
welcomeWindow.setVisible(true);
{
Main.main(args);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

@ -0,0 +1,57 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.splashscreen;
import net.java.sip.communicator.service.gui.*;
import org.osgi.framework.*;
public class SplashScreenActivator
implements BundleActivator,
ServiceListener,
BundleListener
{
private WelcomeWindow welcomeWindow;
private BundleContext bundleContext;
public void start(BundleContext bundleContext) throws Exception
{
this.bundleContext = bundleContext;
welcomeWindow = new WelcomeWindow();
welcomeWindow.pack();
welcomeWindow.setVisible(true);
this.bundleContext.addServiceListener(this);
this.bundleContext.addBundleListener(this);
}
public void stop(BundleContext arg0) throws Exception
{
}
public void serviceChanged(ServiceEvent evt)
{
ServiceReference serviceRef = evt.getServiceReference();
if(serviceRef.getBundle().getState() != Bundle.STARTING)
return;
if (bundleContext.getServiceReference(UIService.class.getName())
== serviceRef)
{
this.welcomeWindow.close();
}
}
public void bundleChanged(BundleEvent evt)
{
welcomeWindow.setBundle(evt.getBundle().getHeaders().get("Bundle-Name").toString());
}
}

@ -1,15 +1,11 @@
package net.java.sip.communicator.launcher;
package net.java.sip.communicator.plugin.splashscreen;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
public class WelcomeWindow
extends JDialog
implements ActionListener
{
private WindowBackground mainPanel
= new WindowBackground();
@ -17,8 +13,8 @@ public class WelcomeWindow
private JLabel titleLabel = new JLabel(
"SIP Communicator");
//private JLabel versionLabel = new JLabel(
// " " + System.getProperty("sip-communicator.version"));
private JLabel versionLabel = new JLabel(
" " + System.getProperty("sip-communicator.version"));
private JTextArea logoArea
= new JTextArea("Open Source VoIP & Instant Messaging");
@ -38,6 +34,12 @@ public class WelcomeWindow
private static final Font FONT = new Font(FONT_NAME, Font.PLAIN,
new Integer(FONT_SIZE).intValue());
private JPanel loadingPanel = new JPanel(new BorderLayout());
private JLabel loadingLabel = new JLabel("Loading: ");
private JLabel bundleLabel = new JLabel();
public WelcomeWindow()
{
this.setTitle("SIP Communicator");
@ -48,16 +50,16 @@ public WelcomeWindow()
this.textPanel.setPreferredSize(new Dimension(470, 240));
this.textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS));
this.textPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
this.textPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 0, 15));
this.textPanel.setOpaque(false);
this.titleLabel.setFont(FONT.deriveFont(Font.BOLD, 28));
this.titleLabel.setForeground(DARK_BLUE);
this.titleLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
//this.versionLabel.setFont(FONT.deriveFont(Font.BOLD, 18));
//this.versionLabel.setForeground(Color.GRAY);
//this.versionLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
this.versionLabel.setFont(FONT.deriveFont(Font.BOLD, 18));
this.versionLabel.setForeground(Color.GRAY);
this.versionLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
this.logoArea.setFont(FONT.deriveFont(Font.BOLD, 12));
this.logoArea.setForeground(DARK_BLUE);
@ -67,7 +69,7 @@ public WelcomeWindow()
this.logoArea.setEditable(false);
this.logoArea.setPreferredSize(new Dimension(100, 20));
this.logoArea.setAlignmentX(Component.RIGHT_ALIGNMENT);
this.logoArea.setBorder(BorderFactory.createEmptyBorder(20, 200, 0, 0));
this.logoArea.setBorder(BorderFactory.createEmptyBorder(20, 180, 0, 0));
this.rightsArea.setContentType("text/html");
this.rightsArea.setText(
@ -96,84 +98,45 @@ public WelcomeWindow()
this.licenseArea.setEditable(false);
this.licenseArea.setAlignmentX(Component.RIGHT_ALIGNMENT);
this.bundleLabel.setFont(loadingLabel.getFont().deriveFont(Font.PLAIN));
this.loadingPanel.setOpaque(false);
this.loadingPanel.add(loadingLabel, BorderLayout.WEST);
this.loadingPanel.add(bundleLabel, BorderLayout.CENTER);
this.loadingPanel.setAlignmentX(Component.RIGHT_ALIGNMENT);
this.textPanel.add(titleLabel);
//this.textPanel.add(versionLabel);
this.textPanel.add(versionLabel);
this.textPanel.add(logoArea);
this.textPanel.add(rightsArea);
this.textPanel.add(licenseArea);
this.mainPanel.add(textPanel, BorderLayout.CENTER);
this.mainPanel.add(loadingPanel, BorderLayout.SOUTH);
this.getContentPane().add(mainPanel);
this.setResizable(false);
this.mainPanel.setPreferredSize(new Dimension(527, 305));
this.mainPanel.setPreferredSize(new Dimension(570, 330));
this.setLocation(
Toolkit.getDefaultToolkit().getScreenSize().width/2
- 527/2,
Toolkit.getDefaultToolkit().getScreenSize().height/2
- 305/2
);
Timer timer = new Timer(200, this);
timer.setRepeats(true);
timer.start();
);
}
protected void close(boolean isEscaped)
protected void close()
{
this.dispose();
}
/**
* Constructs the window background in order to have a background image.
*/
private class WindowBackground extends JPanel {
private Image bgImage;
public WindowBackground() {
try
{
bgImage = ImageIO.read(
WelcomeWindow.class.getResource("aboutWindowBackground.png"));
}
catch (IOException e)
{
e.printStackTrace();
}
this.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
}
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
Graphics2D g2 = (Graphics2D) g;
g2.drawImage(bgImage, 0, 0, null);
g2.setColor(new Color(255, 255, 255, 100));
g2.fillRect(0, 0, getWidth(), getHeight());
}
}
public void actionPerformed(ActionEvent e)
public void setBundle(String bundleName)
{
if(System.getProperty("uiService") != null
&& System.getProperty("uiService").equals("started"))
{
this.dispose();
}
this.bundleLabel.setText(bundleName);
this.loadingPanel.revalidate();
this.loadingPanel.repaint();
}
}

@ -0,0 +1,55 @@
package net.java.sip.communicator.plugin.splashscreen;
import java.awt.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
/**
* Constructs the window background in order to have a background image.
*/
public class WindowBackground
extends JPanel
{
private Image bgImage;
public WindowBackground()
{
this.setOpaque(true);
try
{
bgImage = ImageIO.read(WindowBackground.class
.getResource("aboutWindowBackground.png"));
}
catch (IOException e)
{
e.printStackTrace();
}
this.setPreferredSize(new Dimension(bgImage.getWidth(this), bgImage
.getHeight(this)));
}
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.drawImage(bgImage, 0, 0, null);
g2.setColor(new Color(255, 255, 255, 170));
g2.fillRect(0, 0, getWidth(), getHeight());
g2.setColor(new Color(150, 150, 150));
g2.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, 5, 5);
}
}

@ -0,0 +1,171 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.splashscreen;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
/**
* The <tt>WindowBackground</tt> is a <tt>JComponent</tt>, which is
* added to a <tt>Window</tt> in order to make it transparent.
* <p>
* <b>How to use the <tt>WindowBackground</tt>?</b>
* The <tt>WindowBackground</tt> is created and added to the content pane
* of the <tt>Window</tt> that should be made transparent. All other components
* then are added to the <tt>WindowBackground</tt> component and not
* directly to the window content pane.
* <p>
* <b>How it works?</b>
* The <tt>WindowBackground</tt> is a <tt>JComponent</tt> which is not
* really transparent, but only looks like. It overrides the
* <code>paintComponent</code> method of <tt>JComponent</tt> to paint its
* own background image, which is an exact image of the screen at the position
* where the window will apear and with the same size. The
* <tt>java.awt.Robot</tt> class is used to make the screen capture.
* <p>
* Note that the effect of transparence is gone when behind there is an
* application which shows dynamic images or something the moves, like
* a movie for example.
*
* @author Yana Stamcheva
*/
public class WindowTransparentBackground
extends JPanel
implements ActionListener
{
private BufferedImage bg1;
private BufferedImage bg2;
private BufferedImage bg3;
private BufferedImage bg4;
private Robot robot;
private Image bgImage;
private Timer refreshBgTimer;
private int bgX;
private int bgY;
private int bgWidth;
private int bgHeight;
/**
* Creates an instance of <tt>WindowBackground</tt> by specifying
* the parent <tt>Window</tt> - this is the window that should be made
* transparent.
*
* @param window The parent <tt>Window</tt>
*/
public WindowTransparentBackground() {
try {
robot = new Robot();
bgImage = ImageIO.read(
WindowBackground.class.getResource("aboutWindowBackground.png"));
bgWidth = bgImage.getWidth(null);
bgHeight = bgImage.getHeight(null);
bgX = Toolkit.getDefaultToolkit().getScreenSize().width/2
- bgWidth/2;
bgY = Toolkit.getDefaultToolkit().getScreenSize().width/2
- bgHeight/2;
} catch (AWTException e) {
e.printStackTrace();
return;
}
catch (IOException e)
{
e.printStackTrace();
return;
}
this.updateBackground(bgX, bgY, bgWidth, bgHeight);
refreshBgTimer = new Timer(4000, this);
refreshBgTimer.setRepeats(true);
refreshBgTimer.start();
}
/**
* Updates the background. Makes a new screen capture at the given
* coordiantes.
*
* @param x The x coordinate.
* @param y The y coordinate.
*/
public void updateBackground(int x, int y, int w, int h) {
this.bg1 = robot.createScreenCapture(new Rectangle(x, y, 30, 30));
this.bg2 = robot.createScreenCapture(new Rectangle(w - 30, y, 30, 30));
this.bg3 = robot.createScreenCapture(new Rectangle(x, h - 30, 30, 30));
this.bg4 = robot.createScreenCapture(new Rectangle(w - 30, y - 30, 30, 30));
}
public void stopRefresh()
{
refreshBgTimer.stop();
this.robot = null;
}
/**
* Overrides the <code>paintComponent</code> method in <tt>JComponent</tt>
* to paint the screen capture image as a background of this component.
*/
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.drawImage(this.bg1, 0, 0, null);
g2.drawImage(this.bg2, bgWidth - 30, 0, null);
g2.drawImage(this.bg3, 0, bgHeight - 30, null);
g2.drawImage(this.bg4, bgWidth - 30, bgHeight - 30, null);
g2.drawImage(bgImage, 1, 1, null);
g2.setColor(new Color(255, 255, 255, 130));
g2.fillRoundRect(0, 0, bgWidth, bgHeight, 40, 40);
}
public void actionPerformed(ActionEvent e)
{
this.updateBackground(bgX, bgY, bgWidth, bgHeight);
this.revalidate();
this.repaint();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

@ -0,0 +1,11 @@
Bundle-Activator: net.java.sip.communicator.plugin.splashscreen.SplashScreenActivator
Bundle-Name: Splash Screen plugin
Bundle-Description: Splash Screen plugin.
Bundle-Vendor: sip-communicator.org
Bundle-Version: 0.0.1
Import-Package: org.osgi.framework,
net.java.sip.communicator.service.gui,
net.java.sip.communicator.service.gui.event,
javax.swing,
javax.swing.event,
javax.imageio
Loading…
Cancel
Save