Revision: 2964
          http://vexi.svn.sourceforge.net/vexi/?rev=2964&view=rev
Author:   clrg
Date:     2008-07-14 14:56:40 -0700 (Mon, 14 Jul 2008)

Log Message:
-----------
Tidy up syntax and add useful toString() for Picture.java

Modified Paths:
--------------
    trunk/core/org.vexi.core/src/org/vexi/graphics/Picture.java

Modified: trunk/core/org.vexi.core/src/org/vexi/graphics/Picture.java
===================================================================
--- trunk/core/org.vexi.core/src/org/vexi/graphics/Picture.java 2008-07-10 
08:58:16 UTC (rev 2963)
+++ trunk/core/org.vexi.core/src/org/vexi/graphics/Picture.java 2008-07-14 
21:56:40 UTC (rev 2964)
@@ -47,30 +47,30 @@
     protected synchronized void loaded() {
         if (loadedCallbacks == null) return;
         
-        for (int i=0;i<loadedCallbacks.size();i++)
+        for (int i=0; i<loadedCallbacks.size(); i++)
             Scheduler.add((Callable)loadedCallbacks.elementAt(i));
         loadedCallbacks.removeAllElements();
         loadedCallbacks = null;
     }
 
-    /** turns a stream into aPicture.Source and passes it to the callback */
+    /** turns a stream into a Picture.Source and passes it to the callback */
     public static Picture load(JS stream, Callable callback) {
         Picture ret = (Picture)cache.get(stream);
         if (ret == null) cache.put(stream, ret = 
Platform.createPicture(stream));
         // can return ret here outside of sync block for caller to assign as 
callback
-        //is executed in the same interpreter as the caller, synchronously.
+        // is executed in the same interpreter as the caller, synchronously.
         ret.load(callback);
         return ret;
     }
     
     /** turns a stream into a Picture.Source and passes it to the callback */
-    private void load( final Callable callback) {
+    private void load(final Callable callback) {
         synchronized(this) {
-            if(isLoaded || callback == null) return;
+            if (isLoaded || callback == null) return;
             
             // Previous demand for this image means it is already loading
             // add to callbacks and return
-            if(loadedCallbacks != null) {
+            if (loadedCallbacks != null) {
                 loadedCallbacks.addElement(callback);
                 return;
             }
@@ -81,9 +81,9 @@
             
             new java.lang.Thread() { public void run() {
                 try { 
-                       InputStream in = b == null ? 
-                                       Fountain.getInputStream(stream) : 
b.getImage();
-                    if(in == null) throw new JSExn("not a valid image stream");
+                    InputStream in = b == null ? 
+                        Fountain.getInputStream(stream) : b.getImage();
+                    if (in == null) throw new JSExn("not a valid image 
stream");
        
                     PushbackInputStream pbis = new PushbackInputStream(in);
                     int firstByte = pbis.read();
@@ -99,8 +99,8 @@
                     Log.warn(Picture.class,"Couldn't load picture from stream 
" + stream.unclone());
                     if(e instanceof JSExn) 
Log.uWarn(Picture.class,e.getMessage());
                     else {
-                       Log.uWarn(Picture.class,"System error loading image");
-                       Log.warn(Picture.class, e);
+                        Log.uWarn(Picture.class,"System error loading image");
+                        Log.warn(Picture.class, e);
                     }
                 } finally {
                     loaded();
@@ -108,4 +108,10 @@
             } }.start();
         }
     }
+    
+    public String toString(){
+        return "Picture "+stream+", "
+            +(isLoaded?"loaded":(loadFailed?"failed":"not loaded"))+", "
+            +(loadedCallbacks==null?"no":""+loadedCallbacks.size())+" 
callbacks";
+    }
 }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to