您的位置:首页 > 编程语言 > ASP

ASP获取字符串长度的自定义函数

2008-02-13 17:43 411 查看
第一步:创建一个Java   Bean用来生成jpg文件  

  源程序如下:  

//生成图片的   Java   Bean  
//作者:崔冠宇  
//日期:2001-08-24  
import   java.io.*;  
import   java.util.*;  
import   com.sun.image.codec.jpeg.*;  
import   java.awt.image.*;  
import   java.awt.*;  

public   class   ChartGraphics   {  
 BufferedImage   image;  
 public   void   createImage(String   fileLocation)   {  
  try   {  
   FileOutputStream   fos   =   new   FileOutputStream(fileLocation);  
   BufferedOutputStream   bos   =   new   BufferedOutputStream(fos);  
   JPEGImageEncoder   encoder   =   JPEGCodec.createJPEGEncoder(bos);  
   encoder.encode(image);  
   bos.close();  
  }   catch(Exception   e)   {  
   System.out.println(e);  
  }  
 }  

 public   void   graphicsGeneration(int   h1,int   h2,int   h3,int   h4,int   h5)   {  

  final   int   X=10;  
  int   imageWidth   =   300;//图片的宽度  
  int   imageHeight   =   300;//图片的高度  
  int   columnWidth=30;//柱的宽度  
  int   columnHeight=200;//柱的最大高度  

  ChartGraphics   chartGraphics   =   new   ChartGraphics();  
  chartGraphics.image   =   new   BufferedImage(imageWidth,   imageHeight,   BufferedImage.TYPE_INT_RGB);  
  Graphics   graphics   =   chartGraphics.image.getGraphics();  
  graphics.setColor(Color.white);  
  graphics.fillRect(0,0,imageWidth,imageHeight);  
  graphics.setColor(Color.red);  
  graphics.drawRect(X+1*columnWidth,   columnHeight-h1,   columnWidth,   h1);  
  graphics.drawRect(X+2*columnWidth,   columnHeight-h2,   columnWidth,   h2);  
  graphics.drawRect(X+3*columnWidth,   columnHeight-h3,   columnWidth,   h3);  
  graphics.drawRect(X+4*columnWidth,   columnHeight-h4,   columnWidth,   h4);  
  graphics.drawRect(X+5*columnWidth,   columnHeight-h5,   columnWidth,   h5);  
  chartGraphics.createImage( "D:\\temp\\chart.jpg ");  
 }  
}  
引自:http://topic.csdn.net/t/20031030/15/2410774.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: