home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &… the Search for Life CD 3 / 0_CD-ROM.iso / install / jre1_3 / lib / rt.jar / javax / swing / text / LabelView.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.3 KB  |  117 lines

  1. package javax.swing.text;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.FontMetrics;
  6. import java.awt.Shape;
  7. import java.awt.Toolkit;
  8. import javax.swing.event.DocumentEvent;
  9.  
  10. public class LabelView extends GlyphView implements TabableView {
  11.    private Font font;
  12.    // $FF: renamed from: fg java.awt.Color
  13.    private Color field_0;
  14.    // $FF: renamed from: bg java.awt.Color
  15.    private Color field_1;
  16.    private boolean underline;
  17.    private boolean strike;
  18.    private boolean superscript;
  19.    private boolean subscript;
  20.  
  21.    public LabelView(Element var1) {
  22.       super(var1);
  23.    }
  24.  
  25.    final void sync() {
  26.       if (this.font == null) {
  27.          this.setPropertiesFromAttributes();
  28.       }
  29.  
  30.    }
  31.  
  32.    protected void setUnderline(boolean var1) {
  33.       this.underline = var1;
  34.    }
  35.  
  36.    protected void setStrikeThrough(boolean var1) {
  37.       this.strike = var1;
  38.    }
  39.  
  40.    protected void setSuperscript(boolean var1) {
  41.       this.superscript = var1;
  42.    }
  43.  
  44.    protected void setSubscript(boolean var1) {
  45.       this.subscript = var1;
  46.    }
  47.  
  48.    protected void setPropertiesFromAttributes() {
  49.       AttributeSet var1 = ((View)this).getAttributes();
  50.       if (var1 != null) {
  51.          Document var2 = ((View)this).getDocument();
  52.          if (!(var2 instanceof StyledDocument)) {
  53.             throw new StateInvariantError("LabelView needs StyledDocument");
  54.          }
  55.  
  56.          StyledDocument var3 = (StyledDocument)var2;
  57.          this.font = var3.getFont(var1);
  58.          this.field_0 = var3.getForeground(var1);
  59.          if (var1.isDefined(StyleConstants.Background)) {
  60.             this.field_1 = var3.getBackground(var1);
  61.          } else {
  62.             this.field_1 = null;
  63.          }
  64.  
  65.          this.setUnderline(StyleConstants.isUnderline(var1));
  66.          this.setStrikeThrough(StyleConstants.isStrikeThrough(var1));
  67.          this.setSuperscript(StyleConstants.isSuperscript(var1));
  68.          this.setSubscript(StyleConstants.isSubscript(var1));
  69.       }
  70.  
  71.    }
  72.  
  73.    protected FontMetrics getFontMetrics() {
  74.       this.sync();
  75.       return Toolkit.getDefaultToolkit().getFontMetrics(this.font);
  76.    }
  77.  
  78.    public Color getBackground() {
  79.       this.sync();
  80.       return this.field_1;
  81.    }
  82.  
  83.    public Color getForeground() {
  84.       this.sync();
  85.       return this.field_0;
  86.    }
  87.  
  88.    public Font getFont() {
  89.       this.sync();
  90.       return this.font;
  91.    }
  92.  
  93.    public boolean isUnderline() {
  94.       this.sync();
  95.       return this.underline;
  96.    }
  97.  
  98.    public boolean isStrikeThrough() {
  99.       this.sync();
  100.       return this.strike;
  101.    }
  102.  
  103.    public boolean isSubscript() {
  104.       this.sync();
  105.       return this.subscript;
  106.    }
  107.  
  108.    public boolean isSuperscript() {
  109.       this.sync();
  110.       return this.superscript;
  111.    }
  112.  
  113.    public void changedUpdate(DocumentEvent var1, Shape var2, ViewFactory var3) {
  114.       this.font = null;
  115.    }
  116. }
  117.