1 23 24 package de.laures.cewolf.taglib.tags; 25 26 import java.awt.Paint ; 27 import java.util.Map ; 28 29 import javax.servlet.jsp.JspException ; 30 import javax.servlet.jsp.PageContext ; 31 32 import de.laures.cewolf.ChartPostProcessor; 33 import de.laures.cewolf.taglib.AbstractChartDefinition; 34 import de.laures.cewolf.taglib.TaglibConstants; 35 36 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 { 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 getChartId() { 63 return getId(); 64 } 65 66 70 public void setTitle(String title) { 71 chartDefinition.setTitle(title); 72 } 73 74 78 public void setXaxislabel(String xAxisLabel) { 79 chartDefinition.setXAxisLabel(xAxisLabel); 80 } 81 82 86 public void setYaxislabel(String yAxisLabel) { 87 chartDefinition.setYAxisLabel(yAxisLabel); 88 } 89 90 public void setBackground(String src) { 91 String srcFile = pageContext.getServletContext().getRealPath(src); 92 chartDefinition.setBackground(srcFile); 93 } 94 95 public void setBackgroundimagealpha(Float alpha) { 96 chartDefinition.setBackgroundImageAlpha(alpha.floatValue()); 97 } 98 99 public void setAntialias(boolean anti) { 100 chartDefinition.setAntialias(anti); 101 } 102 103 107 public void setShowlegend(boolean legend) { 108 chartDefinition.setShowLegend(legend); 109 } 110 111 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); 124 } 125 } 126 127 public void addChartPostProcessor(ChartPostProcessor pp, Map params) { 128 chartDefinition.addPostProcessor(pp); 129 chartDefinition.addPostProcessorParams(params); 130 } 131 132 public void setPaint(Paint paint){ 133 chartDefinition.setPaint(paint); 134 } 135 136 140 public void setType(String type) { 141 chartDefinition.setType(type); 142 } 143 144 } 145 | Popular Tags |