gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/gzz view/CellVobFactory.java view/LastOpDec...


From: Benja Fallenstein
Subject: [Gzz-commits] gzz/gzz view/CellVobFactory.java view/LastOpDec...
Date: Sat, 21 Sep 2002 18:48:01 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Benja Fallenstein <address@hidden>      02/09/21 18:48:01

Modified files:
        gzz/view       : CellVobFactory.java LastOpDecorator.java 
        gzz/vob        : HBroken.java 
Added files:
        gzz/view       : CellHBox.java CellView.java 

Log message:
        Show real cells in the pending op lines at the bottom of each window

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/view/CellHBox.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/view/CellView.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/view/CellVobFactory.java.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/view/LastOpDecorator.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/HBroken.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: gzz/gzz/view/CellVobFactory.java
diff -c gzz/gzz/view/CellVobFactory.java:1.7 
gzz/gzz/view/CellVobFactory.java:1.8
*** gzz/gzz/view/CellVobFactory.java:1.7        Fri Sep 20 15:45:26 2002
--- gzz/gzz/view/CellVobFactory.java    Sat Sep 21 18:48:01 2002
***************
*** 45,52 ****
   * </pre>
   */
  
! public class CellVobFactory {
! public static final String rcsid = "$Id: CellVobFactory.java,v 1.7 2002/09/20 
19:45:26 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,52 ----
   * </pre>
   */
  
! public class CellVobFactory implements CellView {
! public static final String rcsid = "$Id: CellVobFactory.java,v 1.8 2002/09/21 
22:48:01 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); }
***************
*** 114,119 ****
--- 114,124 ----
      }
  
      static Rectangle rect = new Rectangle();
