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, |
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 |
|
|
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 |
|
|
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); |
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); |