2003/02/22 03:55:06
[org.ibex.core.git] / src / org / xwt / Box.java
index 4cefc9e..17283f6 100644 (file)
@@ -257,6 +257,15 @@ 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 */
@@ -858,7 +867,8 @@ 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) {
+    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) {
         if (surface.abort || invisible) return;
 
         // intersect the x,y,w,h rendering window with ourselves; quit if it's empty
@@ -885,6 +895,24 @@ 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
@@ -894,7 +922,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);   
+            b.render(x2, y2, w2, h2, buf, ctm_);
     }
 
     private void renderBorder(int x, int y, int w, int h, DoubleBuffer buf) {