* Creates a Chunk object based on a list of properties.
* @param attributes
* @return a Chunk
*/
public static Chunk getChunk(Properties attributes) {
Chunk chunk = new Chunk();
chunk.setFont(FontFactory.getFont(attributes));
String value;
value = attributes.getProperty(ElementTags.ITEXT);
if (value != null) {
chunk.append(value);
}
value = attributes.getProperty(ElementTags.LOCALGOTO);
if (value != null) {
chunk.setLocalGoto(value);
}
value = attributes.getProperty(ElementTags.REMOTEGOTO);
if (value != null) {
String page = attributes.getProperty(ElementTags.PAGE);
if (page != null) {
chunk.setRemoteGoto(value, Integer.parseInt(page));
} else {
String destination = attributes
.getProperty(ElementTags.DESTINATION);
if (destination != null) {
chunk.setRemoteGoto(value, destination);
}
}
}
value = attributes.getProperty(ElementTags.LOCALDESTINATION);
if (value != null) {
chunk.setLocalDestination(value);
}
value = attributes.getProperty(ElementTags.SUBSUPSCRIPT);
if (value != null) {
chunk.setTextRise(Float.parseFloat(value + "f"));
}
value = attributes.getProperty(Markup.CSS_KEY_VERTICALALIGN);
if (value != null && value.endsWith("%")) {
float p = Float.parseFloat(value.substring(0, value.length() - 1)
+ "f") / 100f;
chunk.setTextRise(p * chunk.getFont().getSize());
}
value = attributes.getProperty(ElementTags.GENERICTAG);
if (value != null) {
chunk.setGenericTag(value);
}
value = attributes.getProperty(ElementTags.BACKGROUNDCOLOR);
if (value != null) {
chunk.setBackground(Markup.decodeColor(value));
}
return chunk;
}