Hi,
Last time i wrote about Project Management System(PMS). URL for PMS is
http://pms.iitk.ernet.in/
Thanks!!
Deepak
Tuesday, March 30, 2010
Friday, March 19, 2010
Add Graphs by Using JFree Chart
Recently i want to add graphs in PMS application. There are too many ways to do this.One of them is JFree Chart.Steps for this are following..
Step1: Download Demo Application of JfreeChart demo and get library jar.
Step2: Add following lines in your code and import files which is required.
JFreeChart chart = ChartFactory.createPieChart("Pie Chart created by Deepak Pandey", pieDataset, true, true,true);
BufferedImage bi = chart.createBufferedImage(500, 500);
chart.setBackgroundPaint(new Color(173, 230, 163));
BufferedImage buf = chart.createBufferedImage(500, 500, null);
try {
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(response.getOutputStream());
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(buf);
param.setQuality(0.75f, true);
encoder.encode(buf, param);
} catch (Exception e) {
System.out.println("Exception in JSP"+e);
}
Step3: Run you application
You can create this chart on a frame.
Create JFrame Object. and then add JFreeChart object and make this JFrame Object visible.
More Information of this JFreeChart,access following link
http://www.jfree.org
Thanks!!!
Step1: Download Demo Application of JfreeChart demo and get library jar.
Step2: Add following lines in your code and import files which is required.
JFreeChart chart = ChartFactory.createPieChart("Pie Chart created by Deepak Pandey", pieDataset, true, true,true);
BufferedImage bi = chart.createBufferedImage(500, 500);
chart.setBackgroundPaint(new Color(173, 230, 163));
BufferedImage buf = chart.createBufferedImage(500, 500, null);
try {
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(response.getOutputStream());
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(buf);
param.setQuality(0.75f, true);
encoder.encode(buf, param);
} catch (Exception e) {
System.out.println("Exception in JSP"+e);
}
Step3: Run you application
You can create this chart on a frame.
Create JFrame Object. and then add JFreeChart object and make this JFrame Object visible.
More Information of this JFreeChart,access following link
http://www.jfree.org
Thanks!!!
Tuesday, March 2, 2010
Custom tag
1)Create a class which extends BodyTagSupport or implements Tag
package deep;
import javax.servlet.jsp.tagext.BodyTagSupport;
import java.io.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class Deepak extends BodyTagSupport {
BodyContent bodyContent;
public int doStartTag() throws JspException {
return EVAL_BODY_TAG;
OR
return SKIP_BODY;
}
public void setBodyContent(BodyContent
bodyContent) {
this.bodyContent = bodyContent;
}
public int doAfterBody() throws JspException {
return EVAL_BODY_TAG;
OR
return SKIP_BODY;
}
public int doEndTag() throws JspException {
return EVAL_PAGE;
}
}
//If It returns SKIP_PAGE,then code after the tag will not be executed ,in case of EVAL_PAGE it willbe calculated
2)Create tld(For ex:deep.tld)

3)Edit your web.xml


4)Add line in your JSP page
<%@ taglib uri="/WEB-INF/tag/name.tld" prefix="n" %>
and use tag which you defined earlier
5)Run your application
These are the steps which involved in making custom tag.Any suggestion or correction,plz leave comment.
Thanks
Deepak
package deep;
import javax.servlet.jsp.tagext.BodyTagSupport;
import java.io.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
public class Deepak extends BodyTagSupport {
BodyContent bodyContent;
public int doStartTag() throws JspException {
return EVAL_BODY_TAG;
OR
return SKIP_BODY;
}
public void setBodyContent(BodyContent
bodyContent) {
this.bodyContent = bodyContent;
}
public int doAfterBody() throws JspException {
return EVAL_BODY_TAG;
OR
return SKIP_BODY;
}
public int doEndTag() throws JspException {
return EVAL_PAGE;
}
}
//If It returns SKIP_PAGE,then code after the tag will not be executed ,in case of EVAL_PAGE it willbe calculated
2)Create tld(For ex:deep.tld)
3)Edit your web.xml
4)Add line in your JSP page

and use tag which you defined earlier
5)Run your application
These are the steps which involved in making custom tag.Any suggestion or correction,plz leave comment.
Thanks
Deepak
Subscribe to:
Posts (Atom)