home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Canvas;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
-
- class OutlineCanvas extends Canvas {
- Outline Owner;
- boolean FontSet;
- String FontName;
- int FontSize;
- Font TextFont;
- FontMetrics TextFontMetrics;
- Color backColor;
- Color foreColor;
- Color foreScColor;
- Color foreSelColor;
- Color backSelColor;
-
- public OutlineCanvas(Outline owner) {
- this.Owner = owner;
- this.FontSet = false;
- }
-
- public void paint(Graphics g) {
- super.paint(g);
- this.selectColorsFonts(g);
- this.Owner.drawOutline(g);
- }
-
- void SetFonts(Graphics g) {
- if (!this.FontSet) {
- this.TextFont = new Font(this.FontName, 0, this.FontSize);
- this.TextFontMetrics = g.getFontMetrics(this.TextFont);
- this.FontSet = true;
- this.Owner.NodeHeight = this.TextFontMetrics.getHeight();
- if (this.Owner.NodeHeight % 4 != 0) {
- Outline var10000 = this.Owner;
- var10000.NodeHeight += 4 - this.Owner.NodeHeight % 4;
- }
-
- this.Owner.NodesInCanvas = ((Component)this).bounds().height / this.Owner.NodeHeight;
- this.Owner.adjustScrolling();
- }
- }
-
- public void selectColorsFonts(Graphics g) {
- this.SetFonts(g);
- g.setFont(this.TextFont);
- g.setColor(this.foreColor);
- g.translate(-(this.Owner.HorzShift * this.Owner.NodeHeight), 0);
- }
-
- public boolean mouseDown(Event evt, int x, int y) {
- this.Owner.outlineClick(x, y, evt.clickCount);
- return super.mouseDown(evt, x, y);
- }
- }
-