home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 144 / DPCS0200.iso / Internet / Supanet / system / swing.jar / javax / swing / text / html / BlockView.class (.txt) next >
Encoding:
Java Class File  |  1998-11-05  |  2.2 KB  |  72 lines

  1. package javax.swing.text.html;
  2.  
  3. import java.awt.Graphics;
  4. import java.awt.Rectangle;
  5. import java.awt.Shape;
  6. import javax.swing.text.AttributeSet;
  7. import javax.swing.text.BoxView;
  8. import javax.swing.text.CompositeView;
  9. import javax.swing.text.Element;
  10. import javax.swing.text.View;
  11.  
  12. public class BlockView extends BoxView {
  13.    private AttributeSet attr;
  14.    private StyleSheet.BoxPainter painter;
  15.  
  16.    public BlockView(Element var1, int var2) {
  17.       super(var1, var2);
  18.       StyleSheet var3 = this.getStyleSheet();
  19.       this.attr = var3.getViewAttributes(this);
  20.       this.painter = var3.getBoxPainter(this.attr);
  21.       this.setPropertiesFromAttributes();
  22.    }
  23.  
  24.    public float getAlignment(int var1) {
  25.       switch (var1) {
  26.          case 0:
  27.             return 0.0F;
  28.          case 1:
  29.             float var2 = ((BoxView)this).getPreferredSpan(1);
  30.             View var3 = ((CompositeView)this).getView(0);
  31.             float var4 = var3.getPreferredSpan(1);
  32.             float var5 = (int)var2 != 0 ? var4 * var3.getAlignment(1) / var2 : 0.0F;
  33.             return var5;
  34.          default:
  35.             throw new IllegalArgumentException("Invalid axis: " + var1);
  36.       }
  37.    }
  38.  
  39.    public AttributeSet getAttributes() {
  40.       return this.attr;
  41.    }
  42.  
  43.    public int getResizeWeight(int var1) {
  44.       switch (var1) {
  45.          case 0:
  46.             return 1;
  47.          case 1:
  48.             return 0;
  49.          default:
  50.             throw new IllegalArgumentException("Invalid axis: " + var1);
  51.       }
  52.    }
  53.  
  54.    protected StyleSheet getStyleSheet() {
  55.       HTMLDocument var1 = (HTMLDocument)((View)this).getDocument();
  56.       return var1.getStyleSheet();
  57.    }
  58.  
  59.    public void paint(Graphics var1, Shape var2) {
  60.       Rectangle var3 = (Rectangle)var2;
  61.       this.painter.paint(var1, (float)var3.x, (float)var3.y, (float)var3.width, (float)var3.height, this);
  62.       super.paint(var1, var3);
  63.    }
  64.  
  65.    protected void setPropertiesFromAttributes() {
  66.       if (this.attr != null) {
  67.          ((CompositeView)this).setInsets((short)((int)this.painter.getInset(1, this)), (short)((int)this.painter.getInset(2, this)), (short)((int)this.painter.getInset(3, this)), (short)((int)this.painter.getInset(4, this)));
  68.       }
  69.  
  70.    }
  71. }
  72.