2003/04/10 01:41:43
[org.ibex.core.git] / src / org / xwt / Box.java
index 17283f6..caa7c8a 100644 (file)
@@ -257,15 +257,6 @@ public final class Box extends JSObject {
     public Hash traps = null;
 
 
-    // Vector Support /////////////////////////////////////////////////////////////////////
-
-    /** The SVG path for this node */
-    public String path = null;
-
-    /** The affine multiplied by the CTM *before* this element and its children are processed */
-    public SVG.Affine transform = null;
-
-
     // Instance Data: IndexOf  ////////////////////////////////////////////////////////////
 
     /** The indexof() Function; created lazily */
@@ -417,13 +408,14 @@ public final class Box extends JSObject {
 
     /** loads the image described by string str, possibly blocking for a network load */
     static ImageDecoder getImage(String str, final Function callback) {
-        boolean ispng = false;
 
         if (str.indexOf(':') == -1) {
             String s = str;
             byte[] b = Resources.getResource(Resources.resolve(s + ".png", null));
-            if (b == null) return null;
-            return PNG.decode(new ByteArrayInputStream(b), str);
+           if (b != null) return PNG.decode(new ByteArrayInputStream(b), str);
+            b = Resources.getResource(Resources.resolve(s + ".jpeg", null));
+           if (b != null) return Platform.decodeJPEG(new ByteArrayInputStream(b), str);
+           return null;
             
         } else {
             Thread thread = Thread.currentThread();
@@ -436,10 +428,6 @@ public final class Box extends JSObject {
             mythread.setPriority(Thread.MIN_PRIORITY);
             mythread.done.release();
             try {
-                // FIXME use mime types here, not extensions
-                if (str.endsWith(".jpeg") || str.endsWith(".jpg"))
-                    str = "http://xmlrpc.xwt.org/jpeg2png/" + str.substring(str.indexOf("//") + 2);
-
                 HTTP http = new HTTP(str);
                 final HTTP.HTTPInputStream in = http.GET();
                 final int contentLength = in.getContentLength();
@@ -470,9 +458,10 @@ public final class Box extends JSObject {
                             return ret;
                         }
                     };
-                
+
                 if (str.endsWith(".gif")) return GIF.decode(is, str);
-                else return PNG.decode(is, str);
+                else if (str.endsWith(".jpeg") || str.endsWith(".jpg")) return Platform.decodeJPEG(is, str);
+               else return PNG.decode(is, str);
 
             } catch (IOException e) {
                 if (Log.on) Log.log(Box.class, "error while trying to load an image from " + str);
@@ -513,7 +502,7 @@ public final class Box extends JSObject {
                 if (Log.on) Log.log(Box.class, "unable to load image " + s + " at " +
                                     Context.enter().interpreterSourceFile + ":" + Context.enter().interpreterLine);
                 return;
-            }
+           }
             if (sizetoimage) syncSizeToImage();
             dirty();
         }
@@ -867,8 +856,7 @@ public final class Box extends JSObject {
     // Rendering Pipeline /////////////////////////////////////////////////////////////////////
 
     /** Renders self and children within the specified region. All rendering operations are clipped to xIn,yIn,wIn,hIn */
-    void render(int xIn, int yIn, int wIn, int hIn, DoubleBuffer buf) { render(xIn, yIn, wIn, hIn, buf, null); }
-    void render(int xIn, int yIn, int wIn, int hIn, DoubleBuffer buf, SVG.Affine ctm) {
+    void render(int xIn, int yIn, int wIn, int hIn, DoubleBuffer buf) {
         if (surface.abort || invisible) return;
 
         // intersect the x,y,w,h rendering window with ourselves; quit if it's empty
@@ -895,24 +883,6 @@ public final class Box extends JSObject {
             else renderStretchedImage(x, y, w, h, buf);
         }
 
-       // FIXME: this should go at the top of this method
-       SVG.Affine ctm_;
-       if (transform != null) {
-           if (ctm == null) ctm = SVG.Affine.identity();
-           ctm_ = ctm.copy();
-           ctm_.multiply(transform);
-       } else {
-           ctm_ = ctm;
-       }
-
-       if (path != null) {
-           SVG.VP vp = SVG.VP.fromString(path);
-           if (ctm_ != null) vp.multiply(ctm_);
-           vp.sort();
-           vp.fill(buf, null, 0xFFFF0000, null);
-           vp.stroke(buf, 100, textcolor, false);
-       }
-
         if (text != null && !text.equals("")) renderText(x, y, w, h, buf);
 
         // now subtract the pad region from the clip region before proceeding
@@ -922,7 +892,7 @@ public final class Box extends JSObject {
         int h2 = min(y + h, pos(1) + size(1) - pad(1)) - y2;
 
         for(Box b = getChild(0); b != null; b = b.nextSibling())
-            b.render(x2, y2, w2, h2, buf, ctm_);
+            b.render(x2, y2, w2, h2, buf);   
     }
 
     private void renderBorder(int x, int y, int w, int h, DoubleBuffer buf) {