Return-Path: X-Original-To: apmail-pivot-user-archive@www.apache.org Delivered-To: apmail-pivot-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9500C9170 for ; Mon, 4 Jun 2012 03:44:22 +0000 (UTC) Received: (qmail 21357 invoked by uid 500); 4 Jun 2012 03:44:22 -0000 Delivered-To: apmail-pivot-user-archive@pivot.apache.org Received: (qmail 21228 invoked by uid 500); 4 Jun 2012 03:44:19 -0000 Mailing-List: contact user-help@pivot.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@pivot.apache.org Delivered-To: mailing list user@pivot.apache.org Received: (qmail 21151 invoked by uid 99); 4 Jun 2012 03:44:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Jun 2012 03:44:15 +0000 X-ASF-Spam-Status: No, hits=2.9 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [173.201.192.109] (HELO p3plsmtpa06-08.prod.phx3.secureserver.net) (173.201.192.109) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 04 Jun 2012 03:44:06 +0000 Received: (qmail 1653 invoked from network); 4 Jun 2012 03:43:44 -0000 Received: from unknown (76.200.167.198) by p3plsmtpa06-08.prod.phx3.secureserver.net (173.201.192.109) with ESMTP; 04 Jun 2012 03:43:43 -0000 Message-ID: <4FCC2EEE.50200@rbwhitcomb.com> Date: Sun, 03 Jun 2012 20:43:42 -0700 From: Roger and Beth Whitcomb User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: user@pivot.apache.org Subject: Re: Custom style in table view References: <7BE08F16-5428-4FEF-8B92-78D100D74DC8@gmail.com> In-Reply-To: <7BE08F16-5428-4FEF-8B92-78D100D74DC8@gmail.com> Content-Type: multipart/alternative; boundary="------------090905050001000403070707" This is a multi-part message in MIME format. --------------090905050001000403070707 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit You probably would want a custom cell renderer. You can start with the Tutorial on custom TableViews here: http://pivot.apache.org/tutorials/table-views.custom.html What you would end up writing is a small class that subclasses TableViewCellRenderer or implements TableView.CellRenderer. There are several predefined ones you could use as examples such as TableViewCheckboxCellRenderer or TableViewTextAreaCellRenderer. The basic idea is that a renderer does what it takes to display its contents when asked. It can be implemented using another Pivot control (such as a Label) that does the heavy lifting of doing the drawing and size calculations. To do the coloring, you would just set styles on your Label depending on the value. HTH. Thanks for using Pivot and feel free to ask if you need more help. ~Roger On 6/3/12 6:17 PM, Joseph Paterson wrote: > Hi, > > I'm building a TableView using apache-pivot that will have some cells > that will contain a currency value (or '-' if the value is null). For > visual feedback I'd like the text to appear in green if the value is > zero or positive, and in red if the value is negative. I'm not quite > sure where to start with this - any pointers? > > Many thanks, > > Joseph. > --------------090905050001000403070707 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit You probably would want a custom cell renderer.  You can start with the Tutorial on custom TableViews here:  http://pivot.apache.org/tutorials/table-views.custom.html

What you would end up writing is a small class that subclasses TableViewCellRenderer or implements TableView.CellRenderer.  There are several predefined ones you could use as examples such as TableViewCheckboxCellRenderer or TableViewTextAreaCellRenderer.  The basic idea is that a renderer does what it takes to display its contents when asked.  It can be implemented using another Pivot control (such as a Label) that does the heavy lifting of doing the drawing and size calculations.  To do the coloring, you would just set styles on your Label depending on the value.

HTH.  Thanks for using Pivot and feel free to ask if you need more help.

~Roger

On 6/3/12 6:17 PM, Joseph Paterson wrote:
Hi,

I'm building a TableView using apache-pivot that will have some cells that will contain a currency value (or '-' if the value is null). For visual feedback I'd like the text to appear in green if the value is zero or positive, and in red if the value is negative. I'm not quite sure where to start with this - any pointers?

Many thanks,

Joseph.

--------------090905050001000403070707--