Example for using CSS Styles Filter

Oxygen general issues.
dylan
Posts: 15
Joined: Thu Feb 26, 2009 12:12 am

Example for using CSS Styles Filter

Post by dylan »

Can anyone provide an small example of how to work with the StylesFilter interface?

Many thanks,

/d
Radu
Posts: 9434
Joined: Fri Jul 09, 2004 5:18 pm

Re: Example for using CSS Styles Filter

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
dylan
Posts: 15
Joined: Thu Feb 26, 2009 12:12 am

Re: Example for using CSS Styles Filter

Post by dylan »

Thanks Radu,

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

Thoughts?
Radu
Posts: 9434
Joined: Fri Jul 09, 2004 5:18 pm

Re: Example for using CSS Styles Filter

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply