home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2001 December / dppcpro1201.iso / Extras / maple / Viewer / WebEQ / MMLViewerInstall.cab / MMLViewerApplet.cab / webeq3 / app / Equation.class (.txt) < prev    next >
Encoding:
Java Class File  |  2001-05-24  |  21.9 KB  |  1,074 lines

  1. package webeq3.app;
  2.  
  3. import com.ms.security.PermissionID;
  4. import com.ms.security.PolicyEngine;
  5. import java.awt.Canvas;
  6. import java.awt.Color;
  7. import java.awt.Component;
  8. import java.awt.Dimension;
  9. import java.awt.Font;
  10. import java.awt.FontMetrics;
  11. import java.awt.Graphics;
  12. import java.awt.Image;
  13. import java.awt.ScrollPane;
  14. import java.awt.datatransfer.Clipboard;
  15. import java.awt.datatransfer.ClipboardOwner;
  16. import java.awt.datatransfer.Transferable;
  17. import java.util.Enumeration;
  18. import java.util.Vector;
  19. import netscape.security.PrivilegeManager;
  20. import org.w3c.dom.Attr;
  21. import org.w3c.dom.CDATASection;
  22. import org.w3c.dom.Comment;
  23. import org.w3c.dom.DOMException;
  24. import org.w3c.dom.DOMImplementation;
  25. import org.w3c.dom.Document;
  26. import org.w3c.dom.DocumentFragment;
  27. import org.w3c.dom.DocumentType;
  28. import org.w3c.dom.Element;
  29. import org.w3c.dom.EntityReference;
  30. import org.w3c.dom.NamedNodeMap;
  31. import org.w3c.dom.Node;
  32. import org.w3c.dom.NodeList;
  33. import org.w3c.dom.ProcessingInstruction;
  34. import org.w3c.dom.Text;
  35. import webeq3.action.ActionHandler;
  36. import webeq3.action.Message;
  37. import webeq3.action.MessageHandler;
  38. import webeq3.constants.AttributeConstants;
  39. import webeq3.dom.MathMLDOMApplet;
  40. import webeq3.dom.MathMLDOMAttribute;
  41. import webeq3.dom.MathMLDOMNodeList;
  42. import webeq3.dom.MathMLDocument;
  43. import webeq3.fonts.FontBroker;
  44. import webeq3.schema.Box;
  45. import webeq3.schema.ContentBox;
  46. import webeq3.schema.MAction;
  47. import webeq3.schema.MError;
  48. import webeq3.schema.MFenced;
  49. import webeq3.schema.MFrac;
  50. import webeq3.schema.MI;
  51. import webeq3.schema.MMultiscripts;
  52. import webeq3.schema.MN;
  53. import webeq3.schema.MO;
  54. import webeq3.schema.MOver;
  55. import webeq3.schema.MPadded;
  56. import webeq3.schema.MPhantom;
  57. import webeq3.schema.MRoot;
  58. import webeq3.schema.MRow;
  59. import webeq3.schema.MS;
  60. import webeq3.schema.MSpace;
  61. import webeq3.schema.MSqrt;
  62. import webeq3.schema.MStyle;
  63. import webeq3.schema.MSub;
  64. import webeq3.schema.MSubsup;
  65. import webeq3.schema.MSup;
  66. import webeq3.schema.MTable;
  67. import webeq3.schema.MTd;
  68. import webeq3.schema.MText;
  69. import webeq3.schema.MTr;
  70. import webeq3.schema.MUnder;
  71. import webeq3.schema.MUnderover;
  72. import webeq3.util.OutputHandler;
  73.  
  74. public class Equation extends Canvas implements AttributeConstants, MathMLDocument, ClipboardOwner {
  75.    public MathMLDOMApplet applet;
  76.    public Box root = null;
  77.    public ContentBox markupRoot = null;
  78.    protected int[] pts = new int[3];
  79.    public Handler handler;
  80.    // $FF: renamed from: ah webeq3.action.ActionHandler
  81.    public ActionHandler field_0 = new ActionHandler(this);
  82.    // $FF: renamed from: mh webeq3.action.MessageHandler
  83.    public MessageHandler field_1 = new MessageHandler(this);
  84.    // $FF: renamed from: oh webeq3.util.OutputHandler
  85.    public OutputHandler field_2 = null;
  86.    Image my_face = null;
  87.    Graphics my_graphics = null;
  88.    public boolean WizardIsRunning = false;
  89.    public boolean linebreak = false;
  90.    public boolean allow_cut = false;
  91.    public String align = "left";
  92.    public String valign = "baseline";
  93.    public int leftMargin = 2;
  94.    public int padding = 0;
  95.    public boolean fixed_size = false;
  96.    public boolean full_size = false;
  97.    int preferredWidth = 0;
  98.    int preferredHeight = 0;
  99.    public int indent = 0;
  100.    public int offsetx = 0;
  101.    public int offsety = 0;
  102.    public Vector breaks = new Vector();
  103.    public boolean haveSelection = false;
  104.    public boolean cutstart = false;
  105.    public boolean cutend = false;
  106.    public boolean hilight_change = false;
  107.    public Box leftmostSelection = null;
  108.    public Box rightmostSelection = null;
  109.    public int cutstartx = 0;
  110.    public int cutstarty = 0;
  111.    public int cutendx = 0;
  112.    public int cutendy = 0;
  113.    public int canvas_xoff = 0;
  114.    public int canvas_yoff = 0;
  115.    public int rectleft = 0;
  116.    public int rectright = 0;
  117.    public int recttop = 0;
  118.    public int rectbottom = 0;
  119.    public Clipboard system_clipboard = null;
  120.    final int VENDOR_NETSCAPE = 1;
  121.    final int VENDOR_MICROSOFT = 2;
  122.    final int VENDOR_SUN = 3;
  123.    final int VENDOR_OTHER = 0;
  124.    private int vendor;
  125.  
  126.    public Equation() {
  127.    }
  128.  
  129.    public Equation(Handler var1) {
  130.       this.handler = var1;
  131.    }
  132.  
  133.    public void setRoot(Box var1, ContentBox var2) {
  134.       this.root = var1;
  135.       this.markupRoot = var2;
  136.       this.markupRoot.empty = false;
  137.       this.root.cpeer = this.markupRoot;
  138.       this.markupRoot.ppeer = this.root;
  139.       this.resetMessagesAndActions();
  140.    }
  141.  
  142.    public void setHandler(Handler var1) {
  143.       this.handler = var1;
  144.    }
  145.  
  146.    public Handler getHandler() {
  147.       return this.handler;
  148.    }
  149.  
  150.    public void initBG() {
  151.       Color var1 = this.handler.getBackground();
  152.       if (var1 == null) {
  153.          var1 = Color.white;
  154.       }
  155.  
  156.       String var2 = "#" + toHexString(var1.getRed()) + toHexString(var1.getGreen()) + toHexString(var1.getBlue());
  157.       this.root.attribute_stack[17].push(var2);
  158.    }
  159.  
  160.    public void initBG(Color var1) {
  161.       String var2 = "#" + toHexString(var1.getRed()) + toHexString(var1.getGreen()) + toHexString(var1.getBlue());
  162.       this.root.attribute_stack[17].push(var2);
  163.    }
  164.  
  165.    public void initFG() {
  166.       Color var1 = this.handler.getForeground();
  167.       if (var1 == null) {
  168.          var1 = Color.black;
  169.       }
  170.  
  171.       String var2 = "#" + toHexString(var1.getRed()) + toHexString(var1.getGreen()) + toHexString(var1.getBlue());
  172.       this.root.attribute_stack[4].push(var2);
  173.    }
  174.  
  175.    public void initFG(Color var1) {
  176.       String var2 = "#" + toHexString(var1.getRed()) + toHexString(var1.getGreen()) + toHexString(var1.getBlue());
  177.       this.root.attribute_stack[4].push(var2);
  178.    }
  179.  
  180.    public int getVendor() {
  181.       String var1 = System.getProperty("java.vendor").toLowerCase();
  182.       if (var1.indexOf("netscape") != -1) {
  183.          this.vendor = 1;
  184.       } else if (var1.indexOf("sun") != -1) {
  185.          this.vendor = 3;
  186.       } else if (var1.indexOf("microsoft") != -1) {
  187.          this.vendor = 2;
  188.       } else {
  189.          System.out.println("Non netscape, non microsoft java.vendor: " + var1);
  190.          this.vendor = 0;
  191.       }
  192.  
  193.       return this.vendor;
  194.    }
  195.  
  196.    public void lostOwnership(Clipboard var1, Transferable var2) {
  197.       this.system_clipboard = null;
  198.    }
  199.  
  200.    protected boolean haveClipboard() {
  201.       if (this.system_clipboard == null) {
  202.          this.vendor = this.getVendor();
  203.          switch (this.vendor) {
  204.             case 1:
  205.                try {
  206.                   PrivilegeManager.enablePrivilege("UniversalSystemClipboardAccess");
  207.                } catch (Exception var4) {
  208.                   System.out.println("User denied access to systemClipboard.");
  209.                }
  210.                break;
  211.             case 2:
  212.                try {
  213.                   PolicyEngine.assertPermission(PermissionID.UI);
  214.                } catch (Exception var3) {
  215.                }
  216.             case 3:
  217.          }
  218.  
  219.          try {
  220.             this.system_clipboard = ((Component)this).getToolkit().getSystemClipboard();
  221.          } catch (Exception var2) {
  222.             System.out.println("couldn't get system clipboard: " + var2);
  223.          }
  224.       }
  225.  
  226.       return this.system_clipboard != null;
  227.    }
  228.  
  229.    protected void hilight(Box var1) {
  230.       int var2 = var1.getWidth();
  231.       int var3 = var1.getHeight();
  232.       int var4 = var1.abstop;
  233.       int var5 = var4 + var3;
  234.       int var6 = var1.absleft;
  235.       int var7 = var6 + var2;
  236.       if (var7 < this.rectleft || var6 > this.rectright || var4 > this.rectbottom || var5 < this.recttop || this.rectleft > var6 && this.rectright < var7 && this.recttop > var4 && this.rectbottom < var5 && var1.getNumDisplayChildren() != 0) {
  237.          if (var1.getReverseVideo()) {
  238.             var1.setReverseVideo(false);
  239.             this.hilight_change = true;
  240.          }
  241.  
  242.          for(int var14 = 0; var14 < var1.getNumDisplayChildren(); ++var14) {
  243.             this.hilight(var1.getDisplayChild(var14));
  244.          }
  245.  
  246.          int var9 = 0;
  247.          if (var1 instanceof MTable) {
  248.             int var10 = 0;
  249.  
  250.             for(int var12 = 0; var12 < var1.getNumChildren(); ++var12) {
  251.                Box var11 = var1.getChild(var12);
  252.                var10 += var11.getNumChildren();
  253.                var11.setReverseVideo(false);
  254.  
  255.                for(int var13 = 0; var13 < var11.getNumChildren(); ++var13) {
  256.                   if (var11.getChild(var13).getReverseVideo()) {
  257.                      ++var9;
  258.                   }
  259.                }
  260.             }
  261.  
  262.             if (var9 == var10 && var9 > 0) {
  263.                this.highLightChildren(var1);
  264.                var1.setReverseVideo(true);
  265.                this.hilight_change = true;
  266.                if (this.leftmostSelection == null || var6 <= this.leftmostSelection.absleft) {
  267.                   this.leftmostSelection = var1;
  268.                }
  269.  
  270.                if (this.rightmostSelection == null || var7 >= this.rightmostSelection.absleft + this.rightmostSelection.getWidth()) {
  271.                   this.rightmostSelection = var1;
  272.                }
  273.             }
  274.          } else {
  275.             int var15 = -1;
  276.             boolean var16 = false;
  277.  
  278.             for(int var17 = 0; var17 < var1.getNumChildren(); ++var17) {
  279.                if (!var1.getChild(var17).getReverseVideo()) {
  280.                   if (var15 >= 0) {
  281.                      var16 = true;
  282.                   }
  283.                } else {
  284.                   if (var16 && var1 instanceof MStyle) {
  285.                      for(int var18 = var15 + 1; var18 < var17; ++var18) {
  286.                         var1.getChild(var18).setReverseVideo(true);
  287.                         this.highLightChildren(var1.getChild(var18));
  288.                      }
  289.  
  290.                      var16 = false;
  291.                   }
  292.  
  293.                   var15 = var17;
  294.                   ++var9;
  295.                }
  296.             }
  297.  
  298.             if (var9 == var1.children.size() && var9 > 0 && !(var1 instanceof MTr)) {
  299.                this.highLightChildren(var1);
  300.                var1.setReverseVideo(true);
  301.                this.hilight_change = true;
  302.                if (this.leftmostSelection == null || var6 <= this.leftmostSelection.absleft) {
  303.                   this.leftmostSelection = var1;
  304.                }
  305.  
  306.                if (this.rightmostSelection == null || var7 >= this.rightmostSelection.absleft + this.rightmostSelection.getWidth()) {
  307.                   this.rightmostSelection = var1;
  308.                }
  309.             } else {
  310.                String var19 = var1.getClass().getName();
  311.                if (var9 == var1.children.size() - 1 && (var19.equals("webeq3.schema.MSub") || var19.equals("webeq3.schema.MSup") || var19.equals("webeq3.schema.MUnder") || var19.equals("webeq3.schema.MOver") || var19.equals("webeq3.schema.MSqrt"))) {
  312.                   var1.setReverseVideo(true);
  313.                   this.hilight_change = true;
  314.                   if (this.leftmostSelection == null || var6 <= this.leftmostSelection.absleft) {
  315.                      this.leftmostSelection = var1;
  316.                   }
  317.  
  318.                   if (this.rightmostSelection == null || var7 >= this.rightmostSelection.absleft + this.rightmostSelection.getWidth()) {
  319.                      this.rightmostSelection = var1;
  320.                   }
  321.                }
  322.             }
  323.          }
  324.  
  325.       } else {
  326.          if (var1 instanceof MTr) {
  327.             for(int var8 = 0; var8 < var1.getNumDisplayChildren(); ++var8) {
  328.                this.hilight(var1.getDisplayChild(var8));
  329.             }
  330.          } else if (!var1.getReverseVideo()) {
  331.             var1.setReverseVideo(true);
  332.             this.hilight_change = true;
  333.             this.highLightChildren(var1);
  334.          }
  335.  
  336.          if (var1.getReverseVideo()) {
  337.             this.haveSelection = true;
  338.             if (this.leftmostSelection == null || var6 < this.leftmostSelection.absleft) {
  339.                this.leftmostSelection = var1;
  340.             }
  341.  
  342.             if (this.rightmostSelection == null || var7 > this.rightmostSelection.absleft + this.rightmostSelection.getWidth()) {
  343.                this.rightmostSelection = var1;
  344.             }
  345.          }
  346.  
  347.       }
  348.    }
  349.  
  350.    protected void highLightChildren(Box var1) {
  351.       Object var2 = null;
  352.  
  353.       for(int var3 = 0; var3 < var1.getNumDisplayChildren(); ++var3) {
  354.          Box var4 = var1.getDisplayChild(var3);
  355.          var4.setReverseVideo(true);
  356.          this.highLightChildren(var4);
  357.       }
  358.  
  359.    }
  360.  
  361.    public int[] normalVirtualCoords(int var1, int var2) {
  362.       var1 -= this.canvas_xoff + this.padding;
  363.       var2 -= this.canvas_yoff + this.padding;
  364.       if (!MStyle.allowForcedBreaks && !this.linebreak) {
  365.          var1 -= this.offsetx;
  366.          var2 -= this.offsety;
  367.       } else {
  368.          int var3 = 5 + this.root.getHeight();
  369.          int var4 = var2 / var3;
  370.          var2 -= var4 * var3;
  371.          Integer var5 = null;
  372.          if (var4 > 0 && var4 <= this.breaks.size()) {
  373.             var5 = (Integer)this.breaks.elementAt(var4 - 1);
  374.          }
  375.  
  376.          if (var5 == null) {
  377.             var5 = new Integer(0);
  378.          }
  379.  
  380.          Integer var6 = null;
  381.          if (var4 >= 0 && var4 < this.breaks.size()) {
  382.             var6 = (Integer)this.breaks.elementAt(var4);
  383.          }
  384.  
  385.          if (var6 == null) {
  386.             var6 = new Integer(this.root.getWidth());
  387.          }
  388.  
  389.          if (var1 > Math.abs(var6) - Math.abs(var5)) {
  390.             if (var6 < 0) {
  391.                var1 = -var6 - 1;
  392.             } else {
  393.                var1 = var6 - this.indent - 1;
  394.             }
  395.          } else if (var4 > 0) {
  396.             if (var4 <= this.breaks.size()) {
  397.                if (var5 < 0) {
  398.                   var1 -= var5;
  399.                } else {
  400.                   var1 += var5 - this.indent;
  401.                }
  402.             } else {
  403.                var1 += this.root.getWidth();
  404.             }
  405.          }
  406.       }
  407.  
  408.       int[] var10 = new int[]{var1, var2};
  409.       return var10;
  410.    }
  411.  
  412.    public void directRedraw() {
  413.       this.redraw();
  414.    }
  415.  
  416.    public void paint(Graphics var1) {
  417.       if (this.my_face != null) {
  418.          this.checkCanvasOffsets();
  419.          var1.drawImage(this.my_face, this.canvas_xoff + this.padding, this.canvas_yoff + this.padding, this.handler.getImageObserver());
  420.       }
  421.  
  422.       this.postPaint(var1);
  423.       if (this.field_1.hasMessages()) {
  424.          this.field_1.startIfNecessary();
  425.       }
  426.  
  427.    }
  428.  
  429.    public void redraw() {
  430.       try {
  431.          this.root.layout();
  432.       } catch (Exception var4) {
  433.          System.out.println("layout errors -- rendering failed\n" + var4);
  434.          ((Throwable)var4).printStackTrace();
  435.       }
  436.  
  437.       if (((Component)this).getParent() instanceof ScrollPane) {
  438.          ((Component)this).getParent().doLayout();
  439.       }
  440.  
  441.       this.verifyFaceSize();
  442.       this.my_graphics = this.my_face.getGraphics();
  443.       this.my_graphics.setColor(this.root.resolveColor(17));
  444.       this.my_graphics.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
  445.       this.my_graphics.setColor(Color.black);
  446.       this.offsetx = 0;
  447.       this.offsety = 0;
  448.       this.breaks.removeAllElements();
  449.  
  450.       try {
  451.          this.root.paint(this.my_graphics, 0, 0);
  452.       } catch (Exception var3) {
  453.          ((Throwable)var3).printStackTrace();
  454.       }
  455.  
  456.       if ((!this.align.equals("left") || !this.valign.equals("top")) && !this.breaks.isEmpty() && this.adjustBrokenFaceSize()) {
  457.          this.my_graphics = this.my_face.getGraphics();
  458.          this.my_graphics.setColor(this.root.resolveColor(17));
  459.          this.my_graphics.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
  460.          this.my_graphics.setColor(Color.black);
  461.          this.offsetx = 0;
  462.          this.offsety = 0;
  463.          this.breaks.removeAllElements();
  464.  
  465.          try {
  466.             this.root.paint(this.my_graphics, 0, 0);
  467.          } catch (Exception var2) {
  468.             ((Throwable)var2).printStackTrace();
  469.          }
  470.       }
  471.  
  472.       this.my_graphics.dispose();
  473.    }
  474.  
  475.    private void checkCanvasOffsets() {
  476.       if (this.align.equals("center")) {
  477.          this.canvas_xoff = (((Component)this).size().width - 2 * this.padding - this.my_face.getWidth(this.handler.getComponent())) / 2;
  478.       } else if (this.align.equals("right")) {
  479.          this.canvas_xoff = ((Component)this).size().width - this.padding - this.my_face.getWidth(this.handler.getComponent());
  480.       } else {
  481.          this.canvas_xoff = this.leftMargin;
  482.       }
  483.  
  484.       if (this.valign.equals("baseline")) {
  485.          this.canvas_yoff = ((Component)this).size().height / 2 - this.root.getAscent();
  486.       } else if (this.valign.equals("edit")) {
  487.          int var1 = (int)((double)1.5F * (double)this.pts[0]);
  488.          if (var1 < 17) {
  489.             var1 = 17;
  490.          }
  491.  
  492.          if (var1 > 55) {
  493.             var1 = 55;
  494.          }
  495.  
  496.          this.canvas_yoff = var1 > this.root.getAscent() ? var1 - this.root.getAscent() + 5 : 5;
  497.       } else if (this.valign.equals("center")) {
  498.          this.canvas_yoff = (((Component)this).size().height - 2 * this.padding - this.my_face.getHeight(this.handler.getComponent())) / 2;
  499.       } else if (this.valign.equals("top")) {
  500.          this.canvas_yoff = 0;
  501.       } else {
  502.          int var4;
  503.          try {
  504.             var4 = Integer.parseInt(this.valign);
  505.          } catch (NumberFormatException var3) {
  506.             var4 = 0;
  507.          }
  508.  
  509.          this.canvas_yoff = var4;
  510.       }
  511.  
  512.    }
  513.  
  514.    private void verifyFaceSize() {
  515.       int var1 = 0;
  516.       int var2 = 0;
  517.  
  518.       try {
  519.          if (this.fixed_size) {
  520.             var1 = this.preferredWidth;
  521.             var2 = this.preferredHeight;
  522.             var1 -= 2 * this.padding;
  523.             var2 -= 2 * this.padding;
  524.             ((Component)this).setSize(this.preferredWidth, this.preferredHeight);
  525.          } else if (((Component)this).getParent() instanceof ScrollPane) {
  526.             var1 = this.getPreferredWidth();
  527.             var2 = this.getPreferredHeight();
  528.          } else if (this.full_size) {
  529.             var1 = this.handler.size().width;
  530.             var2 = this.handler.size().height;
  531.          } else if (this.linebreak && this.root.getWidth() > this.getSize().width) {
  532.             var1 = this.getSize().width - 2 * this.padding;
  533.             var2 = this.getSize().height - 2 * this.padding;
  534.          } else {
  535.             var1 = this.root.getWidth();
  536.             var2 = this.root.getHeight();
  537.          }
  538.  
  539.          ++var1;
  540.          ++var2;
  541.          if (var1 <= 0) {
  542.             var1 = 1;
  543.          }
  544.  
  545.          if (var2 <= 0) {
  546.             var2 = 1;
  547.          }
  548.  
  549.          if (this.my_face == null || this.my_face.getWidth(this.handler.getComponent()) != var1 || this.my_face.getHeight(this.handler.getComponent()) != var2) {
  550.             this.my_face = this.handler.getComponent().createImage(var1, var2);
  551.          }
  552.       } catch (Exception var4) {
  553.          System.out.println("caught exception " + var4);
  554.          ((Throwable)var4).printStackTrace();
  555.       }
  556.  
  557.    }
  558.  
  559.    private boolean adjustBrokenFaceSize() {
  560.       int var1 = 0;
  561.       int var2 = 0;
  562.  
  563.       try {
  564.          if (this.fixed_size) {
  565.             return false;
  566.          } else if (((Component)this).getParent() instanceof ScrollPane) {
  567.             return false;
  568.          } else if (this.full_size) {
  569.             return false;
  570.          } else {
  571.             var2 = 5 + this.root.getHeight();
  572.             int var3 = 0;
  573.             Object var4 = null;
  574.             int var5 = 0;
  575.  
  576.             for(int var6 = 0; var3 < this.breaks.size(); ++var3) {
  577.                Integer var11 = (Integer)this.breaks.elementAt(var3);
  578.                if (var11 < 0) {
  579.                   var5 = -var11;
  580.                } else {
  581.                   var5 = var11;
  582.                }
  583.  
  584.                if (var5 - var6 > var1) {
  585.                   var1 = var5 - var6;
  586.                }
  587.  
  588.                var2 += 5 + this.root.getHeight();
  589.                var6 = var5;
  590.             }
  591.  
  592.             ++var1;
  593.             ++var2;
  594.             if (var1 <= 0) {
  595.                var1 = 1;
  596.             }
  597.  
  598.             if (var2 <= 0) {
  599.                var2 = 1;
  600.             }
  601.  
  602.             if (this.my_face == null || this.my_face.getWidth(this.handler.getComponent()) != var1 || this.my_face.getHeight(this.handler.getComponent()) != var2) {
  603.                this.my_face = this.handler.getComponent().createImage(var1, var2);
  604.             }
  605.  
  606.             return true;
  607.          }
  608.       } catch (Exception var7) {
  609.          System.out.println("caught exception " + var7);
  610.          ((Throwable)var7).printStackTrace();
  611.          return false;
  612.       }
  613.    }
  614.  
  615.    public void postPaint(Graphics var1) {
  616.    }
  617.  
  618.    public Image getFace() {
  619.       return this.my_face;
  620.    }
  621.  
  622.    public void registerActions() {
  623.       this.recursiveRegActions(this.root);
  624.    }
  625.  
  626.    private void recursiveRegActions(Box var1) {
  627.       int var2 = var1.children.size();
  628.       if (var1.getClass().getName().equals("webeq3.schema.MAction")) {
  629.          this.field_0.registerAction((MAction)var1);
  630.       }
  631.  
  632.       for(int var3 = 0; var3 < var2; ++var3) {
  633.          this.recursiveRegActions(var1.getChild(var3));
  634.       }
  635.  
  636.    }
  637.  
  638.    public void registerMessage(Message var1) {
  639.       if (this.field_1 != null) {
  640.          this.field_1.registerMessage(var1);
  641.       } else {
  642.          this.field_1 = new MessageHandler(this);
  643.          this.field_1.registerMessage(var1);
  644.       }
  645.  
  646.    }
  647.  
  648.    public void resetMessagesAndActions() {
  649.       if (this.field_1 != null) {
  650.          this.field_1.stop();
  651.          this.field_1 = new MessageHandler(this);
  652.       } else {
  653.          this.field_1 = new MessageHandler(this);
  654.       }
  655.  
  656.       if (this.field_0 != null) {
  657.          this.field_0.reset();
  658.       } else {
  659.          this.field_0 = new ActionHandler(this);
  660.       }
  661.  
  662.    }
  663.  
  664.    public void setAlign(String var1) {
  665.       this.align = var1;
  666.    }
  667.  
  668.    public void setVAlign(String var1) {
  669.       this.valign = var1;
  670.    }
  671.  
  672.    public void setLeftMargin(int var1) {
  673.       this.leftMargin = var1;
  674.    }
  675.  
  676.    public void setPadding(int var1) {
  677.       this.padding = var1;
  678.    }
  679.  
  680.    public void setPointSize(int var1) {
  681.       FontBroker.setPointSizes(var1, this.pts, this.handler.getComponent());
  682.       Font var2 = new Font("TimesRoman", 0, this.pts[0]);
  683.       FontMetrics var3 = this.getHandler().getComponent().getFontMetrics(var2);
  684.       this.indent = (int)(1.3 * (double)var3.charWidth('M'));
  685.    }
  686.  
  687.    public void getPointsize(int var1, int[] var2) {
  688.       FontBroker.findPointSizes(var1, var2, this.handler.getComponent());
  689.    }
  690.  
  691.    public void fixSize(int var1, int var2) {
  692.       this.fixed_size = true;
  693.       this.setPreferredSize(var1, var2);
  694.    }
  695.  
  696.    public void fullSize() {
  697.       this.full_size = true;
  698.    }
  699.  
  700.    public void setPreferredSize(int var1, int var2) {
  701.       this.preferredWidth = var1;
  702.       this.preferredHeight = var2;
  703.    }
  704.  
  705.    public int getDisplayWidth() {
  706.       return ((Component)this).size().width - 2 * this.padding;
  707.    }
  708.  
  709.    public Dimension getPreferredSize() {
  710.       return this.getMinimumSize();
  711.    }
  712.  
  713.    public Dimension getMinimumSize() {
  714.       return this.fixed_size ? new Dimension(this.preferredWidth, this.preferredHeight) : new Dimension(this.getPreferredWidth(), this.getPreferredHeight());
  715.    }
  716.  
  717.    public int getPreferredAscent() {
  718.       if (this.valign.equals("baseline")) {
  719.          int var1 = this.root.getAscent() > this.root.getDescent() ? this.root.getAscent() : this.root.getDescent();
  720.          return (int)((double)1.0F * (double)var1) + this.padding + 1;
  721.       } else {
  722.          return this.root.getAscent() + this.padding + 1;
  723.       }
  724.    }
  725.  
  726.    public int getPreferredHeight() {
  727.       if (this.valign.equals("baseline")) {
  728.          int var3 = this.root.getAscent() > this.root.getDescent() ? this.root.getAscent() : this.root.getDescent();
  729.          return (int)((double)2.0F * (double)var3) + 2 * this.padding + 1;
  730.       } else if (((Component)this).getParent() instanceof ScrollPane) {
  731.          int var1 = this.root.getHeight();
  732.          var1 = (var1 + 5) * (this.breaks.size() + 1);
  733.          return var1 + 2 * this.padding + 1 + this.canvas_yoff;
  734.       } else {
  735.          return this.root.getHeight() + 2 * this.padding + 1;
  736.       }
  737.    }
  738.  
  739.    public int getPreferredWidth() {
  740.       if (((Component)this).getParent() instanceof ScrollPane) {
  741.          int var1 = 0;
  742.          int var2 = 0;
  743.          int var3 = 0;
  744.          Object var4 = null;
  745.  
  746.          for(Enumeration var5 = this.breaks.elements(); var5.hasMoreElements(); var1 = var2) {
  747.             Integer var7 = (Integer)var5.nextElement();
  748.             var2 = Math.abs(var7);
  749.             if (var2 - var1 > var3) {
  750.                var3 = var2 - var1;
  751.             }
  752.          }
  753.  
  754.          if (this.root.getWidth() - var1 > var3) {
  755.             var3 = this.root.getWidth() - var1;
  756.          }
  757.  
  758.          return var3 + 2 * this.padding + 1 + 2 * this.leftMargin;
  759.       } else {
  760.          return this.root.getWidth() + 2 * this.padding + 1;
  761.       }
  762.    }
  763.  
  764.    public Dimension getSize() {
  765.       return ((Component)this).size();
  766.    }
  767.  
  768.    public int standardPointsize(int var1) {
  769.       if (var1 < 0) {
  770.          var1 = 0;
  771.       }
  772.  
  773.       if (var1 > 2) {
  774.          var1 = 2;
  775.       }
  776.  
  777.       return this.pts[var1];
  778.    }
  779.  
  780.    private static String toHexString(int var0) {
  781.       String[] var1 = new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};
  782.       if (var0 > 255) {
  783.          var0 = 255;
  784.       }
  785.  
  786.       if (var0 < 0) {
  787.          var0 = 0;
  788.       }
  789.  
  790.       int var2 = var0 / 16;
  791.       int var3 = var0 - var2 * 16;
  792.       return var1[var2] + var1[var3];
  793.    }
  794.  
  795.    public Node appendChild(Node var1) throws DOMException {
  796.       if (var1 != null && var1.getClass().getName().equals("webeq3.schema.Box")) {
  797.          this.setRoot((Box)var1, new ContentBox(this));
  798.          this.initBG(Color.white);
  799.          this.initFG();
  800.          this.redraw();
  801.          this.applet.repaint();
  802.          return var1;
  803.       } else {
  804.          throw new DOMException((short)3, "The child must not be null and must be a Box node");
  805.       }
  806.    }
  807.  
  808.    public Node cloneNode(boolean var1) {
  809.       return null;
  810.    }
  811.  
  812.    public Attr createAttribute(String var1) throws DOMException {
  813.       int var2 = this.lookupIndex(var1);
  814.       MathMLDOMAttribute var3 = new MathMLDOMAttribute(this, var1, var2);
  815.       return var3;
  816.    }
  817.  
  818.    public Attr createAttributeNS(String var1, String var2) throws DOMException {
  819.       return null;
  820.    }
  821.  
  822.    public Comment createComment(String var1) {
  823.       return null;
  824.    }
  825.  
  826.    public CDATASection createCDATASection(String var1) throws DOMException {
  827.       return null;
  828.    }
  829.  
  830.    public DocumentFragment createDocumentFragment() {
  831.       return null;
  832.    }
  833.  
  834.    public Element createElement(String var1) throws DOMException {
  835.       Object var2 = null;
  836.       var1.toLowerCase();
  837.       if (var1.equals("math")) {
  838.          var2 = new Box(this);
  839.       } else if (var1.equals("mrow")) {
  840.          var2 = new MRow();
  841.       } else if (var1.equals("mi")) {
  842.          var2 = new MI(this);
  843.       } else if (var1.equals("mn")) {
  844.          var2 = new MN(this);
  845.       } else if (var1.equals("mo")) {
  846.          var2 = new MO(this);
  847.       } else if (var1.equals("maction")) {
  848.          var2 = new MAction(this);
  849.       } else if (var1.equals("merror")) {
  850.          var2 = new MError(this);
  851.       } else if (var1.equals("mfenced")) {
  852.          var2 = new MFenced(this);
  853.       } else if (var1.equals("mfract")) {
  854.          var2 = new MFrac(this);
  855.       } else if (var1.equals("mmultiscripts")) {
  856.          var2 = new MMultiscripts(this);
  857.       } else if (var1.equals("mover")) {
  858.          var2 = new MOver(this);
  859.       } else if (var1.equals("mpadded")) {
  860.          var2 = new MPadded(this);
  861.       } else if (var1.equals("mphantom")) {
  862.          var2 = new MPhantom(this);
  863.       } else if (var1.equals("mroot")) {
  864.          var2 = new MRoot(this);
  865.       } else if (var1.equals("ms")) {
  866.          var2 = new MS(this);
  867.       } else if (var1.equals("mspace")) {
  868.          var2 = new MSpace(this);
  869.       } else if (var1.equals("msqrt")) {
  870.          var2 = new MSqrt(this);
  871.       } else if (var1.equals("mstyle")) {
  872.          var2 = new MStyle(this);
  873.       } else if (var1.equals("msub")) {
  874.          var2 = new MSub(this);
  875.       } else if (var1.equals("msubsup")) {
  876.          var2 = new MSubsup(this);
  877.       } else if (var1.equals("msup")) {
  878.          var2 = new MSup(this);
  879.       } else if (var1.equals("mtable")) {
  880.          var2 = new MTable(this);
  881.       } else if (var1.equals("mtd")) {
  882.          var2 = new MTd(this);
  883.       } else if (var1.equals("mtext")) {
  884.          var2 = new MText(this);
  885.       } else if (var1.equals("mtr")) {
  886.          var2 = new MTr(this);
  887.       } else if (var1.equals("munder")) {
  888.          var2 = new MUnder(this);
  889.       } else {
  890.          if (!var1.equals("munderover")) {
  891.             throw new DOMException((short)9, "Unknown MathML tag");
  892.          }
  893.  
  894.          var2 = new MUnderover(this);
  895.       }
  896.  
  897.       return (Element)var2;
  898.    }
  899.  
  900.    public Element createElementNS(String var1, String var2) throws DOMException {
  901.       return null;
  902.    }
  903.  
  904.    public EntityReference createEntityReference(String var1) throws DOMException {
  905.       return null;
  906.    }
  907.  
  908.    public ProcessingInstruction createProcessingInstruction(String var1, String var2) throws DOMException {
  909.       return null;
  910.    }
  911.  
  912.    public Text createTextNode(String var1) {
  913.       return null;
  914.    }
  915.  
  916.    public NamedNodeMap getAttributes() {
  917.       return null;
  918.    }
  919.  
  920.    public NodeList getChildNodes() {
  921.       MathMLDOMNodeList var1 = new MathMLDOMNodeList();
  922.       var1.addNode(this.root);
  923.       return var1;
  924.    }
  925.  
  926.    public DocumentType getDoctype() {
  927.       return null;
  928.    }
  929.  
  930.    public Element getDocumentElement() {
  931.       return this.root;
  932.    }
  933.  
  934.    public Element getElementById(String var1) {
  935.       return null;
  936.    }
  937.  
  938.    public NodeList getElementsByTagName(String var1) {
  939.       return this.root.getElementsByTagName(var1);
  940.    }
  941.  
  942.    public NodeList getElementsByTagNameNS(String var1, String var2) {
  943.       return null;
  944.    }
  945.  
  946.    public Node getFirstChild() {
  947.       return this.root;
  948.    }
  949.  
  950.    public DOMImplementation getImplementation() {
  951.       return null;
  952.    }
  953.  
  954.    public Node getLastChild() {
  955.       return this.root;
  956.    }
  957.  
  958.    public String getLocalName() {
  959.       return this.getNodeName();
  960.    }
  961.  
  962.    public String getNamespaceURI() {
  963.       return null;
  964.    }
  965.  
  966.    public Node getNextSibling() {
  967.       return null;
  968.    }
  969.  
  970.    public String getNodeName() {
  971.       return "#document";
  972.    }
  973.  
  974.    public short getNodeType() {
  975.       return 9;
  976.    }
  977.  
  978.    public String getNodeValue() throws DOMException {
  979.       return null;
  980.    }
  981.  
  982.    public void setNodeValue(String var1) throws DOMException {
  983.       throw new DOMException((short)9, "Document doesn't have a value property");
  984.    }
  985.  
  986.    public Document getOwnerDocument() {
  987.       return null;
  988.    }
  989.  
  990.    public Node getParentNode() {
  991.       return null;
  992.    }
  993.  
  994.    public String getPrefix() {
  995.       return null;
  996.    }
  997.  
  998.    public void setPrefix(String var1) throws DOMException {
  999.    }
  1000.  
  1001.    public Node getPreviousSibling() {
  1002.       return null;
  1003.    }
  1004.  
  1005.    public boolean hasChildNodes() {
  1006.       return this.root != null;
  1007.    }
  1008.  
  1009.    public Node importNode(Node var1, boolean var2) throws DOMException {
  1010.       return null;
  1011.    }
  1012.  
  1013.    public Node insertBefore(Node var1, Node var2) throws DOMException {
  1014.       throw new DOMException((short)3, "Cannot insert an additional node into the document");
  1015.    }
  1016.  
  1017.    public void normalize() {
  1018.    }
  1019.  
  1020.    public Node replaceChild(Node var1, Node var2) throws DOMException {
  1021.       if (var2 == this.root && var1.getClass().getName().equals("webeq3.schema.Box")) {
  1022.          this.setRoot((Box)var1, new ContentBox(this));
  1023.          this.initBG(Color.white);
  1024.          this.initFG();
  1025.          this.redraw();
  1026.          this.applet.repaint();
  1027.          return var1;
  1028.       } else {
  1029.          throw new DOMException((short)3, "Can only replace the root node and the replacement node must be a box");
  1030.       }
  1031.    }
  1032.  
  1033.    public Node removeChild(Node var1) throws DOMException {
  1034.       throw new DOMException((short)3, "Can't remove the root node");
  1035.    }
  1036.  
  1037.    public boolean supports(String var1, String var2) {
  1038.       return false;
  1039.    }
  1040.  
  1041.    public int lookupIndex(String var1) {
  1042.       boolean var2 = false;
  1043.  
  1044.       for(int var3 = 0; var3 < 86 && !var2; ++var3) {
  1045.          if (var1.equals(AttributeConstants.attribute_names[var3])) {
  1046.             var2 = true;
  1047.             return var3;
  1048.          }
  1049.       }
  1050.  
  1051.       return -1;
  1052.    }
  1053.  
  1054.    public boolean attributeInUse(MathMLDOMAttribute var1) {
  1055.       return this.findAttribute(this.root, var1);
  1056.    }
  1057.  
  1058.    private boolean findAttribute(Box var1, MathMLDOMAttribute var2) {
  1059.       MathMLDOMAttribute var3 = (MathMLDOMAttribute)var1.attribute_map.getNamedItem(var2.getName());
  1060.       if (var3 != null && var3 == var2) {
  1061.          return true;
  1062.       } else {
  1063.          for(int var4 = 0; var4 < var1.getNumChildren(); ++var4) {
  1064.             Box var5 = var1.getChild(var4);
  1065.             if (this.findAttribute(var5, var2)) {
  1066.                return true;
  1067.             }
  1068.          }
  1069.  
  1070.          return false;
  1071.       }
  1072.    }
  1073. }
  1074.