/[gzz]/gzz/gzz/vob/TextVob.java
ViewVC logotype

Diff of /gzz/gzz/vob/TextVob.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.37 by tjl, Mon Oct 7 17:47:55 2002 UTC revision 1.38 by tjl, Tue Oct 8 07:30:12 2002 UTC
# Line 1  Line 1 
1  /*  /*
2  TextVob.java  TextVob.java
3   *       *    
4   *    Copyright (c) 2001, Ted Nelson and Tuomas Lukka   *    Copyright (c) 2001-2002, Ted Nelson and Tuomas Lukka
5   *   *
6   *    You may use and distribute under the terms of either the GNU Lesser   *    You may use and distribute under the terms of either the GNU Lesser
7   *    General Public License, either version 2 of the license or,   *    General Public License, either version 2 of the license or,
# Line 37  String rcsid = "$Id$"; Line 37  String rcsid = "$Id$";
37    
38      protected final TextStyle style;      protected final TextStyle style;
39      protected final String text;      protected final String text;
40      /** The scale this Vob's TextStyle should be used.      protected final boolean baselined;
41       * XXX Performance?  
      */  
     protected float scale;  
       
42      protected Object key;      protected Object key;
43    
44      public TextVob(TextStyle style, String text) {      public TextVob(TextStyle style, String text, boolean baselined) {
45          super();          super();
46          this.style = style;          this.style = style;
47            this.baselined = baselined;
48          this.text = text;          this.text = text;
         this.scale = 1;  
     }  
   
     public TextVob(TextStyle style, float scale, String text) {  
         this(style, text);  
         this.scale = scale;  
49      }      }
50    
51      public TextVob(TextStyle style, float scale, String text, Object key) {      public TextVob(TextStyle style, String text, boolean baselined, Object key) {
52          this(style, scale, text);          this(style, text, baselined);
53          this.key = key;          this.key = key;
54      }      }
55    
# Line 78  String rcsid = "$Id$"; Line 70  String rcsid = "$Id$";
70                         boolean fast,                         boolean fast,
71                         RenderInfo info1,                         RenderInfo info1,
72                         RenderInfo info2) {                         RenderInfo info2) {
73            // XXX Needs adjusting to baselined!
74          g.setColor(info1.getMixedFgColor());          g.setColor(info1.getMixedFgColor());
75          //info1.getClipRect(rect);          //info1.getClipRect(rect);
76    
# Line 91  String rcsid = "$Id$"; Line 84  String rcsid = "$Id$";
84                        rect.width,                        rect.width,
85                        rect.height + 3);*/                        rect.height + 3);*/
86    
87          float scale = this.scale;          float scale = style.getScaleByHeight(h-3);
         if(scale < 0)  
             scale = style.getScaleByHeight(h-3);  
88          if(dbg) pa("Render @ scale " + scale + ": '"+text+"' "+x+" "+y+" "+w+" "+h);          if(dbg) pa("Render @ scale " + scale + ": '"+text+"' "+x+" "+y+" "+w+" "+h);
89    
90          float fasc = style.getAscent(scale);          float fasc = style.getAscent(scale);
# Line 140  String rcsid = "$Id$"; Line 131  String rcsid = "$Id$";
131    
132      /** The OpenGL renderable for this TextVob.      /** The OpenGL renderable for this TextVob.
133       */       */
134      private GLRen.HorizText2 ht;      private Vob ht;
135      public int addToListGL(GraphicsAPI.Window win,      public int addToListGL(GraphicsAPI.Window win,
136                          int[] list, int curs, int coordsys1,                          int[] list, int curs, int coordsys1,
137                                  int coordsys2) {                                  int coordsys2) {
138          if(dbg) pa("Addtolistgl text "+text);          if(dbg) pa("Addtolistgl text "+text);
139          if(ht == null) {          if(ht == null) {
140              GLTextStyle gls = (GLTextStyle)style;              GLTextStyle gls = (GLTextStyle)style;
141              ht = GLRen.createHorizText2(              ht = GLRen.createHorizText(
142                      gls.theFont,                      gls.theFont,
143                      text, gls.theFont.getHeight(), gls.theFont.getYOffs(),                      text,
144                      scale * gls.fontScale, 0);                      0,
145                        (baselined ? 1 : gls.theFont.getYOffs()),
146                        0,
147                        1, 1);
148          }          }
149          curs = getStartCode().addToListGL(win, list, curs, 0, 0);          curs = getStartCode().addToListGL(win, list, curs, 0, 0);
150          curs = ht.addToListGL(win, list, curs, coordsys1, coordsys2);          curs = ht.addToListGL(win, list, curs, coordsys1, coordsys2);

Legend:
Removed from v.1.37  
changed lines
  Added in v.1.38

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26