+ 
+     public void place(Cell c, VobScene vs, int coordsys,
+                       ViewContext context, float scale) {
+       addCellVobs(c, vs, coordsys, null, context, scale);
+     }
  
      /** Add the vobs that make up a cell into the given coordinate
       * system of the given vobscene.
Index: gzz/gzz/view/LastOpDecorator.java
diff -c gzz/gzz/view/LastOpDecorator.java:1.4 
gzz/gzz/view/LastOpDecorator.java:1.5
*** gzz/gzz/view/LastOpDecorator.java:1.4       Fri Sep 13 07:05:39 2002
--- gzz/gzz/view/LastOpDecorator.java   Sat Sep 21 18:48:01 2002
***************
*** 32,109 ****
   *  directional op entered.
   */
  public class LastOpDecorator implements FallbackSceneDecorator {
! String rcsid = "$Id: LastOpDecorator.java,v 1.4 2002/09/13 11:05:39 benja Exp 
$";
!     public static boolean dbg = false;
      private static void pa(String s) { System.err.println(s); }
  
      static TextStyle style =
        GraphicsAPI.getInstance().getTextStyle("SansSerif", Font.PLAIN, 16);
      static Object key = new Object();
  
      int padding = 15;
  
      public void render(VobScene sc, int into, Fallback fallback, Fallback.Win 
win) {
        Dimension size = sc.getSize();
  
!       String s;
          if(dbg) pa("fallback.binder.directOp: "+fallback.binder.directOp);
  
          if(fallback.mode == fallback.NORMAL) {
              switch(fallback.binder.directOp) {
                  case FallbackBinder.NONE: return;
                  case FallbackBinder.CONNECT:
!                     s = "Connect [where?] to " + cell(win.other.cursor);
                      break;
                  case FallbackBinder.DISCONNECT:
!                     s = "Break [which connection?]"; break;
                  case FallbackBinder.HOP:
!                     s = "Hop [in which direction?]"; break;
                  case FallbackBinder.NEW:
!                     s = "Create a new cell [where?]"; break;
                  case FallbackBinder.CLONE_R:
!                     s = "Clone "  + cell(fallback.windows[1].cursor) + " 
[where?]";
                      break;
                  case FallbackBinder.CLONE_L:
!                     s = "Clone "  + cell(fallback.windows[0].cursor) + " 
[where?]";
                      break;
                  default:
                      throw new IllegalArgumentException("DirOp not known: " +
                                                         
fallback.binder.directOp);
              }
          } else if(fallback.mode == fallback.TEXT_1)
!             s = "Text edit mode (press Tab to finish editing).";
          else if(fallback.mode == fallback.SEARCH)
!             s = "Search for: " + fallback.binder.buffer;
          else return;
  
!       int w = (int)style.getWidth(s, 1.0f);
!       int h = (int)style.getHeight(1.0f);
! 
!       int x = padding;
!       int y = size.height - padding - h;
  
!       TextVob vob = new TextVob(style, s);
  
        int cs = sc.coords.coordsys(into, key, 0, x, y, w, h);
-       sc.map.put(vob, cs);
  
!         if(dbg) pa("Put "+vob+" in cs "+cs+" @ "+x+" "+y+" "+w+" "+h+" 
("+size+")");
!     }
  
!     /** Format a cell's text as part of an opstring. */
!     String cell(Cell c) {
!       if(c == null) return "[which cell?]";
  
!       String t = c.t();
  
!       // Show only first line
!       int n = t.indexOf('\n');
!       if(n > 0)
!           t = t.substring(0, n);
  
!       // Enclose in ''
!       t = "'" + t + "'";
  
!       return "cell " + t;
      }
  }
--- 32,115 ----
   *  directional op entered.
   */
  public class LastOpDecorator implements FallbackSceneDecorator {
! String rcsid = "$Id: LastOpDecorator.java,v 1.5 2002/09/21 22:48:01 benja Exp 
$";
!     public static boolean dbg = true;
      private static void pa(String s) { System.err.println(s); }
  
      static TextStyle style =
        GraphicsAPI.getInstance().getTextStyle("SansSerif", Font.PLAIN, 16);
      static Object key = new Object();
+     static SimpleLinebreaker breaker = new SimpleLinebreaker();
+     static CellVobFactory cvf = new CellVobFactory();
  
      int padding = 15;
  
      public void render(VobScene sc, int into, Fallback fallback, Fallback.Win 
win) {
        Dimension size = sc.getSize();
  
!       HChain ch = new LinebreakableChain();
!       cvf.setCenter(win.cursor);
! 
          if(dbg) pa("fallback.binder.directOp: "+fallback.binder.directOp);
  
          if(fallback.mode == fallback.NORMAL) {
              switch(fallback.binder.directOp) {
                  case FallbackBinder.NONE: return;
                  case FallbackBinder.CONNECT:
!                   ch.addBox(text("Connect [where?] to "));
!                   ch.addBox(cell(win.other.cursor, win));
                      break;
                  case FallbackBinder.DISCONNECT:
!                     ch.addBox(text("Break [which connection?]")); break;
                  case FallbackBinder.HOP:
!                     ch.addBox(text("Hop [in which direction?]")); break;
                  case FallbackBinder.NEW:
!                     ch.addBox(text("Create a new cell [where?]")); break;
                  case FallbackBinder.CLONE_R:
!                     ch.addBox(text("Clone "));
!                   ch.addBox(cell(fallback.windows[1].cursor, win));
!                   ch.addBox(text(" [where?]", 2));
                      break;
                  case FallbackBinder.CLONE_L:
!                     ch.addBox(text("Clone "));
!                   ch.addBox(cell(fallback.windows[0].cursor, win));
!                   ch.addBox(text(" [where?]", 2));
                      break;
                  default:
                      throw new IllegalArgumentException("DirOp not known: " +
                                                         
fallback.binder.directOp);
              }
          } else if(fallback.mode == fallback.TEXT_1)
!             ch.addBox(text("Text edit mode (press Tab to finish editing)."));
          else if(fallback.mode == fallback.SEARCH)
!             ch.addBox(text("Search for: " + fallback.binder.buffer));
          else return;
  
!       float w = size.width - 2*padding;
!       HBroken br = breaker.breakLines(ch, w, 1.0f);
!       float h = br.getHeight();
  
!       float x = padding;
!       float y = size.height - padding - h;
  
        int cs = sc.coords.coordsys(into, key, 0, x, y, w, h);
  
!       br.put(sc, cs);
  
!         if(dbg) pa("Put "+br+" "+ch.length()+" in cs "+cs+" @ "+x+" "+y+" 
"+w+" "+h+" ("+size+")");
!     }
  
!     /** Get the HBox for some text. */
!     HBox text(String s, int i) {
!       return new TextVob(style, 1.0f, s, new Integer(i));
!     }
  
!     HBox text(String s) { return text(s, 1); }
  
!     /** Get the HBox for a cell (as part of the cell's opstring). */
!     HBox cell(Cell c, ViewContext context) {
!       if(c == null) return text("[which cell?]");
  
!       return new CellHBox(c, cvf, context);
      }
  }
Index: gzz/gzz/vob/HBroken.java
diff -c gzz/gzz/vob/HBroken.java:1.1 gzz/gzz/vob/HBroken.java:1.2
*** gzz/gzz/vob/HBroken.java:1.1        Sat Sep 21 17:49:04 2002
--- gzz/gzz/vob/HBroken.java    Sat Sep 21 18:48:01 2002
***************
*** 56,75 ****
      public void put(VobScene vs, int coordsys) {
          int x = 0, y = 0;
  
!         for(int i=1; i<=length; i++) {
!           int from = breaks[i-1];
!           int to;
  
            if(i<length)
                to = breaks[i];
            else
                to = chain.length();
  
-             float h = chain.getHeight(from, to, scale);
- 
            for(int j=from; j<to; j++) {
                HBox box = chain.getBox(j);
                float w = box.getWidth(scale);
                Object key = box.getKey();
  
                int cs = vs.coords.coordsys(coordsys, key, 0, x, y, w, h);
--- 56,78 ----
      public void put(VobScene vs, int coordsys) {
          int x = 0, y = 0;
  
!         for(int i=0; i<=length; i++) {
!           int from, to;
! 
!           if(i>0)
!               from = breaks[i-1];
!           else
!               from = 0;
  
            if(i<length)
                to = breaks[i];
            else
                to = chain.length();
  
            for(int j=from; j<to; j++) {
                HBox box = chain.getBox(j);
                float w = box.getWidth(scale);
+               float h = box.getHeight(scale);
                Object key = box.getKey();
  
                int cs = vs.coords.coordsys(coordsys, key, 0, x, y, w, h);
***************
*** 79,92 ****
            }
  
            x = 0;
!           y += h;
        }
      }
  
      public float getHeight() {
          float h = 0;
!         for(int i=1; i<length; i++)
!           h += chain.getHeight(breaks[i-1], breaks[i], scale);
  
        return h;
      }
--- 82,101 ----
            }
  
            x = 0;
!           y += chain.getHeight(from, to, scale);
        }
      }
  
      public float getHeight() {
          float h = 0;
!       if(length > 0) {
!           h += chain.getHeight(0, breaks[0], scale);
!             for(int i=1; i<length; i++)
!               h += chain.getHeight(breaks[i-1], breaks[i], scale);
!           h += chain.getHeight(breaks[length-1], chain.length(), scale);
!         } else {
!           h = chain.getHeight(0, chain.length(), scale);
!       }
  
        return h;
      }




reply via email to

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