franta-hg@1: /* ================================================================ franta-hg@1: * Cewolf : Chart enabling Web Objects Framework franta-hg@1: * ================================================================ franta-hg@1: * franta-hg@1: * Project Info: http://cewolf.sourceforge.net franta-hg@1: * Project Lead: Guido Laures (guido@laures.de); franta-hg@1: * franta-hg@1: * (C) Copyright 2002, by Guido Laures franta-hg@1: * franta-hg@1: * This library is free software; you can redistribute it and/or modify it under the terms franta-hg@1: * of the GNU Lesser General Public License as published by the Free Software Foundation; franta-hg@1: * either version 2.1 of franta-hg@1: * the License, or (at your option) any later version. franta-hg@1: * franta-hg@1: * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; franta-hg@1: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. franta-hg@1: * See the GNU Lesser General Public License for more details. franta-hg@1: * franta-hg@1: * You should have received a copy of the GNU Lesser General Public License along with this franta-hg@1: * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, franta-hg@1: * Boston, MA 02111-1307, USA. franta-hg@1: */ franta-hg@1: franta-hg@1: package de.laures.cewolf.taglib.tags; franta-hg@1: franta-hg@1: import java.awt.Paint; franta-hg@1: import java.util.Map; franta-hg@1: franta-hg@1: import javax.servlet.jsp.JspException; franta-hg@1: import javax.servlet.jsp.PageContext; franta-hg@1: franta-hg@1: import de.laures.cewolf.ChartPostProcessor; franta-hg@1: import de.laures.cewolf.taglib.AbstractChartDefinition; franta-hg@1: import de.laures.cewolf.taglib.TaglibConstants; franta-hg@1: franta-hg@1: /** franta-hg@1: * Root tag <chart> of a chart definition. Defines all values for the franta-hg@1: * page scope variable of type ChartDefinition which is used by the img franta-hg@1: * tag to render the appropriate chart. franta-hg@1: * @author Guido Laures franta-hg@1: */ franta-hg@1: public abstract class AbstractChartTag extends CewolfTag implements CewolfRootTag, TaglibConstants, Painted { franta-hg@1: franta-hg@1: protected AbstractChartDefinition chartDefinition = createChartDefinition(); franta-hg@1: franta-hg@1: protected abstract AbstractChartDefinition createChartDefinition(); franta-hg@1: franta-hg@1: public int doStartTag(){ franta-hg@1: return EVAL_BODY_INCLUDE; franta-hg@1: } franta-hg@1: franta-hg@1: public int doEndTag() throws JspException { franta-hg@1: pageContext.setAttribute(getId(), chartDefinition, PageContext.PAGE_SCOPE); franta-hg@1: return doAfterEndTag(EVAL_PAGE); franta-hg@1: } franta-hg@1: franta-hg@1: franta-hg@1: public void reset() { franta-hg@1: chartDefinition = createChartDefinition(); franta-hg@1: } franta-hg@1: franta-hg@1: public String getChartId() { franta-hg@1: return getId(); franta-hg@1: } franta-hg@1: franta-hg@1: /** franta-hg@1: * Setter for property title. franta-hg@1: * @param title New value of property title. franta-hg@1: */ franta-hg@1: public void setTitle(String title) { franta-hg@1: chartDefinition.setTitle(title); franta-hg@1: } franta-hg@1: franta-hg@1: /** franta-hg@1: * Setter for property xAxisLabel. franta-hg@1: * @param xAxisLabel New value of property xAxisLabel. franta-hg@1: */ franta-hg@1: public void setXaxislabel(String xAxisLabel) { franta-hg@1: chartDefinition.setXAxisLabel(xAxisLabel); franta-hg@1: } franta-hg@1: franta-hg@1: /** franta-hg@1: * Setter for property xAxisLabel. franta-hg@1: * @param xAxisLabel New value of property xAxisLabel. franta-hg@1: */ franta-hg@1: public void setYaxislabel(String yAxisLabel) { franta-hg@1: chartDefinition.setYAxisLabel(yAxisLabel); franta-hg@1: } franta-hg@1: franta-hg@1: public void setBackground(String src) { franta-hg@1: String srcFile = pageContext.getServletContext().getRealPath(src); franta-hg@1: chartDefinition.setBackground(srcFile); franta-hg@1: } franta-hg@1: franta-hg@1: public void setBackgroundimagealpha(Float alpha) { franta-hg@1: chartDefinition.setBackgroundImageAlpha(alpha.floatValue()); franta-hg@1: } franta-hg@1: franta-hg@1: public void setAntialias(boolean anti) { franta-hg@1: chartDefinition.setAntialias(anti); franta-hg@1: } franta-hg@1: franta-hg@1: /** franta-hg@1: * Setter for property legend. franta-hg@1: * @param legend New value of property legend. franta-hg@1: */ franta-hg@1: public void setShowlegend(boolean legend) { franta-hg@1: chartDefinition.setShowLegend(legend); franta-hg@1: } franta-hg@1: franta-hg@1: /** franta-hg@1: * Setter for property legend. franta-hg@1: * @param legend New value of property legend. franta-hg@1: */ franta-hg@1: public void setLegendanchor(String anchor) { franta-hg@1: if ("north".equalsIgnoreCase(anchor)) { franta-hg@1: chartDefinition.setLegendAnchor(ANCHOR_NORTH); franta-hg@1: } else if ("south".equalsIgnoreCase(anchor)) { franta-hg@1: chartDefinition.setLegendAnchor(ANCHOR_SOUTH); franta-hg@1: } else if ("west".equalsIgnoreCase(anchor)) { franta-hg@1: chartDefinition.setLegendAnchor(ANCHOR_WEST); franta-hg@1: } else if ("east".equalsIgnoreCase(anchor)) { franta-hg@1: chartDefinition.setLegendAnchor(ANCHOR_EAST); franta-hg@1: } franta-hg@1: } franta-hg@1: franta-hg@1: public void addChartPostProcessor(ChartPostProcessor pp, Map params) { franta-hg@1: chartDefinition.addPostProcessor(pp); franta-hg@1: chartDefinition.addPostProcessorParams(params); franta-hg@1: } franta-hg@1: franta-hg@1: public void setPaint(Paint paint){ franta-hg@1: chartDefinition.setPaint(paint); franta-hg@1: } franta-hg@1: franta-hg@1: /** franta-hg@1: * Setter for property type. franta-hg@1: * @param type New value of property type. franta-hg@1: */ franta-hg@1: public void setType(String type) { franta-hg@1: chartDefinition.setType(type); franta-hg@1: } franta-hg@1: franta-hg@1: }