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 / html / HTMLEditorKit$HTMLTextAction.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  2.2 KB  |  75 lines

  1. package javax.swing.text.html;
  2.  
  3. import javax.swing.JEditorPane;
  4. import javax.swing.text.DefaultStyledDocument;
  5. import javax.swing.text.Document;
  6. import javax.swing.text.EditorKit;
  7. import javax.swing.text.Element;
  8. import javax.swing.text.JTextComponent;
  9. import javax.swing.text.StyleConstants;
  10. import javax.swing.text.StyledEditorKit;
  11.  
  12. public abstract class HTMLEditorKit$HTMLTextAction extends StyledEditorKit.StyledTextAction {
  13.    public HTMLEditorKit$HTMLTextAction(String var1) {
  14.       super(var1);
  15.    }
  16.  
  17.    protected HTMLDocument getHTMLDocument(JEditorPane var1) {
  18.       Document var2 = ((JTextComponent)var1).getDocument();
  19.       if (var2 instanceof HTMLDocument) {
  20.          return (HTMLDocument)var2;
  21.       } else {
  22.          throw new IllegalArgumentException("document must be HTMLDocument");
  23.       }
  24.    }
  25.  
  26.    protected HTMLEditorKit getHTMLEditorKit(JEditorPane var1) {
  27.       EditorKit var2 = var1.getEditorKit();
  28.       if (var2 instanceof HTMLEditorKit) {
  29.          return (HTMLEditorKit)var2;
  30.       } else {
  31.          throw new IllegalArgumentException("EditorKit must be HTMLEditorKit");
  32.       }
  33.    }
  34.  
  35.    protected Element[] getElementsAt(HTMLDocument var1, int var2) {
  36.       return this.getElementsAt(((DefaultStyledDocument)var1).getDefaultRootElement(), var2, 0);
  37.    }
  38.  
  39.    private Element[] getElementsAt(Element var1, int var2, int var3) {
  40.       if (var1.isLeaf()) {
  41.          Element[] var5 = new Element[var3 + 1];
  42.          var5[var3] = var1;
  43.          return var5;
  44.       } else {
  45.          Element[] var4 = this.getElementsAt(var1.getElement(var1.getElementIndex(var2)), var2, var3 + 1);
  46.          var4[var3] = var1;
  47.          return var4;
  48.       }
  49.    }
  50.  
  51.    protected int elementCountToTag(HTMLDocument var1, int var2, HTML.Tag var3) {
  52.       int var4 = -1;
  53.  
  54.       Element var5;
  55.       for(var5 = ((DefaultStyledDocument)var1).getCharacterElement(var2); var5 != null && var5.getAttributes().getAttribute(StyleConstants.NameAttribute) != var3; ++var4) {
  56.          var5 = var5.getParentElement();
  57.       }
  58.  
  59.       return var5 == null ? -1 : var4;
  60.    }
  61.  
  62.    protected Element findElementMatchingTag(HTMLDocument var1, int var2, HTML.Tag var3) {
  63.       Element var4 = ((DefaultStyledDocument)var1).getDefaultRootElement();
  64.  
  65.       Element var5;
  66.       for(var5 = null; var4 != null; var4 = var4.getElement(var4.getElementIndex(var2))) {
  67.          if (var4.getAttributes().getAttribute(StyleConstants.NameAttribute) == var3) {
  68.             var5 = var4;
  69.          }
  70.       }
  71.  
  72.       return var5;
  73.    }
  74. }
  75.