KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > laures > cewolf > taglib > tags > ColorTag


1 /* ================================================================
2  * Cewolf : Chart enabling Web Objects Framework
3  * ================================================================
4  *
5  * Project Info: http://cewolf.sourceforge.net
6  * Project Lead: Guido Laures (guido@laures.de);
7  *
8  * (C) Copyright 2002, by Guido Laures
9  *
10  * This library is free software; you can redistribute it and/or modify it under the terms
11  * of the GNU Lesser General Public License as published by the Free Software Foundation;
12  * either version 2.1 of
13  * the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
16  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17  * See the GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License along with this
20  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */

23
24 package de.laures.cewolf.taglib.tags;
25
26 import java.awt.Color JavaDoc;
27 import java.util.Map JavaDoc;
28
29 import de.laures.cewolf.ChartPostProcessor;
30 import de.laures.cewolf.taglib.util.ColorHelper;
31
32
33 /**
34  * Tag <color> which sets the color of its parent tag.
35  * This must implement the Colored interface
36  * @see Colored
37  * @author Guido Laures
38  */

39 public class ColorTag extends CewolfBodyTag implements ChartPostProcessor {
40
41     private Color JavaDoc color = Color.white;
42
43     public int doEndTag() {
44         ((Painted)getParent()).setPaint(color);
45         return doAfterEndTag(EVAL_PAGE);
46     }
47     
48     protected void reset(){
49     }
50
51     public void setColor(String JavaDoc s) {
52         this.color = ColorHelper.getColor(s);
53     }
54
55     protected Color JavaDoc getColor() {
56         return color;
57     }
58     
59     public void processChart(Object JavaDoc chart, Map JavaDoc args){
60         ((org.jfree.chart.JFreeChart)chart).setBackgroundPaint(color);
61     }
62
63 }
64
Popular Tags