home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161a.iso / handson / files / copyjava.exe / com / sun / java / swing / text / ComponentView.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-02-26  |  2.4 KB  |  83 lines

  1. package com.sun.java.swing.text;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Dimension;
  6. import java.awt.Graphics;
  7. import java.awt.Rectangle;
  8. import java.awt.Shape;
  9.  
  10. public class ComponentView extends View {
  11.    // $FF: renamed from: c java.awt.Component
  12.    private Component field_0;
  13.  
  14.    public ComponentView(Element var1) {
  15.       super(var1);
  16.       AttributeSet var2 = var1.getAttributes();
  17.       this.field_0 = StyleConstants.getComponent(var2);
  18.       this.field_0.setVisible(false);
  19.    }
  20.  
  21.    public void paint(Graphics var1, Shape var2) {
  22.       this.field_0.setBounds(var2.getBounds());
  23.       if (!this.field_0.isVisible()) {
  24.          this.field_0.setVisible(true);
  25.       }
  26.  
  27.    }
  28.  
  29.    public float getPreferredSpan(int var1) {
  30.       Dimension var2 = this.field_0.getPreferredSize();
  31.       switch (var1) {
  32.          case 0:
  33.             return (float)var2.width;
  34.          case 1:
  35.             return (float)var2.height;
  36.          default:
  37.             throw new IllegalArgumentException("Invalid axis: " + var1);
  38.       }
  39.    }
  40.  
  41.    public float getAlignment(int var1) {
  42.       switch (var1) {
  43.          case 0:
  44.             return this.field_0.getAlignmentX();
  45.          case 1:
  46.             return this.field_0.getAlignmentY();
  47.          default:
  48.             return super.getAlignment(var1);
  49.       }
  50.    }
  51.  
  52.    public void setSize(float var1, float var2) {
  53.       this.field_0.setSize((int)var1, (int)var2);
  54.    }
  55.  
  56.    public void setParent(View var1) {
  57.       super.setParent(var1);
  58.       if (var1 == null) {
  59.          Container var3 = this.field_0.getParent();
  60.          var3.remove(this.field_0);
  61.       } else {
  62.          Container var2 = ((View)this).getContainer();
  63.          var2.add(this.field_0);
  64.       }
  65.    }
  66.  
  67.    public Shape modelToView(int var1, Shape var2) throws BadLocationException {
  68.       int var3 = ((View)this).getStartOffset();
  69.       int var4 = ((View)this).getEndOffset();
  70.       if (var1 >= var3 && var1 < var4) {
  71.          Rectangle var5 = new Rectangle(var2.getBounds());
  72.          var5.width = 0;
  73.          return var5;
  74.       } else {
  75.          return null;
  76.       }
  77.    }
  78.  
  79.    public int viewToModel(float var1, float var2, Shape var3) {
  80.       return ((View)this).getStartOffset();
  81.    }
  82. }
  83.