mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package cn.hutool.swing;
|
||||
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import cn.hutool.core.net.URLUtil;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.File;
|
||||
|
@@ -7,7 +7,7 @@ import cn.hutool.swing.img.ImgUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import cn.hutool.core.net.URLUtil;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
|
@@ -2,7 +2,7 @@ package cn.hutool.swing.captcha;
|
||||
|
||||
import cn.hutool.swing.img.GraphicsUtil;
|
||||
import cn.hutool.swing.img.ImgUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
|
||||
import java.awt.Color;
|
||||
@@ -57,7 +57,7 @@ public class CircleCaptcha extends AbstractCaptcha {
|
||||
@Override
|
||||
public Image createImage(String code) {
|
||||
final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
final Graphics2D g = ImgUtil.createGraphics(image, ObjectUtil.defaultIfNull(this.background, Color.WHITE));
|
||||
final Graphics2D g = ImgUtil.createGraphics(image, ObjUtil.defaultIfNull(this.background, Color.WHITE));
|
||||
|
||||
// 随机画干扰圈圈
|
||||
drawInterfere(g);
|
||||
|
@@ -2,7 +2,7 @@ package cn.hutool.swing.captcha;
|
||||
|
||||
|
||||
import cn.hutool.swing.img.gif.AnimatedGifEncoder;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
@@ -148,7 +148,7 @@ public class GifCaptcha extends AbstractCaptcha {
|
||||
//或得图形上下文
|
||||
Graphics2D g2d = image.createGraphics();
|
||||
//利用指定颜色填充背景
|
||||
g2d.setColor(ObjectUtil.defaultIfNull(this.background, Color.WHITE));
|
||||
g2d.setColor(ObjUtil.defaultIfNull(this.background, Color.WHITE));
|
||||
g2d.fillRect(0, 0, width, height);
|
||||
AlphaComposite ac;
|
||||
// 字符的y坐标
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.hutool.swing.captcha;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.swing.img.GraphicsUtil;
|
||||
import cn.hutool.swing.img.ImgUtil;
|
||||
@@ -49,7 +49,7 @@ public class LineCaptcha extends AbstractCaptcha {
|
||||
public Image createImage(String code) {
|
||||
// 图像buffer
|
||||
final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
final Graphics2D g = GraphicsUtil.createGraphics(image, ObjectUtil.defaultIfNull(this.background, Color.WHITE));
|
||||
final Graphics2D g = GraphicsUtil.createGraphics(image, ObjUtil.defaultIfNull(this.background, Color.WHITE));
|
||||
|
||||
// 干扰线
|
||||
drawInterfere(g);
|
||||
|
@@ -2,7 +2,7 @@ package cn.hutool.swing.captcha;
|
||||
|
||||
import cn.hutool.swing.img.GraphicsUtil;
|
||||
import cn.hutool.swing.img.ImgUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
|
||||
import java.awt.Color;
|
||||
@@ -57,13 +57,13 @@ public class ShearCaptcha extends AbstractCaptcha {
|
||||
@Override
|
||||
public Image createImage(String code) {
|
||||
final BufferedImage image = new BufferedImage(this.width, this.height, BufferedImage.TYPE_INT_RGB);
|
||||
final Graphics2D g = GraphicsUtil.createGraphics(image, ObjectUtil.defaultIfNull(this.background, Color.WHITE));
|
||||
final Graphics2D g = GraphicsUtil.createGraphics(image, ObjUtil.defaultIfNull(this.background, Color.WHITE));
|
||||
|
||||
// 画字符串
|
||||
drawString(g, code);
|
||||
|
||||
// 扭曲
|
||||
shear(g, this.width, this.height, ObjectUtil.defaultIfNull(this.background, Color.WHITE));
|
||||
shear(g, this.width, this.height, ObjUtil.defaultIfNull(this.background, Color.WHITE));
|
||||
// 画干扰线
|
||||
drawInterfere(g, 0, RandomUtil.randomInt(this.height) + 1, this.width, RandomUtil.randomInt(this.height) + 1, this.interfereCount, ImgUtil.randomColor());
|
||||
|
||||
|
@@ -3,7 +3,7 @@ package cn.hutool.swing.captcha.generator;
|
||||
import cn.hutool.core.math.Calculator;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
||||
/**
|
||||
* 数字计算验证码生成器
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.hutool.swing.captcha.generator;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
||||
/**
|
||||
* 随机字符验证码生成器<br>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.hutool.core.swing.clipboard;
|
||||
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.ClipboardOwner;
|
||||
@@ -134,7 +134,7 @@ public enum ClipboardMonitor implements ClipboardOwner, Runnable, Closeable {
|
||||
Transferable transferable = null;
|
||||
for (ClipboardListener listener : listenerSet) {
|
||||
try {
|
||||
transferable = listener.onChange(clipboard, ObjectUtil.defaultIfNull(transferable, newContents));
|
||||
transferable = listener.onChange(clipboard, ObjUtil.defaultIfNull(transferable, newContents));
|
||||
} catch (Throwable e) {
|
||||
// 忽略事件处理异常,保证所有监听正常执行
|
||||
}
|
||||
@@ -142,7 +142,7 @@ public enum ClipboardMonitor implements ClipboardOwner, Runnable, Closeable {
|
||||
|
||||
if (isRunning) {
|
||||
// 继续监听
|
||||
clipboard.setContents(ObjectUtil.defaultIfNull(transferable, ObjectUtil.defaultIfNull(newContents, contents)), this);
|
||||
clipboard.setContents(ObjUtil.defaultIfNull(transferable, ObjUtil.defaultIfNull(newContents, contents)), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,8 +2,7 @@ package cn.hutool.swing.img;
|
||||
|
||||
import cn.hutool.core.io.FileTypeUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.swing.img.ImgUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.ImageIcon;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.hutool.swing.img;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
@@ -172,7 +172,7 @@ public class GraphicsUtil {
|
||||
}
|
||||
|
||||
g.setFont(font);
|
||||
g.setColor(ObjectUtil.defaultIfNull(color, Color.BLACK));
|
||||
g.setColor(ObjUtil.defaultIfNull(color, Color.BLACK));
|
||||
g.drawString(str, point.x, point.y);
|
||||
|
||||
return g;
|
||||
|
@@ -6,8 +6,8 @@ import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.io.resource.Resource;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.stream.ImageInputStream;
|
||||
@@ -658,7 +658,7 @@ public class Img implements Serializable {
|
||||
int height = image.getHeight(null);
|
||||
Graphics2D g = image.createGraphics();
|
||||
|
||||
g.setColor(ObjectUtil.defaultIfNull(color, Color.BLACK));
|
||||
g.setColor(ObjUtil.defaultIfNull(color, Color.BLACK));
|
||||
if (null != stroke) {
|
||||
g.setStroke(stroke);
|
||||
}
|
||||
@@ -784,7 +784,7 @@ public class Img implements Serializable {
|
||||
* @return 有效的源图片
|
||||
*/
|
||||
private Image getValidSrcImg() {
|
||||
return ObjectUtil.defaultIfNull(this.targetImage, this.srcImage);
|
||||
return ObjUtil.defaultIfNull(this.targetImage, this.srcImage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -9,10 +9,10 @@ import cn.hutool.core.io.resource.Resource;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.core.net.URLUtil;
|
||||
|
||||
import javax.imageio.IIOImage;
|
||||
import javax.imageio.ImageIO;
|
||||
@@ -1399,7 +1399,7 @@ public class ImgUtil {
|
||||
g.setColor(backgroundColor);
|
||||
g.fillRect(0, 0, width, height);
|
||||
}
|
||||
g.setColor(ObjectUtil.defaultIfNull(fontColor, Color.BLACK));
|
||||
g.setColor(ObjUtil.defaultIfNull(fontColor, Color.BLACK));
|
||||
g.setFont(font);// 设置画笔字体
|
||||
g.drawString(str, 0, font.getSize());// 画出字符串
|
||||
g.dispose();
|
||||
|
@@ -2,7 +2,7 @@ package cn.hutool.swing.img;
|
||||
|
||||
import cn.hutool.core.io.FileTypeUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import cn.hutool.core.net.URLUtil;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
Reference in New Issue
Block a user