home *** CD-ROM | disk | FTP | other *** search
- package webeq3.schema;
-
- import java.util.Hashtable;
- import webeq3.app.Equation;
-
- public abstract class MScripts extends LineBreakRewriter {
- Box base = null;
- Box low = null;
- Box high = null;
- double itc = (double)0.0F;
- int truebasewidth = 0;
- int lspace = 0;
- int rspace = 0;
- int high_ascent = 0;
- int low_descent = 0;
- boolean move_scripts = false;
- boolean stretchy = false;
- private static Hashtable baseCheck = new Hashtable();
-
- public MScripts(Box var1) {
- super(var1);
- }
-
- public MScripts() {
- }
-
- public MScripts(Equation var1) {
- super(var1);
- }
-
- public void size() {
- ((Box)this).setfont(super.depth);
- super.bgcolor = ((Box)this).resolveColor(17);
- super.fgcolor = ((Box)this).resolveColor(4);
- this.base = ((Box)this).getChild(0);
- this.low = ((Box)this).getChild(1);
- this.high = ((Box)this).getChild(2);
- this.setChildDepths();
- this.base.layout();
- this.low.layout();
- this.high.layout();
- super.embellished_op = this.base.embellished_op;
-
- Box var1;
- for(var1 = this.base; this.base_check(var1); var1 = var1.getChild(0)) {
- }
-
- if (var1.isItalic()) {
- this.itc = 0.13;
- }
-
- this.truebasewidth = this.base.getWidth();
- if (this.base.getClass().getName().equals("webeq3.schema.MO")) {
- this.lspace = ((MO)this.base).op.lspace;
- this.rspace = ((MO)this.base).op.rspace;
- this.truebasewidth = this.truebasewidth - this.lspace - this.rspace;
- if (((MO)this.base).op.stretchy) {
- this.stretchy = true;
- }
-
- if (((MO)this.base).op.movescripts) {
- this.move_scripts = true;
- }
-
- if ("true".equals(((Box)this).getAttributeByIndex(21))) {
- this.move_scripts = false;
- }
-
- if (this.base.depth > 0) {
- this.move_scripts = false;
- }
- }
-
- if (this.itc == (double)0.0F && (this.high.isItalic() || this.low.isItalic())) {
- this.truebasewidth += (int)(0.2 * (double)super.xheight);
- }
-
- this.sizeScripts();
- }
-
- public void sizeSubSup() {
- Box var1 = this.low;
- Box var2 = this.high;
- double var3 = (double)0.0F;
- double var5 = (double)0.0F;
- int var7 = var1.getWidth() - (int)(this.itc * (double)this.base.getDescent() + (double)0.5F);
- if (var2.getWidth() + (int)(this.itc * (double)this.base.getAscent()) > var7) {
- var7 = var2.getWidth() + (int)(this.itc * (double)this.base.getAscent() + (double)0.5F);
- }
-
- super.width = this.lspace + this.truebasewidth + var7 + this.rspace + 1;
- if (var1.getHeight() != 0) {
- try {
- var3 = Double.valueOf(((Box)this).getAttributeByIndex(25));
- } catch (NumberFormatException var11) {
- }
-
- if (var3 < 0.35) {
- var3 = 0.35;
- }
-
- this.low_descent = (int)(var3 * (double)super.xheight) + var1.getDescent();
- if (this.base.getClass().getName().equals("webeq3.schema.MI")) {
- if (this.low_descent < this.base.getDescent() - (int)(0.2 * (double)super.xheight)) {
- this.low_descent = this.base.getDescent() + (int)(0.1 * (double)super.xheight);
- }
- } else if (this.low_descent < this.base.getDescent() + (int)(0.1 * (double)super.xheight)) {
- this.low_descent = this.base.getDescent() + (int)(0.1 * (double)super.xheight);
- }
-
- if (this.high.getHeight() != 0) {
- if (this.low.getHeight() - this.low_descent > (int)(0.6 * (double)super.xheight)) {
- this.low_descent = this.low.getHeight() - (int)(0.6 * (double)super.xheight);
- }
- } else if (this.low.getHeight() - this.low_descent > (int)(0.8 * (double)super.xheight)) {
- this.low_descent = this.low.getHeight() - (int)(0.8 * (double)super.xheight);
- }
- }
-
- if (var2.getHeight() != 0) {
- try {
- var5 = Double.valueOf(((Box)this).getAttributeByIndex(26));
- } catch (NumberFormatException var10) {
- }
-
- double var8 = var2.depth >= 3 ? 0.55 : 0.8;
- var8 = var8 > var5 ? var8 : var5;
- this.high_ascent = (int)(var8 * (double)super.xheight) + var2.getAscent();
- if (this.high_ascent < this.base.getAscent() + var2.getAscent() - (int)(0.65 * (double)super.xheight)) {
- this.high_ascent = this.base.getAscent() + var2.getAscent() - (int)(0.65 * (double)super.xheight);
- }
-
- if (var1.getHeight() != 0) {
- if (this.high_ascent - var2.getHeight() < (int)(0.8 * (double)super.xheight)) {
- this.high_ascent = var2.getHeight() + (int)(0.8 * (double)super.xheight);
- }
- } else if (this.high_ascent - var2.getHeight() < (int)((double)0.25F * (double)super.xheight)) {
- this.high_ascent = var2.getHeight() + (int)((double)0.25F * (double)super.xheight);
- }
- }
-
- super.ascent = this.base.getAscent() < this.high_ascent ? this.high_ascent : this.base.getAscent();
- super.descent = this.base.getDescent() < this.low_descent ? this.low_descent : this.base.getDescent();
- super.height = super.ascent + super.descent;
- }
-
- public void sizeUnderOver(int var1, int var2) {
- int var3 = this.truebasewidth / 2;
- int var4 = this.truebasewidth - var3;
- if ((int)((double)(this.low.getWidth() / 2) + this.itc * (double)this.base.getDescent() + (double)0.5F) > var3) {
- var3 = (int)((double)(this.low.getWidth() / 2) + this.itc * (double)this.base.getDescent() + (double)0.5F);
- }
-
- if ((int)((double)(this.low.getWidth() / 2) - this.itc * (double)this.base.getDescent() + (double)0.5F) > var4) {
- var4 = (int)((double)(this.low.getWidth() / 2) - this.itc * (double)this.base.getDescent() + (double)0.5F);
- }
-
- if ((int)((double)(this.high.getWidth() / 2) - this.itc * (double)this.base.getAscent() + (double)0.5F) > var3) {
- var3 = (int)((double)(this.high.getWidth() / 2) - this.itc * (double)this.base.getAscent() + (double)0.5F);
- }
-
- if ((int)((double)(this.high.getWidth() / 2) + this.itc * (double)this.base.getAscent() + (double)0.5F) > var4) {
- var4 = (int)((double)(this.high.getWidth() / 2) + this.itc * (double)this.base.getAscent() + (double)0.5F);
- }
-
- super.width = var3 + var4 + this.lspace + this.rspace;
- super.descent = this.base.getDescent() + this.low.getHeight() + var1;
- super.ascent = this.base.getAscent() + this.high.getHeight() + var2;
- super.height = super.ascent + super.descent;
- }
-
- public void positionUnderOver() {
- int var1 = super.width - this.lspace - this.rspace;
- this.base.setTop(super.ascent - this.base.getAscent());
- this.base.setLeft((var1 - this.truebasewidth) / 2 + this.lspace);
- this.low.setTop(super.height - this.low.getHeight());
- this.low.setLeft((int)((double)((var1 - this.low.getWidth()) / 2) - this.itc * (double)this.base.getDescent() + (double)0.5F) + this.lspace);
- this.high.setTop(0);
- this.high.setLeft((int)((double)((var1 - this.high.getWidth()) / 2) + this.itc * (double)this.base.getAscent() + (double)0.5F) + this.lspace);
- }
-
- public void positionSubSup() {
- this.base.setTop(super.ascent - this.base.getAscent());
- this.base.setLeft(0);
- this.low.setTop(super.ascent + this.low_descent - this.low.getHeight());
- this.low.setLeft(this.lspace + this.truebasewidth - (int)(this.itc * (double)this.low_descent + (double)0.5F));
- this.high.setTop(super.ascent - this.high_ascent);
- this.high.setLeft(this.lspace + this.truebasewidth + (int)(this.itc * (double)this.high_ascent + (double)0.5F));
- }
-
- protected boolean base_check(Box var1) {
- String var2 = var1.getClass().getName();
- return "webeq3.schema.MRow".equals(var2) && var1.embellished_op ? true : baseCheck.containsKey(var2);
- }
-
- abstract void setChildDepths();
-
- abstract void sizeScripts();
-
- public boolean isAtomic() {
- return super.useLinearForm ? super.lb_rewrite.isAtomic() : super.atomic;
- }
-
- static {
- baseCheck.put("webeq3.schema.MSubsup", baseCheck);
- baseCheck.put("webeq3.schema.MSub", baseCheck);
- baseCheck.put("webeq3.schema.MSup", baseCheck);
- baseCheck.put("webeq3.schema.MUnderover", baseCheck);
- baseCheck.put("webeq3.schema.MUnder", baseCheck);
- baseCheck.put("webeq3.schema.MOver", baseCheck);
- }
- }
-