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

  1. package com.sun.java.swing.text;
  2.  
  3. import com.sun.java.swing.event.ChangeEvent;
  4. import com.sun.java.swing.event.ChangeListener;
  5. import com.sun.java.swing.event.EventListenerList;
  6. import java.io.IOException;
  7. import java.io.ObjectInputStream;
  8. import java.io.ObjectOutputStream;
  9. import java.io.Serializable;
  10. import java.util.Enumeration;
  11.  
  12. public class StyleContext$NamedStyle implements Style, Serializable {
  13.    // $FF: synthetic field
  14.    private final StyleContext this$0;
  15.    protected EventListenerList listenerList;
  16.    protected ChangeEvent changeEvent;
  17.    private transient AttributeSet attributes;
  18.  
  19.    public StyleContext$NamedStyle(StyleContext var1, String var2, Style var3) {
  20.       this.this$0 = var1;
  21.       this.this$0 = var1;
  22.       this.listenerList = new EventListenerList();
  23.       this.attributes = var1.getEmptySet();
  24.       if (var2 != null) {
  25.          this.setName(var2);
  26.       }
  27.  
  28.       if (var3 != null) {
  29.          this.setResolveParent(var3);
  30.       }
  31.  
  32.    }
  33.  
  34.    public StyleContext$NamedStyle(StyleContext var1, Style var2) {
  35.       this(var1, (String)null, var2);
  36.    }
  37.  
  38.    public StyleContext$NamedStyle(StyleContext var1) {
  39.       this.this$0 = var1;
  40.       this.this$0 = var1;
  41.       this.listenerList = new EventListenerList();
  42.       this.attributes = var1.getEmptySet();
  43.    }
  44.  
  45.    public String toString() {
  46.       return "NamedStyle:" + this.getName() + " " + this.attributes;
  47.    }
  48.  
  49.    public String getName() {
  50.       return this.isDefined(StyleConstants.NameAttribute) ? (String)this.getAttribute(StyleConstants.NameAttribute) : null;
  51.    }
  52.  
  53.    public void setName(String var1) {
  54.       if (var1 != null) {
  55.          this.addAttribute(StyleConstants.NameAttribute, var1);
  56.       }
  57.  
  58.    }
  59.  
  60.    public void addChangeListener(ChangeListener var1) {
  61.       this.listenerList.add(StyleContext.class$com$sun$java$swing$event$ChangeListener != null ? StyleContext.class$com$sun$java$swing$event$ChangeListener : (StyleContext.class$com$sun$java$swing$event$ChangeListener = StyleContext.class$("com.sun.java.swing.event.ChangeListener")), var1);
  62.    }
  63.  
  64.    public void removeChangeListener(ChangeListener var1) {
  65.       this.listenerList.remove(StyleContext.class$com$sun$java$swing$event$ChangeListener != null ? StyleContext.class$com$sun$java$swing$event$ChangeListener : (StyleContext.class$com$sun$java$swing$event$ChangeListener = StyleContext.class$("com.sun.java.swing.event.ChangeListener")), var1);
  66.    }
  67.  
  68.    protected void fireStateChanged() {
  69.       Object[] var1 = this.listenerList.getListenerList();
  70.  
  71.       for(int var2 = var1.length - 2; var2 >= 0; var2 -= 2) {
  72.          if (var1[var2] == (StyleContext.class$com$sun$java$swing$event$ChangeListener != null ? StyleContext.class$com$sun$java$swing$event$ChangeListener : (StyleContext.class$com$sun$java$swing$event$ChangeListener = StyleContext.class$("com.sun.java.swing.event.ChangeListener")))) {
  73.             if (this.changeEvent == null) {
  74.                this.changeEvent = new ChangeEvent(this);
  75.             }
  76.  
  77.             ((ChangeListener)var1[var2 + 1]).stateChanged(this.changeEvent);
  78.          }
  79.       }
  80.  
  81.    }
  82.  
  83.    public int getAttributeCount() {
  84.       return this.attributes.getAttributeCount();
  85.    }
  86.  
  87.    public boolean isDefined(Object var1) {
  88.       return this.attributes.isDefined(var1);
  89.    }
  90.  
  91.    public boolean isEqual(AttributeSet var1) {
  92.       return this.attributes.isEqual(var1);
  93.    }
  94.  
  95.    public AttributeSet copyAttributes() {
  96.       StyleContext$NamedStyle var1 = new StyleContext$NamedStyle(this.this$0);
  97.       var1.attributes = this.attributes.copyAttributes();
  98.       return var1;
  99.    }
  100.  
  101.    public Object getAttribute(Object var1) {
  102.       return this.attributes.getAttribute(var1);
  103.    }
  104.  
  105.    public Enumeration getAttributeNames() {
  106.       return this.attributes.getAttributeNames();
  107.    }
  108.  
  109.    public boolean containsAttribute(Object var1, Object var2) {
  110.       return this.attributes.containsAttribute(var1, var2);
  111.    }
  112.  
  113.    public boolean containsAttributes(AttributeSet var1) {
  114.       return this.attributes.containsAttributes(var1);
  115.    }
  116.  
  117.    public AttributeSet getResolveParent() {
  118.       return this.attributes.getResolveParent();
  119.    }
  120.  
  121.    public void addAttribute(Object var1, Object var2) {
  122.       StyleContext var3 = this.this$0;
  123.       this.attributes = var3.addAttribute(this.attributes, var1, var2);
  124.       this.fireStateChanged();
  125.    }
  126.  
  127.    public void addAttributes(AttributeSet var1) {
  128.       StyleContext var2 = this.this$0;
  129.       this.attributes = var2.addAttributes(this.attributes, var1);
  130.       this.fireStateChanged();
  131.    }
  132.  
  133.    public void removeAttribute(Object var1) {
  134.       StyleContext var2 = this.this$0;
  135.       this.attributes = var2.removeAttribute(this.attributes, var1);
  136.       this.fireStateChanged();
  137.    }
  138.  
  139.    public void removeAttributes(Enumeration var1) {
  140.       StyleContext var2 = this.this$0;
  141.       this.attributes = var2.removeAttributes(this.attributes, var1);
  142.       this.fireStateChanged();
  143.    }
  144.  
  145.    public void removeAttributes(AttributeSet var1) {
  146.       StyleContext var2 = this.this$0;
  147.       if (var1 == this) {
  148.          this.attributes = var2.getEmptySet();
  149.       } else {
  150.          this.attributes = var2.removeAttributes(this.attributes, var1);
  151.       }
  152.  
  153.       this.fireStateChanged();
  154.    }
  155.  
  156.    public void setResolveParent(AttributeSet var1) {
  157.       if (var1 != null) {
  158.          this.addAttribute(StyleConstants.ResolveAttribute, var1);
  159.       } else {
  160.          this.removeAttribute(StyleConstants.ResolveAttribute);
  161.       }
  162.    }
  163.  
  164.    private void writeObject(ObjectOutputStream var1) throws IOException {
  165.       var1.defaultWriteObject();
  166.       StyleContext.writeAttributeSet(var1, this.attributes);
  167.    }
  168.  
  169.    private void readObject(ObjectInputStream var1) throws ClassNotFoundException, IOException {
  170.       var1.defaultReadObject();
  171.       this.attributes = SimpleAttributeSet.EMPTY;
  172.       StyleContext.readAttributeSet(var1, this);
  173.    }
  174. }
  175.