KickJava   Java API By Example, From Geeks To Geeks.

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


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.Paint JavaDoc;
27 import java.util.Map JavaDoc;
28
29 import javax.servlet.jsp.JspException JavaDoc;
30 import javax.servlet.jsp.PageContext JavaDoc;
31
32 import de.laures.cewolf.ChartPostProcessor;
33 import de.laures.cewolf.taglib.AbstractChartDefinition;
34 import de.laures.cewolf.taglib.TaglibConstants;
35
36 /**
37  * Root tag <chart> of a chart definition. Defines all values for the
38  * page scope variable of type ChartDefinition which is used by the img
39  * tag to render the appropriate chart.
40  * @author Guido Laures
41  */

42 public abstract class AbstractChartTag extends CewolfTag implements CewolfRootTag, TaglibConstants, Painted {
43     
44     protected AbstractChartDefinition chartDefinition = createChartDefinition();
45     
46     protected abstract AbstractChartDefinition createChartDefinition();
47     
48     public int doStartTag(){
49         return EVAL_BODY_INCLUDE;
50     }
51     
52     public int doEndTag() throws JspException JavaDoc {
53         pageContext.setAttribute(getId(), chartDefinition, PageContext.PAGE_SCOPE);
54         return doAfterEndTag(EVAL_PAGE);
55     }
56     
57     
58     public void reset() {
59         chartDefinition = createChartDefinition();
60     }
61     
62     public String JavaDoc getChartId() {
63         return getId();
64     }
65     
66     /**
67      * Setter for property title.
68      * @param title New value of property title.
69      */

70     public void setTitle(String JavaDoc title) {
71         chartDefinition.setTitle(title);
72     }
73     
74     /**
75      * Setter for property xAxisLabel.
76      * @param xAxisLabel New value of property xAxisLabel.
77      */

78     public void setXaxislabel(String JavaDoc xAxisLabel) {
79         chartDefinition.setXAxisLabel(xAxisLabel);
80     }
81     
82     /**
83      * Setter for property xAxisLabel.
84      * @param xAxisLabel New value of property xAxisLabel.
85      */

86     public void setYaxislabel(String JavaDoc yAxisLabel) {
87         chartDefinition.setYAxisLabel(yAxisLabel);
88     }
89     
90     public void setBackground(String JavaDoc src) {
91         String JavaDoc srcFile = pageContext.getServletContext().getRealPath(src);
92         chartDefinition.setBackground(srcFile);
93     }
94     
95     public void setBackgroundimagealpha(Float JavaDoc alpha) {
96         chartDefinition.setBackgroundImageAlpha(alpha.floatValue());
97     }
98     
99     public void setAntialias(boolean anti) {
100         chartDefinition.setAntialias(anti);
101     }
102     
103     /**
104      * Setter for property legend.
105      * @param legend New value of property legend.
106      */

107     public void setShowlegend(boolean legend) {
108         chartDefinition.setShowLegend(legend);
109     }
110     
111     /**
112      * Setter for property legend.
113      * @param legend New value of property legend.
114      */

115     public void setLegendanchor(String JavaDoc anchor) {
116         if ("north".equalsIgnoreCase(anchor)) {
117             chartDefinition.setLegendAnchor(ANCHOR_NORTH);
118         } else if ("south".equalsIgnoreCase(anchor)) {
119             chartDefinition.setLegendAnchor(ANCHOR_SOUTH);
120         } else if ("west".equalsIgnoreCase(anchor)) {
121             chartDefinition.setLegendAnchor(ANCHOR_WEST);
122         } else if ("east".equalsIgnoreCase(anchor)) {
123             chartDefinition.setLegendAnchor(ANCHOR_EAST);
124         }
125     }
126     
127     public void addChartPostProcessor(ChartPostProcessor pp, Map JavaDoc params) {
128         chartDefinition.addPostProcessor(pp);
129         chartDefinition.addPostProcessorParams(params);
130     }
131     
132     public void setPaint(Paint JavaDoc paint){
133         chartDefinition.setPaint(paint);
134     }
135
136     /**
137          * Setter for property type.
138          * @param type New value of property type.
139          */

140     public void setType(String JavaDoc type) {
141         chartDefinition.setType(type);
142     }
143     
144 }
145
Popular Tags