home *** CD-ROM | disk | FTP | other *** search
- package webeq3.schema;
-
- import java.awt.Graphics;
- import webeq3.app.Equation;
- import webeq3.util.OutputHandler;
-
- public class MMultiscripts extends Box {
- double itc = (double)0.0F;
- boolean stretchy = false;
- Box base = null;
- Box script = null;
- int num_postscripts = 0;
- int truebasewidth = 0;
- int lspace = 0;
- int rspace = 0;
- int sub_asc = 0;
- int sub_desc = 0;
- int sup_asc = 0;
- int sup_desc = 0;
- int sub_height = 0;
- int sup_height = 0;
- int sub_bottom = 0;
- int sup_top = 0;
- int pre_width = 0;
- int post_width = 0;
- int[] col_widths = null;
-
- public MMultiscripts(Box var1) {
- super(var1);
- super.type = 8;
- }
-
- public MMultiscripts() {
- super.type = 8;
- }
-
- public MMultiscripts(Equation var1) {
- super(var1);
- super.type = 8;
- }
-
- public void postscripts_done() {
- this.num_postscripts = super.children.size();
- }
-
- public void size() {
- this.sub_asc = 0;
- this.sub_desc = 0;
- this.sup_asc = 0;
- this.sup_desc = 0;
- this.sub_height = 0;
- this.sup_height = 0;
- this.sub_bottom = 0;
- this.sup_top = 0;
- this.pre_width = 0;
- this.post_width = 0;
- this.col_widths = new int[(super.children.size() - 1) / 2 + 1];
- if (this.num_postscripts == 0) {
- this.num_postscripts = super.children.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.base.depth = super.depth;
- this.base.layout();
- super.embellished_op = this.base.embellished_op;
-
- Box var1;
- for(var1 = this.base; this.italic_base_check(var1); var1 = var1.getChild(0)) {
- }
-
- if (var1.isItalic()) {
- this.itc = 0.14;
- }
-
- this.truebasewidth = this.base.getWidth();
- if (!this.base.isItalic()) {
- this.truebasewidth += (int)(0.2 * (double)super.xheight);
- }
-
- if (this.base instanceof 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;
- }
- }
-
- for(int var2 = 1; var2 < super.children.size(); ++var2) {
- this.script = ((Box)this).getChild(var2);
- this.script.depth = super.depth + 1;
- this.script.layout();
- if (var2 % 2 != 0) {
- this.col_widths[(var2 - 1) / 2] = this.script.getWidth();
- if (this.sub_asc < this.script.getAscent()) {
- this.sub_asc = this.script.getAscent();
- }
-
- if (this.sub_desc < this.script.getDescent()) {
- this.sub_desc = this.script.getDescent();
- }
- } else {
- if (this.col_widths[(var2 - 2) / 2] < this.script.getWidth()) {
- this.col_widths[(var2 - 2) / 2] = this.script.getWidth();
- }
-
- if (this.sup_asc < this.script.getAscent()) {
- this.sup_asc = this.script.getAscent();
- }
-
- if (this.sup_desc < this.script.getDescent()) {
- this.sup_desc = this.script.getDescent();
- }
- }
- }
-
- this.sup_height = this.sup_asc + this.sup_desc;
- this.sub_height = this.sub_asc + this.sub_desc;
-
- for(int var3 = 0; var3 < (this.num_postscripts - 1) / 2; ++var3) {
- this.post_width += this.col_widths[var3];
- }
-
- for(int var4 = (this.num_postscripts - 1) / 2; var4 < (super.children.size() - 1) / 2; ++var4) {
- this.pre_width += this.col_widths[var4];
- }
-
- super.width = this.pre_width + this.post_width + (int)(this.itc * (double)this.base.getHeight());
- super.width += this.lspace + this.truebasewidth + this.rspace;
- if (super.my_view.linebreak && this.truebasewidth > 8 * super.fm.charWidth('M') || (double)super.width > (double)super.my_view.getDisplayWidth() - (double)1.5F * (double)super.my_view.indent) {
- super.atomic = false;
- }
-
- if (this.sub_height != 0) {
- this.sub_bottom = (int)(0.3 * (double)super.xheight) + this.sub_desc;
- if (this.sub_bottom < this.base.getDescent() - (int)(0.2 * (double)super.xheight)) {
- this.sub_bottom = this.base.getDescent() + (int)(0.1 * (double)super.xheight);
- }
-
- if (this.sup_height != 0) {
- if (this.sub_height - this.sub_bottom > (int)(0.65 * (double)super.xheight)) {
- this.sub_bottom = this.sub_height - (int)(0.65 * (double)super.xheight);
- }
- } else if (this.sub_height - this.sub_bottom > (int)(0.8 * (double)super.xheight)) {
- this.sub_bottom = this.sub_height - (int)(0.8 * (double)super.xheight);
- }
- }
-
- if (this.sup_height != 0) {
- double var5 = this.base.depth >= 2 ? 0.55 : 0.8;
- this.sup_top = (int)(var5 * (double)super.xheight) + this.sup_asc;
- if (this.sup_top < this.base.getAscent() + this.sup_asc - (int)(0.8 * (double)super.xheight)) {
- this.sup_top = this.base.getAscent() + this.sup_asc - (int)(0.8 * (double)super.xheight);
- }
-
- if (this.sub_height != 0) {
- if (this.sup_top - this.sup_height < (int)(0.8 * (double)super.xheight)) {
- this.sup_top = this.sup_height + (int)(0.8 * (double)super.xheight);
- }
- } else if (this.sup_top - this.sup_height < (int)((double)0.25F * (double)super.xheight)) {
- this.sup_top = this.sup_height + (int)((double)0.25F * (double)super.xheight);
- }
- }
-
- super.ascent = this.base.getAscent() < this.sup_top ? this.sup_top : this.base.getAscent();
- super.descent = this.base.getDescent() < this.sub_bottom ? this.sub_bottom : this.base.getDescent();
- super.height = super.ascent + super.descent;
- }
-
- public void position() {
- this.base.setTop(super.ascent - this.base.getAscent());
- this.base.setLeft(this.pre_width - (int)(this.itc * (double)this.base.getDescent()));
- this.position_scripts(this.num_postscripts, super.children.size(), this.lspace);
- this.position_scripts(1, this.num_postscripts, this.pre_width + this.truebasewidth + (int)(this.itc * (double)this.base.getAscent()));
- }
-
- void position_scripts(int var1, int var2, int var3) {
- for(int var4 = var1; var4 < var2; ++var4) {
- this.script = ((Box)this).getChild(var4);
- if (var4 % 2 != 0) {
- this.script.setTop(super.ascent + this.sub_bottom - this.sub_desc - this.script.getAscent());
- this.script.setLeft(var3 + (this.col_widths[(var4 - 1) / 2] - this.script.getWidth()) / 2 - (int)(this.itc * (double)this.base.getDescent()));
- } else {
- this.script.setTop(super.ascent - this.sup_top + this.sup_asc - this.script.getAscent());
- this.script.setLeft(var3 + (this.col_widths[(var4 - 1) / 2] - this.script.getWidth()) / 2 + (int)(this.itc * (double)this.base.getAscent()));
- var3 += this.col_widths[(var4 - 2) / 2];
- }
- }
-
- }
-
- public boolean stretchTo(int var1, int var2) {
- Box var3 = ((Box)this).getChild(0);
- boolean var4 = false;
- if (var3.embellished_op) {
- var4 |= var3.stretchTo(var1, var2);
- this.size();
- this.position();
- }
-
- return var4;
- }
-
- public void printSelected(String var1, OutputHandler var2, boolean var3, boolean var4, String var5, boolean var6, int var7) {
- if (var3 && !super.reverse_video) {
- for(int var10 = 0; var10 < super.children.size(); ++var10) {
- ((Box)this).getChild(var10).printSelected(var1, var2, var3, var4, var5, var6, var7);
- }
- } else if (var6 && super.cpeer != null) {
- super.cpeer.printSelected(var1, var2, var3, var4, var5, var6, var7);
- } else if (super.children.size() == 0) {
- var2.println(var1 + ((Box)this).make_head(false, var5) + "</" + ((Box)this).make_tag(var5) + ">");
- } else {
- var2.println(var1 + ((Box)this).make_head(false, var5));
-
- for(int var9 = 0; var9 < super.children.size(); ++var9) {
- Box var8 = ((Box)this).getChild(var9);
- if (!"".equals(var5)) {
- var5 = var5 + ":";
- }
-
- if (var9 == this.num_postscripts) {
- var2.println(var1 + " " + "<" + var5 + "mprescripts/>");
- }
-
- if (var8.getClass().getName().equals("webeq3.schema.Box")) {
- var2.println(var1 + " " + "<" + var5 + "none/>");
- } else {
- var8.printSelected(var1 + " ", var2, var3, var4, var5, var6, var7);
- }
- }
-
- var2.println(var1 + "</" + ((Box)this).make_tag(var5) + ">");
- }
-
- }
-
- private boolean italic_base_check(Box var1) {
- if (var1 instanceof MRow && var1.getNumChildren() == 1) {
- return true;
- } else {
- return var1 instanceof MUnder | var1 instanceof MOver | var1 instanceof MUnderover | var1 instanceof MSubsup | var1 instanceof MSub | var1 instanceof MSup;
- }
- }
-
- public void paint(Graphics var1, int var2, int var3) {
- ((Box)this).paintBackground(var1, var2, var3);
- if (super.my_view.linebreak) {
- int var4 = var2 + super.left + super.my_view.offsetx;
- int var5 = super.my_view.getDisplayWidth();
- Box var6 = ((Box)this).getChild(0);
- if (var5 - (var4 + var6.getLeft() + super.fm.charWidth('M') + super.breakLookAhead) < 0) {
- super.my_view.offsetx = super.my_view.indent - (var2 + super.left);
- Equation var10000 = super.my_view;
- var10000.offsety += 5 + super.my_view.root.getHeight();
- Integer var7 = new Integer(var2 + super.left);
- super.my_view.breaks.addElement(var7);
- }
-
- for(int var11 = this.num_postscripts; var11 < super.children.size(); ++var11) {
- ((Box)this).getChild(var11).paint(var1, var2 + super.left, var3 + super.top);
- }
-
- int var8 = super.width - (var6.getLeft() + var6.getWidth());
- var6.setLookAhead(super.breakLookAhead + var8);
- var6.paint(var1, var2 + super.left, var3 + super.top);
- var6.setLookAhead(super.breakLookAhead);
-
- for(int var9 = 1; var9 < this.num_postscripts; ++var9) {
- ((Box)this).getChild(var9).paint(var1, var2 + super.left, var3 + super.top);
- }
- } else {
- for(int var10 = 0; var10 < super.children.size(); ++var10) {
- ((Box)this).getChild(var10).paint(var1, var2 + super.left, var3 + super.top);
- }
- }
-
- super.absleft = var2 + super.left;
- super.abstop = var3 + super.top;
- }
- }
-