gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/gzz view/BoxCellView.java vob/impl/OrthoCoo...


From: Benja Fallenstein
Subject: [Gzz-commits] gzz/gzz view/BoxCellView.java vob/impl/OrthoCoo...
Date: Fri, 22 Nov 2002 19:35:22 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Benja Fallenstein <address@hidden>      02/11/22 19:35:21

Modified files:
        gzz/view       : BoxCellView.java 
        gzz/vob/impl   : OrthoCoorder.java 
        gzz/vob/vobs   : TextCursorVob.java TextVob.java 

Log message:
        Kludge clipping in AWT (I'd rather have PEG 1013, but this will do for 
alpha4)

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/view/BoxCellView.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/impl/OrthoCoorder.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/vobs/TextCursorVob.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/vobs/TextVob.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: gzz/gzz/view/BoxCellView.java
diff -u gzz/gzz/view/BoxCellView.java:1.1 gzz/gzz/view/BoxCellView.java:1.2
--- gzz/gzz/view/BoxCellView.java:1.1   Mon Nov 18 05:28:16 2002
+++ gzz/gzz/view/BoxCellView.java       Fri Nov 22 19:35:21 2002
@@ -29,11 +29,9 @@
 import gzz.vob.vobs.*;
 import gzz.client.*;
 import gzz.impl.*;
-import java.awt.Font;
-import java.awt.Dimension;
-import java.awt.Rectangle;
-import java.awt.Color;
+import java.awt.*;
 import java.util.*;
+import java.util.List;
 
 /** A factory for making basic cell vobs.
  * This is an enclosing class and a factory at the same time
@@ -47,7 +45,7 @@
  */
 
 public class BoxCellView extends CellView {
-public static final String rcsid = "$Id: BoxCellView.java,v 1.1 2002/11/18 
10:28:16 humppake Exp $";
+public static final String rcsid = "$Id: BoxCellView.java,v 1.2 2002/11/23 
00:35:21 benja Exp $";
     public static boolean dbg = false;
     private static void p(String s) { if(dbg) pa(s); }
     private static void pa(String s) { System.err.println(s); }
@@ -107,6 +105,8 @@
        into[1] = style.getHeight(scale)/scale + 10;
     }
 
+    static Object UNCLIP = new Object();
+
     /** Get an Id for the slice this Cell is in.
      *  Iff getSliceId(c).equals(getSliceId(d)), c and d are in the same slice.
      */
@@ -161,10 +161,33 @@
                                        boxwh[0]-2*pad, boxwh[1]-2*pad);
        final int unitsq = vs.unitSqCS(box, "UNIT");
 
-       if(!(GraphicsAPI.getInstance() instanceof gzz.client.gl.GLAPI)) {
+       GraphicsAPI api = GraphicsAPI.getInstance();
+       if(api instanceof gzz.client.awt.AWTAPI) {
+           final Shape[] clipshape = new Shape[1];
+           vs.map.put(new Vob() {
+                   public void render(Graphics g, boolean fast,
+                                      Vob.RenderInfo info1,
+                                      Vob.RenderInfo info2) {
+                       clipshape[0] = g.getClip();
+                       info2.getExtRect(rect);
+                       if(BoxCellView.this.dbg) 
+                           pa("Clip: "+rect+" -- was: "+clipshape[0]);
+                       g.clipRect(rect.x, rect.y,
+                                  rect.width, rect.height);
+                   }
+               }, contentBox, box);
+           int unclip_cs = vs.translateCS(contentBox, UNCLIP, 0, 0);
            ccv.place(c, vs, contentBox, context);
+           vs.map.put(new Vob() {
+                   public void render(Graphics g, boolean fast,
+                                      Vob.RenderInfo info1,
+                                      Vob.RenderInfo info2) {
+                       if(BoxCellView.this.dbg) pa("Unclip: "+clipshape[0]);
+                       g.setClip(clipshape[0]);
+                   }
+               }, unclip_cs);
             vs.map.put(bg, unitsq);
-       } else {
+       } else if(api instanceof gzz.client.gl.GLAPI) {
             vs.map.put(bg, unitsq);
            gzz.gfx.gl.Stencil.drawStenciled(
                vs,
@@ -178,6 +201,8 @@
                }},
                false
            );
