home *** CD-ROM | disk | FTP | other *** search
- package java.awt;
-
- import java.awt.image.BufferedImage;
- import java.awt.image.DataBuffer;
- import java.awt.image.DataBufferInt;
- import java.awt.image.SinglePixelPackedSampleModel;
- import java.io.File;
- import java.io.IOException;
- import java.io.InputStream;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLConnection;
-
- public final class SplashScreen {
- private BufferedImage image;
- private long splashPtr;
- private boolean wasClosed;
- private URL imageURL;
- private static SplashScreen theInstance = null;
-
- SplashScreen(long var1) {
- this.splashPtr = var1;
- this.wasClosed = false;
- }
-
- public static synchronized SplashScreen getSplashScreen() {
- if (GraphicsEnvironment.isHeadless()) {
- throw new HeadlessException();
- } else {
- if (theInstance == null) {
- System.loadLibrary("splashscreen");
- long var0 = _getInstance();
- if (var0 == 0L) {
- return null;
- }
-
- if (!_isVisible(var0)) {
- return null;
- }
-
- theInstance = new SplashScreen(var0);
- }
-
- return theInstance.isVisible() ? theInstance : null;
- }
- }
-
- public void setImageURL(URL var1) throws NullPointerException, IOException, IllegalStateException {
- this.checkVisible();
- URLConnection var2 = var1.openConnection();
- var2.connect();
- int var3 = var2.getContentLength();
- InputStream var4 = var2.getInputStream();
- byte[] var5 = new byte[var3];
- int var6 = 0;
-
- while(true) {
- int var7 = var4.available();
- if (var7 <= 0) {
- var7 = 1;
- }
-
- if (var6 + var7 > var3) {
- var3 = var6 * 2;
- if (var6 + var7 > var3) {
- var3 = var7 + var6;
- }
-
- byte[] var8 = var5;
- var5 = new byte[var3];
- System.arraycopy(var8, 0, var5, 0, var6);
- }
-
- int var11 = var4.read(var5, var6, var7);
- if (var11 < 0) {
- synchronized(this) {
- if (!_setImageData(this.splashPtr, var5)) {
- throw new IOException("Bad image format or i/o error when loading image");
- }
-
- this.imageURL = var1;
- return;
- }
- }
-
- var6 += var11;
- }
- }
-
- private void checkVisible() {
- if (!this.isVisible()) {
- throw new IllegalStateException("no splash screen available");
- }
- }
-
- public synchronized URL getImageURL() throws IllegalStateException {
- this.checkVisible();
- if (this.imageURL == null) {
- try {
- String var1 = _getImageFileName(this.splashPtr);
- String var2 = _getImageJarName(this.splashPtr);
- if (var1 != null) {
- if (var2 != null) {
- this.imageURL = new URL("jar:" + (new File(var2)).toURL().toString() + "!/" + var1);
- } else {
- this.imageURL = (new File(var1)).toURL();
- }
- }
- } catch (MalformedURLException var3) {
- }
- }
-
- return this.imageURL;
- }
-
- public Rectangle getBounds() throws IllegalStateException {
- this.checkVisible();
- return _getBounds(this.splashPtr);
- }
-
- public Dimension getSize() throws IllegalStateException {
- return this.getBounds().getSize();
- }
-
- public Graphics2D createGraphics() throws IllegalStateException {
- if (this.image == null) {
- Dimension var1 = this.getSize();
- this.image = new BufferedImage(var1.width, var1.height, 2);
- }
-
- return this.image.createGraphics();
- }
-
- public void update() throws IllegalStateException {
- this.checkVisible();
- if (this.image == null) {
- throw new IllegalStateException("no overlay image available");
- } else {
- DataBuffer var1 = this.image.getRaster().getDataBuffer();
- if (!(var1 instanceof DataBufferInt)) {
- throw new AssertionError("Overlay image DataBuffer is of invalid type == " + var1.getClass().getName());
- } else {
- int var2 = var1.getNumBanks();
- if (var2 != 1) {
- throw new AssertionError("Invalid number of banks ==" + var2 + " in overlay image DataBuffer");
- } else if (!(this.image.getSampleModel() instanceof SinglePixelPackedSampleModel)) {
- throw new AssertionError("Overlay image has invalid sample model == " + this.image.getSampleModel().getClass().getName());
- } else {
- SinglePixelPackedSampleModel var3 = (SinglePixelPackedSampleModel)this.image.getSampleModel();
- int var4 = var3.getScanlineStride();
- Rectangle var5 = this.image.getRaster().getBounds();
- int[] var6 = ((DataBufferInt)var1).getData();
- _update(this.splashPtr, var6, var5.x, var5.y, var5.width, var5.height, var4);
- }
- }
- }
- }
-
- public synchronized void close() throws IllegalStateException {
- this.checkVisible();
- _close(this.splashPtr);
- this.image = null;
- this.wasClosed = true;
- }
-
- public boolean isVisible() {
- return !this.wasClosed && _isVisible(this.splashPtr);
- }
-
- private static native void _update(long var0, int[] var2, int var3, int var4, int var5, int var6, int var7);
-
- private static native boolean _isVisible(long var0);
-
- private static native Rectangle _getBounds(long var0);
-
- private static native long _getInstance();
-
- private static native void _close(long var0);
-
- private static native String _getImageFileName(long var0);
-
- private static native String _getImageJarName(long var0);
-
- private static native boolean _setImageData(long var0, byte[] var2);
- }
-