aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIngo Bauersachs <ingo@jitsi.org>2017-01-14 18:22:15 +0100
committerIngo Bauersachs <ingo@jitsi.org>2017-01-14 18:51:16 +0100
commit6eaa56d09126da3599180d34edb01eeba3aa724e (patch)
treecf54417ce46667e8184691ea6c90ef8266d62fc3 /src
parent0c2e1e5844234fa2f4c5ebe475c88e3e0382f878 (diff)
downloadjitsi-6eaa56d09126da3599180d34edb01eeba3aa724e.zip
jitsi-6eaa56d09126da3599180d34edb01eeba3aa724e.tar.gz
jitsi-6eaa56d09126da3599180d34edb01eeba3aa724e.tar.bz2
Update about window to current license, remove in-app splashscreen
Diffstat (limited to 'src')
-rw-r--r--src/net/java/sip/communicator/plugin/branding/AboutWindow.java105
-rw-r--r--src/net/java/sip/communicator/plugin/branding/BrandingActivator.java134
-rw-r--r--src/net/java/sip/communicator/plugin/branding/WelcomeWindow.java443
3 files changed, 44 insertions, 638 deletions
diff --git a/src/net/java/sip/communicator/plugin/branding/AboutWindow.java b/src/net/java/sip/communicator/plugin/branding/AboutWindow.java
index a010592..1f75f1d 100644
--- a/src/net/java/sip/communicator/plugin/branding/AboutWindow.java
+++ b/src/net/java/sip/communicator/plugin/branding/AboutWindow.java
@@ -20,6 +20,8 @@ package net.java.sip.communicator.plugin.branding;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
+import java.net.*;
+import java.util.*;
import javax.imageio.*;
import javax.swing.*;
@@ -56,9 +58,6 @@ public class AboutWindow
*/
private static final long serialVersionUID = 0L;
- /**
- * The global/shared <code>AboutWindow</code> currently showing.
- */
private static AboutWindow aboutWindow;
/**
@@ -120,8 +119,10 @@ public class AboutWindow
ResourceManagementService resources = BrandingActivator.getResources();
- String applicationName
- = resources.getSettingsString("service.gui.APPLICATION_NAME");
+ String applicationName =
+ resources.getSettingsString("service.gui.APPLICATION_NAME");
+ String website =
+ resources.getSettingsString("service.gui.APPLICATION_WEB_SITE");
this.setTitle(
resources.getI18NString("plugin.branding.ABOUT_WINDOW_TITLE",
@@ -141,14 +142,10 @@ public class AboutWindow
.createEmptyBorder(15, 15, 15, 15));
textPanel.setOpaque(false);
- JLabel titleLabel = null;
- if (isApplicationNameShown())
- {
- titleLabel = new JLabel(applicationName);
- titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 28));
- titleLabel.setForeground(Constants.TITLE_COLOR);
- titleLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
- }
+ JLabel titleLabel = new JLabel(applicationName);
+ titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 28));
+ titleLabel.setForeground(Constants.TITLE_COLOR);
+ titleLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
// Force the use of the custom text field UI in order to fix an
// incorrect rendering on Ubuntu.
@@ -181,7 +178,6 @@ public class AboutWindow
int logoAreaFontSize
= resources.getSettingsInt("plugin.branding.ABOUT_LOGO_FONT_SIZE");
- // FIXME: the message exceeds the window length
JTextArea logoArea =
new JTextArea(resources.getI18NString(
"plugin.branding.LOGO_MESSAGE"));
@@ -192,7 +188,6 @@ public class AboutWindow
logoArea.setLineWrap(true);
logoArea.setWrapStyleWord(true);
logoArea.setEditable(false);
- logoArea.setPreferredSize(new Dimension(100, 20));
logoArea.setAlignmentX(Component.RIGHT_ALIGNMENT);
logoArea.setBorder(BorderFactory
.createEmptyBorder(30, DEFAULT_TEXT_INDENT, 0, 0));
@@ -200,44 +195,38 @@ public class AboutWindow
StyledHTMLEditorPane rightsArea = new StyledHTMLEditorPane();
rightsArea.setContentType("text/html");
+ String host = website;
+ try
+ {
+ host = new URL(website).getHost();
+ }
+ catch (Exception ex)
+ {}
+
rightsArea.appendToEnd(resources.getI18NString(
- "plugin.branding.COPYRIGHT",
+ "plugin.branding.COPYRIGHT_LICENSE",
new String[]
- { Constants.TEXT_COLOR }));
-
- rightsArea.setPreferredSize(new Dimension(50, 20));
- rightsArea
- .setBorder(BorderFactory
+ {
+ Constants.TEXT_COLOR,
+ Integer.toString(Calendar.getInstance().get(Calendar.YEAR)),
+ website,
+ host,
+ applicationName,
+ "http://www.apache.org/licenses/LICENSE-2.0",
+ "Apache License 2.0"
+ }));
+
+ rightsArea.setBorder(BorderFactory
.createEmptyBorder(0, DEFAULT_TEXT_INDENT, 0, 0));
rightsArea.setOpaque(false);
rightsArea.setEditable(false);
rightsArea.setAlignmentX(Component.RIGHT_ALIGNMENT);
rightsArea.addHyperlinkListener(this);
- StyledHTMLEditorPane licenseArea = new StyledHTMLEditorPane();
- licenseArea.setContentType("text/html");
- licenseArea.appendToEnd(resources.
- getI18NString("plugin.branding.LICENSE",
- new String[]{Constants.TEXT_COLOR}));
-
- licenseArea.setPreferredSize(new Dimension(50, 20));
- licenseArea.setBorder(
- BorderFactory.createEmptyBorder(
- resources.getSettingsInt("plugin.branding.ABOUT_PARAGRAPH_GAP"),
- DEFAULT_TEXT_INDENT,
- 0, 0));
- licenseArea.setOpaque(false);
- licenseArea.setEditable(false);
- licenseArea.setAlignmentX(Component.RIGHT_ALIGNMENT);
- licenseArea.addHyperlinkListener(this);
-
- if (titleLabel != null)
- textPanel.add(titleLabel);
-
+ textPanel.add(titleLabel);
textPanel.add(versionLabel);
textPanel.add(logoArea);
textPanel.add(rightsArea);
- textPanel.add(licenseArea);
JButton okButton
= new JButton(resources.getI18NString("service.gui.OK"));
@@ -375,18 +364,17 @@ public class AboutWindow
{
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
{
- String href = e.getDescription();
- ServiceReference serviceReference = BrandingActivator
- .getBundleContext().getServiceReference(
- BrowserLauncherService.class.getName());
+ ServiceReference<BrowserLauncherService> serviceReference =
+ BrandingActivator.getBundleContext().getServiceReference(
+ BrowserLauncherService.class);
if (serviceReference != null)
{
BrowserLauncherService browserLauncherService
- = (BrowserLauncherService) BrandingActivator
+ = BrandingActivator
.getBundleContext().getService(serviceReference);
- browserLauncherService.openURL(href);
+ browserLauncherService.openURL(e.getDescription());
}
}
}
@@ -463,25 +451,4 @@ public class AboutWindow
dispose();
}
}
-
- /**
- * Indicates if the application name should be shown.
- *
- * @return <tt>true</tt> if the application name should be shown,
- * <tt>false</tt> - otherwise
- */
- private boolean isApplicationNameShown()
- {
- String showApplicationNameProp
- = BrandingActivator.getResources().getSettingsString(
- "plugin.branding.IS_APPLICATION_NAME_SHOWN");
-
- if (showApplicationNameProp != null
- && showApplicationNameProp.length() > 0)
- {
- return Boolean.parseBoolean(showApplicationNameProp);
- }
-
- return true;
- }
}
diff --git a/src/net/java/sip/communicator/plugin/branding/BrandingActivator.java b/src/net/java/sip/communicator/plugin/branding/BrandingActivator.java
index f145dfb..f6de958 100644
--- a/src/net/java/sip/communicator/plugin/branding/BrandingActivator.java
+++ b/src/net/java/sip/communicator/plugin/branding/BrandingActivator.java
@@ -33,87 +33,12 @@ import org.osgi.framework.*;
*/
public class BrandingActivator
extends AbstractServiceDependentActivator
- implements BundleListener
{
private final Logger logger = Logger.getLogger(BrandingActivator.class);
-
- /**
- * The name of the boolean property which indicates whether the splash
- * screen (i.e. <code>WelcomeWindow</code>) is to be shown or to not be
- * utilized for the sake of better memory consumption and faster startup.
- */
- private static final String PNAME_SHOW_SPLASH_SCREEN
- = "net.java.sip.communicator.plugin.branding.SHOW_SPLASH_SCREEN";
-
private static BundleContext bundleContext;
-
private static ResourceManagementService resourcesService;
/**
- * The welcome window.
- */
- private WelcomeWindow welcomeWindow;
-
- @Override
- public void start(BundleContext bc) throws Exception
- {
- super.start(bc);
-
- ConfigurationService config = getConfigurationService();
- boolean showSplashScreen
- = (config == null)
- ? true /*
- * Having no ConfigurationService reference is not good
- * for the application so we are better off with the
- * splash screen to actually see which bundles get loaded
- * and maybe be able to debug the problem.
- */
- : config.getBoolean(PNAME_SHOW_SPLASH_SCREEN, false);
-
- /*
- * WelcomeWindow is huge because it has a large image spread all over it
- * so, given it's only necessary before the UIService gets activated, we
- * certainly don't want to keep it around (e.g. as an instance field or
- * as a final variable used inside a BundleListener which never gets
- * removed).
- */
- if (showSplashScreen)
- {
- welcomeWindow = new WelcomeWindow();
- welcomeWindow.pack();
- welcomeWindow.setVisible(true);
- }
- else
- welcomeWindow = null;
-
- bundleContext.addBundleListener(this);
- }
-
- /**
- * Bundle has been started if welcome window is available and visible
- * update it to show the bundle activity.
- * @param evt
- */
- public synchronized void bundleChanged(BundleEvent evt)
- {
- if (welcomeWindow != null
- && welcomeWindow.isShowing()
- && (evt.getType() == BundleEvent.STARTED))
- {
- /*
- * The IBM JRE on GNU/Linux reports the Bundle-Name as null while
- * the SUN JRE reports it as non-null. Just prevent the throwing of
- * a NullPointerException because displaying the Bundle-Name isn't
- * vital anyway.
- */
- Object bundleName = evt.getBundle().getHeaders().get("Bundle-Name");
-
- welcomeWindow.setBundle(
- (bundleName == null) ? null : bundleName.toString());
- }
- }
-
- /**
* Setting context to the activator, as soon as we have one.
*
* @param context the context to set.
@@ -141,31 +66,12 @@ public class BrandingActivator
@Override
public void start(Object dependentService)
{
- // UI-Service started.
-
- /*
- * Don't let bundleContext retain a reference to this
- * listener because it'll retain a reference to
- * welcomeWindow. Besides, we're no longer interested in
- * handling events so it doesn't make sense to even retain
- * this listener.
- */
- bundleContext.removeBundleListener(this);
-
// register the about dialog menu entry
registerMenuEntry((UIService)dependentService);
-
- if (welcomeWindow != null)
- {
- synchronized(this)
- {
- welcomeWindow.close();
- welcomeWindow = null;
- }
- }
}
- public void stop(BundleContext arg0) throws Exception
+ @Override
+ public void stop(BundleContext context) throws Exception
{
}
@@ -185,7 +91,6 @@ public class BrandingActivator
private boolean registerMenuEntryMacOSX(UIService uiService)
{
- Exception exception = null;
try
{
Class<?> clazz =
@@ -195,28 +100,16 @@ public class BrandingActivator
Object result = method.invoke(null, (Object[]) null);
if (result instanceof Boolean)
+ {
return ((Boolean) result).booleanValue();
+ }
}
- catch (ClassNotFoundException ex)
- {
- exception = ex;
- }
- catch (IllegalAccessException ex)
- {
- exception = ex;
- }
- catch (InvocationTargetException ex)
- {
- exception = ex;
- }
- catch (NoSuchMethodException ex)
+ catch (Exception ex)
{
- exception = ex;
+ logger.error("Failed to register Mac OS X-specific About handling.",
+ ex);
}
- if (exception != null)
- logger.error(
- "Failed to register Mac OS X-specific About handling.",
- exception);
+
return false;
}
@@ -272,17 +165,6 @@ public class BrandingActivator
return bundleContext;
}
- private static ConfigurationService getConfigurationService()
- {
- ServiceReference serRef
- = bundleContext
- .getServiceReference(ConfigurationService.class.getName());
- return
- (serRef == null)
- ? null
- : (ConfigurationService) bundleContext.getService(serRef);
- }
-
/**
* Returns the <tt>ResourceManagementService</tt>.
*
diff --git a/src/net/java/sip/communicator/plugin/branding/WelcomeWindow.java b/src/net/java/sip/communicator/plugin/branding/WelcomeWindow.java
deleted file mode 100644
index 7cc78b8..0000000
--- a/src/net/java/sip/communicator/plugin/branding/WelcomeWindow.java
+++ /dev/null
@@ -1,443 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.branding;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.image.*;
-import java.io.*;
-
-import javax.imageio.*;
-import javax.swing.*;
-
-import net.java.sip.communicator.plugin.desktoputil.*;
-
-import org.jitsi.service.resources.*;
-
-/**
- * The <tt>WelcomeWindow</tt> is actually the splash screen shown while the
- * application is loading. It displays the status of the loading process and
- * some general information about the version, licenses and contact details.
- *
- * @author Yana Stamcheva
- */
-public class WelcomeWindow extends JDialog
-{
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- private static final String APPLICATION_NAME
- = BrandingActivator.getResources()
- .getSettingsString("service.gui.APPLICATION_NAME");
-
- private static final int DEFAULT_TEXT_INDENT
- = BrandingActivator.getResources()
- .getSettingsInt("plugin.branding.SPLASH_SCREEN_TEXT_INDENT");
-
- private static final int PREFERRED_HEIGHT = 330;
-
- private static final int PREFERRED_WIDTH = 570;
-
- private final JLabel bundleLabel = new JLabel();
-
- /**
- * Constructor.
- */
- public WelcomeWindow()
- {
- JLabel titleLabel = new JLabel(APPLICATION_NAME);
-
- JLabel versionLabel = new JLabel(" "
- + System.getProperty("sip-communicator.version"));
-
- JTextArea logoArea = new JTextArea(
- BrandingActivator.getResources()
- .getI18NString("plugin.branding.LOGO_MESSAGE"));
-
- StyledHTMLEditorPane rightsArea = new StyledHTMLEditorPane();
-
- StyledHTMLEditorPane licenseArea = new StyledHTMLEditorPane();
-
- JPanel textPanel = new JPanel();
-
- Container mainPanel = new WindowBackground();
-
- this.setTitle(APPLICATION_NAME);
-
- this.setModal(false);
- this.setUndecorated(true);
-
- mainPanel.setLayout(new BorderLayout());
-
- textPanel.setPreferredSize(new Dimension(470, 280));
- textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS));
- textPanel
- .setBorder(BorderFactory.createEmptyBorder(15, 15, 0, 15));
- textPanel.setOpaque(false);
-
- this.initTitleLabel(titleLabel);
-
- this.initVersionLabel(versionLabel);
-
- this.initLogoArea(logoArea);
-
- this.initRightsArea(rightsArea);
-
- this.initLicenseArea(licenseArea);
-
- Component loadingPanel = initLoadingPanel();
-
- textPanel.add(titleLabel);
- textPanel.add(versionLabel);
- textPanel.add(logoArea);
- textPanel.add(rightsArea);
- textPanel.add(licenseArea);
-
- mainPanel.add(textPanel, BorderLayout.CENTER);
- mainPanel.add(loadingPanel, BorderLayout.SOUTH);
-
- this.getContentPane().add(mainPanel);
-
- this.setResizable(false);
-
- mainPanel.setPreferredSize(
- new Dimension(PREFERRED_WIDTH, PREFERRED_HEIGHT));
-
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- this.setLocation(screenSize.width / 2 - 527 / 2,
- screenSize.height / 2 - 305 / 2);
-
- this.initCloseActions();
- }
-
- /**
- * Initializes the title label.
- *
- * @param titleLabel the title label
- */
- private void initTitleLabel(JLabel titleLabel)
- {
- titleLabel.setFont(
- titleLabel.getFont().deriveFont(Font.BOLD, 28));
- titleLabel.setForeground(Constants.TITLE_COLOR);
- titleLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
- }
-
- /**
- * Initializes the version label.
- *
- * @param versionLabel the version label
- */
- private void initVersionLabel(JLabel versionLabel)
- {
- versionLabel.setFont(
- versionLabel.getFont().deriveFont(Font.BOLD, 18));
- versionLabel.setForeground(Constants.TITLE_COLOR);
- versionLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
- }
-
- /**
- * Initializes the logo area.
- *
- * @param logoArea the logo area
- */
- private void initLogoArea(JTextArea logoArea)
- {
- int logoAreaFontSize = BrandingActivator.getResources().
- getSettingsInt("plugin.branding.ABOUT_LOGO_FONT_SIZE");
-
- logoArea.setFont(
- logoArea.getFont().deriveFont(Font.BOLD, logoAreaFontSize));
- logoArea.setForeground(Constants.TITLE_COLOR);
- logoArea.setOpaque(false);
- logoArea.setLineWrap(true);
- logoArea.setWrapStyleWord(true);
- logoArea.setEditable(false);
- logoArea.setPreferredSize(new Dimension(100, 20));
- logoArea.setAlignmentX(Component.RIGHT_ALIGNMENT);
- logoArea.setBorder(BorderFactory
- .createEmptyBorder(20, DEFAULT_TEXT_INDENT, 0, 0));
- }
-
- /**
- * Initializes the copyright area.
- *
- * @param rightsArea the copyright area.
- */
- private void initRightsArea(StyledHTMLEditorPane rightsArea)
- {
- rightsArea.setContentType("text/html");
- rightsArea.appendToEnd(
- BrandingActivator.getResources().getI18NString(
- "plugin.branding.WELCOME_MESSAGE",
- new String[]{
- Constants.TEXT_COLOR,
- APPLICATION_NAME,
- BrandingActivator.getResources()
- .getSettingsString("service.gui.APPLICATION_WEB_SITE")
- }));
-
- rightsArea.setPreferredSize(new Dimension(50, 50));
- rightsArea
- .setBorder(BorderFactory
- .createEmptyBorder(0, DEFAULT_TEXT_INDENT, 0, 0));
- rightsArea.setOpaque(false);
- rightsArea.setEditable(false);
- rightsArea.setAlignmentX(Component.RIGHT_ALIGNMENT);
- }
-
- /**
- * Initializes the license area.
- *
- * @param licenseArea the license area.
- */
- private void initLicenseArea(StyledHTMLEditorPane licenseArea)
- {
- licenseArea.setContentType("text/html");
- licenseArea.appendToEnd(
- BrandingActivator.getResources().getI18NString(
- "plugin.branding.LICENSE",
- new String[]
- {
- Constants.TEXT_COLOR
- }));
-
- licenseArea.setPreferredSize(new Dimension(50, 20));
- licenseArea.setBorder(BorderFactory
- .createEmptyBorder(0, DEFAULT_TEXT_INDENT, 0, 0));
- licenseArea.setOpaque(false);
- licenseArea.setEditable(false);
- licenseArea.setAlignmentX(Component.RIGHT_ALIGNMENT);
- }
-
- private JPanel initLoadingPanel()
- {
- ResourceManagementService resources = BrandingActivator.getResources();
- JLabel loadingLabel
- = new JLabel(
- resources.getI18NString("plugin.branding.LOADING") + ": ");
- JPanel loadingPanel = new JPanel(new BorderLayout());
-
- this.bundleLabel.setFont(loadingLabel.getFont().deriveFont(Font.PLAIN));
-
- loadingPanel.setOpaque(false);
- loadingPanel.add(loadingLabel, BorderLayout.WEST);
- loadingPanel.add(bundleLabel, BorderLayout.CENTER);
-
- int loadingPanelBorder
- = resources
- .getSettingsInt("plugin.branding.LOADING_BUNDLE_PANEL_BORDER");
-
- loadingPanel.setBorder(
- BorderFactory.createEmptyBorder(loadingPanelBorder,
- loadingPanelBorder,
- loadingPanelBorder,
- loadingPanelBorder));
-
- int loadingPanelHeight
- = resources
- .getSettingsInt("plugin.branding.LOADING_BUNDLE_PANEL_HEIGHT");
-
- loadingPanel.setPreferredSize(
- new Dimension(PREFERRED_WIDTH, loadingPanelHeight));
-
- return loadingPanel;
- }
-
- /**
- * Initializes close actions on mouse click and esc key.
- */
- private void initCloseActions()
- {
- // Close the splash screen on simple click or Esc.
- this.getGlassPane().addMouseListener(new MouseAdapter()
- {
- @Override
- public void mouseClicked(MouseEvent e)
- {
- WelcomeWindow.this.close();
- }
- });
-
- this.getGlassPane().setVisible(true);
-
- ActionMap amap = this.getRootPane().getActionMap();
-
- amap.put("close", new CloseAction());
-
- InputMap imap = this.getRootPane().getInputMap(
- JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
-
- imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close");
- }
-
- /**
- * Disposes this window.
- */
- protected void close()
- {
- this.dispose();
- }
-
- /**
- * Sets the name of the currently loading bundle.
- *
- * @param bundleName the name of the bundle to display
- */
- public void setBundle(String bundleName)
- {
- bundleLabel.setText(bundleName);
-
- bundleLabel.revalidate();
- bundleLabel.getParent().repaint();
- }
-
- /**
- * The action invoked when user presses Escape key.
- */
- private class CloseAction extends UIAction
- {
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- public void actionPerformed(ActionEvent e)
- {
- WelcomeWindow.this.close();
- }
- }
-
- /**
- * Constructs the window background in order to have a background image.
- */
- private static class WindowBackground
- extends JPanel
- {
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- private BufferedImage cache;
-
- private int cacheHeight;
-
- private int cacheWidth;
-
- private final Image image;
-
- public WindowBackground()
- {
- setOpaque(true);
-
- Image image = null;
- try
- {
- image =
- ImageIO.read(BrandingActivator.getResources().getImageURL(
- "plugin.branding.SPLASH_SCREEN_BACKGROUND"));
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- this.image = image;
-
- if (image != null)
- {
- setPreferredSize(new Dimension(image.getWidth(this), image
- .getHeight(this)));
- }
- }
-
- @Override
- protected void paintComponent(Graphics g)
- {
- super.paintComponent(g);
-
- g = g.create();
- try
- {
- internalPaintComponent(g);
- }
- finally
- {
- g.dispose();
- }
- }
-
- private void internalPaintComponent(Graphics g)
- {
- AntialiasingManager.activateAntialiasing(g);
-
- Graphics2D g2 = (Graphics2D) g;
-
- /*
- * Drawing an Image with a data layout and color model compatible
- * with this JPanel is magnitudes faster so create and use such an
- * Image from the original drawn by this instance.
- */
- int width = getWidth();
- int height = getHeight();
- boolean imageIsChanging = false;
- if ((cache == null) || (cacheWidth != width)
- || (cacheHeight != height))
- {
- cache =
- g2.getDeviceConfiguration().createCompatibleImage(width,
- height);
- cacheWidth = width;
- cacheHeight = height;
-
- Graphics2D cacheGraphics = cache.createGraphics();
- try
- {
- super.paintComponent(cacheGraphics);
-
- AntialiasingManager.activateAntialiasing(cacheGraphics);
-
- imageIsChanging =
- !cacheGraphics.drawImage(image, 0, 0, null);
-
- cacheGraphics.setColor(new Color(150, 150, 150));
- cacheGraphics.drawRoundRect(0, 0, width - 1, height - 1, 5,
- 5);
- }
- finally
- {
- cacheGraphics.dispose();
- }
- }
-
- g2.drawImage(cache, 0, 0, null);
-
- /*
- * Once the original Image drawn by this instance has been fully
- * loaded, we're free to use its "compatible" caching representation
- * for the purposes of optimized execution speed.
- */
- if (imageIsChanging)
- {
- cache = null;
- }
- }
- }
-}