Package javax.swing.text.html

Examples of javax.swing.text.html.HTMLDocument


        .getFavoritesContainingProgram(mProgram);
    boolean hasFavorites = favorites != null && favorites.length > 0;
    mHighlight.setEnabled(hasFavorites);

    Highlighter highlighter = mInfoEP.getHighlighter();
    HTMLDocument document = (HTMLDocument) mInfoEP.getDocument();
    highlighter.removeAllHighlights();

    if (!hasFavorites
        || !ProgramInfo.getInstance().getSettings().getHighlightFavorite()) {
      return;
    }

    DefaultHighlightPainter painter = new DefaultHighlightPainter(ProgramInfo
        .getInstance().getSettings().getHighlightColor());
    for (Favorite favorite : favorites) {
      ProgramSearcher searcher = null;
      try {
        searcher = favorite.getSearcher();
      } catch (TvBrowserException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      if (searcher instanceof RegexSearcher) {
        Pattern pattern = ((RegexSearcher) searcher).getPattern();
        if (pattern != null) {
          if (pattern.pattern().startsWith(".*")) {
            pattern = Pattern.compile(pattern.pattern().substring(2));
          }
          if (pattern.pattern().endsWith(".*")) {
            pattern = Pattern.compile(pattern.pattern().substring(0,
                pattern.pattern().length() - 2));
          }
          for (HTMLDocument.Iterator it = document
              .getIterator(HTML.Tag.CONTENT); it.isValid(); it.next()) {
            try {
              String fragment = document.getText(it.getStartOffset(), it
                  .getEndOffset()
                  - it.getStartOffset());
              Matcher matcher = pattern.matcher(fragment);
              while (matcher.find()) {
                highlighter.addHighlight(it.getStartOffset() + matcher.start(),
View Full Code Here


      }

      private String getLink(int pos, JEditorPane html) {
        Document doc = html.getDocument();
        if (doc instanceof HTMLDocument) {
          HTMLDocument hdoc = (HTMLDocument) doc;
          Element e = hdoc.getCharacterElement(pos);
          AttributeSet a = e.getAttributes();
          AttributeSet anchor = (AttributeSet) a.getAttribute(HTML.Tag.A);

          if (anchor != null) {
            return (String) anchor.getAttribute(HTML.Attribute.HREF);
View Full Code Here

  public void hyperlinkUpdate(HyperlinkEvent evt) {
    if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
      if (evt instanceof HTMLFrameHyperlinkEvent) {
        HTMLFrameHyperlinkEvent frameEvt = (HTMLFrameHyperlinkEvent) evt;
        HTMLDocument doc = (HTMLDocument) mEditorPane.getDocument();
        doc.processHTMLFrameHyperlinkEvent(frameEvt);
      } else {
        addThisSiteToHistory();
        String filename = evt.getDescription();

        // Falls in Link ein Anker vorkommt, diesen ignorieren
View Full Code Here

    if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED)
  return;

    if (e instanceof HTMLFrameHyperlinkEvent) {
  HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent)e;
  HTMLDocument doc = (HTMLDocument)contentEditorPane.getDocument();
  doc.processHTMLFrameHyperlinkEvent(evt);
    }
    else {
  try {
      pages.goTo(e.getURL());
      updateNavActions();
View Full Code Here

    public DcMultiLineToolTipUI() {
        super();
        if (textPane == null) {
            textPane = ComponentFactory.getTextPane();
            textPane.setDocument(new HTMLDocument());
            textPane.setEditorKit(new HTMLEditorKit());
        }
    }
View Full Code Here

    }
   
    private void setHtmlText(String text) {
        String s = getHtmlText(text);
       
        HTMLDocument document = (HTMLDocument) textPane.getDocument();
        HTMLEditorKit kit = (HTMLEditorKit) textPane.getEditorKit();
       
        try {
            textPane.setText("");
            kit.insertHTML(document, 0, s, 0, 0, null);
View Full Code Here

                    if (e instanceof HTMLFrameHyperlinkEvent) {
                        Debug.message("minibrowser",
                                "processing HTMLFrameHyperlinkEvent");
                        HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e;
                        HTMLDocument doc = (HTMLDocument) pane.getDocument();
                        doc.processHTMLFrameHyperlinkEvent(evt);
                    } else {
                        Debug.message("minibrowser",
                                "processing HyperlinkEvent");
                        try {
                            push(e.getURL());
View Full Code Here

    return true;
  }

  private boolean isInvisible(final javax.swing.text.Element textElement)
  {
    final HTMLDocument htmlDocument = (HTMLDocument) textElement.getDocument();
    final StyleSheet sheet = htmlDocument.getStyleSheet();
    final AttributeSet attr = computeStyle(textElement, sheet);
    final Object o = attr.getAttribute(CSS.Attribute.DISPLAY);
    if ("none".equals(String.valueOf(o)))
    {
      return true;
View Full Code Here

    return false;
  }

  private void configureStyle(final javax.swing.text.Element textElement, final Element result)
  {
    final HTMLDocument htmlDocument = (HTMLDocument) textElement.getDocument();
    final StyleSheet sheet = htmlDocument.getStyleSheet();
    final AttributeSet attr = computeStyle(textElement, sheet);
    parseBorderAndBackgroundStyle(result, sheet, attr);
    parseBoxStyle(result, attr);

    final Font font = sheet.getFont(attr);
View Full Code Here

   * @see javax.swing.event.HyperlinkListener#hyperlinkUpdate(javax.swing.event.HyperlinkEvent)
   */
  public void hyperlinkUpdate (HyperlinkEvent event){
    if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED){
      if (event instanceof HTMLFrameHyperlinkEvent) {
        HTMLDocument doc = (HTMLDocument)viewer.getDocument ();
        doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent)event);
      }else
        displayPage(event.getURL());
    }
  }
View Full Code Here

TOP

Related Classes of javax.swing.text.html.HTMLDocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.