home *** CD-ROM | disk | FTP | other *** search
- package webeq3.schema;
-
- import java.awt.Color;
- import java.awt.Graphics;
- import webeq3.app.Equation;
- import webeq3.constants.FontMapper;
- import webeq3.fonts.ExtendedChar;
-
- public class MFrac extends LineBreakRewriter {
- int mid = 0;
- int dxheight = 0;
- int linethickness = 1;
- int spacing = 0;
-
- public MFrac() {
- super.type = 4;
- }
-
- public MFrac(Box var1) {
- super(var1);
- super.type = 4;
- }
-
- public MFrac(Equation var1) {
- super(var1);
- super.type = 4;
- }
-
- public void size() {
- super.useLinearForm = false;
- Box var1 = ((Box)this).getChild(0);
- Box var2 = ((Box)this).getChild(1);
- String var3 = ((Box)this).getAttributeString(24);
-
- try {
- this.linethickness = Integer.parseInt(var3);
- } catch (NumberFormatException var13) {
- if ("thick".equals(var3)) {
- this.linethickness = 3;
- } else if ("medium".equals(var3)) {
- this.linethickness = 2;
- } else if ("thin".equals(var3)) {
- this.linethickness = 1;
- } else {
- var3 = ((Box)this).getAttributeByIndex(24);
-
- try {
- float var5 = Float.valueOf(var3) * (float)((Box)this).getXHeight();
- this.linethickness = (int)var5;
- if ((double)var5 > 0.001 && this.linethickness == 0) {
- this.linethickness = 1;
- }
- } catch (NumberFormatException var12) {
- }
- }
- }
-
- this.linethickness = super.my_view.standardPointsize(super.depth) > 18 && this.linethickness != 0 ? this.linethickness + 1 : this.linethickness;
- super.fgcolor = ((Box)this).resolveColor(4);
- super.bgcolor = ((Box)this).resolveColor(17);
- ((Box)this).setfont(super.depth);
- int var4 = super.depth == 0 && "true".equals(((Box)this).getAttributeByIndex(21)) ? 0 : 1;
- var1.depth = super.depth + var4;
- var2.depth = super.depth + var4;
- super.attribute_stack[21].push("false");
- var1.layout();
- var2.layout();
- super.attribute_stack[21].pop();
- super.embellished_op = var1.embellished_op;
- int var15 = var1.getWidth();
- int var6 = var2.getWidth();
- super.width = var15 > var6 ? var15 : var6;
- int var7 = (int)((double)super.width * 1.2);
- if (var7 - super.width > 10) {
- var7 = super.width + 10;
- }
-
- if (var7 - super.width < 2) {
- var7 = super.width + 2;
- }
-
- this.spacing = (int)(0.08 * (double)super.my_view.standardPointsize(super.depth));
- super.width = var7 + 2 * this.spacing;
- int var8 = super.my_view.getDisplayWidth();
- if (super.my_view.linebreak && (double)super.width > 0.85 * (double)(var8 - super.my_view.indent)) {
- super.useLinearForm = true;
- if (super.lb_rewrite == null) {
- super.lb_rewrite = new MRow(super.parent);
- MRow var16 = new MRow(super.lb_rewrite);
- super.lb_rewrite.addChild(var16);
- MO var18 = new MO(var16);
- ((Box)var18).addData("(");
- ((Box)var16).addChild(var18);
- ((Box)var16).addChild(var1);
- var1.setParent(this);
- var18 = new MO(var16);
- ((Box)var18).addData(")");
- ((Box)var16).addChild(var18);
- MO var11 = new MO(super.lb_rewrite);
- ((Box)var11).addData("/");
- super.lb_rewrite.addChild(var11);
- var16 = new MRow(super.lb_rewrite);
- super.lb_rewrite.addChild(var16);
- var18 = new MO(var16);
- ((Box)var18).addData("(");
- ((Box)var16).addChild(var18);
- ((Box)var16).addChild(var2);
- var2.setParent(this);
- var18 = new MO(var16);
- ((Box)var18).addData(")");
- ((Box)var16).addChild(var18);
- }
-
- super.lb_rewrite.layout();
- super.width = super.lb_rewrite.getWidth();
- super.ascent = super.lb_rewrite.getAscent();
- super.descent = super.lb_rewrite.getDescent();
- super.height = super.ascent + super.descent;
- } else {
- ((Box)this).setfont(var2.depth);
- this.dxheight = super.xheight;
- ((Box)this).setfont(super.depth);
- ExtendedChar var9 = FontMapper.get('−');
- var9.setFont(super.fn, super.my_view.getHandler().getComponent());
- double var10 = 0.9 * (double)var9.getAscent();
- super.ascent = var1.getAscent() + (int)(var10 + 0.35 * (double)this.dxheight + (double)(this.linethickness / 2));
- if (0.35 * (double)this.dxheight - (double)(this.linethickness / 2) < (double)(var1.getDescent() + 2)) {
- super.ascent += (int)((double)var1.getDescent() - 0.35 * (double)this.dxheight + (double)(this.linethickness / 2) + (double)2.0F);
- }
-
- super.descent = var2.getDescent() + (int)(1.8 * (double)this.dxheight - var10);
- if (var2.getHeight() > super.descent + (int)(var10 - (double)0.25F * (double)this.dxheight - (double)(this.linethickness / 2))) {
- super.descent = var2.getHeight() - (int)(var10 - (double)0.25F * (double)this.dxheight - (double)(this.linethickness / 2));
- }
-
- super.height = super.ascent + super.descent;
- this.mid = super.ascent - (int)(var10 + (double)(this.linethickness / 2) + (double)0.5F);
- }
-
- }
-
- public void position() {
- Box var1 = ((Box)this).getChild(0);
- Box var2 = ((Box)this).getChild(1);
- if (super.useLinearForm) {
- super.lb_rewrite.setLeft(0);
- super.lb_rewrite.setTop(0);
- } else {
- var1.setLeft((super.width - var1.getWidth()) / 2);
- var2.setLeft((super.width - var2.getWidth()) / 2);
- var1.setTop(super.top);
- var2.setTop(super.top + super.height - var2.getHeight());
- }
-
- }
-
- public void paint(Graphics var1, int var2, int var3) {
- if (super.useLinearForm) {
- super.lb_rewrite.paint(var1, var2 + super.left, var3 + super.top);
- } else {
- ((Box)this).paintBackground(var1, var2, var3);
- ((Box)this).getChild(0).paint(var1, var2 + super.left, var3 + super.top);
- ((Box)this).getChild(1).paint(var1, var2 + super.left, var3 + super.top);
- if (super.reverse_video) {
- var1.setColor(super.bgcolor);
- } else {
- var1.setColor(super.fgcolor);
- }
-
- var1.fillRect(var2 + super.left + super.my_view.offsetx + this.spacing, var3 + super.top + super.my_view.offsety + this.mid, super.width - 2 * this.spacing, this.linethickness);
- var1.setColor(Color.black);
- }
-
- super.absleft = var2 + super.left;
- super.abstop = var3 + super.top;
- }
- }
-