是报表数据展现么??如果是当然是SERVLET ,
public class SZxt extends HttpServlet
{
public void service (HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
PrintWriter out = response.getWriter();
response.setContentType("text/plain");
//定义一个Image对象。
BufferedImage image = new BufferedImage(640, 480, BufferedImage.TYPE_INT_RGB);
//定义一个graphics的类型。
Graphics2D g = image.createGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
//定义一些变量。
Polygon p = null;
int i_total = 0;
float total=0f;
int p_values[][] = new int[14][30];
String p_text[] = new String[14];
String p_date[] = new String[30];
Color colors[] = new Color[17];
colors[0] = new Color(255,0,0);
colors[1] = new Color(255,144,0);
colors[2] = new Color(255,255,0);
colors[3] = new Color(0,255,0);
colors[4] = new Color(0,255,255);
colors[5] = new Color(0,0,255);
colors[6] = new Color(255,0,255);
colors[7] = new Color(64,128,128);
colors[8] = new Color(192,192,192);
colors[9] = new Color(128,128,64);
colors[10] = new Color(255,128,255);
colors[11] = new Color(128,128,255);
colors[12] = new Color(0,128,255);
colors[13] = new Color(255,255,255);//背景颜色
colors[14] = new Color(200,200,200);//阴影颜色
colors[15] = new Color(0,0,0);//黑色
colors[16] = new Color(155,203,232);//水印
//设定输出图象的背景和大小
g.setPaint(colors[13]);
Rectangle2D rectangle = new Rectangle2D.Double(0, 0, 640, 480);
g.fill(rectangle);
GradientPaint gp = null;
gp = new GradientPaint(0, 0, colors[13], 200, 100, colors[13]);
g.setPaint(gp);
//接收参数,
String ls_bt = "";
ls_bt = request.getParameter("BT");
if(ls_bt == null)
ls_bt = "无标题";
ls_bt = ls_bt.trim();
//接受数值,
String ls_temp = "";
String ls_temp_j = "";
int li_count = 1;
int li_length = 0;
ls_temp = request.getParameter("date");
if(ls_temp == null)
ls_temp = "";
ls_temp = ls_temp.trim();
//System.out.println(ls_temp);
if(!ls_temp.equals(""))
{
li_count = 1;
li_length = ls_temp.length();
for(int j = 0;
j < li_length;
j++)
{
if(ls_temp.substring(j,j+1).equals(","))
{
p_date[li_count] = ls_temp_j;
li_count++;
ls_temp_j = "";
}
else
{
ls_temp_j = ls_temp_j + ls_temp.substring(j,j+1);
}
}
}
ls_temp_j = "";
for(int i = 1;
i < 14;
i++)
{
ls_temp = request.getParameter(i+"");
if(ls_temp == null)
ls_temp = "";
ls_temp = ls_temp.trim();
if(!ls_temp.equals(""))
{
li_count = 1;
li_length = ls_temp.length();
//System.out.println(li_length);
for(int j = 0;
j < li_length;
j++)
{
if(ls_temp.substring(j,j+1).equals(","))
{
p_values[li_count] = Integer.parseInt(ls_temp_j);
//System.out.println("p_values["+i+"]["+li_count+"] ---- " + p_values[li_count]);
li_count++;
ls_temp_j = "";
}
else
{
if(!ls_temp.substring(j,j+1).equals("."))
ls_temp_j = ls_temp_j + ls_temp.substring(j,j+1);
}
}
}
}
//System.out.println("p_values[1][3] ---- " + p_values[1][3]);
//设置最大数为10000;
i_total = 5000;
for(int j = 1;
j < 14;
j++)
{
p_text[j] = request.getParameter("text_" + j);
if(p_text[j] == null)
p_text[j] = "";
//System.out.println(p_text[j]);
//request.getParameter("text" + j);
}
for(int i=1;i<11;i++)
{
g.setColor(colors[16]);
g.drawLine(20,340 - i*20,620,340 - i*20);
}
for(int i=1;i<31;i++)
{
g.setColor(colors[16]);
g.drawLine(20 + i*20,140,20 + i*20,340);
}
g.setColor(colors[15]);
g.drawLine(20,340,620,340);
g.drawLine(617,343,620,340);
g.drawLine(617,337,620,340);
g.drawLine(20,140,20,340);
g.drawLine(20,140,17,143);
g.drawLine(20,140,23,143);
for(int i=1;i<14;i++)
{
for(int j=1;j<30;j++)
{
if(p_values[j] != 0)
{
g.setColor(colors[i - 1]);
if(j != 1)
{
g.drawLine(20+20*(j-1),340 - p_values[j]*100/i_total,20+20*(j-2),340 - p_values[j - 1]*100/i_total);
}
g.setColor(colors[15]);
g.fillRect(16+20*(j-1),336 - p_values[j]*100/i_total,8,8);
g.setColor(colors[i - 1]);
g.fillRect(17+20*(j-1),337 - p_values[j]*100/i_total,6,6);
}
}
}
//输出文字
byte byte3 = 10;
int i = 0;
for(int tCounter1 = 1;
tCounter1 < 8;
tCounter1 ++)
{
if(!p_text[tCounter1].equals(""))
{
g.setColor(Color.black);
g.fillRect(5,360+i * 20, 12, 12);
g.setColor(colors[tCounter1-1]);
g.fillRect(5+ 1, 360+i * 20 + 1, 10, 10);
g.setColor(Color.black);
g.drawString(p_text[tCounter1], 5 +13, 360 + i * 20 + 11);
}
i++;
}
i=0;
for(int tCounter1 = 7;
tCounter1 < 14;
tCounter1 ++)
{
//if(p_text[tCounter1] != null&&p_values[tCounter1]>0)
if(!p_text[tCounter1].equals(""))
{
g.setColor(Color.black);
g.fillRect(305,360+i * 20, 12, 12);
g.setColor(colors[tCounter1-1]);
g.fillRect(305+ 1, 360+i * 20 + 1, 10, 10);
g.setColor(Color.black);
g.drawString(p_text[tCounter1], 305 +13, 360 + i * 20 + 11);
}
i++;
}
g.setFont(new Font("Serif", Font.BOLD, 8));
for(int j = 1;
j < 30;
j++)
{
if(p_date[j] != null)
g.drawString(p_date[j].substring(5,p_date[j].length()), 10 + (j -1) * 20, 350);
//System.out.println( 10 + (j -1) * 20+"--"+p_date[j]);
}
g.setFont(new Font("Serif", Font.BOLD, 20));
g.setColor(colors[15]);
g.drawString(ls_bt, 50, 50);
response.setContentType("image/jpeg");
// Assign correct content-type
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(response.getOutputStream());
// Create JPEG encoder
JPEGEncodeParam jpegParams = encoder.getDefaultJPEGEncodeParam(image);
jpegParams.setQuality(2.0f, false);
// Set quality to 100% for JPEG
encoder.setJPEGEncodeParam(jpegParams);
encoder.encode(image);
// Encode image to JPEG and send to browser
}
}