当前位置: 首页>>代码示例>>Java>>正文


Java Tag类代码示例

本文整理汇总了Java中javax.swing.text.html.HTML.Tag的典型用法代码示例。如果您正苦于以下问题:Java Tag类的具体用法?Java Tag怎么用?Java Tag使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Tag类属于javax.swing.text.html.HTML包,在下文中一共展示了Tag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTextIndex

import javax.swing.text.html.HTML.Tag; //导入依赖的package包/类
public int getTextIndex() {
    return EventQueueWait.exec(new Callable<Integer>() {
        @Override public Integer call() throws Exception {
            String href = getText();
            int hRefIndex = 0;
            int current = 0;
            JEditorPane editor = (JEditorPane) parent.getComponent();
            HTMLDocument document = (HTMLDocument) editor.getDocument();
            Iterator iterator = document.getIterator(Tag.A);
            while (iterator.isValid()) {
                if (current++ >= index) {
                    return hRefIndex;
                }
                String attribute = ((HTMLDocument) ((JEditorPane) parent.getComponent()).getDocument())
                        .getText(iterator.getStartOffset(), iterator.getEndOffset() - iterator.getStartOffset());
                if (attribute != null && attribute.equals(href)) {
                    hRefIndex++;
                }
                iterator.next();
            }
            return -1;
        }
    });
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:25,代码来源:JEditorPaneTagJavaElement.java

示例2: selectByProperties

import javax.swing.text.html.HTML.Tag; //导入依赖的package包/类
private List<IJavaElement> selectByProperties(final ArrayList<IJavaElement> r, JSONObject o) {
    final Properties p;
    if (o.has("select")) {
        String spec = o.getString("select");
        if (!spec.startsWith("text=") && !spec.startsWith("link=")) {
            int pos = Integer.parseInt(spec);
            return Arrays.asList((IJavaElement) new JEditorPanePosJavaElement(this, pos));
        }
        p = parseSelectProperties(spec);
    } else {
        p = PropertyHelper.asProperties(o);
    }
    EventQueueWait.exec(new Runnable() {
        @Override public void run() {
            fillElements(Tag.A, r, new PropertyPredicate(p));
        }
    });
    return r;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:JEditorPaneJavaElement.java

示例3: handleStartTag

import javax.swing.text.html.HTML.Tag; //导入依赖的package包/类
@Override
public void handleStartTag(HTML.Tag tag, MutableAttributeSet att, int pos)
{
	if (tag.equals(HTML.Tag.A))
	{ // <a href=...> tag
		String attribute = (String) att.getAttribute(HTML.Attribute.HREF);
		if (attribute != null)
		{
			addReferencedDocument(attribute);
		}
	}
	else if (tag.equals(HTML.Tag.TITLE))
	{
		this.inTitle = true;
	}
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:17,代码来源:HelpController.java

示例4: findFrame

import javax.swing.text.html.HTML.Tag; //导入依赖的package包/类
/**
 * Finds the named frame inside this document.
 *
 * @param target the name to look for
 *
 * @return the frame if there is a matching frame, <code>null</code>
 *         otherwise
 */
private Element findFrame(String target)
{
  ElementIterator i = new ElementIterator(this);
  Element next = null;
  while ((next = i.next()) != null)
    {
      AttributeSet atts = next.getAttributes();
      if (atts.getAttribute(StyleConstants.NameAttribute) == HTML.Tag.FRAME)
        {
          String name = (String) atts.getAttribute(HTML.Attribute.NAME);
          if (name != null && name.equals(target))
            break;
        }
    }
  return next;
}
 
开发者ID:vilie,项目名称:javify,代码行数:25,代码来源:HTMLDocument.java

示例5: end

import javax.swing.text.html.HTML.Tag; //导入依赖的package包/类
/**
 * Called when an end tag is seen for one of the types of tags associated
 * with this Action.
 */
public void end(HTML.Tag t)
{
  if (t == HTML.Tag.OPTION)
    {
      option = null;
    }
  else
    {
      if (t == HTML.Tag.TEXTAREA)
        {
          inTextArea = false;
        }
      else if (t == HTML.Tag.SELECT)
        {
          selectModel = null;
          numOptions = 0;
        }
      // Finish the element.
      super.end(t);
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:26,代码来源:HTMLDocument.java

示例6: start

import javax.swing.text.html.HTML.Tag; //导入依赖的package包/类
public void start(HTML.Tag tag, MutableAttributeSet atts)
{
  pushCharacterStyle();
  charAttr.addAttribute(tag, atts.copyAttributes());
  StyleSheet styleSheet = getStyleSheet();
  // TODO: Add other tags here.
  if (tag == HTML.Tag.FONT)
    {
      String color = (String) atts.getAttribute(HTML.Attribute.COLOR);
      if (color != null)
        styleSheet.addCSSAttribute(charAttr, CSS.Attribute.COLOR, color);
      String face = (String) atts.getAttribute(HTML.Attribute.FACE);
      if (face != null)
        styleSheet.addCSSAttribute(charAttr, CSS.Attribute.FONT_FAMILY,
                                   face);
      String size = (String) atts.getAttribute(HTML.Attribute.SIZE);
      if (size != null)
        styleSheet.addCSSAttribute(charAttr, CSS.Attribute.FONT_SIZE,
                                   size);
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:22,代码来源:HTMLDocument.java

示例7: handleSimpleTag

import javax.swing.text.html.HTML.Tag; //导入依赖的package包/类
/**
 * This is a callback from the parser that should be routed to the
 * appropriate handler for the tag.
 *
 * @param t the HTML.Tag that was encountered
 * @param a the attribute set
 * @param pos the position at which the tag was encountered
 */
public void handleSimpleTag(HTML.Tag t, MutableAttributeSet a, int pos)
{
  if (t == insertTag)
    insertTagEncountered = true;

  if (shouldInsert())
    {
      TagAction action = (TagAction) tagToAction.get(t);
      if (action != null)
        {
          action.start(t, a);
          action.end(t);
        }
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:24,代码来源:HTMLDocument.java

示例8: preContent

import javax.swing.text.html.HTML.Tag; //导入依赖的package包/类
/**
 * Adds the given text that was encountered in a <PRE> element.
 * This adds synthesized lines to hold the text runs.
 *
 * @param data the text
 */
protected void preContent(char[] data)
{
  int start = 0;
  for (int i = 0; i < data.length; i++)
    {
      if (data[i] == '\n')
        {
          addContent(data, start, i - start + 1);
          blockClose(HTML.Tag.IMPLIED);
          MutableAttributeSet atts = new SimpleAttributeSet();
          atts.addAttribute(CSS.Attribute.WHITE_SPACE, "pre");
          blockOpen(HTML.Tag.IMPLIED, atts);
          start = i + 1;
        }
    }
  if (start < data.length)
    {
      // Add remaining last line.
      addContent(data, start, data.length - start);
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:28,代码来源:HTMLDocument.java

示例9: blockOpen

import javax.swing.text.html.HTML.Tag; //导入依赖的package包/类
/**
 * Instructs the parse buffer to create a block element with the given
 * attributes.
 *
 * @param t the tag that requires opening a new block
 * @param attr the attribute set for the new block
 */
protected void blockOpen(HTML.Tag t, MutableAttributeSet attr)
{
  if (inImpliedParagraph())
    blockClose(HTML.Tag.IMPLIED);

  // Push the new tag on top of the stack.
  parseStack.push(t);

  DefaultStyledDocument.ElementSpec element;

  AbstractDocument.AttributeContext ctx = getAttributeContext();
  AttributeSet copy = attr.copyAttributes();
  copy = ctx.addAttribute(copy, StyleConstants.NameAttribute, t);
  element = new DefaultStyledDocument.ElementSpec(copy,
                           DefaultStyledDocument.ElementSpec.StartTagType);
  parseBuffer.addElement(element);
}
 
开发者ID:vilie,项目名称:javify,代码行数:25,代码来源:HTMLDocument.java

示例10: addSpecialElement

import javax.swing.text.html.HTML.Tag; //导入依赖的package包/类
/**
 * Adds content that is specified in the attribute set.
 *
 * @param t the HTML.Tag
 * @param a the attribute set specifying the special content
 */
protected void addSpecialElement(HTML.Tag t, MutableAttributeSet a)
{
  if (t != HTML.Tag.FRAME && ! inParagraph())
    {
      blockOpen(HTML.Tag.IMPLIED, new SimpleAttributeSet());
    }

  a.addAttribute(StyleConstants.NameAttribute, t);

  // The two spaces are required because some special elements like HR
  // must be broken. At least two characters are needed to break into the
  // two parts.
  DefaultStyledDocument.ElementSpec spec =
    new DefaultStyledDocument.ElementSpec(a.copyAttributes(),
      DefaultStyledDocument.ElementSpec.ContentType,
      new char[] {' '}, 0, 1 );
  parseBuffer.add(spec);
}
 
开发者ID:vilie,项目名称:javify,代码行数:25,代码来源:HTMLDocument.java

示例11: setInnerHTML

import javax.swing.text.html.HTML.Tag; //导入依赖的package包/类
/**
 * Replaces the children of the given element with the contents of
 * the string. The document must have an HTMLEditorKit.Parser set.
 * This will be seen as at least two events, n inserts followed by a remove.
 *
 * @param elem - the brance element whose children will be replaced
 * @param htmlText - the string to be parsed and assigned to element.
 * @throws BadLocationException
 * @throws IOException
 * @throws IllegalArgumentException - if elem is a leaf
 * @throws IllegalStateException - if an HTMLEditorKit.Parser has not been set
 */
public void setInnerHTML(Element elem, String htmlText)
  throws BadLocationException, IOException
{
  if (elem.isLeaf())
    throw new IllegalArgumentException("Element is a leaf");

  int start = elem.getStartOffset();
  int end = elem.getEndOffset();

  HTMLEditorKit.ParserCallback reader = getInsertingReader(
    end, 0, 0, HTML.Tag.BODY, elem);

  // TODO charset
  getParser().parse(new StringReader(htmlText), reader, true);

  // Remove the previous content
  remove(start, end - start);
}
 
开发者ID:vilie,项目名称:javify,代码行数:31,代码来源:HTMLDocument.java

示例12: setOuterHTML

import javax.swing.text.html.HTML.Tag; //导入依赖的package包/类
/**
   * Replaces the given element in the parent with the string. When replacing a
   * leaf, this will attempt to make sure there is a newline present if one is
   * needed. This may result in an additional element being inserted. This will
   * be seen as at least two events, n inserts followed by a remove. The
   * HTMLEditorKit.Parser must be set.
   *
   * @param elem - the branch element whose parent will be replaced
   * @param htmlText - the string to be parsed and assigned to elem
   * @throws BadLocationException
   * @throws IOException
   * @throws IllegalStateException - if parser is not set
   */
public void setOuterHTML(Element elem, String htmlText)
      throws BadLocationException, IOException
  {
    // Remove the current element:
    int start = elem.getStartOffset();
    int end = elem.getEndOffset();

    remove(start, end-start);

    HTMLEditorKit.ParserCallback reader = getInsertingReader(
      start, 0, 0, HTML.Tag.BODY, elem);

    // TODO charset
    getParser().parse(new StringReader(htmlText), reader, true);
  }
 
开发者ID:vilie,项目名称:javify,代码行数:29,代码来源:HTMLDocument.java

示例13: handleSimpleTag

import javax.swing.text.html.HTML.Tag; //导入依赖的package包/类
/**
 * This is a callback from the parser that should be routed to the
 * appropriate handler for the tag.
 * 
 * @param t the HTML.Tag that was encountered
 * @param a the attribute set
 * @param pos the position at which the tag was encountered
 */
public void handleSimpleTag(HTML.Tag t, MutableAttributeSet a, int pos)
{
  if (t == insertTag)
    insertTagEncountered = true;

  if (shouldInsert())
    {
      TagAction action = (TagAction) tagToAction.get(t);
      if (action != null)
        {
          action.start(t, a);
          action.end(t);
        }
    }
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:24,代码来源:HTMLDocument.java

示例14: blockOpen

import javax.swing.text.html.HTML.Tag; //导入依赖的package包/类
/**
 * Instructs the parse buffer to create a block element with the given 
 * attributes.
 * 
 * @param t the tag that requires opening a new block
 * @param attr the attribute set for the new block
 */
protected void blockOpen(HTML.Tag t, MutableAttributeSet attr)
{
  if (inImpliedParagraph())
    blockClose(HTML.Tag.IMPLIED);

  // Push the new tag on top of the stack.
  parseStack.push(t);

  DefaultStyledDocument.ElementSpec element;

  AbstractDocument.AttributeContext ctx = getAttributeContext();
  AttributeSet copy = attr.copyAttributes();
  copy = ctx.addAttribute(copy, StyleConstants.NameAttribute, t);
  element = new DefaultStyledDocument.ElementSpec(copy,
                           DefaultStyledDocument.ElementSpec.StartTagType);
  parseBuffer.addElement(element);
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:25,代码来源:HTMLDocument.java

示例15: addSpecialElement

import javax.swing.text.html.HTML.Tag; //导入依赖的package包/类
/**
  * Adds content that is specified in the attribute set.
  * 
  * @param t the HTML.Tag
  * @param a the attribute set specifying the special content
  */
 protected void addSpecialElement(HTML.Tag t, MutableAttributeSet a)
 {
   if (t != HTML.Tag.FRAME && ! inParagraph())
     {
       blockOpen(HTML.Tag.IMPLIED, new SimpleAttributeSet());
     }

   a.addAttribute(StyleConstants.NameAttribute, t);
   
   // The two spaces are required because some special elements like HR
   // must be broken. At least two characters are needed to break into the
   // two parts.
   DefaultStyledDocument.ElementSpec spec =
     new DefaultStyledDocument.ElementSpec(a.copyAttributes(),
DefaultStyledDocument.ElementSpec.ContentType, 
       new char[] {' '}, 0, 1 );
   parseBuffer.add(spec);
 }
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:25,代码来源:HTMLDocument.java


注:本文中的javax.swing.text.html.HTML.Tag类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。