From: <ka...@us...> - 2008-08-12 21:02:10
|
Revision: 3115 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3115&view=rev Author: kappa1 Date: 2008-08-12 21:02:06 +0000 (Tue, 12 Aug 2008) Log Message: ----------- Added al_solaris parameter to LWJGL's Appletloader. LWJGL Applets should be ready to go on Solaris as soon as binaries are. 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-08-12 18:03:10 UTC (rev 3114) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2008-08-12 21:02:06 UTC (rev 3115) @@ -83,6 +83,7 @@ * <li>al_windows - [String] Jar containing native files for windows.</li> * <li>al_linux - [String] Jar containing native files for linux.</li> * <li>al_mac - [String] Jar containing native files for mac.</li> + * <li>al_solaris - [String] Jar containing native files for solaris.</li> * </ul> * </p> * <p> @@ -498,10 +499,12 @@ if (osName.startsWith("Win")) { nativeJar = getParameter("al_windows"); - } else if (osName.startsWith("Linux") || osName.startsWith("FreeBSD") || osName.startsWith("SunOS")) { + } else if (osName.startsWith("Linux") || osName.startsWith("FreeBSD")) { nativeJar = getParameter("al_linux"); } else if (osName.startsWith("Mac")) { nativeJar = getParameter("al_mac"); + } else if (osName.startsWith("Solaris") || osName.startsWith("SunOS")) { + nativeJar = getParameter("al_solaris"); } else { fatalErrorOccured("OS (" + osName + ") not supported"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-03-10 15:34:49
|
Revision: 3176 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3176&view=rev Author: kappa1 Date: 2009-03-10 15:34:38 +0000 (Tue, 10 Mar 2009) Log Message: ----------- When an applet is run in debug mode, output in console that a cached version of the applet is being loaded. A number of people were having problems with applets not updating, this was due to them leaving the cache tag on by mistake, hopefully this should alert them earlier and avoid time being wasted in tracking the issue. 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 2009-03-09 21:53:11 UTC (rev 3175) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2009-03-10 15:34:38 UTC (rev 3176) @@ -581,6 +581,10 @@ if (latestVersion <= readVersionFile(dir)) { cacheAvailable = true; percentage = 90; + + if(debugMode) { + System.out.println("Loading Cached Applet Version " + latestVersion); + } debug_sleep(2000); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-03-19 19:50:46
|
Revision: 3187 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3187&view=rev Author: kappa1 Date: 2009-03-19 19:50:38 +0000 (Thu, 19 Mar 2009) Log Message: ----------- Bugfix for incorrect speed calculation, thanks to Dashiva for spotting it. 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 2009-03-19 19:12:37 UTC (rev 3186) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2009-03-19 19:50:38 UTC (rev 3187) @@ -767,7 +767,7 @@ // 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; + float downloadSpeed = (float) downloadedAmount / timeLapse; // round to two decimal places downloadSpeed = ((int)(downloadSpeed*100))/100f; // set current speed message This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-05-08 20:29:32
|
Revision: 3209 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3209&view=rev Author: kappa1 Date: 2009-05-08 20:29:22 +0000 (Fri, 08 May 2009) Log Message: ----------- Spelling Mistake fix, oops :) 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 2009-04-30 18:50:00 UTC (rev 3208) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2009-05-08 20:29:22 UTC (rev 3209) @@ -205,7 +205,7 @@ /** generic error message to display on error */ protected String[] genericErrorMessage = { "An error occured while loading the applet.", - "Plese contact support to resolve this issue.", + "Please contact support to resolve this issue.", "<placeholder for error message>"}; /** whether a certificate refused error occured */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-05-22 09:14:47
|
Revision: 3211 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3211&view=rev Author: kappa1 Date: 2009-05-22 09:14:38 +0000 (Fri, 22 May 2009) Log Message: ----------- BUG FIX: downloaded jars can now connect to the host they were from. 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 2009-05-18 13:24:05 UTC (rev 3210) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2009-05-22 09:14:38 UTC (rev 3211) @@ -44,17 +44,22 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.FilePermission; 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.SocketPermission; import java.net.URL; import java.net.URLClassLoader; import java.net.URLConnection; import java.security.AccessControlException; import java.security.AccessController; +import java.security.CodeSource; +import java.security.PermissionCollection; import java.security.PrivilegedExceptionAction; +import java.security.SecureClassLoader; import java.security.cert.Certificate; import java.util.Enumeration; import java.util.StringTokenizer; @@ -63,6 +68,9 @@ import java.util.jar.JarOutputStream; import java.util.jar.Pack200; +import sun.net.www.ParseUtil; +import sun.security.util.SecurityConstants; + /** * <p> * The AppletLoader enables deployment of LWJGL to applets in an easy @@ -170,6 +178,9 @@ /** urls of the jars to download */ protected URL[] urlList; + /** classLoader used to added downloaded jars to the classpath */ + protected ClassLoader classLoader; + /** actual thread that does the loading */ protected Thread loaderThread; @@ -666,19 +677,45 @@ percentage = 95; - Class[] parameters = new Class[] {URL.class}; + URL[] urls = new URL[urlList.length]; - // 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 + getJarName(urlList[i])); - - // add to class path - Method method = URLClassLoader.class.getDeclaredMethod("addURL", parameters); - method.setAccessible(true); - method.invoke(getClass().getClassLoader(), new Object[] {u}); + for (int i = 0; i < urlList.length; i++) { + urls[i] = new URL("file:" + path + getJarName(urlList[i])); } + // added downloaded jars to the classpath with required permissions + classLoader = new URLClassLoader(urls) { + protected PermissionCollection getPermissions (CodeSource codesource) { + PermissionCollection perms = null; + + try { + // getPermissions from original classloader is important as it checks for signed jars ands shows any security dialogs needed + Method method = SecureClassLoader.class.getDeclaredMethod("getPermissions", new Class[] { CodeSource.class }); + method.setAccessible(true); + perms = (PermissionCollection)method.invoke(getClass().getClassLoader(), new Object[] {codesource}); + + String host = getCodeBase().getHost(); + + if (host != null && (host.length() > 0)) { + // add permission to downloaded jars to access host they were from + perms.add(new SocketPermission(host, SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION)); + } + else if (codesource.getLocation().getProtocol().equals("file")) { + // if running locally add file permission + String path = codesource.getLocation().getFile().replace('/', File.separatorChar); + path = ParseUtil.decode(path); + if (path.endsWith(File.separator)) path += "-"; + perms.add(new FilePermission(path, SecurityConstants.FILE_READ_ACTION)); + } + + } catch (Exception e) { + e.printStackTrace(); + } + + return perms; + } + }; + debug_sleep(2000); // add natives files path to native class path @@ -699,7 +736,7 @@ debug_sleep(2000); - Class appletClass = Class.forName(getParameter("al_main")); + Class appletClass = classLoader.loadClass(getParameter("al_main")); lwjglApplet = (Applet) appletClass.newInstance(); lwjglApplet.setStub(this); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-05-22 09:31:08
|
Revision: 3212 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3212&view=rev Author: kappa1 Date: 2009-05-22 09:30:50 +0000 (Fri, 22 May 2009) Log Message: ----------- Special thanks to Riven in helping find the bug below :) 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 2009-05-22 09:14:38 UTC (rev 3211) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2009-05-22 09:30:50 UTC (rev 3212) @@ -536,7 +536,6 @@ * 3) extract natives * 4) add to jars to class path * 5) switch applets - * */ public void run() { state = STATE_CHECKING_CACHE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-05-28 18:17:13
|
Revision: 3217 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3217&view=rev Author: kappa1 Date: 2009-05-28 18:17:04 +0000 (Thu, 28 May 2009) Log Message: ----------- dependence on 'sun.net.www.ParseUtil;' removed. 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 2009-05-27 08:04:39 UTC (rev 3216) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2009-05-28 18:17:04 UTC (rev 3217) @@ -68,7 +68,6 @@ import java.util.jar.JarOutputStream; import java.util.jar.Pack200; -import sun.net.www.ParseUtil; import sun.security.util.SecurityConstants; /** @@ -78,7 +77,7 @@ * while the relevant jars (generic and native) are downloaded from a specified source. * </p> * <p> - * The downloaded are extracted to the users temporary directory - and if enabled, cached for + * The downloaded jars are extracted to the users temporary directory - and if enabled, cached for * faster loading in future uses. * </p> * <p> @@ -103,6 +102,7 @@ * <li>al_fgcolor - [String] Hex formated color to use as foreground. <i>Default: 000000</i>.</li> * <li>al_errorcolor - [String] Hex formated color to use as foreground color on error. <i>Default: ff0000</i>.</li> * <li>al_debug - [boolean] Whether to enable debug mode. <i>Default: false</i>.</li> + * <li>al_prepend_host - [boolean] Whether to limit caching to this domain, disable if your applet is hosted on multple domains and needs to share the cache. <i>Default: true</i>.</li> * </ul> * </p> * @author kappaOne @@ -172,19 +172,19 @@ /** Color to write errors in */ protected Color errorColor = Color.red; - /** color to write forground in */ + /** color to write foreground in */ protected Color fgColor = Color.black; /** urls of the jars to download */ protected URL[] urlList; - /** classLoader used to added downloaded jars to the classpath */ + /** classLoader used to add downloaded jars to the classpath */ protected ClassLoader classLoader; /** actual thread that does the loading */ protected Thread loaderThread; - /** animation thread that renders our loaderscreen while loading */ + /** animation thread that renders our load screen while loading */ protected Thread animationThread; /** applet to load after all downloads are complete */ @@ -682,13 +682,13 @@ urls[i] = new URL("file:" + path + getJarName(urlList[i])); } - // added downloaded jars to the classpath with required permissions + // add downloaded jars to the classpath with required permissions classLoader = new URLClassLoader(urls) { protected PermissionCollection getPermissions (CodeSource codesource) { PermissionCollection perms = null; try { - // getPermissions from original classloader is important as it checks for signed jars ands shows any security dialogs needed + // getPermissions from original classloader is important as it checks for signed jars and shows any security dialogs needed Method method = SecureClassLoader.class.getDeclaredMethod("getPermissions", new Class[] { CodeSource.class }); method.setAccessible(true); perms = (PermissionCollection)method.invoke(getClass().getClassLoader(), new Object[] {codesource}); @@ -696,14 +696,12 @@ String host = getCodeBase().getHost(); if (host != null && (host.length() > 0)) { - // add permission to downloaded jars to access host they were from + // add permission for downloaded jars to access host they were from perms.add(new SocketPermission(host, SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION)); } else if (codesource.getLocation().getProtocol().equals("file")) { // if running locally add file permission String path = codesource.getLocation().getFile().replace('/', File.separatorChar); - path = ParseUtil.decode(path); - if (path.endsWith(File.separator)) path += "-"; perms.add(new FilePermission(path, SecurityConstants.FILE_READ_ACTION)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2009-06-11 21:07:37
|
Revision: 3222 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3222&view=rev Author: matzon Date: 2009-06-11 21:07:34 +0000 (Thu, 11 Jun 2009) Log Message: ----------- print stacktrace if possible on fatal errors, fixed NPE in paint 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 2009-06-03 18:29:05 UTC (rev 3221) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2009-06-11 21:07:34 UTC (rev 3222) @@ -48,6 +48,9 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.io.Writer; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.SocketPermission; @@ -237,7 +240,7 @@ String[] requiredArgs = {"al_main", "al_logo", "al_progressbar", "al_jars"}; for(int i=0; i<requiredArgs.length; i++) { if(getParameter(requiredArgs[i]) == null) { - fatalErrorOccured("missing required applet parameter: " + requiredArgs[i]); + fatalErrorOccured("missing required applet parameter: " + requiredArgs[i], null); return; } } @@ -261,7 +264,7 @@ //sanity check if(logo == null || progressbar == null) { - fatalErrorOccured("Unable to load logo and progressbar images"); + fatalErrorOccured("Unable to load logo and progressbar images", null); } // check for lzma support @@ -281,6 +284,18 @@ } } + /** + * Generates a stacktrace in the form of a string + * @param exception Exception to make stacktrace of + * @return Stacktrace of exception in the form of a string + */ + private String generateStacktrace(Exception exception) { + Writer result = new StringWriter(); + PrintWriter printWriter = new PrintWriter(result); + exception.printStackTrace(printWriter); + return result.toString(); + } + /* * @see java.applet.Applet#start() */ @@ -397,11 +412,13 @@ } 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(errorMessage[i], messageX, messageY + i*fm.getHeight()); + if(errorMessage[i] != null) { + int messageX = (getWidth() - fm.stringWidth(errorMessage[i])) / 2; + int messageY = (getHeight() - (fm.getHeight() * errorMessage.length)) / 2; + + og.setColor(errorColor); + og.drawString(errorMessage[i], messageX, messageY + i*fm.getHeight()); + } } } else { og.setColor(fgColor); @@ -517,11 +534,11 @@ } else if (osName.startsWith("Solaris") || osName.startsWith("SunOS")) { nativeJar = getParameter("al_solaris"); } else { - fatalErrorOccured("OS (" + osName + ") not supported"); + fatalErrorOccured("OS (" + osName + ") not supported", null); } if (nativeJar == null) { - fatalErrorOccured("no lwjgl natives files found"); + fatalErrorOccured("no lwjgl natives files found", null); } else { nativeJar = trimExtensionByCapabilities(nativeJar); urlList[jarCount - 1] = new URL(path, nativeJar); @@ -626,10 +643,10 @@ state = STATE_DONE; } catch (AccessControlException ace) { - fatalErrorOccured(ace.getMessage()); + fatalErrorOccured(ace.getMessage(), ace); certificateRefused = true; } catch (Exception e) { - fatalErrorOccured(e.getMessage()); + fatalErrorOccured(e.getMessage(), e); } finally { loaderThread = null; } @@ -1172,10 +1189,13 @@ * * @param error Error message to print */ - protected void fatalErrorOccured(String error) { + protected void fatalErrorOccured(String error, Exception e) { fatalError = true; fatalErrorDescription = "Fatal error occured (" + state + "): " + error; System.out.println(fatalErrorDescription); + if(e != null) { + System.out.println(generateStacktrace(e)); + } repaint(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-06-15 13:09:12
|
Revision: 3223 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3223&view=rev Author: kappa1 Date: 2009-06-15 13:08:52 +0000 (Mon, 15 Jun 2009) Log Message: ----------- Fix: allow logo's outside the appletloader.jar to be used. 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 2009-06-11 21:07:34 UTC (rev 3222) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2009-06-15 13:08:52 UTC (rev 3223) @@ -38,7 +38,6 @@ import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Image; -import java.awt.Toolkit; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; @@ -71,6 +70,8 @@ import java.util.jar.JarOutputStream; import java.util.jar.Pack200; +import javax.imageio.ImageIO; + import sun.security.util.SecurityConstants; /** @@ -259,8 +260,8 @@ errorColor = getColor("al_errorcolor", Color.red); // load logos - logo = getImage("/" + getParameter("al_logo")); - progressbar = getImage("/" + getParameter("al_progressbar")); + logo = getImage(getParameter("al_logo")); + progressbar = getImage(getParameter("al_progressbar")); //sanity check if(logo == null || progressbar == null) { @@ -1112,11 +1113,14 @@ */ protected Image getImage(String s) { try { - DataInputStream datainputstream = new DataInputStream(getClass().getResourceAsStream(s)); - byte abyte0[] = new byte[datainputstream.available()]; - datainputstream.readFully(abyte0); - datainputstream.close(); - return Toolkit.getDefaultToolkit().createImage(abyte0); + URL url = AppletLoader.class.getResource("/"+s); + + // if logo not found in jar, look at URL + if (url == null) { + url = new URL(getCodeBase(), s); + } + + return ImageIO.read(url); } catch (Exception e) { /* */ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-07-01 18:06:05
|
Revision: 3225 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3225&view=rev Author: kappa1 Date: 2009-07-01 18:05:44 +0000 (Wed, 01 Jul 2009) Log Message: ----------- fix: Animated gif's were not working with ImageIO as it only returns a BufferedImage, so switched to Toolkit with MediaTracker. 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 2009-06-19 10:32:57 UTC (rev 3224) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2009-07-01 18:05:44 UTC (rev 3225) @@ -38,6 +38,7 @@ import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Image; +import java.awt.MediaTracker; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; @@ -70,8 +71,6 @@ import java.util.jar.JarOutputStream; import java.util.jar.Pack200; -import javax.imageio.ImageIO; - import sun.security.util.SecurityConstants; /** @@ -1115,12 +1114,19 @@ try { URL url = AppletLoader.class.getResource("/"+s); - // if logo not found in jar, look at URL + // if image not found in jar, look outside it if (url == null) { url = new URL(getCodeBase(), s); } - return ImageIO.read(url); + Image image = super.getImage(url); + + // wait for image to load + MediaTracker tracker = new MediaTracker(this); + tracker.addImage(image, 0); + tracker.waitForAll(); + + return image; } catch (Exception e) { /* */ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-09-03 20:16:20
|
Revision: 3235 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3235&view=rev Author: kappa1 Date: 2009-09-03 20:15:46 +0000 (Thu, 03 Sep 2009) Log Message: ----------- Java caching properly disabled, this should prevent the AppletLoader from continuing to load jars from the java cache which have become corrupt. The infamous "Fatal Error occured (5): null" bug should now go away on refresh as the files are redownloaded. 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 2009-08-12 14:48:37 UTC (rev 3234) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2009-09-03 20:15:46 UTC (rev 3235) @@ -52,6 +52,7 @@ import java.io.StringWriter; import java.io.Writer; import java.lang.reflect.Constructor; +import java.lang.reflect.Field; import java.lang.reflect.Method; import java.net.SocketPermission; import java.net.URL; @@ -779,11 +780,15 @@ state = STATE_DOWNLOADING; URLConnection urlconnection; + + // disable the java caching + Field field = URLConnection.class.getDeclaredField("defaultUseCaches"); + field.setAccessible(true); + field.setBoolean(URLConnection.class, false); // 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(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-09-09 11:24:39
|
Revision: 3238 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3238&view=rev Author: kappa1 Date: 2009-09-09 11:24:29 +0000 (Wed, 09 Sep 2009) Log Message: ----------- Undo fix for the error 5: null error, since it does not work. 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 2009-09-08 15:07:15 UTC (rev 3237) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2009-09-09 11:24:29 UTC (rev 3238) @@ -52,7 +52,6 @@ import java.io.StringWriter; import java.io.Writer; import java.lang.reflect.Constructor; -import java.lang.reflect.Field; import java.lang.reflect.Method; import java.net.SocketPermission; import java.net.URL; @@ -781,14 +780,10 @@ URLConnection urlconnection; - // disable the java caching - Field field = URLConnection.class.getDeclaredField("defaultUseCaches"); - field.setAccessible(true); - field.setBoolean(URLConnection.class, false); - // 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(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-10-08 00:04:07
|
Revision: 3244 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3244&view=rev Author: kappa1 Date: 2009-10-08 00:03:55 +0000 (Thu, 08 Oct 2009) Log Message: ----------- AppletLoader file download handling improved. Unknown Caching that was causing problems has been found and disabled. The infamous "Fatal Error occured (5): null" bug should really be dead this time :) 3 attempts are made to download a file if it fails to download. File size is now verified after a downloaded to make sure it is the correct size. 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 2009-09-29 13:51:41 UTC (rev 3243) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2009-10-08 00:03:55 UTC (rev 3244) @@ -53,6 +53,7 @@ import java.io.Writer; import java.lang.reflect.Constructor; import java.lang.reflect.Method; +import java.net.HttpURLConnection; import java.net.SocketPermission; import java.net.URL; import java.net.URLClassLoader; @@ -780,11 +781,15 @@ URLConnection urlconnection; + // store file sizes, used for download verification + int[] fileSizes = new int[urlList.length]; + // 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(); + fileSizes[i] = urlconnection.getContentLength(); + totalSizeDownload += fileSizes[i]; } int initialPercentage = percentage = 10; @@ -792,48 +797,88 @@ // download each jar byte buffer[] = new byte[65536]; for (int i = 0; i < urlList.length; i++) { - debug_sleep(2000); - - urlconnection = urlList[i].openConnection(); - String currentFile = getFileName(urlList[i]); - InputStream inputstream = getJarInputStream(currentFile, urlconnection); - FileOutputStream fos = new FileOutputStream(path + currentFile); + int unsuccessfulAttempts = 0; + int maxUnsuccessfulAttempts = 3; + boolean downloadFile = true; - - 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) + "%"; + // download the jar a max of 3 times + while(downloadFile) { + downloadFile = false; - 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) downloadedAmount / 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(); + debug_sleep(2000); + + urlconnection = urlList[i].openConnection(); + + if (urlconnection instanceof HttpURLConnection) { + urlconnection.setRequestProperty("Cache-Control", "no-cache"); + urlconnection.connect(); + } + + String currentFile = getFileName(urlList[i]); + InputStream inputstream = getJarInputStream(currentFile, urlconnection); + FileOutputStream fos = new FileOutputStream(path + currentFile); + + + int bufferSize; + long downloadStartTime = System.currentTimeMillis(); + int downloadedAmount = 0; + int fileSize = 0; + String downloadSpeedMessage = ""; + + while ((bufferSize = inputstream.read(buffer, 0, buffer.length)) != -1) { + debug_sleep(10); + fos.write(buffer, 0, bufferSize); + currentSizeDownload += bufferSize; + fileSize += 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) downloadedAmount / 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; } - subtaskMessage += downloadSpeedMessage; + inputstream.close(); + fos.close(); + + // download complete, verify if it was successful + if (urlconnection instanceof HttpURLConnection) { + if (fileSize == fileSizes[i]) { + // successful download + } + else if (fileSizes[i] <= 0) { + // If contentLength for fileSizes[i] <= 0, we don't know if the download + // is complete. We're going to guess the download is complete. + } + else { + unsuccessfulAttempts++; + // download failed try again + if (unsuccessfulAttempts < maxUnsuccessfulAttempts) { + downloadFile = true; + currentSizeDownload -= fileSize; // reset progress bar + } + else { + // retry attempts exhasted, download failed + fatalErrorOccured("failed to download " + currentFile, null); + } + } + } } - - inputstream.close(); - fos.close(); } subtaskMessage = ""; } @@ -1233,4 +1278,4 @@ } -} +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2009-10-12 11:56:53
|
Revision: 3245 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3245&view=rev Author: kappa1 Date: 2009-10-12 11:56:46 +0000 (Mon, 12 Oct 2009) Log Message: ----------- Stop AppletLoader on download failure, instead of displaying error and continuing download of files. 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 2009-10-08 00:03:55 UTC (rev 3244) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2009-10-12 11:56:46 UTC (rev 3245) @@ -874,7 +874,7 @@ } else { // retry attempts exhasted, download failed - fatalErrorOccured("failed to download " + currentFile, null); + throw new Exception("failed to download " + currentFile); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2009-11-20 23:06:32
|
Revision: 3251 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3251&view=rev Author: matzon Date: 2009-11-20 23:06:24 +0000 (Fri, 20 Nov 2009) Log Message: ----------- workaround for missing certificate for AppletLoader if cached 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 2009-11-15 21:36:49 UTC (rev 3250) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2009-11-20 23:06:24 UTC (rev 3251) @@ -54,6 +54,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.HttpURLConnection; +import java.net.JarURLConnection; import java.net.SocketPermission; import java.net.URL; import java.net.URLClassLoader; @@ -1045,6 +1046,16 @@ // get the current certificate to compare against native files Certificate[] certificate = AppletLoader.class.getProtectionDomain().getCodeSource().getCertificates(); + + // workaround for bug where cached applet loader does not have certificates!? + if (certificate == null) { + URL location = AppletLoader.class.getProtectionDomain().getCodeSource().getLocation(); + + // manually load the certificate + JarURLConnection jurl = (JarURLConnection) (new URL("jar:" + location.toString() + "!/org/lwjgl/util/applet/AppletLoader.class").openConnection()); + jurl.setDefaultUseCaches(true); + certificate = jurl.getCertificates(); + } // create native folder File nativeFolder = new File(path + "natives"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2009-11-20 23:26:35
|
Revision: 3252 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3252&view=rev Author: matzon Date: 2009-11-20 23:26:26 +0000 (Fri, 20 Nov 2009) Log Message: ----------- use HEAD request when determening file size 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 2009-11-20 23:06:24 UTC (rev 3251) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2009-11-20 23:26:26 UTC (rev 3252) @@ -73,6 +73,8 @@ import java.util.jar.JarOutputStream; import java.util.jar.Pack200; +import com.sun.net.ssl.HttpsURLConnection; + import sun.security.util.SecurityConstants; /** @@ -789,6 +791,9 @@ for (int i = 0; i < urlList.length; i++) { urlconnection = urlList[i].openConnection(); urlconnection.setDefaultUseCaches(false); + if (urlconnection instanceof HttpURLConnection) { + ((HttpURLConnection) urlconnection).setRequestMethod("HEAD"); + } fileSizes[i] = urlconnection.getContentLength(); totalSizeDownload += fileSizes[i]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2009-11-20 23:28:48
|
Revision: 3253 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3253&view=rev Author: matzon Date: 2009-11-20 23:28:37 +0000 (Fri, 20 Nov 2009) Log Message: ----------- cleanup imports 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 2009-11-20 23:26:26 UTC (rev 3252) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2009-11-20 23:28:37 UTC (rev 3253) @@ -73,8 +73,6 @@ import java.util.jar.JarOutputStream; import java.util.jar.Pack200; -import com.sun.net.ssl.HttpsURLConnection; - import sun.security.util.SecurityConstants; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2010-04-01 18:28:05
|
Revision: 3304 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3304&view=rev Author: kappa1 Date: 2010-04-01 18:27:51 +0000 (Thu, 01 Apr 2010) Log Message: ----------- Added better support for FreeBSD to appletloader. Thx to monty_hall for the patch. 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 2010-04-01 15:05:32 UTC (rev 3303) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2010-04-01 18:27:51 UTC (rev 3304) @@ -96,6 +96,7 @@ * <li>al_linux - [String] Jar containing native files for linux.</li> * <li>al_mac - [String] Jar containing native files for mac.</li> * <li>al_solaris - [String] Jar containing native files for solaris.</li> + * <li>al_freebsd - [String] Jar containing native files for freebsd.</li> * </ul> * </p> * <p> @@ -529,12 +530,14 @@ if (osName.startsWith("Win")) { nativeJar = getParameter("al_windows"); - } else if (osName.startsWith("Linux") || osName.startsWith("FreeBSD")) { + } else if (osName.startsWith("Linux")) { nativeJar = getParameter("al_linux"); } else if (osName.startsWith("Mac")) { nativeJar = getParameter("al_mac"); } else if (osName.startsWith("Solaris") || osName.startsWith("SunOS")) { nativeJar = getParameter("al_solaris"); + } else if (osName.startsWith("FreeBSD")) { + nativeJar = getParameter("al_freebsd"); } else { fatalErrorOccured("OS (" + osName + ") not supported", null); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2010-04-01 21:01:58
|
Revision: 3305 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3305&view=rev Author: kappa1 Date: 2010-04-01 21:01:51 +0000 (Thu, 01 Apr 2010) Log Message: ----------- Allow LWJGL applets to work when seperate_jvm parameter is not supported (i.e. java plugin1). 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 2010-04-01 18:27:51 UTC (rev 3304) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2010-04-01 21:01:51 UTC (rev 3305) @@ -52,6 +52,7 @@ import java.io.StringWriter; import java.io.Writer; import java.lang.reflect.Constructor; +import java.lang.reflect.Field; import java.lang.reflect.Method; import java.net.HttpURLConnection; import java.net.JarURLConnection; @@ -68,6 +69,7 @@ import java.security.cert.Certificate; import java.util.Enumeration; import java.util.StringTokenizer; +import java.util.Vector; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.JarOutputStream; @@ -233,6 +235,9 @@ "Please accept the permissions dialog to allow", "the applet to continue the loading process."}; + /** have natives been loaded by another instance of this applet */ + static protected boolean natives_loaded = false; + /* * @see java.applet.Applet#init() */ @@ -736,13 +741,67 @@ }; debug_sleep(2000); - + + // unload natives loaded by a previous instance of this lwjgl applet + unloadNatives(path); + // add natives files path to native class path System.setProperty("org.lwjgl.librarypath", path + "natives"); // Make sure jinput knows about the new path too System.setProperty("net.java.games.input.librarypath", path + "natives"); + + // mark natives as loaded + natives_loaded = true; } + + /** + * Unload natives loaded by a different classloader. + * + * Due to limitations of the jvm, native files can only + * be loaded once and only be used by the classloader + * they were loaded from. + * + * Due to the way applets on plugin1 work, one jvm must + * be used for all applets. We need to use multiple + * classloaders in the same jvm due to LWJGL's static + * nature. I order to solver this we simply remove the + * natives from a previous classloader allowing a new + * classloader to use those natives in the same jvm. + * + * This method will only attempt to unload natives from a + * previous classloader if it detects that the natives have + * been loaded in the same jvm. + * + * @param nativePath directory where natives are stored + */ + private void unloadNatives(String nativePath) { + + // check whether natives have been loaded into this jvm + if (!natives_loaded) { + return; + } + + try { + Field field = ClassLoader.class.getDeclaredField("loadedLibraryNames"); + field.setAccessible(true); + Vector libs = (Vector) field.get(getClass().getClassLoader()); + + String path = new File(nativePath).getCanonicalPath(); + + for (int i = 0; i < libs.size(); i++) { + String s = (String) libs.get(i); + + // if a native from the nativePath directory is loaded, unload it + if (s.startsWith(path)) { + libs.remove(i); + i--; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } /** * replace the current applet with the lwjgl applet This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2010-05-21 22:55:17
|
Revision: 3343 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3343&view=rev Author: kappa1 Date: 2010-05-21 22:55:11 +0000 (Fri, 21 May 2010) Log Message: ----------- small 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 2010-05-21 22:26:23 UTC (rev 3342) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2010-05-21 22:55:11 UTC (rev 3343) @@ -339,7 +339,6 @@ if (lwjglApplet != null) { lwjglApplet.stop(); } - super.stop(); } /* @@ -352,8 +351,6 @@ progressbar = null; logo = null; - - super.destroy(); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2010-07-04 11:03:26
|
Revision: 3361 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3361&view=rev Author: kappa1 Date: 2010-07-04 11:03:20 +0000 (Sun, 04 Jul 2010) Log Message: ----------- Appletloader: Added parameter support for al_windows32, al_windows64, al_linux32 and al_linux64 for those that would like to split their 32/64 bit natives files to provide a smaller download. 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 2010-06-16 12:33:38 UTC (rev 3360) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2010-07-04 11:03:20 UTC (rev 3361) @@ -106,11 +106,17 @@ * <ul> * <li>al_version - [int or float] Version of deployment. If this is specified, the jars will be cached and * reused if the version matches. If version doesn't match all of the files are reloaded.</li> + * <li>al_debug - [boolean] Whether to enable debug mode. <i>Default: false</i>.</li> + * <li>al_prepend_host - [boolean] Whether to limit caching to this domain, disable if your applet is hosted on multple domains and needs to share the cache. <i>Default: true</i>.</li> + * <ul> + * <li>al_windows64 - [String] If specified it will be used instead of al_windows on 64bit windows systems.</li> + * <li>al_windows32 - [String] If specifed it will be used instead of al_windows on 32bit windows systems.</li> + * <li>al_linux64 - [String] If specifed it will be used instead of al_linux on 64bit linux systems.</li> + * <li>al_linux32 - [String] If specifed it will be used instead of al_linux on 32bit linux systems.</li> + * <ul> * <li>al_bgcolor - [String] Hex formated color to use as background. <i>Default: ffffff</i>.</li> * <li>al_fgcolor - [String] Hex formated color to use as foreground. <i>Default: 000000</i>.</li> * <li>al_errorcolor - [String] Hex formated color to use as foreground color on error. <i>Default: ff0000</i>.</li> - * <li>al_debug - [boolean] Whether to enable debug mode. <i>Default: false</i>.</li> - * <li>al_prepend_host - [boolean] Whether to limit caching to this domain, disable if your applet is hosted on multple domains and needs to share the cache. <i>Default: true</i>.</li> * </ul> * </p> * @author kappaOne @@ -531,9 +537,31 @@ String nativeJar = null; if (osName.startsWith("Win")) { - nativeJar = getParameter("al_windows"); + + // check if arch specific natives have been specified + if (System.getProperty("os.arch").endsWith("64")) { + nativeJar = getParameter("al_windows64"); + } else { + nativeJar = getParameter("al_windows32"); + } + + if (nativeJar == null) { + nativeJar = getParameter("al_windows"); + } + } else if (osName.startsWith("Linux")) { - nativeJar = getParameter("al_linux"); + + // check if arch specific natives have been specified + if (System.getProperty("os.arch").endsWith("64")) { + nativeJar = getParameter("al_linux64"); + } else { + nativeJar = getParameter("al_linux32"); + } + + if (nativeJar == null) { + nativeJar = getParameter("al_linux"); + } + } else if (osName.startsWith("Mac")) { nativeJar = getParameter("al_mac"); } else if (osName.startsWith("Solaris") || osName.startsWith("SunOS")) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2010-07-04 14:35:47
|
Revision: 3362 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3362&view=rev Author: kappa1 Date: 2010-07-04 14:35:41 +0000 (Sun, 04 Jul 2010) Log Message: ----------- AppletLoader: Parameters boxbgcolor, boxfgcolor and boxerrorcolor have been added. Previous parameters al_bgcolor, al_fgcolor and al_errorcolor have been removed. Unlike the previous color support now you can specify the color as a string name of any AWT Color ("red", "blue", "yellow", etc), RGB format (0-255, e.g. "255,0,0") or html HEX color (must use leading #, previous didn't need to have the # e.g. "#FF0000"). This is to match the color support of boxbgcolor and boxfgcolor of the java plugin, so now the color is set and appears before the appletloader is even loaded. 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 2010-07-04 11:03:20 UTC (rev 3361) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2010-07-04 14:35:41 UTC (rev 3362) @@ -114,9 +114,9 @@ * <li>al_linux64 - [String] If specifed it will be used instead of al_linux on 64bit linux systems.</li> * <li>al_linux32 - [String] If specifed it will be used instead of al_linux on 32bit linux systems.</li> * <ul> - * <li>al_bgcolor - [String] Hex formated color to use as background. <i>Default: ffffff</i>.</li> - * <li>al_fgcolor - [String] Hex formated color to use as foreground. <i>Default: 000000</i>.</li> - * <li>al_errorcolor - [String] Hex formated color to use as foreground color on error. <i>Default: ff0000</i>.</li> + * <li>boxbgcolor - [String] any String AWT color ("red", "blue", etc), RGB (0-255) or hex formated color (#RRGGBB) to use as background. <i>Default: #ffffff</i>.</li> + * <li>boxfgcolor - [String] any String AWT color ("red", "blue", etc), RGB (0-255) or hex formated color (#RRGGBB) to use as foreground. <i>Default: #000000</i>.</li> + * <li>boxerrorcolor - [String] any String AWT color ("red", "blue", etc), RGB (0-255) or hex formated color (#RRGGBB) to use as foreground color on error. <i>Default: #ff0000</i>.</li> * </ul> * </p> * @author kappaOne @@ -266,11 +266,11 @@ prependHost = getBooleanParameter("al_prepend_host", true); // get colors of applet - bgColor = getColor("al_bgcolor", Color.white); + bgColor = getColor("boxbgcolor", Color.white); setBackground(bgColor); - fgColor = getColor("al_fgcolor", Color.black); - errorColor = getColor("al_errorcolor", Color.red); + fgColor = getColor("boxfgcolor", Color.black); + errorColor = getColor("boxerrorcolor", Color.red); // load logos logo = getImage(getParameter("al_logo")); @@ -1318,12 +1318,39 @@ * @param defaultColor Default color to use if no color to load * @return Color to use */ - protected Color getColor(String color, Color defaultColor) { - String param_color = getParameter(color); - if (param_color != null) { - return new Color(Integer.parseInt(param_color, 16)); - } - return defaultColor; + protected Color getColor(String param, Color defaultColor) { + String color = getParameter(param); + + if (color == null) return defaultColor; + + // Check if RGB format + if (color.indexOf(",") != -1) { + StringTokenizer st = new StringTokenizer(color, ","); + + // We've got three components for the color + try { + return new Color(Integer.parseInt(st.nextToken().trim()), + Integer.parseInt(st.nextToken().trim()), + Integer.parseInt(st.nextToken().trim())); + } catch (Exception e) { + // failed to parse + return defaultColor; + } + } + + // Check & decode if the color is in hexadecimal color format (i.e. #808000) + try { + return Color.decode(color); + } catch (NumberFormatException e) { + // ignore exception + } + + // Get the color by name if it exists + try { + return (Color)Color.class.getField(color).get(null); + } catch (Exception e) { + return defaultColor; + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2010-07-08 21:12:26
|
Revision: 3367 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3367&view=rev Author: kappa1 Date: 2010-07-08 21:12:20 +0000 (Thu, 08 Jul 2010) Log Message: ----------- AppletLoader: auto centre logo if applet is resized. 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 2010-07-07 12:37:40 UTC (rev 3366) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2010-07-08 21:12:20 UTC (rev 3367) @@ -399,16 +399,16 @@ Graphics og = offscreen.getGraphics(); FontMetrics fm = og.getFontMetrics(); - // set background color + // clear background color og.setColor(bgColor); - og.fillRect(0, 0, getWidth(), getHeight()); + og.fillRect(0, 0, offscreen.getWidth(null), offscreen.getHeight(null)); // get logo position so its in the middle of applet int x = 0, y = 0; if(logo != null && !fatalError) { - x = (getWidth() - logo.getWidth(this)) / 2; - y = (getHeight() - logo.getHeight(this)) / 2; + x = (offscreen.getWidth(null) - logo.getWidth(this)) / 2; + y = (offscreen.getHeight(null) - logo.getHeight(this)) / 2; } og.setColor(fgColor); @@ -424,8 +424,8 @@ for(int i=0; i<errorMessage.length; i++) { if(errorMessage[i] != null) { - int messageX = (getWidth() - fm.stringWidth(errorMessage[i])) / 2; - int messageY = (getHeight() - (fm.getHeight() * errorMessage.length)) / 2; + int messageX = (offscreen.getWidth(null) - fm.stringWidth(errorMessage[i])) / 2; + int messageY = (offscreen.getHeight(null) - (fm.getHeight() * errorMessage.length)) / 2; og.setColor(errorColor); og.drawString(errorMessage[i], messageX, messageY + i*fm.getHeight()); @@ -438,27 +438,27 @@ og.drawImage(logo, x, y, null); // draw message - int messageX = (getWidth() - fm.stringWidth(message)) / 2; + int messageX = (offscreen.getWidth(null) - fm.stringWidth(message)) / 2; int messageY = y + logo.getHeight(null) + 20; og.drawString(message, messageX, messageY); // draw subtaskmessage, if any if(subtaskMessage.length() > 0) { - messageX = (getWidth() - fm.stringWidth(subtaskMessage)) / 2; + messageX = (offscreen.getWidth(null) - fm.stringWidth(subtaskMessage)) / 2; og.drawString(subtaskMessage, messageX, messageY+20); } // draw loading bar, clipping it depending on percentage done int barSize = (progressbar.getWidth(this) * percentage) / 100; - og.clipRect(0, 0, x + barSize, getHeight()); + og.clipRect(0, 0, x + barSize, offscreen.getHeight(null)); og.drawImage(progressbar, x, y, null); } og.dispose(); - // finally draw it all - g.drawImage(offscreen, 0, 0, null); - } + // finally draw it all centred + g.drawImage(offscreen, (getWidth() - offscreen.getWidth(null))/2, (getHeight() - offscreen.getHeight(null))/2, null); + } /** * @return string describing the state of the loader This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2010-07-10 11:57:01
|
Revision: 3371 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3371&view=rev Author: kappa1 Date: 2010-07-10 11:56:55 +0000 (Sat, 10 Jul 2010) Log Message: ----------- AppletLoader: fixed flicker on animated gifs using ImageObserver. When image is ready to be drawn it is copied into a buffer image ready to be drawn. Also now supports variable time animated gifs and not limited to drawing only every 100ms. 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 2010-07-09 21:46:27 UTC (rev 3370) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2010-07-10 11:56:55 UTC (rev 3371) @@ -39,6 +39,7 @@ import java.awt.Graphics; import java.awt.Image; import java.awt.MediaTracker; +import java.awt.image.ImageObserver; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; @@ -172,14 +173,17 @@ protected int totalSizeExtract; /** logo to be shown while loading */ - protected Image logo; + protected Image logo, logoBuffer; /** progressbar to render while loading */ - protected Image progressbar; + protected Image progressbar, progressbarBuffer; /** offscreen image used */ protected Image offscreen; + /** set to true while painting is done */ + protected boolean painting; + /** background color of applet */ protected Color bgColor = Color.white; @@ -357,6 +361,9 @@ progressbar = null; logo = null; + + logoBuffer = null; + progressbarBuffer = null; } /** @@ -393,6 +400,18 @@ // create offscreen if missing if (offscreen == null) { offscreen = createImage(getWidth(), getHeight()); + + // create buffers for animated gifs + logoBuffer = createImage(logo.getWidth(null), logo.getHeight(null)); + progressbarBuffer = createImage(logo.getWidth(null), logo.getHeight(null)); + + // add image observer, it will notify when next animated gif frame is ready + offscreen.getGraphics().drawImage(logo, 0, 0, this); + offscreen.getGraphics().drawImage(progressbar, 0, 0, this); + + // in case image is not animated fill image buffers once + imageUpdate(logo, ImageObserver.FRAMEBITS, 0, 0, 0, 0); + imageUpdate(progressbar, ImageObserver.FRAMEBITS, 0, 0, 0, 0); } // draw everything onto an image before drawing to avoid flicker @@ -407,8 +426,8 @@ int x = 0, y = 0; if(logo != null && !fatalError) { - x = (offscreen.getWidth(null) - logo.getWidth(this)) / 2; - y = (offscreen.getHeight(null) - logo.getHeight(this)) / 2; + x = (offscreen.getWidth(null) - logo.getWidth(null)) / 2; + y = (offscreen.getHeight(null) - logo.getHeight(null)) / 2; } og.setColor(fgColor); @@ -433,13 +452,15 @@ } } else { og.setColor(fgColor); - + + painting = true; + // draw logo - og.drawImage(logo, x, y, null); + og.drawImage(logoBuffer, x, y, this); // draw message int messageX = (offscreen.getWidth(null) - fm.stringWidth(message)) / 2; - int messageY = y + logo.getHeight(null) + 20; + int messageY = y + logoBuffer.getHeight(null) + 20; og.drawString(message, messageX, messageY); // draw subtaskmessage, if any @@ -449,16 +470,53 @@ } // draw loading bar, clipping it depending on percentage done - int barSize = (progressbar.getWidth(this) * percentage) / 100; + int barSize = (progressbarBuffer.getWidth(null) * percentage) / 100; og.clipRect(0, 0, x + barSize, offscreen.getHeight(null)); - og.drawImage(progressbar, x, y, null); + og.drawImage(progressbarBuffer, x, y, this); + + painting = false; } og.dispose(); - - // finally draw it all centred + + // finally draw it all g.drawImage(offscreen, (getWidth() - offscreen.getWidth(null))/2, (getHeight() - offscreen.getHeight(null))/2, null); } + + /** + * When an animated gif frame is ready to be drawn the ImageObserver + * will call this method. + * + * The Image frame is copied into a buffer, which is then drawn. + * This is done to prevent image tearing on gif animations. + */ + public boolean imageUpdate(Image img, int flag, int x, int y, int width, int height) { + + // if image frame is ready to be drawn and is currently not being painted + if (flag == ImageObserver.FRAMEBITS && !painting) { + Image buffer; + + // select which buffer to fill + if (img == logo) buffer = logoBuffer; + else buffer = progressbarBuffer; + + Graphics g = buffer.getGraphics(); + + // clear background on buffer + g.setColor(bgColor); + g.fillRect(0, 0, buffer.getWidth(null), buffer.getHeight(null)); + + // buffer background is cleared, so draw logo under progressbar + if (img == progressbar) g.drawImage(logoBuffer, 0, 0, null); + + g.drawImage(img, 0, 0, this); + g.dispose(); + + repaint(); + } + + return true; + } /** * @return string describing the state of the loader This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ka...@us...> - 2010-07-11 12:16:50
|
Revision: 3372 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3372&view=rev Author: kappa1 Date: 2010-07-11 12:13:34 +0000 (Sun, 11 Jul 2010) Log Message: ----------- Appletloader: Initial implementation of a proper caching system. Files will only be downloaded if lastModified time is different from when files were downloaded previously. al_cache parameter is used to disable and enable this caching (default: true). This caching will not be used if al_version parameter is used. 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 2010-07-10 11:56:55 UTC (rev 3371) +++ trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java 2010-07-11 12:13:34 UTC (rev 3372) @@ -48,6 +48,8 @@ import java.io.FilePermission; import java.io.IOException; import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.StringWriter; @@ -69,6 +71,7 @@ import java.security.SecureClassLoader; import java.security.cert.Certificate; import java.util.Enumeration; +import java.util.HashMap; import java.util.StringTokenizer; import java.util.Vector; import java.util.jar.JarEntry; @@ -107,6 +110,7 @@ * <ul> * <li>al_version - [int or float] Version of deployment. If this is specified, the jars will be cached and * reused if the version matches. If version doesn't match all of the files are reloaded.</li> + * <li>al_cache - [boolean] Whether to use cache system. If al_version is used then cache is not used. <i>Default: true</i>.</li> * <li>al_debug - [boolean] Whether to enable debug mode. <i>Default: false</i>.</li> * <li>al_prepend_host - [boolean] Whether to limit caching to this domain, disable if your applet is hosted on multple domains and needs to share the cache. <i>Default: true</i>.</li> * <ul> @@ -220,6 +224,15 @@ /** whether to prepend host to cache path */ protected boolean prependHost; + /** Used to store file names with lastModified time */ + protected HashMap filesLastModified; + + /** Sizes of files to download */ + protected int[] fileSizes; + + /** whether to use caching system, only download files that have changed */ + protected boolean cacheEnabled; + /** String to display as a subtask */ protected String subtaskMessage = ""; @@ -262,7 +275,10 @@ return; } } - + + // whether to use cache system + cacheEnabled = getBooleanParameter("al_cache", true); + // whether to run in debug mode debugMode = getBooleanParameter("al_debug", false); @@ -479,7 +495,7 @@ og.dispose(); - // finally draw it all + // finally draw it all centred g.drawImage(offscreen, (getWidth() - offscreen.getWidth(null))/2, (getHeight() - offscreen.getHeight(null))/2, null); } @@ -528,7 +544,7 @@ case STATE_DETERMINING_PACKAGES: return "Determining packages to load"; case STATE_CHECKING_CACHE: - return "Checking cache for existing files"; + return "Calculate download size and check cache"; case STATE_DOWNLOADING: return "Downloading packages"; case STATE_EXTRACTING_PACKAGES: @@ -681,11 +697,12 @@ if (!dir.exists()) { dir.mkdirs(); } - dir = new File(dir, "version"); + + File versionFile = new File(dir, "version"); + + // if specified applet version already available don't download anything + boolean versionAvailable = false; - // if applet already available don't download anything - boolean cacheAvailable = false; - // version of applet String version = getParameter("al_version"); float latestVersion = 0; @@ -696,10 +713,10 @@ latestVersion = Float.parseFloat(version); // if version file exists - if (dir.exists()) { + if (versionFile.exists()) { // compare to new version - if (latestVersion <= readVersionFile(dir)) { - cacheAvailable = true; + if (latestVersion <= readVersionFile(versionFile)) { + versionAvailable = true; percentage = 90; if(debugMode) { @@ -711,9 +728,12 @@ } // if jars not available or need updating download them - if (!cacheAvailable) { + if (!versionAvailable) { + // get jars file sizes and check cache + getJarInfo(dir); // 5-15% + // downloads jars from the server - downloadJars(path); // 10-55% + downloadJars(path); // 15-55% // Extract Pack and LZMA files extractJars(path); // 55-65% @@ -721,11 +741,14 @@ // Extracts Native Files extractNatives(path); // 65-85% - // add version information once jars downloaded successfully + // save version information once jars downloaded successfully if (version != null) { percentage = 90; writeVersionFile(dir, latestVersion); } + + // save file names with last modified info once downloaded successfully + writeCacheFile(new File(dir, "cache"), filesLastModified); } // add the downloaded jars and natives to classpath @@ -771,8 +794,35 @@ dos.writeFloat(version); dos.close(); } + + /** + * read the current cache file + * + * @param file the file to read + * @return the hashmap containing the files names and lastModified times + * @throws Exception if it fails to read hashmap + */ + protected HashMap readCacheFile(File file) throws Exception { + ObjectInputStream dis = new ObjectInputStream(new FileInputStream(file)); + HashMap hashMap = (HashMap)dis.readObject(); + dis.close(); + return hashMap; + } /** + * write out cache file of applet + * + * @param file the file to write out to + * @param filesLastModified the hashmap containing files names and lastModified times + * @throws Exception if it fails to write file + */ + protected void writeCacheFile(File file, HashMap filesLastModified) throws Exception { + ObjectOutputStream dos = new ObjectOutputStream(new FileOutputStream(file)); + dos.writeObject(filesLastModified); + dos.close(); + } + + /** * Edits the ClassPath at runtime to include the jars * that have just been downloaded and then adds the * lwjgl natives folder property. @@ -848,7 +898,7 @@ * Due to the way applets on plugin1 work, one jvm must * be used for all applets. We need to use multiple * classloaders in the same jvm due to LWJGL's static - * nature. I order to solver this we simply remove the + * nature. I order to solve this we simply remove the * natives from a previous classloader allowing a new * classloader to use those natives in the same jvm. * @@ -913,23 +963,33 @@ state = STATE_START_REAL_APPLET; lwjglApplet.start(); } - + /** - * Will download the jars from the server using the list of urls - * in urlList, while at the same time updating progress bar + * This method will get the files sizes of the files to download. + * It wil further get the lastModified time of files + * and save it in a hashmap, if cache is enabled it will mark + * those files that have not changed since last download to not + * redownloaded. * - * @param path location of the directory to save to - * @throws Exception if download fails + * @param dir - location to read cache file from + * @throws Exception - if fails to get infomation */ - protected void downloadJars(String path) throws Exception { + protected void getJarInfo(File dir) throws Exception { - state = STATE_DOWNLOADING; - + filesLastModified = new HashMap(); + + // store file sizes and mark which files not to download + fileSizes = new int[urlList.length]; + URLConnection urlconnection; - // store file sizes, used for download verification - int[] fileSizes = new int[urlList.length]; + File cacheFile = new File(dir, "cache"); + // if cache file exists, load it + if (cacheFile.exists()) { + filesLastModified = readCacheFile(cacheFile); + } + // calculate total size of jars to download for (int i = 0; i < urlList.length; i++) { urlconnection = urlList[i].openConnection(); @@ -937,16 +997,57 @@ if (urlconnection instanceof HttpURLConnection) { ((HttpURLConnection) urlconnection).setRequestMethod("HEAD"); } + fileSizes[i] = urlconnection.getContentLength(); - totalSizeDownload += fileSizes[i]; + + long lastModified = urlconnection.getLastModified(); + String fileName = getFileName(urlList[i]); + + + if (cacheEnabled && lastModified != 0 && + filesLastModified.containsKey(fileName)) { + long savedLastModified = (Long)filesLastModified.get(fileName); + + // if lastModifed time is the same, don't redownload + if (savedLastModified == lastModified) { + fileSizes[i] = -2; // mark it to not redownload + } + } + + if (fileSizes[i] >= 0) { + totalSizeDownload += fileSizes[i]; + } + + // put key and value in the hashmap + filesLastModified.put(fileName, lastModified); + + // update progress bar + percentage = 5 + (int)(10 * i/(float)urlList.length); } + } + + /** + * Will download the jars from the server using the list of urls + * in urlList, while at the same time updating progress bar + * + * @param path location of the directory to save to + * @throws Exception if download fails + */ + protected void downloadJars(String path) throws Exception { - int initialPercentage = percentage = 10; + state = STATE_DOWNLOADING; + URLConnection urlconnection; + + int initialPercentage = percentage = 15; + // download each jar byte buffer[] = new byte[65536]; for (int i = 0; i < urlList.length; i++) { + // skip file if marked as -2 (already downloaded and not changed) + if (fileSizes[i] == -2) continue; + int unsuccessfulAttempts = 0; int maxUnsuccessfulAttempts = 3; boolean downloadFile = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |