1 /* ================================================================
2 * Cewolf : Chart enabling Web Objects Framework
3 * ================================================================
5 * Project Info: http://cewolf.sourceforge.net
6 * Project Lead: Guido Laures (guido@laures.de);
8 * (C) Copyright 2002, by Guido Laures
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.
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.
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.
24 package de.laures.cewolf.taglib.tags;
26 import java.awt.Paint;
29 import javax.servlet.jsp.JspException;
30 import javax.servlet.jsp.PageContext;
32 import de.laures.cewolf.ChartPostProcessor;
33 import de.laures.cewolf.taglib.AbstractChartDefinition;
34 import de.laures.cewolf.taglib.TaglibConstants;
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
42 public abstract class AbstractChartTag extends CewolfTag implements CewolfRootTag, TaglibConstants, Painted {
44 protected AbstractChartDefinition chartDefinition = createChartDefinition();
46 protected abstract AbstractChartDefinition createChartDefinition();
48 public int doStartTag(){
49 return EVAL_BODY_INCLUDE;
52 public int doEndTag() throws JspException {
53 pageContext.setAttribute(getId(), chartDefinition, PageContext.PAGE_SCOPE);
54 return doAfterEndTag(EVAL_PAGE);
59 chartDefinition = createChartDefinition();
62 public String getChartId() {
67 * Setter for property title.
68 * @param title New value of property title.
70 public void setTitle(String title) {
71 chartDefinition.setTitle(title);
75 * Setter for property xAxisLabel.
76 * @param xAxisLabel New value of property xAxisLabel.
78 public void setXaxislabel(String xAxisLabel) {
79 chartDefinition.setXAxisLabel(xAxisLabel);
83 * Setter for property xAxisLabel.
84 * @param xAxisLabel New value of property xAxisLabel.
86 public void setYaxislabel(String yAxisLabel) {
87 chartDefinition.setYAxisLabel(yAxisLabel);
90 public void setBackground(String src) {
91 String srcFile = pageContext.getServletContext().getRealPath(src);
92 chartDefinition.setBackground(srcFile);
95 public void setBackgroundimagealpha(Float alpha) {
96 chartDefinition.setBackgroundImageAlpha(alpha.floatValue());
99 public void setAntialias(boolean anti) {
100 chartDefinition.setAntialias(anti);
104 * Setter for property legend.
105 * @param legend New value of property legend.
107 public void setShowlegend(boolean legend) {
108 chartDefinition.setShowLegend(legend);
112 * Setter for property legend.
113 * @param legend New value of property legend.
115 public void setLegendanchor(String 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);
127 public void addChartPostProcessor(ChartPostProcessor pp, Map params) {
128 chartDefinition.addPostProcessor(pp);
129 chartDefinition.addPostProcessorParams(params);
132 public void setPaint(Paint paint){
133 chartDefinition.setPaint(paint);
137 * Setter for property type.
138 * @param type New value of property type.
140 public void setType(String type) {
141 chartDefinition.setType(type);