home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1996 October / PCO_10.ISO / filesbbs / clearweb.arj / CVIEW.CMP / APPLET.ZIP / OutlineCanvas.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-08-15  |  2.1 KB  |  61 lines

  1. import java.awt.Canvas;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Event;
  5. import java.awt.Font;
  6. import java.awt.FontMetrics;
  7. import java.awt.Graphics;
  8.  
  9. class OutlineCanvas extends Canvas {
  10.    Outline Owner;
  11.    boolean FontSet;
  12.    String FontName;
  13.    int FontSize;
  14.    Font TextFont;
  15.    FontMetrics TextFontMetrics;
  16.    Color backColor;
  17.    Color foreColor;
  18.    Color foreScColor;
  19.    Color foreSelColor;
  20.    Color backSelColor;
  21.  
  22.    public OutlineCanvas(Outline owner) {
  23.       this.Owner = owner;
  24.       this.FontSet = false;
  25.    }
  26.  
  27.    public void paint(Graphics g) {
  28.       super.paint(g);
  29.       this.selectColorsFonts(g);
  30.       this.Owner.drawOutline(g);
  31.    }
  32.  
  33.    void SetFonts(Graphics g) {
  34.       if (!this.FontSet) {
  35.          this.TextFont = new Font(this.FontName, 0, this.FontSize);
  36.          this.TextFontMetrics = g.getFontMetrics(this.TextFont);
  37.          this.FontSet = true;
  38.          this.Owner.NodeHeight = this.TextFontMetrics.getHeight();
  39.          if (this.Owner.NodeHeight % 4 != 0) {
  40.             Outline var10000 = this.Owner;
  41.             var10000.NodeHeight += 4 - this.Owner.NodeHeight % 4;
  42.          }
  43.  
  44.          this.Owner.NodesInCanvas = ((Component)this).bounds().height / this.Owner.NodeHeight;
  45.          this.Owner.adjustScrolling();
  46.       }
  47.    }
  48.  
  49.    public void selectColorsFonts(Graphics g) {
  50.       this.SetFonts(g);
  51.       g.setFont(this.TextFont);
  52.       g.setColor(this.foreColor);
  53.       g.translate(-(this.Owner.HorzShift * this.Owner.NodeHeight), 0);
  54.    }
  55.  
  56.    public boolean mouseDown(Event evt, int x, int y) {
  57.       this.Owner.outlineClick(x, y, evt.clickCount);
  58.       return super.mouseDown(evt, x, y);
  59.    }
  60. }
  61.