當前位置: 首頁>>代碼示例>>Java>>正文


Java MutableAttributeSet.getAttribute方法代碼示例

本文整理匯總了Java中javax.swing.text.MutableAttributeSet.getAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Java MutableAttributeSet.getAttribute方法的具體用法?Java MutableAttributeSet.getAttribute怎麽用?Java MutableAttributeSet.getAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.text.MutableAttributeSet的用法示例。


在下文中一共展示了MutableAttributeSet.getAttribute方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleStartTag

import javax.swing.text.MutableAttributeSet; //導入方法依賴的package包/類
public @Override void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) {

            if ( t == HTML.Tag.DT ) {
                where = IN_DT;
                currentDii = null;
            }
            else if ( t == HTML.Tag.A && where == IN_DT ) {
                where = IN_AREF;
                Object val = a.getAttribute( HTML.Attribute.HREF );
                if ( val != null ) {
                    hrefVal = val.toString();
                    currentDii = new DocIndexItem( null, null, contextURL, hrefVal );
                }
            }
            else if ( t == HTML.Tag.A && (where == IN_DESCRIPTION_SUFFIX || where == IN_DESCRIPTION) ) {
                // Just ignore
            }
            else if ( (t == HTML.Tag.B || t == HTML.Tag.SPAN)/* && where == IN_AREF */) {
                /*where = IN_AREF;*/
                // Ignore formatting
            }
            else {
                where = IN_BALAST;
            }
        }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:SearchThreadJdk12.java

示例2: handleStartTag

import javax.swing.text.MutableAttributeSet; //導入方法依賴的package包/類
public @Override void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) {

            if ( t == HTML.Tag.DT ) {
                where = IN_DT;
                currentDii = null;
            }
            else if ( t == HTML.Tag.A && where == IN_DT ) {
                where = IN_AREF;
                Object val = a.getAttribute( HTML.Attribute.HREF );
                if ( val != null ) {
                    hrefVal = val.toString();
                    currentDii = new DocIndexItem( null, null, contextURL, hrefVal );
                }
            }
            else if ( t == HTML.Tag.A && (where == IN_DESCRIPTION_SUFFIX || where == IN_DESCRIPTION) ) {
                // Just ignore
            }
            else if ( (t == HTML.Tag.B || t == HTML.Tag.SPAN) && where == IN_AREF ) {
                where = IN_AREF;
            }
            else {
                where = IN_BALAST;
            }
        }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:SearchThreadJdk12_japan.java

示例3: handleSimpleTag

