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


Java MutableAttributeSet類代碼示例

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


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

示例1: convertToHTML40

import javax.swing.text.MutableAttributeSet; //導入依賴的package包/類
/**
 * Copies the given AttributeSet to a new set, converting
 * any CSS attributes found to arguments of an HTML style
 * attribute.
 */
private static void convertToHTML40(AttributeSet from, MutableAttributeSet to) {
    Enumeration keys = from.getAttributeNames();
    String value = "";
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        if (key instanceof CSS.Attribute) {
            value = value + " " + key + "=" + from.getAttribute(key) + ";";
        }
        else {
            to.addAttribute(key, from.getAttribute(key));
        }
    }
    if (value.length() > 0) {
        to.addAttribute(HTML.Attribute.STYLE, value);
    }
}
 
開發者ID:ser316asu,項目名稱:Neukoelln_SER316,代碼行數:22,代碼來源:AltHTMLWriter.java

示例2: add

import javax.swing.text.MutableAttributeSet; //導入依賴的package包/類
public static AttrSet add(Context context, Object... keyValuePairs) throws Exception {
    @SuppressWarnings("unchecked")
    List<Item> list = (List<Item>) context.getInstance(List.class);
    MutableAttributeSet expected = new SimpleAttributeSet();
    for (int i = keyValuePairs.length; i > 0;) {
        Object value = keyValuePairs[--i];
        Object key = keyValuePairs[--i];
        expected.addAttribute(key, value);
    }
    AttrSet attrSet = AttrSet.get(keyValuePairs);
    Item item = new Item(expected, attrSet);
    list.add(item);
    StringBuilder sb = context.logOpBuilder();
    if (sb != null) {
        sb.append("Add[").append(list.size() - 1).append("]: ").append(expected);
        context.logOp(sb);
    }
    return attrSet;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:AttrSetTesting.java

示例3: handleStartTag

import javax.swing.text.MutableAttributeSet; //導入依賴的package包/類
@Override
public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) {
    String tag = t.toString();
    if (logger.isLoggable(Level.FINE)) {
        logger.log(Level.FINE, "StartTag <{0}> with attributes: {1}",
                   new Object[]{ tag, Collections.list(a.getAttributeNames()).toString() });
    }
    if (TAG_TITLE.equalsIgnoreCase(tag)) {
        readingTitle = true;
        return ;
    } else {
        readingTitle = false;
    }
    if (TAG_FORM.equalsIgnoreCase(tag)) {
        readingForm = true;
        inputs.clear();
        inputs.add(new SimpleAttributeSet(a));
        return ;
    }
    if (readingForm) {
        if (TAG_INPUT.equalsIgnoreCase(tag)) {
            inputs.add(new SimpleAttributeSet(a));
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:ButtonsHTMLParser.java

示例4: 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

示例5: 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

示例6: 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

示例7: do_setFont

import javax.swing.text.MutableAttributeSet; //導入依賴的package包/類
/** Changes the font and tabsize for the document. */
public final void do_setFont(String fontName, int fontSize, int tabSize) {
   if (tabSize < 1) tabSize = 1; else if (tabSize > 100) tabSize = 100;
   if (fontName.equals(this.font) && fontSize == this.fontSize && tabSize == this.tabSize) return;
   this.font = fontName;
   this.fontSize = fontSize;
   this.tabSize = tabSize;
   for(MutableAttributeSet s: all) { StyleConstants.setFontFamily(s, fontName);  StyleConstants.setFontSize(s, fontSize); }
   do_reapplyAll();
   BufferedImage im = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB); // this is used to derive the tab width
   int gap = tabSize * im.createGraphics().getFontMetrics(new Font(fontName, Font.PLAIN, fontSize)).charWidth('X');
   TabStop[] pos = new TabStop[100];
   for(int i=0; i<100; i++) { pos[i] = new TabStop(i*gap + gap); }
   StyleConstants.setTabSet(tabset, new TabSet(pos));
   setParagraphAttributes(0, getLength(), tabset, false);
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:17,代碼來源:OurSyntaxDocument.java

示例8: createFontAttribute

import javax.swing.text.MutableAttributeSet; //導入依賴的package包/類
/**
 * Create/update an HTML &lt;font&gt; 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

示例9: 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

示例10: addSpecialElement

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

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

示例12: preContent

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

示例13: createFontAttribute

import javax.swing.text.MutableAttributeSet; //導入依賴的package包/類
/**
 * Create/update an HTML &lt;font&gt; 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

示例14: convertToHTML40

import javax.swing.text.MutableAttributeSet; //導入依賴的package包/類
/**
 * Copies the given AttributeSet to a new set, converting any CSS attributes
 * found to arguments of an HTML style attribute.
 */
private static void convertToHTML40(AttributeSet from, MutableAttributeSet to) {
	Enumeration keys = from.getAttributeNames();
	String value = "";
	while (keys.hasMoreElements()) {
		Object key = keys.nextElement();
		if (key instanceof CSS.Attribute) {
			value = value + " " + key + "=" + from.getAttribute(key) + ";";
		} else {
			to.addAttribute(key, from.getAttribute(key));
		}
	}
	if (value.length() > 0) {
		to.addAttribute(HTML.Attribute.STYLE, value);
	}
}
 
開發者ID:cst316,項目名稱:spring16project-Fortran,代碼行數:20,代碼來源:AltHTMLWriter.java

示例15: 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


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