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/AbstractChartTag.java Sat Feb 28 21:31:02 2009 +0100
1.3 @@ -0,0 +1,144 @@
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.Paint;
1.30 +import java.util.Map;
1.31 +
1.32 +import javax.servlet.jsp.JspException;
1.33 +import javax.servlet.jsp.PageContext;
1.34 +
1.35 +import de.laures.cewolf.ChartPostProcessor;
1.36 +import de.laures.cewolf.taglib.AbstractChartDefinition;
1.37 +import de.laures.cewolf.taglib.TaglibConstants;
1.38 +
1.39 +/**
1.40 + * Root tag <chart> of a chart definition. Defines all values for the
1.41 + * page scope variable of type ChartDefinition which is used by the img
1.42 + * tag to render the appropriate chart.
1.43 + * @author Guido Laures
1.44 + */
1.45 +public abstract class AbstractChartTag extends CewolfTag implements CewolfRootTag, TaglibConstants, Painted {
1.46 +
1.47 + protected AbstractChartDefinition chartDefinition = createChartDefinition();
1.48 +
1.49 + protected abstract AbstractChartDefinition createChartDefinition();
1.50 +
1.51 + public int doStartTag(){
1.52 + return EVAL_BODY_INCLUDE;
1.53 + }
1.54 +
1.55 + public int doEndTag() throws JspException {
1.56 + pageContext.setAttribute(getId(), chartDefinition, PageContext.PAGE_SCOPE);
1.57 + return doAfterEndTag(EVAL_PAGE);
1.58 + }
1.59 +
1.60 +
1.61 + public void reset() {
1.62 + chartDefinition = createChartDefinition();
1.63 + }
1.64 +
1.65 + public String getChartId() {
1.66 + return getId();
1.67 + }
1.68 +
1.69 + /**
1.70 + * Setter for property title.
1.71 + * @param title New value of property title.
1.72 + */
1.73 + public void setTitle(String title) {
1.74 + chartDefinition.setTitle(title);
1.75 + }
1.76 +
1.77 + /**
1.78 + * Setter for property xAxisLabel.
1.79 + * @param xAxisLabel New value of property xAxisLabel.
1.80 + */
1.81 + public void setXaxislabel(String xAxisLabel) {
1.82 + chartDefinition.setXAxisLabel(xAxisLabel);
1.83 + }
1.84 +
1.85 + /**
1.86 + * Setter for property xAxisLabel.
1.87 + * @param xAxisLabel New value of property xAxisLabel.
1.88 + */
1.89 + public void setYaxislabel(String yAxisLabel) {
1.90 + chartDefinition.setYAxisLabel(yAxisLabel);
1.91 + }
1.92 +
1.93 + public void setBackground(String src) {
1.94 + String srcFile = pageContext.getServletContext().getRealPath(src);
1.95 + chartDefinition.setBackground(srcFile);
1.96 + }
1.97 +
1.98 + public void setBackgroundimagealpha(Float alpha) {
1.99 + chartDefinition.setBackgroundImageAlpha(alpha.floatValue());
1.100 + }
1.101 +
1.102 + public void setAntialias(boolean anti) {
1.103 + chartDefinition.setAntialias(anti);
1.104 + }
1.105 +
1.106 + /**
1.107 + * Setter for property legend.
1.108 + * @param legend New value of property legend.
1.109 + */
1.110 + public void setShowlegend(boolean legend) {
1.111 + chartDefinition.setShowLegend(legend);
1.112 + }
1.113 +
1.114 + /**
1.115 + * Setter for property legend.
1.116 + * @param legend New value of property legend.
1.117 + */
1.118 + public void setLegendanchor(String anchor) {
1.119 + if ("north".equalsIgnoreCase(anchor)) {
1.120 + chartDefinition.setLegendAnchor(ANCHOR_NORTH);
1.121 + } else if ("south".equalsIgnoreCase(anchor)) {
1.122 + chartDefinition.setLegendAnchor(ANCHOR_SOUTH);
1.123 + } else if ("west".equalsIgnoreCase(anchor)) {
1.124 + chartDefinition.setLegendAnchor(ANCHOR_WEST);
1.125 + } else if ("east".equalsIgnoreCase(anchor)) {
1.126 + chartDefinition.setLegendAnchor(ANCHOR_EAST);
1.127 + }
1.128 + }
1.129 +
1.130 + public void addChartPostProcessor(ChartPostProcessor pp, Map params) {
1.131 + chartDefinition.addPostProcessor(pp);
1.132 + chartDefinition.addPostProcessorParams(params);
1.133 + }
1.134 +
1.135 + public void setPaint(Paint paint){
1.136 + chartDefinition.setPaint(paint);
1.137 + }
1.138 +
1.139 + /**
1.140 + * Setter for property type.
1.141 + * @param type New value of property type.
1.142 + */
1.143 + public void setType(String type) {
1.144 + chartDefinition.setType(type);
1.145 + }
1.146 +
1.147 +}