本文整理了Java中javax.swing.text.MutableAttributeSet
类的一些代码示例,展示了MutableAttributeSet
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MutableAttributeSet
类的具体详情如下:
包路径:javax.swing.text.MutableAttributeSet
类名称:MutableAttributeSet
暂无
代码示例来源:origin: stackoverflow.com
class Page extends HTMLEditorKit.ParserCallback {
public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) {
if (t == HTML.Tag.A) {
String link = null;
Enumeration<?> attributeNames = a.getAttributeNames();
if (attributeNames.nextElement().equals(HTML.Attribute.HREF))
link = a.getAttribute(HTML.Attribute.HREF).toString();
//save link some where
}
}
}
代码示例来源:origin: chatty/chatty
public MutableAttributeSet banMessage(User user, String message) {
MutableAttributeSet style = new SimpleAttributeSet(standard());
style.addAttribute(Attribute.IS_BAN_MESSAGE, user);
style.addAttribute(Attribute.TIMESTAMP, System.currentTimeMillis());
style.addAttribute(Attribute.BAN_MESSAGE, message);
return style;
}
代码示例来源:origin: org.apache.maven.doxia/doxia-module-xdoc
/**
* The default align is <code>center</code>.
*
* {@inheritDoc}
* @see javax.swing.text.html.HTML.Tag#TABLE
*/
public void tableRows( int[] justification, boolean grid )
{
// similar to super.tableRows( justification, grid ) but without class.
this.tableRows = true;
setCellJustif( justification );
if ( this.tableAttributes == null )
{
this.tableAttributes = new SinkEventAttributeSet( 0 );
}
MutableAttributeSet att = new SinkEventAttributeSet();
if ( !tableAttributes.isDefined( Attribute.BORDER.toString() ) )
{
att.addAttribute( Attribute.BORDER, ( grid ? "1" : "0" ) );
}
att.addAttributes( tableAttributes );
tableAttributes.removeAttributes( tableAttributes );
writeStartTag( TABLE, att );
}
代码示例来源:origin: chatty/chatty
private void addBy(MutableAttributeSet attributes, String byName) {
java.util.List<String> old = (java.util.List)attributes.getAttribute(Attribute.ACTION_BY);
java.util.List<String> changed;
if (old != null) {
changed = new ArrayList<>(old);
} else {
changed = new ArrayList<>();
}
// If already present, append to end
changed.remove(byName);
changed.add(byName);
attributes.addAttribute(Attribute.ACTION_BY, changed);
}
代码示例来源:origin: girtel/Net2Plan
@Override
protected void writeAttributes(AttributeSet attr) throws IOException
{
convAttr.removeAttributes(convAttr);
convertToHTML(attr, convAttr);
Enumeration names = convAttr.getAttributeNames();
while (names.hasMoreElements())
{
Object name = names.nextElement();
if (name instanceof HTML.Tag || name instanceof StyleConstants || name == HTML.Attribute.ENDTAG) continue;
write(" " + name + "=\"" + convAttr.getAttribute(name) + "\"");
}
}
}
代码示例来源:origin: stackoverflow.com
public class BackgroundColorAction extends StyledEditorKit.StyledTextAction {
private Color color;
public BackgroundColorAction(Color color) {
super(StyleConstants.Background.toString());
this.color = color;
}
@Override
public void actionPerformed(ActionEvent ae) {
JEditorPane editor = getEditor(ae);
if (editor == null) {
return;
}
//Add span Tag
String htmlStyle = "background-color:" + Util.getHTMLColor(color);
SimpleAttributeSet attr = new SimpleAttributeSet();
attr.addAttribute(HTML.Attribute.STYLE, htmlStyle);
MutableAttributeSet outerAttr = new SimpleAttributeSet();
outerAttr.addAttribute(HTML.Tag.SPAN, attr);
//Next line is just an instruction to editor to change color
StyleConstants.setBackground(outerAttr, this.color);
setCharacterAttributes(editor, outerAttr, false);
}
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
public void actionPerformed(ActionEvent e)
{
if(!(this.isEnabled()))
{
return;
}
JEditorPane editor = getEditor(e);
if(editor != null)
{
String stylename = (String)(parent.getSelectedItem());
if(stylename == null)
{
return;
}
else if(stylename.equals(Translatrix.getTranslationString("NoCSSStyle")))
{
return;
}
boolean replace = false;
MutableAttributeSet attr = null;
SimpleAttributeSet cls = new SimpleAttributeSet();
cls.addAttribute(HTML.Attribute.CLASS, stylename);
attr = new SimpleAttributeSet();
attr.addAttribute(HTML.Tag.FONT, cls);
MutableAttributeSet inattr = ((HTMLEditorKit)(editor.getEditorKitForContentType("text/html"))).getInputAttributes();
inattr.addAttributes(attr);
setCharacterAttributes(editor, attr, replace);
}
}
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
public void actionPerformed(ActionEvent ae) {
JTextPane parentTextPane = parentEkit.getTextPane();
String selText = parentTextPane.getSelectedText();
int textLength = -1;
if (selText != null) {
textLength = selText.length();
}
if (selText == null || textLength < 1) {
return;
}
JEditorPane editor = getEditor(ae);
if (editor != null) {
StyledEditorKit kit = getStyledEditorKit(editor);
MutableAttributeSet attr = kit.getInputAttributes();
boolean newValue = (attr.getAttribute(htmlTag) == Boolean.TRUE) ? false : true;
SimpleAttributeSet sas = new SimpleAttributeSet();
sas.addAttribute(htmlTag, Boolean.valueOf(newValue));
//StyleConstants.setUnderline(sas, newValue);
setCharacterAttributes(editor, sas, false);
}
}
}
代码示例来源:origin: org.piccolo2d/piccolo2d-core
clientProperties = new SimpleAttributeSet();
clientProperties.removeAttribute(key);
clientProperties.addAttribute(key, value);
if (clientProperties.getAttributeCount() == 0 && clientProperties.getResolveParent() == null) {
clientProperties = null;
代码示例来源:origin: igniterealtime/Spark
/**
* Inserts a link into the current document.
*
* @param link - the link to insert( ex. http://www.javasoft.com )
* @throws BadLocationException if the location is not available for insertion.
*/
public void insertLink( Document doc, String link ) throws BadLocationException
{
// Create a new style, based on the style used for generic text, for the link.
final MutableAttributeSet linkStyle = new SimpleAttributeSet( getMessageStyle().copyAttributes() );
StyleConstants.setForeground( linkStyle, (Color) UIManager.get( "Link.foreground" ) );
StyleConstants.setUnderline( linkStyle, true );
linkStyle.addAttribute( "link", link );
doc.insertString( doc.getLength(), link, linkStyle );
}
代码示例来源:origin: igniterealtime/Spark
public MutableAttributeSet applyMessageStyle( char directive, MutableAttributeSet messageStyle )
{
final MutableAttributeSet style = new SimpleAttributeSet( messageStyle.copyAttributes() );
switch ( directive )
{
case '*':
StyleConstants.setBold( style, true );
break;
case '_':
StyleConstants.setItalic( style, true );
break;
case '~':
StyleConstants.setStrikeThrough( style, true );
break;
case '`':
StyleConstants.setFontFamily( style, "Monospaced" );
break;
case 'K': // Keyword
StyleConstants.setForeground( style, ((Color) messageStyle.getAttribute( Foreground )).brighter().brighter().brighter() );
break;
default:
Log.warning( "Cannot apply message style for unrecognized directive: " + directive );
}
return style;
}
代码示例来源:origin: pentaho/pentaho-reporting
continue;
} else {
SimpleAttributeSet hrefAttributeSet = new SimpleAttributeSet();
hrefAttributeSet.addAttribute( HTML.Attribute.HREF, attr.getAttribute( HTML.Attribute.HREF ) );
muxList.add( hrefAttributeSet );
final MutableAttributeSet retval = new SimpleAttributeSet();
for ( int i = muxList.size() - 1; i >= 0; i-- ) {
final AttributeSet o = muxList.get( i );
retval.addAttributes( o );
代码示例来源:origin: org.apache.airavata/airavata-workflow-model-core
/**
* @see javax.swing.text.html.HTMLEditorKit.ParserCallback#handleStartTag(javax.swing.text.html.HTML.Tag,
* javax.swing.text.MutableAttributeSet, int)
*/
@Override
public void handleStartTag(Tag tag, MutableAttributeSet attrSet, int pos) {
if (tag == HTML.Tag.A) {
String name = (String) attrSet.getAttribute(HTML.Attribute.HREF);
addComponents(name);
}
}
}
代码示例来源:origin: stackoverflow.com
private Vector tagValues = new Vector(10);
private Vector tagsToRemove = new Vector(10);
private MutableAttributeSet convAttr = new SimpleAttributeSet();
private MutableAttributeSet oConvAttr = new SimpleAttributeSet();
to.removeAttributes(to);
if (from != null)
to.addAttribute(key, from.getAttribute(key));
to.addAttribute(HTML.Attribute.STYLE, value);
protected void writeAttributes(AttributeSet attr) throws IOException
convAttr.removeAttributes(convAttr);
convertToHTML(attr, convAttr);
Enumeration names = convAttr.getAttributeNames();
代码示例来源:origin: org.apache.maven.doxia/doxia-module-twiki
/** {@inheritDoc} */
public void verbatim( SinkEventAttributes attributes )
{
MutableAttributeSet atts = SinkUtils.filterAttributes( attributes, SinkUtils.SINK_VERBATIM_ATTRIBUTES );
if ( atts == null )
{
atts = new SinkEventAttributeSet();
}
boolean boxed = false;
if ( atts.isDefined( SinkEventAttributes.DECORATION ) )
{
boxed = "boxed".equals( atts.getAttribute( SinkEventAttributes.DECORATION ).toString() );
}
if ( boxed )
{
atts.addAttribute( Attribute.CLASS, "source" );
}
atts.removeAttribute( SinkEventAttributes.DECORATION );
String width = (String) atts.getAttribute( Attribute.WIDTH.toString() );
atts.removeAttribute( Attribute.WIDTH.toString() );
writeStartTag( Tag.DIV, atts );
writeEOL( true );
if ( width != null )
{
atts.addAttribute( Attribute.WIDTH.toString(), width );
}
atts.removeAttribute( Attribute.ALIGN.toString() );
atts.removeAttribute( Attribute.CLASS.toString() );
writeStartTag( VERBATIM_TAG, atts );
}
代码示例来源:origin: stackoverflow.com
final SimpleAttributeSet set = new SimpleAttributeSet();
StyleConstants.setForeground(set, Color.RED);
int p0 = textPane2.getSelectionStart();
textPane2.getCaret().setDot(textPane2.getText().length());
MutableAttributeSet inputAttributes = textPane2.getInputAttributes();
inputAttributes.addAttributes(set);
代码示例来源:origin: stackoverflow.com
getContentPane().add(contentPanel);
set = new SimpleAttributeSet();
StyleConstants.setFontFamily(set, "Courier New");
StyleConstants.setForeground(set, Color.GREEN);
k.getInputAttributes().removeAttributes(set);
代码示例来源:origin: RPTools/maptool
/**
* Sets the background color.
*
* @param a the attribute set
* @param fg the color
*/
public static void setTwoToneColor(MutableAttributeSet a, Color fg) {
a.addAttribute(TwoToneColor, fg);
}
代码示例来源:origin: org.apache.maven.doxia/doxia-module-fo
private SinkEventAttributeSet getGraphicsAttributes( String logo )
{
MutableAttributeSet atts = null;
try
{
atts = DoxiaUtils.getImageAttributes( logo );
}
catch ( IOException e )
{
getLog().debug( e );
}
if ( atts == null )
{
return new SinkEventAttributeSet( new String[]{ SinkEventAttributes.HEIGHT, COVER_HEADER_HEIGHT } );
}
// FOP dpi: 72
// Max width : 3.125 inch, table cell size, see #coverPage()
final int maxWidth = 225; // 3.125 * 72
if ( Integer.parseInt( atts.getAttribute( SinkEventAttributes.WIDTH ).toString() ) > maxWidth )
{
atts.addAttribute( "content-width", "3.125in" );
}
return new SinkEventAttributeSet( atts );
}
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
changes.addEdit(new AttributeUndoableEdit(e, sCopy, false));
MutableAttributeSet attr = (MutableAttributeSet) e.getAttributes();
Enumeration aNames = attr.getAttributeNames();
Object value;
Object aName;
while (aNames.hasMoreElements()) {
aName = aNames.nextElement();
value = attr.getAttribute(aName);
if (value != null && !value.toString().equalsIgnoreCase(tag.toString())) {
attr.removeAttribute(aName);
attr.addAttributes(a);
changes.end();
fireChangedUpdate(changes);
内容来源于网络,如有侵权,请联系作者删除!