import javax.swing.text.MutableAttributeSet; //導入方法依賴的package包/類
public @Override void handleSimpleTag(HTML.Tag t, MutableAttributeSet a, int pos) {
    if (t == HTML.Tag.META) {
        String value = (String) a.getAttribute(HTML.Attribute.CONTENT);
        if (value != null) {
            StringTokenizer tk = new StringTokenizer(value,";"); // NOI18N
            while (tk.hasMoreTokens()) {
                String str = tk.nextToken().trim();
                if (str.startsWith("charset")) {        //NOI18N
                    str = str.substring(7).trim();
                    if (str.charAt(0)=='=') {
                        this.encoding = str.substring(1).trim();
                        try {
                            this.in.close();
                        } catch (IOException ioe) {/*Ignore it*/}
                        return;                                
                    }
                }
            }
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:JavadocRegistry.java

示例4: createFontAttribute

import javax.swing.text.MutableAttributeSet; //導入方法依賴的package包/類
/**
 * Create/update an HTML <font> tag attribute.  The
 * value of the attribute should be a MutableAttributeSet so
 * that the attributes can be updated as they are discovered.
 */
private static void createFontAttribute(CSS.Attribute a, AttributeSet from, MutableAttributeSet to) {
    MutableAttributeSet fontAttr = (MutableAttributeSet) to.getAttribute(HTML.Tag.FONT);
    if (fontAttr == null) {
        fontAttr = new SimpleAttributeSet();
        to.addAttribute(HTML.Tag.FONT, fontAttr);
    }
    // edit the parameters to the font tag
    String htmlValue = from.getAttribute(a).toString();
    if (a == CSS.Attribute.FONT_FAMILY) {
        fontAttr.addAttribute(HTML.Attribute.FACE, htmlValue);
    }
    else if (a == CSS.Attribute.FONT_SIZE) {
        fontAttr.addAttribute(HTML.Attribute.SIZE, htmlValue);
    }
    else if (a == CSS.Attribute.COLOR) {
        fontAttr.addAttribute(HTML.Attribute.COLOR, htmlValue);
    }
}
 
開發者ID:cst316,項目名稱:spring16project-Modula-2,代碼行數:24,代碼來源:AltHTMLWriter.java

示例5: createFontAttribute

import javax.swing.text.MutableAttributeSet; //導入方法依賴的package包/類
/**
 * Create/update an HTML <font> tag attribute. The value of the
 * attribute should be a MutableAttributeSet so that the attributes can be
 * updated as they are discovered.
 */
private static void createFontAttribute(CSS.Attribute a, AttributeSet from, MutableAttributeSet to) {
	MutableAttributeSet fontAttr = (MutableAttributeSet) to.getAttribute(HTML.Tag.FONT);
	if (fontAttr == null) {
		fontAttr = new SimpleAttributeSet();
		to.addAttribute(HTML.Tag.FONT, fontAttr);
	}
	// edit the parameters to the font tag
	String htmlValue = from.getAttribute(a).toString();
	if (a == CSS.Attribute.FONT_FAMILY) {
		fontAttr.addAttribute(HTML.Attribute.FACE, htmlValue);
	} else if (a == CSS.Attribute.FONT_SIZE) {
		fontAttr.addAttribute(HTML.Attribute.SIZE, htmlValue);
	} else if (a == CSS.Attribute.COLOR) {
		fontAttr.addAttribute(HTML.Attribute.COLOR, htmlValue);
	}
}
 
開發者ID:cst316,項目名稱:spring16project-Fortran,代碼行數:22,代碼來源:AltHTMLWriter.java

示例6: handleStartTag

import javax.swing.text.MutableAttributeSet; //導入方法依賴的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

示例7: start

import javax.swing.text.MutableAttributeSet; //導入方法依賴的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

示例8: handleSimpleTag

import javax.swing.text.MutableAttributeSet; //導入方法依賴的package包/類
public void handleSimpleTag(HTML.Tag t, MutableAttributeSet a, int pos) {
    String href = (String) a.getAttribute(HTML.Attribute.HREF);

    if ((href == null) && (t == HTML.Tag.FRAME))
        href = (String) a.getAttribute(HTML.Attribute.SRC);

    if (href == null)
        return;

    int i = href.indexOf('#');
    if (i != -1)
        href = href.substring(0, i);

    if (href.toLowerCase().startsWith("mailto:"))
        return;

    handleLink(base, href);
}
 
開發者ID:FreedomZZQ,項目名稱:crawler-java,代碼行數:19,代碼來源:Crawler.java

示例9: setDefault

import javax.swing.text.MutableAttributeSet; //導入方法依賴的package包/類
public boolean setDefault(MutableAttributeSet target)
{
    if (swingDefault != rtfDefault ||
        ( target.getAttribute(swingName) != null ) )
      target.addAttribute(swingName, Boolean.valueOf(rtfDefault));
    return true;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:8,代碼來源:RTFAttributes.java

示例10: handleSimpleTag

import javax.swing.text.MutableAttributeSet; //導入方法依賴的package包/類
@Override
public void handleSimpleTag(Tag tag, MutableAttributeSet att, int pos)
{
	if (tag.equals(HTML.Tag.META))
	{
		String nameAttribute = (String) att.getAttribute(HTML.Attribute.NAME);
		String contentAttribute = (String) att.getAttribute(HTML.Attribute.CONTENT);
		if ("keywords".equalsIgnoreCase(nameAttribute) && contentAttribute != null)
		{
			searchWords(contentAttribute);
		}
	}
}
 
開發者ID:valsr,項目名稱:SweetHome3D,代碼行數:14,代碼來源:HelpController.java

示例11: handleStartTag

import javax.swing.text.MutableAttributeSet; //導入方法依賴的package包/類
public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) {
	if (t == HTML.Tag.A) {
		skipLink = false;
		m_CurrentFile = (String)a.getAttribute(HTML.Attribute.HREF);
	}
}
 
開發者ID:hyounesy,項目名稱:ChAsE,代碼行數:7,代碼來源:UrlCrawler.java

示例12: translateTag

import javax.swing.text.MutableAttributeSet; //導入方法依賴的package包/類
/**
 * Translate the HTML character attribute to the Swing style constant.
 *
 * @param charAttr the character attributes of the html tag
 * @param t the html tag itself
 * @param a the attribute set where the translated attributes will be stored
 *
 * @return true if some attributes were translated, false otherwise.
 */
public static boolean translateTag(MutableAttributeSet charAttr,
                                   Tag t, MutableAttributeSet a)
{
  if(t == Tag.FONT)
    {
      Object color = a.getAttribute(Attribute.COLOR);
      if(color != null)
        {
          Color c = getColor(color.toString());
          if( c == null )
            return false;
          charAttr.addAttribute(StyleConstants.Foreground, c);
          return true;
        }

      if(a.getAttribute(Attribute.SIZE) != null)
        {
          // FIXME
          //      charAttr.addAttribute(StyleConstants.FontSize,
          //                            new java.lang.Integer(72));
          return true;
        }
    }

  if( t == Tag.B )
    {
      charAttr.addAttribute(StyleConstants.Bold, Boolean.TRUE);
      return true;
    }

  if( t == Tag.I )
    {
      charAttr.addAttribute(StyleConstants.Italic, Boolean.TRUE);
      return true;
    }

  if( t == Tag.U )
    {
      charAttr.addAttribute(StyleConstants.Underline, Boolean.TRUE);
      return true;
    }

  if( t == Tag.STRIKE )
    {
      charAttr.addAttribute(StyleConstants.StrikeThrough, Boolean.TRUE);
      return true;
    }

  if( t == Tag.SUP )
    {
      charAttr.addAttribute(StyleConstants.Superscript, Boolean.TRUE);
      return true;
    }

  if( t == Tag.SUB )
    {
      charAttr.addAttribute(StyleConstants.Subscript, Boolean.TRUE);
      return true;
    }
  return false;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:71,代碼來源:CharacterAttributeTranslator.java


注:本文中的javax.swing.text.MutableAttributeSet.getAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。