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

  1. package webeq3.app;
  2.  
  3. import java.awt.Choice;
  4. import java.awt.Component;
  5. import java.awt.Container;
  6. import java.awt.Event;
  7. import java.awt.FlowLayout;
  8. import java.awt.Font;
  9. import java.awt.Frame;
  10. import java.awt.Label;
  11. import java.awt.Panel;
  12. import java.util.Enumeration;
  13. import java.util.Hashtable;
  14.  
  15. public class Controls extends Frame {
  16.    static Controls controls;
  17.    Hashtable equations = new Hashtable();
  18.    Panel sizes = new Panel();
  19.    Label copyright = new Label("WebEQ -- Copyright (c) 1998");
  20.    Label copyright2 = new Label("Geometry Technologies, Inc.               ");
  21.    Label point_size_label = new Label("   Point sizes: ");
  22.    Choice pointsize = new Choice();
  23.    int current_size = 0;
  24.    int[] realsizes = new int[11];
  25.    int numfonts = 0;
  26.  
  27.    public Controls() {
  28.       int[] var1 = new int[]{72, 48, 36, 30, 24, 18, 16, 14, 12, 10, 8};
  29.  
  30.       for(int var4 = 0; var4 < 11; ++var4) {
  31.          Font var2 = new Font("TimesRoman", 0, var1[var4]);
  32.          Font var3 = new Font("TimesRoman", 2, var1[var4]);
  33.          if (var2 != null && var3 != null) {
  34.             this.pointsize.addItem(String.valueOf(var1[var4]));
  35.             this.realsizes[this.numfonts] = var1[var4];
  36.             ++this.numfonts;
  37.          }
  38.       }
  39.  
  40.       try {
  41.          this.pointsize.select(0);
  42.       } catch (Exception var6) {
  43.       }
  44.  
  45.       ((Container)this).setLayout(new FlowLayout(0, 5, 5));
  46.       ((Container)this).add("copyright;side=nw", this.copyright);
  47.       ((Container)this).add("copyright;side=nw", this.copyright2);
  48.       ((Container)this).add("pointsizelabel;side=s", this.point_size_label);
  49.       ((Container)this).add("pointsize;side=s", this.pointsize);
  50.       ((Frame)this).setTitle("WebEQ Controls");
  51.       ((Component)this).resize(300, 180);
  52.       ((Component)this).repaint();
  53.    }
  54.  
  55.    public static synchronized Controls getControls() {
  56.       if (controls == null) {
  57.          controls = new Controls();
  58.       }
  59.  
  60.       return controls;
  61.    }
  62.  
  63.    public boolean handleEvent(Event var1) {
  64.       if (controls == null) {
  65.          return false;
  66.       } else if (var1.target == this.pointsize && var1.id == 1001) {
  67.          this.current_size = Integer.valueOf(this.pointsize.getSelectedItem());
  68.          Enumeration var2 = this.equations.elements();
  69.  
  70.          while(var2.hasMoreElements()) {
  71.             PEquation var3 = (PEquation)var2.nextElement();
  72.             ((Equation)var3).setPointSize(this.current_size);
  73.             ((Equation)var3).redraw();
  74.             ((Equation)var3).getHandler().repaint();
  75.          }
  76.  
  77.          return true;
  78.       } else if (var1.id == 201) {
  79.          controls.hide();
  80.          return true;
  81.       } else {
  82.          return false;
  83.       }
  84.    }
  85.  
  86.    public synchronized void registerEquation(PEquation var1, int var2) {
  87.       if (this.current_size == 0) {
  88.          this.reset(var2);
  89.       }
  90.  
  91.       this.equations.put(var1, var1);
  92.       if (var2 != this.current_size) {
  93.          ((Equation)var1).setPointSize(this.current_size);
  94.          ((Equation)var1).redraw();
  95.          ((Equation)var1).getHandler().repaint();
  96.       }
  97.  
  98.    }
  99.  
  100.    public void reset(int var1) {
  101.       if (this.current_size != var1) {
  102.          for(int var2 = 0; var2 < this.numfonts; ++var2) {
  103.             if (var1 >= this.realsizes[var2]) {
  104.                this.current_size = this.realsizes[var2];
  105.  
  106.                try {
  107.                   this.pointsize.select(var2);
  108.                } catch (Exception var4) {
  109.                }
  110.                break;
  111.             }
  112.          }
  113.       }
  114.  
  115.    }
  116.  
  117.    public synchronized void setAllSizes(int var1) {
  118.       Enumeration var2 = this.equations.elements();
  119.  
  120.       while(var2.hasMoreElements()) {
  121.          PEquation var3 = (PEquation)var2.nextElement();
  122.          ((Equation)var3).setPointSize(var1);
  123.          ((Equation)var3).redraw();
  124.          ((Equation)var3).getHandler().repaint();
  125.       }
  126.  
  127.    }
  128.  
  129.    public synchronized void unregisterEquation(PEquation var1) {
  130.       this.equations.remove(var1);
  131.    }
  132. }
  133.