KickJava   Java API By Example, From Geeks To Geeks.

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


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
28
29 /**
30  * Tag <gradient-paint> which defines a paint of type gradient.
31  * @author Guido Laures
32  */

33 public class GradientTag extends CewolfTag implements Pointed {
34
35     private SerializableGradientPaint gPaint = new SerializableGradientPaint();
36     private int pointCount = 0;
37
38     public int doStartTag() {
39         return EVAL_PAGE;
40     }
41
42     public int doEndTag() {
43         ((Painted)getParent()).setPaint(gPaint);
44         return doAfterEndTag(EVAL_PAGE);
45     }
46
47     public void reset() {
48         gPaint = new SerializableGradientPaint();
49         pointCount = 0;
50     }
51
52     public void addPoint(int x, int y, Color JavaDoc c) {
53         switch (pointCount) {
54             case 0:
55                 gPaint.setPoint1(x, y, c);
56                 break;
57             default:
58                 gPaint.setPoint2(x, y, c);
59         }
60         pointCount ++;
61     }
62
63     /**
64      * Setter for property cyclic.
65      * @param cyclic New value of property cyclic.
66      */

67     public void setCyclic(boolean cyclic) {
68         gPaint.setCyclic(cyclic);
69     }
70
71 }
72
Popular Tags