Page 1 of 1

Example for using CSS Styles Filter

Posted: Fri Apr 24, 2009 2:27 am
by dylan
Can anyone provide an small example of how to work with the StylesFilter interface?

Many thanks,

/d

Re: Example for using CSS Styles Filter

Posted: Fri Apr 24, 2009 11:29 am
by Radu
Hi Dylan,

See an example below:

Code: Select all


  /**
* @see ro.sync.ecss.extensions.api.StylesFilter#filter(ro.sync.ecss.css.Styles, ro.sync.ecss.extensions.api.node.AuthorNode)
*/
public ro.sync.ecss.css.Styles filter(Styles styles, AuthorNode authorNode) {
//Use font size of 8 for "para"
if(authorNode.getName().equals("para")) {
ro.sync.exml.view.graphics.Font original = styles.getFont();
ro.sync.exml.view.graphics.Font modified = new ro.sync.exml.view.graphics.Font(original.getName(), original.getStyle(), 8);
styles.setProperty(Styles.KEY_FONT, modified);
}
//Use foreground color red for "bold"
if(authorNode.getName().equals("bold")) {
ro.sync.exml.view.graphics.Color red = ro.sync.exml.view.graphics.Color.COLOR_RED;
styles.setProperty(Styles.KEY_FOREGROUND_COLOR, red);
}
//Use left border width of 5 pixels for "italic"
if(authorNode.getName().equals("italic")) {
styles.setProperty(Styles.KEY_BORDER_LEFT_WIDTH, new Integer(5));
}
return styles;
}
Basically you first check what class is expected for the value which you want to set by calling the getter for that property and then you can overwrite the property with the new value.

Regards,
Radu

Re: Example for using CSS Styles Filter

Posted: Fri Apr 24, 2009 7:10 pm
by dylan
Thanks Radu,

Unfortunately, it appears that ro.sync.exml.view has been obfuscated!

Thoughts?

Re: Example for using CSS Styles Filter

Posted: Mon Apr 27, 2009 10:45 am
by Radu
Hi Dylan,

Indeed, the package is obfuscated in 10.2 and you cannot access the Font or Color.
We'll correct this and contact you for more details.

Regards,
Radu