java/cewolf-1.0/src/main/java/de/laures/cewolf/taglib/tags/GradientTag.java
changeset 1 639991d0808a
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/java/cewolf-1.0/src/main/java/de/laures/cewolf/taglib/tags/GradientTag.java	Sat Feb 28 21:31:02 2009 +0100
     1.3 @@ -0,0 +1,71 @@
     1.4 +/* ================================================================
     1.5 + * Cewolf : Chart enabling Web Objects Framework
     1.6 + * ================================================================
     1.7 + *
     1.8 + * Project Info:  http://cewolf.sourceforge.net
     1.9 + * Project Lead:  Guido Laures (guido@laures.de);
    1.10 + *
    1.11 + * (C) Copyright 2002, by Guido Laures
    1.12 + *
    1.13 + * This library is free software; you can redistribute it and/or modify it under the terms
    1.14 + * of the GNU Lesser General Public License as published by the Free Software Foundation;
    1.15 + * either version 2.1 of
    1.16 + * the License, or (at your option) any later version.
    1.17 + *
    1.18 + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
    1.19 + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    1.20 + * See the GNU Lesser General Public License for more details.
    1.21 + *
    1.22 + * You should have received a copy of the GNU Lesser General Public License along with this
    1.23 + * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
    1.24 + * Boston, MA 02111-1307, USA.
    1.25 + */
    1.26 +
    1.27 +package de.laures.cewolf.taglib.tags;
    1.28 +
    1.29 +import java.awt.Color;
    1.30 +
    1.31 +
    1.32 +/** 
    1.33 + * Tag <gradient-paint> which defines a paint of type gradient.
    1.34 + * @author  Guido Laures 
    1.35 + */
    1.36 +public class GradientTag extends CewolfTag implements Pointed {
    1.37 +
    1.38 +    private SerializableGradientPaint gPaint = new SerializableGradientPaint();
    1.39 +    private int pointCount = 0;
    1.40 +
    1.41 +    public int doStartTag() {
    1.42 +        return EVAL_PAGE;
    1.43 +    }
    1.44 +
    1.45 +    public int doEndTag() {
    1.46 +        ((Painted)getParent()).setPaint(gPaint);
    1.47 +        return doAfterEndTag(EVAL_PAGE);
    1.48 +    }
    1.49 +
    1.50 +    public void reset() {
    1.51 +        gPaint = new SerializableGradientPaint();
    1.52 +        pointCount = 0;
    1.53 +    }
    1.54 +
    1.55 +    public void addPoint(int x, int y, Color c) {
    1.56 +        switch (pointCount) {
    1.57 +            case 0:
    1.58 +                gPaint.setPoint1(x, y, c);
    1.59 +                break;
    1.60 +            default:
    1.61 +                gPaint.setPoint2(x, y, c);
    1.62 +        }
    1.63 +        pointCount ++;
    1.64 +    }
    1.65 +
    1.66 +    /**
    1.67 +     * Setter for property cyclic.
    1.68 +     * @param cyclic New value of property cyclic.
    1.69 +     */
    1.70 +    public void setCyclic(boolean cyclic) {
    1.71 +        gPaint.setCyclic(cyclic);
    1.72 +    }
    1.73 +
    1.74 +}