From: <ma...@us...> - 2007-06-11 18:10:21
|
Revision: 2851 http://svn.sourceforge.net/java-game-lib/?rev=2851&view=rev Author: matzon Date: 2007-06-11 11:10:19 -0700 (Mon, 11 Jun 2007) Log Message: ----------- applied kappaOne's Permision denied handling made some minor cleanup Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2007-06-10 20:31:41 UTC (rev 2850) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2007-06-11 18:10:19 UTC (rev 2851) @@ -47,7 +47,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.lang.reflect.Method; -import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; import java.net.URLConnection; @@ -165,9 +164,6 @@ /** urls of the jars to download */ protected URL[] urlList; - /** list of jars to download */ - protected String jarList; - /** actual thread that does the loading */ protected Thread loaderThread; @@ -197,6 +193,14 @@ "Plese contact support to resolve this issue.", "<placeholder for error message>"}; + /** whether a certificate refused error occured */ + protected boolean certificateRefused; + + /** error message to display if user refuses to accept certicate*/ + protected String[] certificateRefusedMessage = { "Permissions for Applet Refused.", + "Please accept the permissions dialog to allow", + "the applet to continue the loading process."}; + /* * @see java.applet.Applet#init() */ @@ -223,17 +227,10 @@ logo = getImage("/" + getParameter("al_logo")); progressbar = getImage("/" + getParameter("al_progressbar")); - // jars to load - jarList = getParameter("al_jars"); - //sanity check if(logo == null || progressbar == null) { fatalErrorOccured("Unable to load logo and progressbar images"); - return; } - - // parse the urls for the jars into the url list - loadJarURLs(); } /* @@ -247,7 +244,7 @@ animationThread = new Thread() { public void run() { - while(state != STATE_DONE) { + while(loaderThread != null) { repaint(); AppletLoader.this.sleep(100); } @@ -307,7 +304,7 @@ /* * @see java.awt.Container#paint(java.awt.Graphics) */ - public final synchronized void paint(Graphics g) { + public synchronized void paint(Graphics g) { // paint applet if available if(lwjglApplet != null && state == STATE_DONE) { @@ -337,49 +334,18 @@ } og.setColor(fgColor); - String message = null; + String message = getDescriptionForState(); - switch (state) { - case STATE_INIT: - message = "Initializing loader"; - break; - case STATE_DETERMINING_PACKAGES: - message = "Determining packages to load"; - break; - case STATE_CHECKING_CACHE: - message = "Checking cache for existing files"; - break; - case STATE_DOWNLOADING: - message = "Downloading packages"; - break; - case STATE_EXTRACTING_PACKAGES: - message = "Extracting downloaded packages"; - break; - case STATE_UPDATING_CLASSPATH: - message = "Updating classpath"; - break; - case STATE_SWITCHING_APPLET: - message = "Switching applet"; - break; - case STATE_INITIALIZE_REAL_APPLET: - message = "Initializing real applet"; - break; - case STATE_START_REAL_APPLET: - message = "Starting real applet"; - break; - case STATE_DONE: - message = "Done loading"; - break; - } - + // if we had a failure of some sort, notify the user if (fatalError) { - genericErrorMessage[genericErrorMessage.length-1] = fatalErrorDescription; - for(int i=0; i<genericErrorMessage.length; i++) { - int messageX = (getWidth() - fm.stringWidth(genericErrorMessage[i])) / 2; - int messageY = (getHeight() - (fm.getHeight() * genericErrorMessage.length)) / 2; + String[] errorMessage = (certificateRefused) ? certificateRefusedMessage : genericErrorMessage; + + for(int i=0; i<errorMessage.length; i++) { + int messageX = (getWidth() - fm.stringWidth(errorMessage[i])) / 2; + int messageY = (getHeight() - (fm.getHeight() * errorMessage.length)) / 2; og.setColor(errorColor); - og.drawString(genericErrorMessage[i], messageX, messageY + i*fm.getHeight()); + og.drawString(errorMessage[i], messageX, messageY + i*fm.getHeight()); } } else { og.setColor(fgColor); @@ -411,49 +377,77 @@ } /** + * @return string describing the state of the loader + */ + protected String getDescriptionForState() { + switch (state) { + case STATE_INIT: + return "Initializing loader"; + case STATE_DETERMINING_PACKAGES: + return "Determining packages to load"; + case STATE_CHECKING_CACHE: + return "Checking cache for existing files"; + case STATE_DOWNLOADING: + return "Downloading packages"; + case STATE_EXTRACTING_PACKAGES: + return "Extracting downloaded packages"; + case STATE_UPDATING_CLASSPATH: + return "Updating classpath"; + case STATE_SWITCHING_APPLET: + return "Switching applet"; + case STATE_INITIALIZE_REAL_APPLET: + return "Initializing real applet"; + case STATE_START_REAL_APPLET: + return "Starting real applet"; + case STATE_DONE: + return "Done loading"; + default: + return "unknown state"; + } + } + + /** * Reads list of jars to download and adds the urls to urlList * also finds out which OS you are on and adds appropriate native * jar to the urlList */ - protected void loadJarURLs() { + protected void loadJarURLs() throws Exception { state = STATE_DETERMINING_PACKAGES; - + + // jars to load + String jarList = getParameter("al_jars"); + StringTokenizer jar = new StringTokenizer(jarList, ", "); int jarCount = jar.countTokens() + 1; urlList = new URL[jarCount]; - try { - URL path = getCodeBase(); + URL path = getCodeBase(); - // set jars urls - for (int i = 0; i < jarCount - 1; i++) { - urlList[i] = new URL(path, jar.nextToken()); - } + // set jars urls + for (int i = 0; i < jarCount - 1; i++) { + urlList[i] = new URL(path, jar.nextToken()); + } - // native jar url - String osName = System.getProperty("os.name"); - String nativeJar = null; + // native jar url + String osName = System.getProperty("os.name"); + String nativeJar = null; + + if (osName.startsWith("Win")) { + nativeJar = getParameter("al_windows"); + } else if (osName.startsWith("Linux") || osName.startsWith("FreeBSD") || osName.startsWith("SunOS")) { + nativeJar = getParameter("al_linux"); + } else if (osName.startsWith("Mac")) { + nativeJar = getParameter("al_mac"); + } else { + fatalErrorOccured("OS (" + osName + ") not supported"); + } - if (osName.startsWith("Win")) { - nativeJar = getParameter("al_windows"); - } else if (osName.startsWith("Linux") || osName.startsWith("FreeBSD") || osName.startsWith("SunOS")) { - nativeJar = getParameter("al_linux"); - } else if (osName.startsWith("Mac")) { - nativeJar = getParameter("al_mac"); - } else { - fatalErrorOccured("OS (" + osName + ") not supported"); - } - - if (nativeJar == null) { - fatalErrorOccured("no lwjgl natives files found"); - } else { - urlList[jarCount - 1] = new URL(path, nativeJar); - } - - } catch (MalformedURLException e) { - fatalErrorOccured(e.getMessage()); + if (nativeJar == null) { + fatalErrorOccured("no lwjgl natives files found"); + } else { + urlList[jarCount - 1] = new URL(path, nativeJar); } } @@ -478,6 +472,9 @@ sleep(2000); } + // parse the urls for the jars into the url list + loadJarURLs(); + // get path where applet will be stored String path = (String) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { @@ -542,10 +539,12 @@ state = STATE_DONE; } catch (AccessControlException ace) { fatalErrorOccured(ace.getMessage()); + certificateRefused = true; } catch (Exception e) { fatalErrorOccured(e.getMessage()); } finally { loaderThread = null; + repaint(); } } @@ -797,6 +796,10 @@ subtaskMessage = ""; jarFile.close(); + + // delete native jar as it is no longer needed + File f = new File(path + nativeJar); + f.delete(); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2007-06-11 18:43:14
|
Revision: 2852 http://svn.sourceforge.net/java-game-lib/?rev=2852&view=rev Author: matzon Date: 2007-06-11 11:43:13 -0700 (Mon, 11 Jun 2007) Log Message: ----------- no longer null'ing SecurityManager Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2007-06-11 18:10:19 UTC (rev 2851) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2007-06-11 18:43:13 UTC (rev 2852) @@ -589,8 +589,8 @@ percentage = 95; - Class[] parameters = new Class[] { URL.class}; - + Class[] parameters = new Class[] {URL.class}; + // modify class path by adding downloaded jars to it for (int i = 0; i < urlList.length; i++) { // get location of jar as a url @@ -599,7 +599,7 @@ // add to class path Method method = URLClassLoader.class.getDeclaredMethod("addURL", parameters); method.setAccessible(true); - method.invoke((URLClassLoader) ClassLoader.getSystemClassLoader(), new Object[] { u}); + method.invoke(getClass().getClassLoader(), new Object[] {u}); } if(debugMode) { @@ -611,10 +611,6 @@ // Make sure jinput knows about the new path too System.setProperty("net.java.games.input.librarypath", path + "natives"); - - // replace security system to avoid bug where vm fails to - // recognise downloaded jars as signed, when they are - System.setSecurityManager(null); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2007-10-13 07:37:45
|
Revision: 2898 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2898&view=rev Author: matzon Date: 2007-10-13 00:37:39 -0700 (Sat, 13 Oct 2007) Log Message: ----------- fix: generic error message placeholder String text was not being replace by the error message - kappaOne Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2007-09-19 14:10:48 UTC (rev 2897) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2007-10-13 07:37:39 UTC (rev 2898) @@ -340,6 +340,10 @@ if (fatalError) { String[] errorMessage = (certificateRefused) ? certificateRefusedMessage : genericErrorMessage; + if (!certificateRefused) { + errorMessage[errorMessage.length-1] = fatalErrorDescription; + } + for(int i=0; i<errorMessage.length; i++) { int messageX = (getWidth() - fm.stringWidth(errorMessage[i])) / 2; int messageY = (getHeight() - (fm.getHeight() * errorMessage.length)) / 2; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2007-10-20 21:20:02
|
Revision: 2903 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2903&view=rev Author: matzon Date: 2007-10-20 14:20:00 -0700 (Sat, 20 Oct 2007) Log Message: ----------- applied kappaOnes latest fixes Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2007-10-20 19:02:48 UTC (rev 2902) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2007-10-20 21:20:00 UTC (rev 2903) @@ -34,6 +34,7 @@ import java.applet.Applet; import java.applet.AppletStub; import java.awt.Color; +import java.awt.FlowLayout; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.GridLayout; @@ -287,11 +288,11 @@ return lwjglApplet; } - /* - * @see java.applet.AppletStub#appletResize(int, int) + /** + * Transfers the call of AppletResize from the stub to the lwjglApplet. */ public void appletResize(int width, int height) { - /* uhm? */ + resize(width, height); } /* @@ -306,9 +307,8 @@ */ public synchronized void paint(Graphics g) { - // paint applet if available - if(lwjglApplet != null && state == STATE_DONE) { - lwjglApplet.paint(g); + // don't paint loader if applet loaded + if(state == STATE_DONE) { return; } @@ -634,16 +634,17 @@ lwjglApplet = (Applet) appletClass.newInstance(); lwjglApplet.setStub(this); + lwjglApplet.setSize(getWidth(), getHeight()); - setLayout(new GridLayout(1, 1)); + setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0)); add(lwjglApplet); - validate(); state = STATE_INITIALIZE_REAL_APPLET; lwjglApplet.init(); state = STATE_START_REAL_APPLET; lwjglApplet.start(); + validate(); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2007-10-24 21:25:57
|
Revision: 2908 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2908&view=rev Author: matzon Date: 2007-10-24 14:25:54 -0700 (Wed, 24 Oct 2007) Log Message: ----------- reworked urlconnection.getInputStream to threaded usage, to avoid Opera issue (detective work: kappaOne) Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2007-10-24 21:23:32 UTC (rev 2907) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2007-10-24 21:25:54 UTC (rev 2908) @@ -44,6 +44,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.reflect.Method; @@ -468,7 +469,7 @@ state = STATE_CHECKING_CACHE; - percentage = 5; + percentage = 5; try { if(debugMode) { @@ -677,7 +678,7 @@ urlconnection = urlList[i].openConnection(); String currentFile = getFileName(urlList[i]); - InputStream inputstream = urlconnection.getInputStream(); + InputStream inputstream = getJarInputStream(currentFile, urlconnection); FileOutputStream fos = new FileOutputStream(path + currentFile); @@ -691,11 +692,62 @@ percentage = initialPercentage + ((currentSizeDownload * 55) / totalSizeDownload); subtaskMessage = "Retrieving: " + currentFile + " " + ((currentSizeDownload * 100) / totalSizeDownload) + "%"; } + + inputstream.close(); + fos.close(); } subtaskMessage = ""; } /** + * Retrieves a jar files input stream. This method exists primarily to fix an Opera hang in getInputStream + * @param urlconnection connection to get input stream from + * @return InputStream or null if not possible + */ + private InputStream getJarInputStream(final String currentFile, final URLConnection urlconnection) throws Exception { + final InputStream[] is = new InputStream[1]; + + // try to get the input stream 3 times. + // Wait at most 5 seconds before interrupting the thread + for (int j = 0; j < 3 && is[0] == null; j++) { + Thread t = new Thread() { + public void run() { + try { + is[0] = urlconnection.getInputStream(); + } catch (IOException e) { + /* ignored */ + } + } + }; + t.setName("JarInputStreamThread"); + t.start(); + + int iterationCount = 0; + while(is == null && iterationCount++ < 5) { + try { + t.join(1000); + } catch (InterruptedException inte) { + /* ignored */ + } + } + + try { + t.interrupt(); + t.join(); + } catch (InterruptedException inte) { + /* ignored */ + } + } + + if(is[0] == null) { + throw new Exception("Unable to get input stream for " + currentFile); + } + + + return is[0]; + } + + /** * This method will extract all file from the native jar and extract them * to the subdirectory called "natives" in the local path, will also check * to see if the native jar files is signed properly This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2007-10-24 21:55:42
|
Revision: 2909 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2909&view=rev Author: matzon Date: 2007-10-24 14:55:39 -0700 (Wed, 24 Oct 2007) Log Message: ----------- miscellaneous minor fixes to improve the loading and displaying of the applet Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2007-10-24 21:25:54 UTC (rev 2908) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2007-10-24 21:55:39 UTC (rev 2909) @@ -33,8 +33,8 @@ import java.applet.Applet; import java.applet.AppletStub; +import java.awt.BorderLayout; import java.awt.Color; -import java.awt.FlowLayout; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Image; @@ -207,6 +207,8 @@ */ public void init() { + state = STATE_INIT; + // sanity check String[] requiredArgs = {"al_main", "al_logo", "al_progressbar", "al_jars"}; for(int i=0; i<requiredArgs.length; i++) { @@ -221,6 +223,8 @@ // get colors of applet bgColor = getColor("al_bgcolor", Color.white); + setBackground(bgColor); + fgColor = getColor("al_fgcolor", Color.black); errorColor = getColor("al_errorcolor", Color.red); @@ -621,7 +625,7 @@ * replace the current applet with the lwjgl applet * using AppletStub and initialise and start it */ - protected void switchApplet() throws Exception { + protected synchronized void switchApplet() throws Exception { state = STATE_SWITCHING_APPLET; percentage = 100; @@ -636,7 +640,7 @@ lwjglApplet.setStub(this); lwjglApplet.setSize(getWidth(), getHeight()); - setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0)); + setLayout(new BorderLayout()); add(lwjglApplet); state = STATE_INITIALIZE_REAL_APPLET; @@ -644,7 +648,12 @@ state = STATE_START_REAL_APPLET; lwjglApplet.start(); + + + // fix for issue with applet not showing up in firefox + setVisible(false); validate(); + setVisible(true); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2008-04-06 22:15:20
|
Revision: 2971 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=2971&view=rev Author: matzon Date: 2008-04-06 15:15:16 -0700 (Sun, 06 Apr 2008) Log Message: ----------- fixed issue with prematurely interrupting the inputstream getter thread\nmade secondary check for inputstream null Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-06 21:34:22 UTC (rev 2970) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-06 22:15:16 UTC (rev 2971) @@ -732,7 +732,7 @@ t.start(); int iterationCount = 0; - while(is == null && iterationCount++ < 5) { + while(is[0] == null && iterationCount++ < 5) { try { t.join(1000); } catch (InterruptedException inte) { @@ -740,12 +740,14 @@ } } - try { - t.interrupt(); - t.join(); - } catch (InterruptedException inte) { - /* ignored */ - } + if(is[0] == null) { + try { + t.interrupt(); + t.join(); + } catch (InterruptedException inte) { + /* ignored */ + } + } } if(is[0] == null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2008-04-13 16:32:59
|
Revision: 3015 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3015&view=rev Author: matzon Date: 2008-04-13 09:32:55 -0700 (Sun, 13 Apr 2008) Log Message: ----------- dont add the platform native jar to the classpath Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-13 11:28:41 UTC (rev 3014) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-13 16:32:55 UTC (rev 3015) @@ -616,7 +616,7 @@ Class[] parameters = new Class[] {URL.class}; // modify class path by adding downloaded jars to it - for (int i = 0; i < urlList.length; i++) { + for (int i = 0; i < urlList.length-1; i++) { // get location of jar as a url URL u = new URL("file:" + path + getFileName(urlList[i])); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2008-04-18 22:34:17
|
Revision: 3023 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3023&view=rev Author: matzon Date: 2008-04-18 15:34:11 -0700 (Fri, 18 Apr 2008) Log Message: ----------- support for pack200 and lzma jars Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-13 19:12:51 UTC (rev 3022) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-18 22:34:11 UTC (rev 3023) @@ -47,6 +47,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; @@ -59,6 +60,8 @@ import java.util.StringTokenizer; import java.util.jar.JarEntry; import java.util.jar.JarFile; +import java.util.jar.JarOutputStream; +import java.util.jar.Pack200; /** * <p> @@ -99,6 +102,7 @@ * $Id$ */ public class AppletLoader extends Applet implements Runnable, AppletStub { + /** initializing */ public static final int STATE_INIT = 1; @@ -192,6 +196,12 @@ /** state of applet loader */ protected int state = STATE_INIT; + /** whether lzma is supported */ + protected boolean lzmaSupported = false; + + /** whether pack200 is supported */ + protected boolean pack200Supported = false; + /** generic error message to display on error */ protected String[] genericErrorMessage = { "An error occured while loading the applet.", "Plese contact support to resolve this issue.", @@ -209,7 +219,6 @@ * @see java.applet.Applet#init() */ public void init() { - state = STATE_INIT; // sanity check @@ -242,6 +251,22 @@ if(logo == null || progressbar == null) { fatalErrorOccured("Unable to load logo and progressbar images"); } + + // check for lzma support + try { + Class.forName("LZMA.LzmaInputStream"); + lzmaSupported = true; + } catch (Throwable e) { + /* no lzma support */ + } + + // check pack200 support + try { + java.util.jar.Pack200.class.getSimpleName(); + pack200Supported = true; + } catch (Throwable e) { + /* no pack200 support */ + } } /* @@ -419,6 +444,22 @@ return "unknown state"; } } + + /** + * Trims the passed file string based on the available capabilities + * @param file string of files to be trimmed + * @return trimmed string based on capabilities of client + */ + protected String trimExtensionByCapabilities(String file) { + if (!pack200Supported) { + file = file.replaceAll(".pack", ""); + } + + if (!lzmaSupported) { + file = file.replaceAll(".lzma", ""); + } + return file; + } /** * Reads list of jars to download and adds the urls to urlList @@ -431,6 +472,8 @@ // jars to load String jarList = getParameter("al_jars"); + jarList = trimExtensionByCapabilities(jarList); + StringTokenizer jar = new StringTokenizer(jarList, ", "); int jarCount = jar.countTokens() + 1; @@ -461,6 +504,7 @@ if (nativeJar == null) { fatalErrorOccured("no lwjgl natives files found"); } else { + nativeJar = trimExtensionByCapabilities(nativeJar); urlList[jarCount - 1] = new URL(path, nativeJar); } } @@ -476,7 +520,6 @@ * */ public void run() { - state = STATE_CHECKING_CACHE; percentage = 5; @@ -542,7 +585,10 @@ // if jars not available or need updating download them if (!cacheAvailable) { // downloads jars from the server - downloadJars(path); // 10-65% + downloadJars(path); // 10-55% + + // Extract Pack and LZMA files + extractJars(path); // 55-65% // Extracts Native Files extractNatives(path); // 65-85% @@ -699,7 +745,7 @@ if(debugMode) { sleep(2000); } - + urlconnection = urlList[i].openConnection(); String currentFile = getFileName(urlList[i]); @@ -714,7 +760,7 @@ } fos.write(buffer, 0, bufferSize); currentSizeDownload += bufferSize; - percentage = initialPercentage + ((currentSizeDownload * 55) / totalSizeDownload); + percentage = initialPercentage + ((currentSizeDownload * 45) / totalSizeDownload); subtaskMessage = "Retrieving: " + currentFile + " " + ((currentSizeDownload * 100) / totalSizeDownload) + "%"; } @@ -729,7 +775,7 @@ * @param urlconnection connection to get input stream from * @return InputStream or null if not possible */ - private InputStream getJarInputStream(final String currentFile, final URLConnection urlconnection) throws Exception { + protected InputStream getJarInputStream(final String currentFile, final URLConnection urlconnection) throws Exception { final InputStream[] is = new InputStream[1]; // try to get the input stream 3 times. @@ -773,8 +819,110 @@ return is[0]; } + + /** + * Extract LZMA File + * @param in Input path to pack file + * @param out output path to resulting file + * @throws exception if any errors occur + */ + protected void extractLZMA(String in, String out) throws Exception { + + File f = new File(in); + FileInputStream fileInputHandle = new FileInputStream(f); + // use reflection to avoid hard dependency + Class clazz = Class.forName( "LZMA.LzmaInputStream" ); + Constructor constructor = clazz.getDeclaredConstructor( new Class[] {InputStream.class} ); + InputStream inputHandle = (InputStream) constructor.newInstance( new Object[] {fileInputHandle} ); + + OutputStream outputHandle; + outputHandle = new FileOutputStream(out); + + byte [] buffer = new byte [1<<14]; + + int ret = inputHandle.read(buffer); + while (ret >= 1) { + outputHandle.write(buffer,0,ret); + ret = inputHandle.read(buffer); + } + + inputHandle.close(); + outputHandle.close(); + + outputHandle = null; + inputHandle = null; + + // delete LZMA file, as it is no longer needed + f.delete(); + + if(debugMode) { + sleep(1000); + } + } + /** + * Extract Pack File + * @param in Input path to pack file + * @param out output path to resulting file + * @throws exception if any errors occur + */ + protected void extractPack(String in, String out) throws Exception { + File f = new File(in); + FileOutputStream fostream = new FileOutputStream(out); + JarOutputStream jostream = new JarOutputStream(fostream); + + Pack200.Unpacker unpacker = Pack200.newUnpacker(); + unpacker.unpack(f, jostream); + jostream.close(); + + // delete pack file as its no longer needed + f.delete(); + + if(debugMode) { + sleep(1000); + } + } + + /** + * Extract all jars from any lzma/pack files + * + * @param path output path + * @throws exception if any errors occur + */ + protected void extractJars(String path) throws Exception { + state = STATE_EXTRACTING_PACKAGES; + + float increment = (float) 10.0 / urlList.length; + // extract all lzma and pack.lzma files + for (int i = 0; i < urlList.length; i++) { + percentage += (int) (increment * (i+1)); + String filename = getFileName(urlList[i]); + + if(debugMode) { + sleep(1000); + } + + if (filename.endsWith(".pack.lzma")) { + extractLZMA(path + filename, path + filename.replaceAll(".lzma", "")); + extractPack(path + filename.replaceAll(".lzma", ""), path + filename.replaceAll(".pack.lzma", "")); + // update list to contain .jar file + urlList[i] = new URL("file://" + path + filename.replaceAll(".pack.lzma", "")); + } + else if (filename.endsWith(".pack")) { + extractPack(path + filename, path + filename.replace(".pack", "")); + // update list to contain .jar file + urlList[i] = new URL("file://" + path + filename.replaceAll(".pack", "")); + } + else if (filename.endsWith(".lzma")) { + extractLZMA(path + filename, path + filename.replace(".lzma", "")); + // update list to contain .jar file + urlList[i] = new URL("file://" + path + filename.replaceAll(".lzma", "")); + } + } + } + + /** * This method will extract all file from the native jar and extract them * to the subdirectory called "natives" in the local path, will also check * to see if the native jar files is signed properly @@ -783,7 +931,7 @@ * @throws Exception if it fails to extract files */ protected void extractNatives(String path) throws Exception { - + state = STATE_EXTRACTING_PACKAGES; int initialPercentage = percentage; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2008-04-19 18:42:12
|
Revision: 3025 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3025&view=rev Author: matzon Date: 2008-04-19 11:42:02 -0700 (Sat, 19 Apr 2008) Log Message: ----------- fixed issue with filenames when cache is turned on Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-18 22:41:05 UTC (rev 3024) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-19 18:42:02 UTC (rev 3025) @@ -658,6 +658,21 @@ state = STATE_UPDATING_CLASSPATH; percentage = 95; + + // update filenames to match extracted files + for (int i = 0; i < urlList.length; i++) { + String filename = getFileName(urlList[i]); + + if (filename.endsWith(".pack.lzma")) { + urlList[i] = new URL("file://" + path + filename.replaceAll(".pack.lzma", "")); + } + else if (filename.endsWith(".pack")) { + urlList[i] = new URL("file://" + path + filename.replaceAll(".pack", "")); + } + else if (filename.endsWith(".lzma")) { + urlList[i] = new URL("file://" + path + filename.replaceAll(".lzma", "")); + } + } Class[] parameters = new Class[] {URL.class}; @@ -906,18 +921,12 @@ if (filename.endsWith(".pack.lzma")) { extractLZMA(path + filename, path + filename.replaceAll(".lzma", "")); extractPack(path + filename.replaceAll(".lzma", ""), path + filename.replaceAll(".pack.lzma", "")); - // update list to contain .jar file - urlList[i] = new URL("file://" + path + filename.replaceAll(".pack.lzma", "")); } else if (filename.endsWith(".pack")) { extractPack(path + filename, path + filename.replace(".pack", "")); - // update list to contain .jar file - urlList[i] = new URL("file://" + path + filename.replaceAll(".pack", "")); } else if (filename.endsWith(".lzma")) { extractLZMA(path + filename, path + filename.replace(".lzma", "")); - // update list to contain .jar file - urlList[i] = new URL("file://" + path + filename.replaceAll(".lzma", "")); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2008-04-20 17:00:00
|
Revision: 3027 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3027&view=rev Author: matzon Date: 2008-04-20 09:59:57 -0700 (Sun, 20 Apr 2008) Log Message: ----------- fix: native file name also has to be updated if they are using lzma or pack Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-20 15:53:11 UTC (rev 3026) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-20 16:59:57 UTC (rev 3027) @@ -659,27 +659,12 @@ percentage = 95; - // update filenames to match extracted files - for (int i = 0; i < urlList.length; i++) { - String filename = getFileName(urlList[i]); - - if (filename.endsWith(".pack.lzma")) { - urlList[i] = new URL("file://" + path + filename.replaceAll(".pack.lzma", "")); - } - else if (filename.endsWith(".pack")) { - urlList[i] = new URL("file://" + path + filename.replaceAll(".pack", "")); - } - else if (filename.endsWith(".lzma")) { - urlList[i] = new URL("file://" + path + filename.replaceAll(".lzma", "")); - } - } - Class[] parameters = new Class[] {URL.class}; // modify class path by adding downloaded jars to it for (int i = 0; i < urlList.length-1; i++) { // get location of jar as a url - URL u = new URL("file:" + path + getFileName(urlList[i])); + URL u = new URL("file:" + path + getJarName(urlList[i])); // add to class path Method method = URLClassLoader.class.getDeclaredMethod("addURL", parameters); @@ -946,7 +931,7 @@ int initialPercentage = percentage; // get name of jar file with natives from urlList, it will be the last url - String nativeJar = getFileName(urlList[urlList.length - 1]); + String nativeJar = getJarName(urlList[urlList.length - 1]); // get the current certificate to compare against native files Certificate[] certificate = AppletLoader.class.getProtectionDomain().getCodeSource().getCertificates(); @@ -1076,9 +1061,29 @@ } return null; } - + /** + * Get jar name from URL. + * + * @param url Get jar file name from this url + * @return file name as string + */ + protected String getJarName(URL url) { + String fileName = url.getFile(); + + if (fileName.endsWith(".pack.lzma")) { + fileName = fileName.replaceAll(".pack.lzma", ""); + } else if (fileName.endsWith(".pack")) { + fileName = fileName.replaceAll(".pack", ""); + } else if (fileName.endsWith(".lzma")) { + fileName = fileName.replaceAll(".lzma", ""); + } + + return fileName.substring(fileName.lastIndexOf('/') + 1); + } + + /** * Get file name portion of URL. * * @param url Get file name from this url This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2008-04-20 19:55:57
|
Revision: 3029 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3029&view=rev Author: matzon Date: 2008-04-20 12:55:55 -0700 (Sun, 20 Apr 2008) Log Message: ----------- fixed percentage calculation error in extractJars added subtask messages to extractJars reworked debug/sleep Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-20 18:46:34 UTC (rev 3028) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-20 19:55:55 UTC (rev 3029) @@ -346,7 +346,7 @@ if(state == STATE_DONE) { return; } - + // create offscreen if missing if (offscreen == null) { offscreen = createImage(getWidth(), getHeight()); @@ -524,10 +524,8 @@ percentage = 5; - try { - if(debugMode) { - sleep(2000); - } + try { + debug_sleep(2000); // parse the urls for the jars into the url list loadJarURLs(); @@ -575,9 +573,7 @@ if (latestVersion <= readVersionFile(dir)) { cacheAvailable = true; percentage = 90; - if(debugMode) { - sleep(2000); - } + debug_sleep(2000); } } } @@ -672,9 +668,7 @@ method.invoke(getClass().getClassLoader(), new Object[] {u}); } - if(debugMode) { - sleep(2000); - } + debug_sleep(2000); // add natives files path to native class path System.setProperty("org.lwjgl.librarypath", path + "natives"); @@ -692,9 +686,7 @@ state = STATE_SWITCHING_APPLET; percentage = 100; - if(debugMode) { - sleep(2000); - } + debug_sleep(2000); Class appletClass = Class.forName(getParameter("al_main")); lwjglApplet = (Applet) appletClass.newInstance(); @@ -742,9 +734,7 @@ // download each jar byte buffer[] = new byte[65536]; for (int i = 0; i < urlList.length; i++) { - if(debugMode) { - sleep(2000); - } + debug_sleep(2000); urlconnection = urlList[i].openConnection(); @@ -755,9 +745,7 @@ int bufferSize; while ((bufferSize = inputstream.read(buffer, 0, buffer.length)) != -1) { - if(debugMode) { - sleep(10); - } + debug_sleep(10); fos.write(buffer, 0, bufferSize); currentSizeDownload += bufferSize; percentage = initialPercentage + ((currentSizeDownload * 45) / totalSizeDownload); @@ -855,10 +843,6 @@ // delete LZMA file, as it is no longer needed f.delete(); - - if(debugMode) { - sleep(1000); - } } /** @@ -878,10 +862,6 @@ // delete pack file as its no longer needed f.delete(); - - if(debugMode) { - sleep(1000); - } } /** @@ -896,21 +876,26 @@ float increment = (float) 10.0 / urlList.length; // extract all lzma and pack.lzma files for (int i = 0; i < urlList.length; i++) { - percentage += (int) (increment * (i+1)); + percentage = 55 + (int) (increment * (i+1)); String filename = getFileName(urlList[i]); - if(debugMode) { - sleep(1000); - } - if (filename.endsWith(".pack.lzma")) { + subtaskMessage = "Extracting: " + filename + " to " + filename.replaceAll(".lzma", ""); + debug_sleep(1000); extractLZMA(path + filename, path + filename.replaceAll(".lzma", "")); + + subtaskMessage = "Extracting: " + filename.replaceAll(".lzma", "") + " to " + filename.replaceAll(".pack.lzma", ""); + debug_sleep(1000); extractPack(path + filename.replaceAll(".lzma", ""), path + filename.replaceAll(".pack.lzma", "")); } else if (filename.endsWith(".pack")) { + subtaskMessage = "Extracting: " + filename + " to " + filename.replace(".pack", ""); + debug_sleep(1000); extractPack(path + filename, path + filename.replace(".pack", "")); } else if (filename.endsWith(".lzma")) { + subtaskMessage = "Extracting: " + filename + " to " + filename.replace(".lzma", ""); + debug_sleep(1000); extractLZMA(path + filename, path + filename.replace(".lzma", "")); } } @@ -986,9 +971,7 @@ } } - if(debugMode) { - sleep(1000); - } + debug_sleep(1000); InputStream in = jarFile.getInputStream(jarFile.getEntry(entry.getName())); OutputStream out = new FileOutputStream(path + "natives" + File.separator + entry.getName()); @@ -997,9 +980,7 @@ byte buffer[] = new byte[65536]; while ((bufferSize = in.read(buffer, 0, buffer.length)) != -1) { - if(debugMode) { - sleep(10); - } + debug_sleep(10); out.write(buffer, 0, bufferSize); currentSizeExtract += bufferSize; @@ -1137,13 +1118,26 @@ /** * Utility method for sleeping + * Will only really sleep if debug has been enabled * @param ms milliseconds to sleep */ + protected void debug_sleep(long ms) { + if(debugMode) { + sleep(ms); + } + } + + /** + * Utility method for sleeping + * @param ms milliseconds to sleep + */ protected void sleep(long ms) { try { Thread.sleep(ms); } catch (Exception e) { /* ignored */ } - } + } + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2008-04-22 20:49:33
|
Revision: 3041 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3041&view=rev Author: kappa1 Date: 2008-04-22 13:32:32 -0700 (Tue, 22 Apr 2008) Log Message: ----------- added check to prevent multiple applet instances starting. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-22 19:59:47 UTC (rev 3040) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-22 20:32:32 UTC (rev 3041) @@ -273,22 +273,27 @@ * @see java.applet.Applet#start() */ public void start() { - if(loaderThread == null && !fatalError) { - loaderThread = new Thread(this); - loaderThread.setName("AppletLoader.loaderThread"); - loaderThread.start(); - - animationThread = new Thread() { - public void run() { - while(loaderThread != null) { - repaint(); - AppletLoader.this.sleep(100); + if (lwjglApplet != null) { + lwjglApplet.start(); + } + else { + if(loaderThread == null && !fatalError) { + loaderThread = new Thread(this); + loaderThread.setName("AppletLoader.loaderThread"); + loaderThread.start(); + + animationThread = new Thread() { + public void run() { + while(loaderThread != null) { + repaint(); + AppletLoader.this.sleep(100); + } + animationThread = null; } - animationThread = null; - } - }; - animationThread.setName("AppletLoader.animationthread"); - animationThread.start(); + }; + animationThread.setName("AppletLoader.animationthread"); + animationThread.start(); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2008-04-24 20:43:48
|
Revision: 3044 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3044&view=rev Author: kappa1 Date: 2008-04-24 13:43:42 -0700 (Thu, 24 Apr 2008) Log Message: ----------- Firefox workaround no longer needed to get applet going. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-24 17:45:50 UTC (rev 3043) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-24 20:43:42 UTC (rev 3044) @@ -701,18 +701,13 @@ setLayout(new BorderLayout()); add(lwjglApplet); + validate(); state = STATE_INITIALIZE_REAL_APPLET; lwjglApplet.init(); state = STATE_START_REAL_APPLET; lwjglApplet.start(); - - - // fix for issue with applet not showing up in firefox - setVisible(false); - validate(); - setVisible(true); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2008-04-25 02:18:29
|
Revision: 3045 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3045&view=rev Author: kappa1 Date: 2008-04-24 19:18:27 -0700 (Thu, 24 Apr 2008) Log Message: ----------- Fix for caching problem, now ensures latest jars are downloaded when using the appletloader caching tag, also no longer fails on receiving incorrect content-type from server. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-24 20:43:42 UTC (rev 3044) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-25 02:18:27 UTC (rev 3045) @@ -737,6 +737,7 @@ debug_sleep(2000); urlconnection = urlList[i].openConnection(); + urlconnection.setUseCaches(false); String currentFile = getFileName(urlList[i]); InputStream inputstream = getJarInputStream(currentFile, urlconnection); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2008-04-27 13:37:17
|
Revision: 3047 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3047&view=rev Author: kappa1 Date: 2008-04-27 06:37:00 -0700 (Sun, 27 Apr 2008) Log Message: ----------- switch caching off globally instead of on a per connection bases. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-25 17:21:59 UTC (rev 3046) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-04-27 13:37:00 UTC (rev 3047) @@ -726,6 +726,7 @@ // calculate total size of jars to download for (int i = 0; i < urlList.length; i++) { urlconnection = urlList[i].openConnection(); + urlconnection.setDefaultUseCaches(false); totalSizeDownload += urlconnection.getContentLength(); } @@ -737,8 +738,7 @@ debug_sleep(2000); urlconnection = urlList[i].openConnection(); - urlconnection.setUseCaches(false); - + String currentFile = getFileName(urlList[i]); InputStream inputstream = getJarInputStream(currentFile, urlconnection); FileOutputStream fos = new FileOutputStream(path + currentFile); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2008-05-06 21:47:58
|
Revision: 3067 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3067&view=rev Author: kappa1 Date: 2008-05-06 14:47:49 -0700 (Tue, 06 May 2008) Log Message: ----------- workaround no longer needed for paint() and switchApplet(), removes blank screen delay between java2d and lwjgl switch. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-05-05 17:24:42 UTC (rev 3066) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-05-06 21:47:49 UTC (rev 3067) @@ -345,7 +345,7 @@ /* * @see java.awt.Container#paint(java.awt.Graphics) */ - public synchronized void paint(Graphics g) { + public void paint(Graphics g) { // don't paint loader if applet loaded if(state == STATE_DONE) { @@ -686,7 +686,7 @@ * replace the current applet with the lwjgl applet * using AppletStub and initialise and start it */ - protected synchronized void switchApplet() throws Exception { + protected void switchApplet() throws Exception { state = STATE_SWITCHING_APPLET; percentage = 100; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2008-05-11 14:42:02
|
Revision: 3068 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3068&view=rev Author: kappa1 Date: 2008-05-11 07:41:46 -0700 (Sun, 11 May 2008) Log Message: ----------- removed repaint() which had no effect. Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-05-06 21:47:49 UTC (rev 3067) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-05-11 14:41:46 UTC (rev 3068) @@ -322,7 +322,7 @@ } /** - * Retrieves the applet that has been loaded. Usefull for liveconnect. + * Retrieves the applet that has been loaded. Useful for liveconnect. */ public Applet getApplet() { return lwjglApplet; @@ -615,7 +615,6 @@ fatalErrorOccured(e.getMessage()); } finally { loaderThread = null; - repaint(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2008-05-22 00:04:13
|
Revision: 3069 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3069&view=rev Author: kappa1 Date: 2008-05-21 17:04:11 -0700 (Wed, 21 May 2008) Log Message: ----------- added support for displaying the current download speed Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java Modified: trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-05-11 14:41:46 UTC (rev 3068) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-05-22 00:04:11 UTC (rev 3069) @@ -744,12 +744,34 @@ int bufferSize; + long downloadStartTime = System.currentTimeMillis(); + int downloadedAmount = 0; + String downloadSpeedMessage = ""; + while ((bufferSize = inputstream.read(buffer, 0, buffer.length)) != -1) { debug_sleep(10); fos.write(buffer, 0, bufferSize); currentSizeDownload += bufferSize; percentage = initialPercentage + ((currentSizeDownload * 45) / totalSizeDownload); subtaskMessage = "Retrieving: " + currentFile + " " + ((currentSizeDownload * 100) / totalSizeDownload) + "%"; + + downloadedAmount += bufferSize; + long timeLapse = System.currentTimeMillis() - downloadStartTime; + // update only if a second or more has passed + if (timeLapse >= 1000) { + // get kb/s, nice that bytes/millis is same as kilobytes/seconds + float downloadSpeed = (float) bufferSize / timeLapse; + // round to two decimal places + downloadSpeed = ((int)(downloadSpeed*100))/100f; + // set current speed message + downloadSpeedMessage = " @ " + downloadSpeed + " KB/sec"; + // reset downloaded amount + downloadedAmount = 0; + // reset start time + downloadStartTime = System.currentTimeMillis(); + } + + subtaskMessage += downloadSpeedMessage; } inputstream.close(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |