home *** CD-ROM | disk | FTP | other *** search
- package webeq3.schema;
-
- import java.awt.Graphics;
- import webeq3.app.Equation;
- import webeq3.fonts.CharRender;
- import webeq3.fonts.ExtendedChar;
-
- public class MRoot extends LineBreakRewriter {
- int pad = 0;
- int rad_ascent = 0;
- int rad_left = 0;
- int sqr_left = 2;
- ExtendedChar sqr = new ExtendedChar('√', -1);
-
- public MRoot(Box var1) {
- super(var1);
- super.type = 4;
- }
-
- public MRoot() {
- }
-
- public MRoot(Equation var1) {
- super(var1);
- super.type = 4;
- }
-
- public void size() {
- Box var1 = ((Box)this).getChild(0);
- Box var2 = ((Box)this).getChild(1);
- super.fgcolor = ((Box)this).resolveColor(4);
- super.bgcolor = ((Box)this).resolveColor(17);
- var1.depth = super.depth;
- var1.layout();
- var2.depth = super.depth + 2;
- var2.layout();
- ((Box)this).setfont(super.depth);
- this.sqr.setFont(super.fn, super.my_view.getHandler().getComponent());
- this.pad = (int)((double)0.5F * (double)super.xheight);
- super.width = this.sqr.getWidth() + this.pad + var1.getWidth();
- if (var2.getWidth() > (int)(0.7 * (double)this.sqr.getWidth())) {
- this.sqr_left = var2.getWidth() - (int)(0.7 * (double)this.sqr.getWidth());
- super.width += this.sqr_left;
- } else {
- this.rad_left = (int)(0.7 * (double)this.sqr.getWidth()) - var2.getWidth();
- }
-
- super.useLinearForm = false;
- if (super.my_view.linebreak && (double)super.width > 0.85 * (double)super.my_view.getDisplayWidth()) {
- super.useLinearForm = true;
- if (super.lb_rewrite == null) {
- super.lb_rewrite = new MSup(super.parent);
- MRow var3 = new MRow(super.lb_rewrite);
- super.lb_rewrite.addChild(var3);
- MO var4 = new MO(var3);
- ((Box)var4).addData("(");
- ((Box)var3).addChild(var4);
- ((Box)var3).addChild(var1);
- var4 = new MO(var3);
- ((Box)var4).addData(")");
- ((Box)var3).addChild(var4);
- MFrac var5 = new MFrac(super.lb_rewrite);
- super.lb_rewrite.addChild(var5);
- MN var6 = new MN(var5);
- ((Box)var6).addData("1");
- ((Box)var5).addChild(var6);
- Object var7;
- if (var2.getClass().getName().equals("webeq3.schema.Box")) {
- var7 = new MN(var5);
- ((Box)var7).addData("2");
- } else {
- var7 = var2;
- }
-
- ((Box)var5).addChild((Box)var7);
- }
-
- super.lb_rewrite.layout();
- super.width = super.lb_rewrite.width;
- super.ascent = super.lb_rewrite.ascent;
- super.descent = super.lb_rewrite.descent;
- super.height = super.ascent + super.descent;
- } else {
- super.ascent = (int)((double)var1.getAscent() + 0.15 * (double)super.xheight);
- if (super.ascent < this.sqr.getAscent()) {
- super.ascent = this.sqr.getAscent();
- }
-
- this.rad_ascent = super.ascent;
- if (var2.getHeight() + (int)((double)1.0F * (double)super.xheight) > super.ascent) {
- super.ascent += var2.getHeight() + (int)((double)1.0F * (double)super.xheight) - super.ascent;
- }
-
- super.descent = (int)((double)var1.getDescent() + 0.2 * (double)super.xheight);
- if ((double)super.descent < 0.6 * (double)super.xheight) {
- super.descent = (int)(0.6 * (double)super.xheight);
- }
-
- super.height = super.ascent + super.descent;
- }
-
- }
-
- public void position() {
- if (super.useLinearForm) {
- super.lb_rewrite.setTop(0);
- super.lb_rewrite.setLeft(0);
- } else {
- Box var1 = ((Box)this).getChild(0);
- Box var2 = ((Box)this).getChild(1);
- var2.setTop(super.ascent - var2.getHeight() - (int)((double)1.0F * (double)super.xheight));
- var2.setLeft(this.rad_left);
- var1.setTop(super.ascent - var1.getAscent());
- var1.setLeft(super.width - var1.getWidth() - this.pad / 5);
- }
-
- }
-
- public void paint(Graphics var1, int var2, int var3) {
- if (super.useLinearForm) {
- super.lb_rewrite.paint(var1, var2 + super.left, var3 + super.top);
- } else {
- int var4 = super.left + var2 + super.my_view.offsetx;
- int var5 = super.top + var3 + super.my_view.offsety;
- super.paint(var1, var2, var3);
- this.sqr.setHeight(super.descent + this.rad_ascent);
- if (super.reverse_video) {
- CharRender.paint(var1, this.sqr, var4 + this.sqr_left, var5 + super.height, super.bgcolor, super.fgcolor, super.my_view.getHandler().getComponent());
- } else {
- CharRender.paint(var1, this.sqr, var4 + this.sqr_left, var5 + super.height, super.fgcolor, super.bgcolor, super.my_view.getHandler().getComponent());
- }
-
- if (super.reverse_video) {
- var1.setColor(super.bgcolor);
- } else {
- var1.setColor(super.fgcolor);
- }
-
- int var6 = var5 + super.ascent - this.rad_ascent > 0 ? var5 + super.ascent - this.rad_ascent : 0;
- var1.drawLine(var4 + this.sqr_left + this.sqr.getWidth(), var6, var4 + super.width, var6);
- if (this.sqr.getSize() > 18) {
- var1.drawLine(var4 + this.sqr_left + this.sqr.getWidth(), var6 + 1, var4 + super.width, var6 + 1);
- }
- }
-
- super.absleft = var2 + super.left;
- super.abstop = var3 + super.top;
- }
- }
-