+       } else {
+           throw new Error("Unsupported API: "+api);
        }
     }
 }
Index: gzz/gzz/vob/impl/OrthoCoorder.java
diff -u gzz/gzz/vob/impl/OrthoCoorder.java:1.3 
gzz/gzz/vob/impl/OrthoCoorder.java:1.4
--- gzz/gzz/vob/impl/OrthoCoorder.java:1.3      Thu Nov 21 04:52:35 2002
+++ gzz/gzz/vob/impl/OrthoCoorder.java  Fri Nov 22 19:35:21 2002
@@ -29,7 +29,7 @@
  */
 
 public class OrthoCoorder extends VobCoorder {
-public static final String rcsid = "$Id: OrthoCoorder.java,v 1.3 2002/11/21 
09:52:35 humppake Exp $";
+public static final String rcsid = "$Id: OrthoCoorder.java,v 1.4 2002/11/23 
00:35:21 benja Exp $";
     public static boolean dbg = false;
     private static void p(String s) { if(dbg) pa(s); }
     private static void pa(String s) { System.err.println(s); }
@@ -45,6 +45,7 @@
 
     float[] cs1rect = new float[4];
     float[] cs2rect = new float[4];
+    float[] wh = new float[4];
 
     void setInterpInfo(int cs1, OrthoCoorder other, int cs2,
                              float fract,
@@ -54,17 +55,21 @@
                        ) {
            for(int i=0; i<2; i++) 
                cs1rect[i] = cs2rect[i] = 0;
-           for(int i=2; i<4; i++) 
-               cs1rect[i] = cs2rect[i] = 1;
            OrthoCoordsys sys1 = sys, sys2 = other.sys;
+           sys1.getSqSize(cs1, wh);
+           cs1rect[2] = wh[0]; cs1rect[3] = wh[1];
+           sys2.getSqSize(cs2, wh);
+           cs2rect[2] = wh[0]; cs2rect[3] = wh[1];
            sys1.transformRect(cs1, cs1rect);
            sys2.transformRect(cs2, cs2rect);
+           wh[0] = 0; wh[1] = 0; wh[2] = 1; wh[3] = 1;
+           sys1.transformRect(cs1, wh);
            info.setCoords(sys1.depth[cs1],
                        xscale * i(cs1rect[0], cs2rect[0], fract) + xoffs,
                        yscale * i(cs1rect[1], cs2rect[1], fract) + yoffs,
                        xscale * i(cs1rect[2], cs2rect[2], fract),
                        yscale * i(cs1rect[3], cs2rect[3], fract),
-                       0, 0, 2000, 2000);
+                       0, 0, xscale * wh[2], yscale * wh[3]);
            // XXX Cliprect wrong
            p("SetInterp: "+info.x+" "+info.y+" "+info.w+" "+info.h +
                        " \n\t"+xoffs+" "+yoffs+" "+xscale+" "+yscale);
@@ -73,11 +78,12 @@
     void setInfo(int cs, float xoffs, float yoffs,
                                float xscale, float yscale,
                                OrthoRenderInfo info) {
+       wh[0] = 0; wh[1] = 0; wh[2] = 1; wh[3] = 1;
+       sys.transformRect(cs, wh);
        info.setCoords(sys.depth[cs],
                       xscale * sys.x[cs] + xoffs, yscale * sys.y[cs] + yoffs,
                       xscale * sys.w[cs], yscale * sys.h[cs],
-                      xscale * sys.cx(cs) + xoffs, yscale * sys.cy(cs) + yoffs,
-                      xscale * sys.cw(cs), yscale * sys.ch(cs));
+                      0, 0, xscale * wh[2], yscale * wh[3]);
     }
 
     public boolean contains(int cs, float px, float py, float[] 
internalcoords) {
Index: gzz/gzz/vob/vobs/TextCursorVob.java
diff -u gzz/gzz/vob/vobs/TextCursorVob.java:1.2 
gzz/gzz/vob/vobs/TextCursorVob.java:1.3
--- gzz/gzz/vob/vobs/TextCursorVob.java:1.2     Mon Nov  4 17:15:04 2002
+++ gzz/gzz/vob/vobs/TextCursorVob.java Fri Nov 22 19:35:21 2002
@@ -39,7 +39,7 @@
  */
 
 public class TextCursorVob extends Vob {
-String rcsid = "$Id: TextCursorVob.java,v 1.2 2002/11/04 22:15:04 tjl Exp $";
+String rcsid = "$Id: TextCursorVob.java,v 1.3 2002/11/23 00:35:21 benja Exp $";
     public static boolean dbg = false;
     private static void p(String s) { if(dbg) pa(s); }
     private static void pa(String s) { System.err.println(s); }
@@ -66,24 +66,15 @@
 
         info1.getExtRect(rect);
         float bx = rect.x, by = rect.y;
-        info2.getExtRect(rect);
+        info1.getClipRect(rect);
         float bw = rect.width, bh = rect.height;
-       
-        /*Shape oldClip = g.getClip();
-       info1.getClipRect(rect);
-       g.clipRect(rect.x, rect.y,
-                      rect.width+2, rect.height);
-
-       info1.getExtRect(rect);*/
-
-        float scale = textvob.getScale();
-       if(scale < 0)
-           scale = style.getScaleByHeight(bh-3);
+
+        float scale = style.getScaleByHeight(bh);
 
        float h = style.getHeight(scale);
         float text_w = style.getWidth(text.substring(0, offs), scale);
 
-        int x = (int)(bx + text_w);
+        int x = (int)(bx + text_w + 3);
        int y = (int)(by + bh/2 - h/2);
 
         g.drawLine(x, y, x, y + (int)h);
Index: gzz/gzz/vob/vobs/TextVob.java
diff -u gzz/gzz/vob/vobs/TextVob.java:1.4 gzz/gzz/vob/vobs/TextVob.java:1.5
--- gzz/gzz/vob/vobs/TextVob.java:1.4   Thu Nov 21 22:55:20 2002
+++ gzz/gzz/vob/vobs/TextVob.java       Fri Nov 22 19:35:21 2002
@@ -48,7 +48,7 @@
  * XXX Diagram!
  */
 public class TextVob extends HBox.VobHBox {
-String rcsid = "$Id: TextVob.java,v 1.4 2002/11/22 03:55:20 humppake Exp $";
+String rcsid = "$Id: TextVob.java,v 1.5 2002/11/23 00:35:21 benja Exp $";
     public static boolean dbg = false;
     private static void pa(String s) { System.err.println(s); }
 
@@ -108,18 +108,19 @@
 
         info1.getExtRect(rect);
         float x = rect.x, y = rect.y;
+       info1.getClipRect(rect);
         float w = rect.width, h = rect.height;
 
        /* info2.getExtRect(rect); */
 
-       Shape oldClip = g.getClip();
+       //Shape oldClip = g.getClip();
        /*g.clipRect(rect.x, rect.y,
                       rect.width,
                      rect.height + 3);*/
        /*  float scale = style.getScaleByHeight(h-3); // Why h-3? */
 
        float scale = style.getScaleByHeight(h);
-        if(dbg) pa("Render @ scale " + scale + ": '"+text+"' 
"+getWidth(scale)+" "+y+" "+w+" "+h);
+        if(dbg) pa("Render @ scale " + scale + ": '"+text+"' 
"+getWidth(scale)+" -- pos: "+x+" "+y+" "+w+" "+h);
 
        float fasc = style.getAscent(scale);
        float fdsc = style.getDescent(scale);
@@ -130,7 +131,7 @@
 
        ((AWTTextStyle)style).render(g, (int)x, (int)ty, text, scale, null);
 
-       g.setClip(oldClip);
+       //g.setClip(oldClip);
     }
 
     static private Vob start, stop;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]