java-gnome version 4.0.15

org.gnome.pango
Class AttributeList

Object
  extended by org.freedesktop.bindings.Pointer
      extended by org.gnome.glib.Boxed
          extended by org.gnome.pango.AttributeList

public final class AttributeList
extends Boxed

A list of Attributes that will be applied to a piece of text.

Used as follows. First, build your text up into a String and initialize the Layout with it. You'll also have to create the wrapper that will hold the list of Attributes that will be applied to that Layout.

 layout = new Layout(cr);
 layout.setText(str);
 
 list = new AttributeList();
 
Then, iterate over your text and for each span where you want formatting, create one or more Attributes and specify the ranges that each will apply. For instance, for a word starting at offset 15 and being 4 characters wide.
 attr = new StyleAttribute(Style.ITALIC);
 attr.setIndexes(15, 4);
 list.insert(attr);
 
 attr = new ForegroundColorAttribute(0.1, 0.5, 0.9);
 attr.setIndexes(15, 4);
 list.insert(attr);
 
etc, adding each one to the AttributeList. Finally, tell the Layout to use that list:
 layout.setAttributes(list);
 
and you're on your way.

Since:
4.0.10
Author:
Andrew Cowie

Constructor Summary
AttributeList()
          Create an AttributeList.
 
Method Summary
 void insert(Attribute attr)
          Insert an Attribute into this list.
 void insertBefore(Attribute attr)
          Insert an Attribute into this list.
 
Methods inherited from class org.freedesktop.bindings.Pointer
toString
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AttributeList

public AttributeList()
Create an AttributeList. You'll want a new one for each paragraph of text you render.

Since:
4.0.10
Method Detail

insert

public void insert(Attribute attr)
Insert an Attribute into this list. It will be inserted after any other Attributes already in the list possessing the same start index.

Throws:
IllegalStateException - If you attempt to reuse an Attribute that is already in an AttributeList.
Since:
4.0.10

insertBefore

public void insertBefore(Attribute attr)
Insert an Attribute into this list. Same as insert() except that the Attribute will come before other Attributes already in the list possessing the same start index.

Throws:
IllegalStateException - If you attempt to reuse an Attribute that is already in an AttributeList.
Since:
4.0.10


java-gnome