home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Java / JDesignerPro / Jdp3_0.exe / data1.cab / Program_Files / JDPMain.jar / JDPChiselFrameSidePanel.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-01-15  |  4.3 KB  |  211 lines

  1. import java.awt.Color;
  2. import java.awt.Component;
  3. import java.awt.Container;
  4. import java.awt.Dimension;
  5. import java.awt.Event;
  6. import java.awt.Font;
  7. import java.awt.FontMetrics;
  8. import java.awt.Graphics;
  9. import java.awt.Image;
  10. import java.awt.LayoutManager;
  11. import java.awt.Panel;
  12. import java.awt.Rectangle;
  13. import java.awt.image.ImageObserver;
  14.  
  15. class JDPChiselFrameSidePanel extends Panel {
  16.    Image offscreen;
  17.    Rectangle offscreensize;
  18.    // $FF: renamed from: gr java.awt.Graphics
  19.    Graphics field_0;
  20.    Container target;
  21.    JDPUser user;
  22.    String orientation;
  23.    String panelTitle;
  24.    String titlePos;
  25.    Rectangle Bounds;
  26.    // $FF: renamed from: fm java.awt.FontMetrics
  27.    protected FontMetrics field_1;
  28.    int[] boldWidths;
  29.    Font thisFont;
  30.    Font lastFont;
  31.    int prevTitleHeight;
  32.  
  33.    public JDPChiselFrameSidePanel(JDPUser var1, String var2, String var3, String var4) {
  34.       this.user = var1;
  35.       this.orientation = var2;
  36.       this.panelTitle = var3;
  37.       this.titlePos = var4;
  38.       Rectangle var5 = ((Component)this).bounds();
  39.       if (var2.compareTo(var4) == 0) {
  40.          ((Container)this).setLayout((LayoutManager)null);
  41.          var5 = ((Component)this).bounds();
  42.          ((Component)this).reshape(0, 0, var5.width, 12);
  43.       } else {
  44.          if (var2.equals("West")) {
  45.             ((Container)this).setLayout((LayoutManager)null);
  46.             ((Component)this).reshape(0, 0, 6, var5.height);
  47.          }
  48.  
  49.          if (var2.equals("East")) {
  50.             ((Container)this).setLayout((LayoutManager)null);
  51.             ((Component)this).reshape(0, 0, 6, var5.height);
  52.          }
  53.  
  54.          if (var2.equals("South")) {
  55.             ((Container)this).setLayout((LayoutManager)null);
  56.             ((Component)this).reshape(0, 0, var5.width, 6);
  57.          }
  58.  
  59.       }
  60.    }
  61.  
  62.    public void paint(Graphics var1) {
  63.       this.update(var1);
  64.    }
  65.  
  66.    public Dimension minimumSize() {
  67.       Dimension var1 = new Dimension(7, 6);
  68.       if (this.orientation.equals(this.titlePos)) {
  69.          int var2 = 20;
  70.          int var3 = 14;
  71.          if (this.boldWidths != null) {
  72.             var2 = this.StringWidth(this.panelTitle) + 15;
  73.          }
  74.  
  75.          if (this.field_1 != null) {
  76.             var3 = this.field_1.getHeight();
  77.          }
  78.  
  79.          var1 = new Dimension(var2, var3);
  80.       }
  81.  
  82.       return var1;
  83.    }
  84.  
  85.    public void update(Graphics var1) {
  86.       Rectangle var2 = ((Component)this).bounds();
  87.       if (var2.width != 0 && var2.height != 0) {
  88.          if (this.offscreen == null || var2.width != this.offscreensize.width || var2.height != this.offscreensize.height) {
  89.             if (var2.width < 6) {
  90.                var2.width = 6;
  91.             }
  92.  
  93.             if (var2.height < 6) {
  94.                var2.height = 6;
  95.             }
  96.  
  97.             this.offscreen = ((Component)this).createImage(var2.width, var2.height);
  98.             this.offscreensize = var2;
  99.             this.field_0 = this.offscreen.getGraphics();
  100.             this.field_0.setFont(((Component)this).getFont());
  101.          }
  102.  
  103.          Color var3 = ((Component)this).getBackground();
  104.          this.field_0.setColor(var3);
  105.          this.field_0.fillRect(0, 0, var2.width, var2.height);
  106.          this.field_0.setColor(Color.black);
  107.          this.field_0.setColor(((Component)this).getForeground());
  108.          if (this.thisFont == null) {
  109.             if (this.user != null) {
  110.                this.thisFont = this.user.boldFont;
  111.             } else {
  112.                this.thisFont = ((Component)this).getFont();
  113.                this.thisFont = new Font(this.thisFont.getName(), 1, this.thisFont.getSize());
  114.             }
  115.          }
  116.  
  117.          this.field_0.setFont(this.thisFont);
  118.          this.StringWidth("");
  119.          if (this.field_1 != null) {
  120.             int var4 = this.field_1.getHeight();
  121.             if (var4 != this.prevTitleHeight && this.prevTitleHeight != 0 || var4 != ((Component)this).bounds().height) {
  122.                this.prevTitleHeight = var4;
  123.                if (this.target == null) {
  124.                   this.target = ((Component)this).getParent();
  125.                }
  126.  
  127.                this.target.layout();
  128.                this.target.paintAll(this.target.getGraphics());
  129.             }
  130.  
  131.             this.prevTitleHeight = var4;
  132.          }
  133.  
  134.          this.Bounds = ((Component)this).bounds();
  135.          if (this.orientation.compareTo("East") == 0) {
  136.             this.field_0.setColor(JDPUtils.darker(var3));
  137.             this.field_0.drawLine(this.Bounds.width - 5, 0, this.Bounds.width - 5, this.Bounds.height);
  138.             this.field_0.setColor(JDPUtils.brighter(var3));
  139.             this.field_0.drawLine(this.Bounds.width - 4, 0, this.Bounds.width - 4, this.Bounds.height);
  140.          } else if (this.orientation.compareTo("West") == 0) {
  141.             this.field_0.setColor(JDPUtils.darker(var3));
  142.             this.field_0.drawLine(3, 0, 3, this.Bounds.height);
  143.             this.field_0.setColor(JDPUtils.brighter(var3));
  144.             this.field_0.drawLine(4, 0, 4, this.Bounds.height);
  145.          } else if (this.orientation.compareTo("South") == 0) {
  146.             this.field_0.setColor(JDPUtils.darker(var3));
  147.             this.field_0.drawLine(3, 0, 3, this.Bounds.height - 3);
  148.             this.field_0.drawLine(this.Bounds.width - 5, 0, this.Bounds.width - 5, this.Bounds.height - 4);
  149.             this.field_0.drawLine(4, this.Bounds.height - 4, this.Bounds.width - 4, this.Bounds.height - 4);
  150.             this.field_0.setColor(JDPUtils.brighter(var3));
  151.             this.field_0.drawLine(4, 0, 4, this.Bounds.height - 4);
  152.             this.field_0.drawLine(this.Bounds.width - 4, 0, this.Bounds.width - 4, this.Bounds.height - 3);
  153.             this.field_0.drawLine(3, this.Bounds.height - 3, this.Bounds.width - 4, this.Bounds.height - 3);
  154.             if (this.orientation.equals(this.titlePos) && !this.panelTitle.equals("")) {
  155.                this.field_0.setColor(var3);
  156.                this.field_0.fillRect(6, this.Bounds.height - 8, (int)((double)this.panelTitle.length() * (double)6.0F), this.Bounds.height - 5);
  157.                this.field_0.setColor(((Component)this).getForeground());
  158.                this.field_0.drawString(this.panelTitle, 8, this.Bounds.height - 3);
  159.             }
  160.          } else if (this.orientation.compareTo("North") == 0) {
  161.             this.field_0.setColor(JDPUtils.darker(var3));
  162.             this.field_0.drawLine(3, this.Bounds.height - 7, 3, this.Bounds.height);
  163.             this.field_0.drawLine(this.Bounds.width - 5, this.Bounds.height - 7, this.Bounds.width - 5, this.Bounds.height);
  164.             this.field_0.drawLine(3, this.Bounds.height - 7, this.Bounds.width - 4, this.Bounds.height - 7);
  165.             this.field_0.setColor(JDPUtils.brighter(var3));
  166.             this.field_0.drawLine(4, this.Bounds.height - 6, 4, this.Bounds.height);
  167.             this.field_0.drawLine(this.Bounds.width - 4, this.Bounds.height - 6, this.Bounds.width - 4, this.Bounds.height);
  168.             this.field_0.drawLine(4, this.Bounds.height - 6, this.Bounds.width - 5, this.Bounds.height - 6);
  169.             if (this.orientation.equals(this.titlePos) && !this.panelTitle.equals("")) {
  170.                this.field_0.setColor(var3);
  171.                this.field_0.fillRect(6, this.Bounds.height - 8, this.StringWidth(this.panelTitle) + 3, this.Bounds.height - 5);
  172.                this.field_0.setColor(((Component)this).getForeground());
  173.                this.field_0.drawString(this.panelTitle, 8, this.Bounds.height - 3);
  174.             }
  175.          }
  176.  
  177.          var1.drawImage(this.offscreen, 0, 0, (ImageObserver)null);
  178.       }
  179.    }
  180.  
  181.    public Dimension preferredSize() {
  182.       return this.minimumSize();
  183.    }
  184.  
  185.    public void layout() {
  186.       ((Component)this).repaint();
  187.    }
  188.  
  189.    public boolean handleEvent(Event var1) {
  190.       switch (var1.id) {
  191.          case 202:
  192.             ((Component)this).repaint();
  193.             return false;
  194.          default:
  195.             return false;
  196.       }
  197.    }
  198.  
  199.    int StringWidth(String var1) {
  200.       if (this.field_1 == null || this.lastFont == null || this.field_0 != null && !this.field_0.getFont().equals(this.lastFont)) {
  201.          this.field_1 = this.field_0.getFontMetrics();
  202.          this.lastFont = this.field_0.getFont();
  203.          if (this.field_1 != null) {
  204.             this.boldWidths = this.field_1.getWidths();
  205.          }
  206.       }
  207.  
  208.       return this.field_1 != null ? this.field_1.stringWidth(var1) : 0;
  209.    }
  210. }
  211.