home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / javax / swing / text / StyledEditorKit.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  4.2 KB  |  65 lines

  1. package javax.swing.text;
  2.  
  3. import javax.swing.Action;
  4. import javax.swing.JComponent;
  5. import javax.swing.JEditorPane;
  6.  
  7. public class StyledEditorKit extends DefaultEditorKit {
  8.    private static final ViewFactory defaultFactory = new StyledViewFactory();
  9.    Element currentRun;
  10.    Element currentParagraph;
  11.    MutableAttributeSet inputAttributes = new 1(this);
  12.    private AttributeTracker inputAttributeUpdater = new AttributeTracker(this);
  13.    private static final Action[] defaultActions = new Action[]{new FontFamilyAction("font-family-SansSerif", "SansSerif"), new FontFamilyAction("font-family-Monospaced", "Monospaced"), new FontFamilyAction("font-family-Serif", "Serif"), new FontSizeAction("font-size-8", 8), new FontSizeAction("font-size-10", 10), new FontSizeAction("font-size-12", 12), new FontSizeAction("font-size-14", 14), new FontSizeAction("font-size-16", 16), new FontSizeAction("font-size-18", 18), new FontSizeAction("font-size-24", 24), new FontSizeAction("font-size-36", 36), new FontSizeAction("font-size-48", 48), new AlignmentAction("left-justify", 0), new AlignmentAction("center-justify", 1), new AlignmentAction("right-justify", 2), new BoldAction(), new ItalicAction(), new UnderlineAction()};
  14.  
  15.    public MutableAttributeSet getInputAttributes() {
  16.       return this.inputAttributes;
  17.    }
  18.  
  19.    public Element getCharacterAttributeRun() {
  20.       return this.currentRun;
  21.    }
  22.  
  23.    public Object clone() {
  24.       return new StyledEditorKit();
  25.    }
  26.  
  27.    public Action[] getActions() {
  28.       return TextAction.augmentList(super.getActions(), defaultActions);
  29.    }
  30.  
  31.    public Document createDefaultDocument() {
  32.       return new DefaultStyledDocument();
  33.    }
  34.  
  35.    public void install(JEditorPane var1) {
  36.       ((JTextComponent)var1).addCaretListener(this.inputAttributeUpdater);
  37.       ((JComponent)var1).addPropertyChangeListener(this.inputAttributeUpdater);
  38.       Caret var2 = ((JTextComponent)var1).getCaret();
  39.       if (var2 != null) {
  40.          this.inputAttributeUpdater.updateInputAttributes(var2.getDot(), var2.getMark(), var1);
  41.       }
  42.  
  43.    }
  44.  
  45.    public void deinstall(JEditorPane var1) {
  46.       ((JTextComponent)var1).removeCaretListener(this.inputAttributeUpdater);
  47.       ((JComponent)var1).removePropertyChangeListener(this.inputAttributeUpdater);
  48.       this.currentRun = null;
  49.       this.currentParagraph = null;
  50.    }
  51.  
  52.    public ViewFactory getViewFactory() {
  53.       return defaultFactory;
  54.    }
  55.  
  56.    protected void createInputAttributes(Element var1, MutableAttributeSet var2) {
  57.       var2.removeAttributes(var2);
  58.       var2.addAttributes(var1.getAttributes());
  59.       var2.removeAttribute(StyleConstants.ComponentAttribute);
  60.       var2.removeAttribute(StyleConstants.IconAttribute);
  61.       var2.removeAttribute("$ename");
  62.       var2.removeAttribute(StyleConstants.ComposedTextAttribute);
  63.    }
  64. }
  65.