本文整理匯總了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;
}
}
示例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;
}
}
示例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;
}
}
}
}
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
示例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;
}