|
|
|
@ -8,25 +8,39 @@ import java.awt.Color;
|
|
|
|
|
import java.awt.Font; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
* 链接字符串工具类 |
|
|
|
|
* |
|
|
|
|
* @author Harrison |
|
|
|
|
* @version 10.0 |
|
|
|
|
* created by Harrison on 2022/05/24 |
|
|
|
|
**/ |
|
|
|
|
public class LinkStrUtils { |
|
|
|
|
|
|
|
|
|
public static final UILabel LABEL = new UILabel(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 创建链接label |
|
|
|
|
* */ |
|
|
|
|
public static UILabel generateLabel(String html, JComponent templateLabel) { |
|
|
|
|
|
|
|
|
|
String style = generateStyle(templateLabel.getBackground(), templateLabel.getFont(), templateLabel.getForeground()); |
|
|
|
|
String fullHtml = generateHtmlTag(style, html); |
|
|
|
|
return new UILabel(fullHtml); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 创建链接字符串,html格式 |
|
|
|
|
* */ |
|
|
|
|
public static String generateHtmlTag(String html) { |
|
|
|
|
|
|
|
|
|
String defaultStyle = generateDefaultStyle(); |
|
|
|
|
return generateHtmlTag(defaultStyle, html); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 创建链接字符串,html格式 |
|
|
|
|
* */ |
|
|
|
|
public static String generateHtmlTag(String style, String html) { |
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(style)) { |
|
|
|
@ -37,16 +51,25 @@ public class LinkStrUtils {
|
|
|
|
|
} |
|
|
|
|
return "<html><body style=\"" + style + "\">" + html + "</body></html>"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 创建链接字符串,html格式 |
|
|
|
|
* */ |
|
|
|
|
public static String generateLinkTag(String link, String text) { |
|
|
|
|
|
|
|
|
|
return "<a href=\"" + link + "\">" + text + "</a>"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 创建链接字符串,无下划线,html格式 |
|
|
|
|
* */ |
|
|
|
|
public static String generateLinkTagWithoutUnderLine(String link, String text) { |
|
|
|
|
return "<a style=\"text-decoration:none;\" href=\"" + link + "\">" + text + "</a>"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 创建链接字符串的html style |
|
|
|
|
* */ |
|
|
|
|
public static String generateStyle(Color backgroundColor, Font font, Color fontColor) { |
|
|
|
|
|
|
|
|
|
// 构建相同风格样式
|
|
|
|
@ -60,6 +83,9 @@ public class LinkStrUtils {
|
|
|
|
|
return style.toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 创建链接字符串的html style |
|
|
|
|
* */ |
|
|
|
|
public static String generateStyle(Font font, Color fontColor) { |
|
|
|
|
|
|
|
|
|
// 构建相同风格样式
|
|
|
|
@ -72,7 +98,9 @@ public class LinkStrUtils {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 创建默认style |
|
|
|
|
* */ |
|
|
|
|
public static String generateDefaultStyle() { |
|
|
|
|
|
|
|
|
|
return generateStyle(LABEL.getBackground(), LABEL.getFont(), LABEL.getForeground()); |
|
|
|
|