资源简介
cms后台管理系统, cms后台管理系统, cms后台管理系统
代码片段和文件信息
package org.konghao.basic.util;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.util.Random;
public class Captcha {
private int width;
private int height;
private int num;
private String code;
private static final Random ran = new Random();
private static Captcha captcha;
private Captcha(){
code = “0123456789“;
num = 4;
}
public static Captcha getInstance() {
if(captcha==null) captcha = new Captcha();
return captcha;
}
public void set(int widthint heightint numString code) {
this.width = width;
this.height = height;
this.setNum(num);
this.setCode(code);
}
public void set(int widthint height) {
this.width = width;
this.height = height;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String generateCheckcode() {
StringBuffer cc = new StringBuffer();
for(int i=0;i cc.append(code.charAt(ran.nextInt(code.length())));
}
return cc.toString();
}
public BufferedImage generateCheckImg(String checkcode) {
//创建一个图片对象
BufferedImage img = new BufferedImage(width height BufferedImage.TYPE_INT_RGB);
//获取图片对象的画笔
Graphics2D graphic = img.createGraphics();
graphic.setColor(Color.WHITE);
graphic.fillRect(0 0 width height);
graphic.setColor(Color.BLACK);
graphic.drawRect(0 0 width-1 height-1);
Font font = new Font(“宋体“Font.BOLD+Font.ITALIC(int)(height*0.8));
graphic.setFont(font);
for(int i=0;i graphic.setColor(new Color(ran.nextInt(255)ran.nextInt(255)ran.nextInt(255)));
graphic.drawString(String.valueOf(checkcode.charAt(i)) i*(width/num)+4 (int)(height*0.8));
}
//加一些点
for(int i=0;i<(width+height);i++) {
graphic.setColor(new Color(ran.nextInt(255)ran.nextInt(255)ran.nextInt(255)));
graphic.drawOval(ran.nextInt(width) ran.nextInt(height) 1 1);
}
//加一些线
for(int i=0;i<4;i++) {
graphic.setColor(new Color(ran.nextInt(255)ran.nextInt(255)ran.nextInt(255)));
graphic.drawLine(0 ran.nextInt(height) width ran.nextInt(height));
}
return img;
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-10-11 20:02 cms\
目录 0 2017-10-11 20:02 cms\basic-common\
文件 1022 2013-04-28 16:12 cms\basic-common\.classpath
文件 564 2013-04-28 16:12 cms\basic-common\.project
目录 0 2017-10-11 20:02 cms\basic-common\.settings\
文件 119 2013-04-28 16:12 cms\basic-common\.settings\org.eclipse.core.resources.prefs
文件 243 2013-04-28 16:12 cms\basic-common\.settings\org.eclipse.jdt.core.prefs
文件 90 2013-04-28 16:12 cms\basic-common\.settings\org.eclipse.m2e.core.prefs
目录 0 2017-10-13 17:44 cms\basic-common\.svn\
文件 3 2013-04-28 16:34 cms\basic-common\.svn\entries
文件 3 2013-04-28 16:34 cms\basic-common\.svn\format
目录 0 2017-10-11 20:02 cms\basic-common\.svn\pristine\
目录 0 2017-10-11 20:02 cms\basic-common\.svn\pristine\05\
文件 564 2013-04-28 16:34 cms\basic-common\.svn\pristine\05\05fecd9a6de6ed247b24cf7d07f05e10c35efac0.svn-ba
目录 0 2017-10-11 20:02 cms\basic-common\.svn\pristine\0d\
文件 119 2013-04-28 16:34 cms\basic-common\.svn\pristine\0d\0d78a989c585aac6e6244dedcef06df92d4ea31b.svn-ba
目录 0 2017-10-11 20:02 cms\basic-common\.svn\pristine\2a\
文件 2627 2013-05-17 23:01 cms\basic-common\.svn\pristine\2a\2adeb0bdb3ccfb8cdf86f7ebca875900923c38a0.svn-ba
目录 0 2017-10-11 20:02 cms\basic-common\.svn\pristine\41\
文件 650 2013-04-28 16:34 cms\basic-common\.svn\pristine\41\41633887046d8e987f2f0f522f614c5451424a30.svn-ba
目录 0 2017-10-11 20:02 cms\basic-common\.svn\pristine\5d\
文件 692 2013-05-21 15:16 cms\basic-common\.svn\pristine\5d\5d42dd249764df909eaa50519e19f5f0ffc190af.svn-ba
目录 0 2017-10-11 20:02 cms\basic-common\.svn\pristine\8b\
文件 411 2013-05-17 23:01 cms\basic-common\.svn\pristine\8b\8b84b8417d5486b5317f77db620767527dcf5d20.svn-ba
目录 0 2017-10-11 20:02 cms\basic-common\.svn\pristine\a1\
文件 90 2013-04-28 16:34 cms\basic-common\.svn\pristine\a1\a112be21c325d37ebc17baafd40c0386b5d09df1.svn-ba
目录 0 2017-10-11 20:02 cms\basic-common\.svn\pristine\a2\
文件 243 2013-04-28 16:34 cms\basic-common\.svn\pristine\a2\a2557d0c92536585bd6574cbcbfd682feac5fa33.svn-ba
目录 0 2017-10-11 20:02 cms\basic-common\.svn\pristine\a3\
文件 4456 2013-04-28 16:34 cms\basic-common\.svn\pristine\a3\a3b79b5ad352c865eb10f1dcd6639462d63da61a.svn-ba
目录 0 2017-10-11 20:02 cms\basic-common\.svn\pristine\a6\
............此处省略2025个文件信息
- 上一篇:锂电池组SOC估计算法经典文献
- 下一篇:unity+tuio实现触屏demo
评论
共有 条评论