Search
Monday, January 05, 2009 ..:: Forum ::.. Register  Login
 
  Forum  Templates  Tags & Template...  Dynamic font coloring based on content?
Previous Previous
 
Next Next
New Post 7/29/2008 10:18 AM
Resolved
  villelm
2 posts
www.truarx.com
No Ranking


Dynamic font coloring based on content? 

Is it possible to dynamically change the color of content without a series of wr:if tags to compare text values?

I've got content like:

<Nodes>
   <node name="rednode" value="2"/>
   <node name="bluenode" value="3"/>
   <node name="orangenode" value="4"/>
</Nodes>

<content>
   <row name="ben" value="2">
   <row name="ryan" value="3">
</content>

where I'm iterating through the content rows and printing out the name attributes, but I'd like them to be color coded, based upon joining them with the corresponding <node> node where the values are equal?

example:  

Ben (would be red)
ryan (would be blue) 

 
New Post 7/29/2008 10:42 AM
  rfligg
43 posts
7th Level Poster


Re: Dynamic font coloring based on content? 

Villem,

 

Currently changing the color of text can only be done using Java Beans.  We include an example in our RedNegative.java Bean example.  The link to this example and wiki article is located is here:  http://ohana.windward.net/Wiki/tabid/57/topic/Using%20beans%20in%20your%20template/Default.aspx

You can see that once the bean is setup it is just a matter of setting result.setColor(Color.NAMEOFCOLOR) after you have stored the text in result.

    private BeanResult display(String value, String type, String pattern, Locale locale) throws BeanProviderException {

        // set up to draw in black and revert to the original formatting after the value is written
        BeanResult result = new BeanResult(value);
        result.fontColor = Color.black;
        result.resetBack = true;

        // if no node, that is not an error
        if (value == null)
            return result;

        // the number could be formatted - get the raw number and see if it is negative.
        try {
            String rawText = StringTagFormatter.dataToRaw(value, type, pattern, locale);
            if ((rawText == null) || (rawText.length() == 0))
                return result;
            double num = Double.parseDouble(rawText);
            if (num < 0.0)
                result.setColor(Color.red);
        } catch (Exception ex) {
            throw new BeanProviderException(value + " is not a number", ex);
        }

        return result;

--Ryan

 

 

 

 

 
New Post 7/29/2008 11:29 AM
  villelm
2 posts
www.truarx.com
No Ranking


Re: Dynamic font coloring based on content? 

Thanks, Ryan.  Unfortunately, I'm using .NET so I guess its the old multiple wr:if statements.

 
Previous Previous
 
Next Next
  Forum  Templates  Tags & Template...  Dynamic font coloring based on content?
Membership Membership:
Latest New User Latest: GrahamA
New Today New Today: 0
New Yesterday New Yesterday: 0
User Count Overall: 56

People Online People Online:
Visitors Visitors: 1
Members Members: 0
Total Total: 1

Online Now Online Now:
All contents copyright (c) 2002 - 2008 by Windward Studios, Inc. All Rights Reserved.   Terms Of Use  Privacy Statement