001: /* ================================================================
002: * Cewolf : Chart enabling Web Objects Framework
003: * ================================================================
004: *
005: * Project Info: http://cewolf.sourceforge.net
006: * Project Lead: Guido Laures (guido@laures.de);
007: *
008: * (C) Copyright 2002, by Guido Laures
009: *
010: * This library is free software; you can redistribute it and/or modify it under the terms
011: * of the GNU Lesser General Public License as published by the Free Software Foundation;
012: * either version 2.1 of
013: * the License, or (at your option) any later version.
014: *
015: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
016: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
017: * See the GNU Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public License along with this
020: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
021: * Boston, MA 02111-1307, USA.
022: */
023:
024: package de.laures.cewolf.taglib.tags;
025:
026: import java.awt.Paint;
027: import java.util.Map;
028:
029: import javax.servlet.jsp.JspException;
030: import javax.servlet.jsp.PageContext;
031:
032: import de.laures.cewolf.ChartPostProcessor;
033: import de.laures.cewolf.taglib.AbstractChartDefinition;
034: import de.laures.cewolf.taglib.TaglibConstants;
035:
036: /**
037: * Root tag <chart> of a chart definition. Defines all values for the
038: * page scope variable of type ChartDefinition which is used by the img
039: * tag to render the appropriate chart.
040: * @author Guido Laures
041: */
042: public abstract class AbstractChartTag extends CewolfTag implements
043: CewolfRootTag, TaglibConstants, Painted {
044:
045: protected AbstractChartDefinition chartDefinition = createChartDefinition();
046:
047: protected abstract AbstractChartDefinition createChartDefinition();
048:
049: public int doStartTag() {
050: return EVAL_BODY_INCLUDE;
051: }
052:
053: public int doEndTag() throws JspException {
054: pageContext.setAttribute(getId(), chartDefinition,
055: PageContext.PAGE_SCOPE);
056: return doAfterEndTag(EVAL_PAGE);
057: }
058:
059: public void reset() {
060: chartDefinition = createChartDefinition();
061: }
062:
063: public String getChartId() {
064: return getId();
065: }
066:
067: /**
068: * Setter for property title.
069: * @param title New value of property title.
070: */
071: public void setTitle(String title) {
072: chartDefinition.setTitle(title);
073: }
074:
075: /**
076: * Setter for property xAxisLabel.
077: * @param xAxisLabel New value of property xAxisLabel.
078: */
079: public void setXaxislabel(String xAxisLabel) {
080: chartDefinition.setXAxisLabel(xAxisLabel);
081: }
082:
083: /**
084: * Setter for property xAxisLabel.
085: * @param xAxisLabel New value of property xAxisLabel.
086: */
087: public void setYaxislabel(String yAxisLabel) {
088: chartDefinition.setYAxisLabel(yAxisLabel);
089: }
090:
091: public void setBackground(String src) {
092: String srcFile = pageContext.getServletContext().getRealPath(
093: src);
094: chartDefinition.setBackground(srcFile);
095: }
096:
097: public void setBackgroundimagealpha(Float alpha) {
098: chartDefinition.setBackgroundImageAlpha(alpha.floatValue());
099: }
100:
101: public void setAntialias(boolean anti) {
102: chartDefinition.setAntialias(anti);
103: }
104:
105: /**
106: * Setter for property legend.
107: * @param legend New value of property legend.
108: */
109: public void setShowlegend(boolean legend) {
110: chartDefinition.setShowLegend(legend);
111: }
112:
113: /**
114: * Setter for property legend.
115: * @param legend New value of property legend.
116: */
117: public void setLegendanchor(String anchor) {
118: if ("north".equalsIgnoreCase(anchor)) {
119: chartDefinition.setLegendAnchor(ANCHOR_NORTH);
120: } else if ("south".equalsIgnoreCase(anchor)) {
121: chartDefinition.setLegendAnchor(ANCHOR_SOUTH);
122: } else if ("west".equalsIgnoreCase(anchor)) {
123: chartDefinition.setLegendAnchor(ANCHOR_WEST);
124: } else if ("east".equalsIgnoreCase(anchor)) {
125: chartDefinition.setLegendAnchor(ANCHOR_EAST);
126: }
127: }
128:
129: public void addChartPostProcessor(ChartPostProcessor pp, Map params) {
130: chartDefinition.addPostProcessor(pp);
131: chartDefinition.addPostProcessorParams(params);
132: }
133:
134: public void setPaint(Paint paint) {
135: chartDefinition.setPaint(paint);
136: }
137:
138: /**
139: * Setter for property type.
140: * @param type New value of property type.
141: */
142: public void setType(String type) {
143: chartDefinition.setType(type);
144: }
145:
146: }
|