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

  1. package com.sun.java.swing.text;
  2.  
  3. import com.sun.java.swing.Icon;
  4. import java.awt.Graphics;
  5. import java.awt.Rectangle;
  6. import java.awt.Shape;
  7.  
  8. public class IconView extends View {
  9.    // $FF: renamed from: c com.sun.java.swing.Icon
  10.    private Icon field_0;
  11.  
  12.    public IconView(Element var1) {
  13.       super(var1);
  14.       AttributeSet var2 = var1.getAttributes();
  15.       this.field_0 = StyleConstants.getIcon(var2);
  16.    }
  17.  
  18.    public void paint(Graphics var1, Shape var2) {
  19.       Rectangle var3 = var2.getBounds();
  20.       this.field_0.paintIcon(((View)this).getContainer(), var1, var3.x, var3.y);
  21.    }
  22.  
  23.    public float getPreferredSpan(int var1) {
  24.       switch (var1) {
  25.          case 0:
  26.             return (float)this.field_0.getIconWidth();
  27.          case 1:
  28.             return (float)this.field_0.getIconHeight();
  29.          default:
  30.             throw new IllegalArgumentException("Invalid axis: " + var1);
  31.       }
  32.    }
  33.  
  34.    public float getAlignment(int var1) {
  35.       switch (var1) {
  36.          case 1:
  37.             return 1.0F;
  38.          default:
  39.             return super.getAlignment(var1);
  40.       }
  41.    }
  42.  
  43.    public Shape modelToView(int var1, Shape var2) throws BadLocationException {
  44.       int var3 = ((View)this).getStartOffset();
  45.       int var4 = ((View)this).getEndOffset();
  46.       if (var1 >= var3 && var1 < var4) {
  47.          Rectangle var5 = new Rectangle(var2.getBounds());
  48.          var5.width = 0;
  49.          return var5;
  50.       } else {
  51.          return null;
  52.       }
  53.    }
  54.  
  55.    public int viewToModel(float var1, float var2, Shape var3) {
  56.       var3.getBounds();
  57.       return ((View)this).getStartOffset();
  58.    }
  59.  
  60.    public void setSize(float var1, float var2) {
  61.    }
  62. }
  63.