[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gzz/view TextCellContentView.java
From: |
Benja Fallenstein |
Subject: |
[Gzz-commits] gzz/gzz/view TextCellContentView.java |
Date: |
Mon, 25 Nov 2002 19:56:09 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Benja Fallenstein <address@hidden> 02/11/25 19:56:08
Modified files:
gzz/view : TextCellContentView.java
Log message:
ARGH ARGH ARGH! Fixed the bug, but what a KLUDGE!
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/view/TextCellContentView.java.diff?tr1=1.30&tr2=1.31&r1=text&r2=text
Patches:
Index: gzz/gzz/view/TextCellContentView.java
diff -u gzz/gzz/view/TextCellContentView.java:1.30
gzz/gzz/view/TextCellContentView.java:1.31
--- gzz/gzz/view/TextCellContentView.java:1.30 Mon Nov 25 19:33:03 2002
+++ gzz/gzz/view/TextCellContentView.java Mon Nov 25 19:56:08 2002
@@ -39,7 +39,7 @@
*/
public class TextCellContentView extends CellContentView {
-public static final String rcsid = "$Id: TextCellContentView.java,v 1.30
2002/11/26 00:33:03 benja Exp $";
+public static final String rcsid = "$Id: TextCellContentView.java,v 1.31
2002/11/26 00:56:08 benja Exp $";
public static boolean dbg = false;
private static void pa(String s) { System.err.println(s); }
@@ -71,6 +71,7 @@
}
float[] boxwh = new float[2];
+ java.awt.Point point;
public void place(Cell c, VobScene vs, int box,
ViewContext context) {
String s = c.t();
@@ -96,16 +97,21 @@
vs.coords.getSqSize(box, boxwh);
float middle = boxwh[0] / 2.0f;
- float scale = style.getScaleByHeight(boxwh[1]);
+
+ float y0 = vs.coords.transformPoint(box, 0, 0, point).y;
+ float y1 = vs.coords.transformPoint(box, 0, boxwh[1], point).y;
+
+ float h = y1-y0;
+ float scale = style.getScaleByHeight(h);
if(dbg) {
pa("text: "+s);
- pa("scaled_h: "+boxwh[1]);
+ pa("scaled_h: "+h);
pa("scale: "+scale);
}
- float width = style.getWidth(s, scale);
- float left = style.getWidth(s.substring(0, center), scale);
+ float width = style.getWidth(s, scale) * boxwh[1]/h;
+ float left = style.getWidth(s.substring(0, center), scale) *
boxwh[1]/h;
float right = width - left;
// Possibly offset text so cursor is visible.
@@ -118,23 +124,23 @@
Object key = (line < KEY.length) ? KEY[line] : new Integer(line+1);
int offsetcs = vs.orthoCS(box, key, 0, textOffset, 0, 1, 1);
- placeVob(c, vs, offsetcs, brBefore, brAfter, offs, context, boxwh[1]);
+ placeVob(c, vs, offsetcs, brBefore, brAfter, offs, context, boxwh[1],
h, scale);
}
static Object WH_KEY = new Object();
static Object CURS_KEY = new Object();
LineVob cursorVob = new LineVob(0, 0, 0, 1, Color.black);
protected void placeVob(Cell c, VobScene vs, int cs, int start, int end,
- int offs, ViewContext context, float scaled_h) {
+ int offs, ViewContext context, float h, float
scaled_h, float scale) {
// XXX should optimize for common case: no substring()
TextVob vob = new TextVob(style, c.t().substring(start, end));
- int cs_scaled = vs.orthoCS(cs, WH_KEY, 0, 0, 0, scaled_h, scaled_h);
+ int cs_scaled = vs.orthoCS(cs, WH_KEY, 0, 0, 0, h, h);
vs.map.put(vob, cs_scaled);
if(offs >= 0 && offs >= start && offs <= end) {
- float xscale = style.getScaleByHeight(scaled_h);
- float x = style.getWidth(c.t().substring(start, offs), xscale);
- int cs_cursor = vs.orthoCS(cs, CURS_KEY, -1, x+1, 0, 0,scaled_h);
+ float x = style.getWidth(c.t().substring(start, offs), scale);
+ x *= h/scaled_h;
+ int cs_cursor = vs.orthoCS(cs, CURS_KEY, -1, x+1, 0, 0, h);
// v.map.put(new TextCursorVob(vob, offs), cs);
vs.map.put(cursorVob, cs_cursor);
}