/[classpath]/classpath/javax/swing/text/StyleContext.java
ViewVC logotype

Diff of /classpath/javax/swing/text/StyleContext.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by mark, Sat Jul 2 20:32:51 2005 UTC revision 1.5 by audriusa, Tue Jul 5 13:53:33 2005 UTC
# Line 380  public class StyleContext Line 380  public class StyleContext
380    // FIXME: also not sure if these tables ought to be static (singletons),    // FIXME: also not sure if these tables ought to be static (singletons),
381    // shared across all StyleContexts. I think so, but it's not clear in    // shared across all StyleContexts. I think so, but it's not clear in
382    // docs. revert to non-shared if you think it matters.    // docs. revert to non-shared if you think it matters.
383      
384      /**
385       * The name of the default style.
386       */
387    public static final String DEFAULT_STYLE = "default";    public static final String DEFAULT_STYLE = "default";
388        
389      /**
390       * The default style for this style context.
391       */
392      NamedStyle defaultStyle = new NamedStyle(DEFAULT_STYLE, null);
393      
394    static Hashtable sharedAttributeSets = new Hashtable();    static Hashtable sharedAttributeSets = new Hashtable();
395    static Hashtable sharedFonts = new Hashtable();    static Hashtable sharedFonts = new Hashtable();
396    
# Line 392  public class StyleContext Line 400  public class StyleContext
400    EventListenerList listenerList;    EventListenerList listenerList;
401    Hashtable styleTable;    Hashtable styleTable;
402        
403      /**
404       * Creates a new instance of the style context. Add the default style
405       * to the style table.
406       */
407    public StyleContext()    public StyleContext()
408    {    {
409      listenerList = new EventListenerList();      listenerList = new EventListenerList();
410      styleTable = new Hashtable();      styleTable = new Hashtable();
411        styleTable.put(DEFAULT_STYLE, defaultStyle);
412    }    }
413    
414    protected SmallAttributeSet createSmallAttributeSet(AttributeSet a)    protected SmallAttributeSet createSmallAttributeSet(AttributeSet a)
# Line 436  public class StyleContext Line 449  public class StyleContext
449      styleTable.remove(name);      styleTable.remove(name);
450    }    }
451    
452      /**
453       * Get the style from the style table. If the passed name
454       * matches {@link #DEFAULT_STYLE}, returns the default style.
455       * Otherwise returns the previously defined style of
456       * <code>null</code> if the style with the given name is not defined.
457       *
458       * @param name the name of the style.
459       *
460       * @return the style with the given name or null if no such defined.
461       */
462    public Style getStyle(String name)    public Style getStyle(String name)
463    {    {
464      return (Style) styleTable.get(name);      return (Style) styleTable.get(name);
465    }    }
466      
467      /**
468       * Get the names of the style. The returned enumeration always
469       * contains at least one member, the default style.
470       */
471    public Enumeration getStyleNames()    public Enumeration getStyleNames()
472    {    {
473      return styleTable.keys();      return styleTable.keys();

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26