Commit 9330be5e authored by mengmeng's avatar mengmeng

初始化上传-V1

parents
Pipeline #237 failed with stages
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
target
# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar
*.iml
.idea
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
\ No newline at end of file
木兰宽松许可证, 第2版
木兰宽松许可证, 第2版
2020年1月 http://license.coscl.org.cn/MulanPSL2
您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束:
0. 定义
“软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
“贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
“贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
“法人实体”是指提交贡献的机构及其“关联实体”。
“关联实体”是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。
1. 授予版权许可
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。
2. 授予专利许可
每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。
3. 无商标许可
“本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。
4. 分发限制
您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。
5. 免责声明与责任限制
“软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。
6. 语言
“本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。
条款结束
如何将木兰宽松许可证,第2版,应用到您的软件
如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步:
1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字;
2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中;
3, 请将如下声明文本放入每个源文件的头部注释中。
Copyright (c) [Year] [name of copyright holder]
[Software Name] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
Mulan Permissive Software License,Version 2
Mulan Permissive Software License,Version 2 (Mulan PSL v2)
January 2020 http://license.coscl.org.cn/MulanPSL2
Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions:
0. Definition
Software means the program and related documents which are licensed under this License and comprise all Contribution(s).
Contribution means the copyrightable work licensed by a particular Contributor under this License.
Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License.
Legal Entity means the entity making a Contribution and all its Affiliates.
Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity.
1. Grant of Copyright License
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not.
2. Grant of Patent License
Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken.
3. No Trademark License
No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4.
4. Distribution Restriction
You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software.
5. Disclaimer of Warranty and Limitation of Liability
THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
6. Language
THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL.
END OF THE TERMS AND CONDITIONS
How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software
To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps:
i Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner;
ii Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package;
iii Attach the statement to the appropriate annotated syntax at the beginning of each source file.
Copyright (c) [Year] [name of copyright holder]
[Software Name] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
QRCodeBuilder 二维码生成工具
#### 项目简介:
QRCodeBuilder是使用javafx开发的一款二维码生成工具,可快速生成二维码。
**xJavaFxTool交流QQ群:== [387473650(此群已满)](https://jq.qq.com/?_wv=1027&k=59UDEAD) 请加群②[1104780992](https://jq.qq.com/?_wv=1027&k=bhAdkju9) ==**
#### 环境搭建说明:
- 开发环境为jdk1.8,基于maven构建
- 使用eclipase或Intellij Idea开发(推荐使用[Intellij Idea](https://www.jetbrains.com/?from=xJavaFxTool))
- 该项目为javaFx开发的实用小工具集[xJavaFxTool](https://gitee.com/xwintop/xJavaFxTool)的插件。
- 本项目使用了[lombok](https://projectlombok.org/),在查看本项目时如果您没有下载lombok 插件,请先安装,不然找不到get/set等方法
- 依赖的[xcore包](https://gitee.com/xwintop/xcore)已上传至git托管的maven平台,git托管maven可参考教程(若无法下载请拉取项目自行编译)。[教程地址:点击进入](http://blog.csdn.net/u011747754/article/details/78574026)
![二维码生成工具.png](images/二维码生成工具.png)
![二维码生成工具.gif](images/二维码生成工具.gif)
#### 版本记录
- 1.0.0
1. 完成基本功能配置
- 1.0.1 20200419
1. 优化界面布局
QRCodeBuilder
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xwintop</groupId>
<artifactId>x-QRCodeBuilder</artifactId>
<version>0.0.2</version>
<packaging>jar</packaging>
<name>x-QRCodeBuilder</name>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>aliyunmaven</id>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</repository>
<repository>
<id>xwintop-maven</id>
<url>https://864381832.github.io/maven/repository</url>
</repository>
<repository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<url>http://repo.spring.io/milestone</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.xwintop</groupId>
<artifactId>xcore</artifactId>
<version>0.0.6</version>
<!-- <scope>provided</scope>-->
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.6</version>
<scope>provided</scope>
</dependency>
<!--map转换json-->
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>net.sf.ezmorph</groupId>
<artifactId>ezmorph</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<!-- 二维码识别与生成工具库 -->
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.3.3</version>
</dependency>
<!-- java注册全局热键工具类 -->
<dependency>
<groupId>com.github.tulskiy</groupId>
<artifactId>jkeymaster</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<encoding>utf-8</encoding>
<archive>
<manifest>
<mainClass>com.xwintop.xJavaFxTool.QrCodeBuilderMain</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
package com.xwintop.xJavaFxTool;
import com.xwintop.xcore.javafx.FxApp;
import java.net.URL;
import java.util.ResourceBundle;
import com.xwintop.xcore.util.javafx.JavaFxSystemUtil;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class QrCodeBuilderMain extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
FxApp.init(primaryStage, null);
FXMLLoader fXMLLoader = QrCodeBuilderMain.getFXMLLoader();
ResourceBundle resourceBundle = fXMLLoader.getResources();
Parent root = fXMLLoader.load();
//是否允许动态调整窗口大小
primaryStage.setResizable(false);
// primaryStage.setResizable(true);
primaryStage.setTitle(resourceBundle.getString("Title"));
primaryStage.getIcons().add(new Image("/images/QRCodeBuilderIcon.png"));
//设置初始化窗口大小
// double[] screenSize = JavaFxSystemUtil.getScreenSizeByScale(0.74D, 1.0D);
// primaryStage.setScene(new Scene(root, screenSize[0], screenSize[1]));
primaryStage.setScene(new Scene(root, 1000, 700));
primaryStage.show();
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
System.exit(0);
}
});
}
public static FXMLLoader getFXMLLoader() {
ResourceBundle resourceBundle = ResourceBundle.getBundle("locale.QRCodeBuilder");
URL url = Object.class.getResource("/com/xwintop/xJavaFxTool/fxmlView/littleTools/QRCodeBuilder.fxml");
return new FXMLLoader(url, resourceBundle);
}
}
package com.xwintop.xJavaFxTool.utils;
import com.xwintop.xJavaFxTool.view.littleTools.PeopleInfo;
import java.util.List;
import java.util.Map;
/**
* @author Eve
* @email mengmengeve@gmail.com
* @create 2021/6/7
*/
public class CommonUtils {
/**
* 判断输入是否为null
*
*/
public static String ifInputContainNull(Map<String,Object> map){
boolean flag =true;
String result = "";
for(Map.Entry<String,Object> entry : map.entrySet()){
if(entry.getValue() == null || "".equals(entry.getValue()) ){
flag = false;
// result += entry.getKey();
break;
}
}
if(!flag){
return result = "请您核对所有信息均已输入";
}
return result;
}
}
package com.xwintop.xJavaFxTool.utils;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
public enum CorrectionLevel {
L(ErrorCorrectionLevel.L, "~7%", 7),
M(ErrorCorrectionLevel.M, "~15%", 15),
Q(ErrorCorrectionLevel.Q, "~25%", 25),
H(ErrorCorrectionLevel.H, "~30%", 30),
;
private ErrorCorrectionLevel errorCorrectionLevel;
private String name;
private int maxOverlay;
CorrectionLevel(ErrorCorrectionLevel errorCorrectionLevel, String name, int maxOverlay) {
this.errorCorrectionLevel = errorCorrectionLevel;
this.name = name;
this.maxOverlay = maxOverlay;
}
public ErrorCorrectionLevel getErrorCorrectionLevel() {
return errorCorrectionLevel;
}
public String getName() {
return name;
}
public int getMaxOverlay() {
return maxOverlay;
}
}
package com.xwintop.xJavaFxTool.utils;
import com.google.zxing.*;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.client.j2se.MatrixToImageConfig;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import javafx.embed.swing.SwingFXUtils;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
/**
* @ClassName: QRCodeUtil
* @Description: 二维码工具类
* @author: Administrator
* @date: 2017年8月12日 下午2:21:08
*/
public class QRCodeUtil {
private static final int width = 300;// 默认二维码宽度
private static final int height = 300;// 默认二维码高度
private static final String format = "png";// 默认二维码文件格式
private static final Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>();// 二维码参数
private static final Map<DecodeHintType, Object> dhints = new HashMap<DecodeHintType, Object>();// 识别二维码参数
static {
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");// 字符编码
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);// 容错等级 L、M、Q、H 其中 L 为最低, H 为最高
hints.put(EncodeHintType.MARGIN, 2);// 二维码边界空白大小 1,2,3,4 (4为默认,最大)
dhints.put(DecodeHintType.CHARACTER_SET, "UTF-8");
}
/**
* 返回一个 BufferedImage 对象
*
* @param content
* 二维码内容
* @param width
* 宽
* @param height
* 高
*/
public static BufferedImage toBufferedImage(String content, int width, int height)
throws WriterException, IOException {
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
return MatrixToImageWriter.toBufferedImage(bitMatrix);
}
public static BufferedImage toBufferedImage(String content) throws WriterException, IOException {
return toBufferedImage(content,width, height);
}
/**
* @Title: toImage
* @Description: 转换为javaFxImage二维码图片
*/
public static Image toImage(String content, int width, int height) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
try {
writeToStream(content, stream, width, height);
} catch (Exception e) {
e.printStackTrace();
}
Image image = new Image(new ByteArrayInputStream(stream.toByteArray()));
return image;
}
public static Image toImage(String content, int width, int height,String format,ErrorCorrectionLevel errorCorrectionLevel,Integer margin,Color onColor,Color offColor,String formatImage) {
Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>();// 二维码参数
hints.put(EncodeHintType.CHARACTER_SET, format);// 字符编码
hints.put(EncodeHintType.ERROR_CORRECTION, errorCorrectionLevel);// 容错等级 L、M、Q、H 其中 L 为最低, H 为最高
hints.put(EncodeHintType.MARGIN, margin);// 二维码边界空白大小 1,2,3,4 (4为默认,最大)
ByteArrayOutputStream stream = new ByteArrayOutputStream();
try {
java.awt.Color onColorw = new java.awt.Color((float)onColor.getRed(), (float)onColor.getGreen(), (float)onColor.getBlue(), (float)onColor.getOpacity());
java.awt.Color offColorw = new java.awt.Color((float)offColor.getRed(), (float)offColor.getGreen(), (float)offColor.getBlue(), (float)offColor.getOpacity());
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
MatrixToImageConfig config = new MatrixToImageConfig(onColorw.getRGB(), offColorw.getRGB());
MatrixToImageWriter.writeToStream(bitMatrix, formatImage, stream,config);
} catch (Exception e) {
e.printStackTrace();
}
Image image = new Image(new ByteArrayInputStream(stream.toByteArray()));
return image;
}
/**
* 二维码绘制logo
* @param image 二维码图片文件
* @param logoImg logo图片文件
* */
public static Image encodeImgLogo(Image image,Image logoImg,int logoSize){
BufferedImage twodimensioncode = SwingFXUtils.fromFXImage(image, null);
try{
//读取二维码图片
//获取画笔
Graphics2D g = twodimensioncode.createGraphics();
//读取logo图片
BufferedImage logo = SwingFXUtils.fromFXImage(logoImg, null);
//设置二维码大小,太大,会覆盖二维码,此处15%
int logoWidth = logo.getWidth(null) > twodimensioncode.getWidth()*logoSize /100 ? (twodimensioncode.getWidth()*logoSize /100) : logo.getWidth(null);
int logoHeight = logo.getHeight(null) > twodimensioncode.getHeight()*logoSize /100 ? (twodimensioncode.getHeight()*logoSize /100) : logo.getHeight(null);
//设置logo图片放置位置
//中心
int x = (twodimensioncode.getWidth() - logoWidth) / 2;
int y = (twodimensioncode.getHeight() - logoHeight) / 2;
//右下角,15为调整值
// int x = twodimensioncode.getWidth() - logoWidth-15;
// int y = twodimensioncode.getHeight() - logoHeight-15;
//开始合并绘制图片
g.drawImage(logo, x, y, logoWidth, logoHeight, null);
g.drawRoundRect(x, y, logoWidth, logoHeight, 15 ,15);
//logo边框大小
g.setStroke(new BasicStroke(2));
//logo边框颜色
g.setColor(java.awt.Color.WHITE);
g.drawRect(x, y, logoWidth, logoHeight);
g.dispose();
logo.flush();
twodimensioncode.flush();
}catch(Exception e){
System.out.println("二维码绘制logo失败");
}
return SwingFXUtils.toFXImage(twodimensioncode, null) ;
}
public static BufferedImage encodeImgLogo(File twodimensioncodeImg,File logoImg){
BufferedImage twodimensioncode = null;
try{
if(!twodimensioncodeImg.isFile() || !logoImg.isFile()){
System.out.println("输入非图片");
return null;
}
//读取二维码图片
twodimensioncode = ImageIO.read(twodimensioncodeImg);
//获取画笔
Graphics2D g = twodimensioncode.createGraphics();
//读取logo图片
BufferedImage logo = ImageIO.read(logoImg);
//设置二维码大小,太大,会覆盖二维码,此处20%
int logoWidth = logo.getWidth(null) > twodimensioncode.getWidth()*2 /10 ? (twodimensioncode.getWidth()*2 /10) : logo.getWidth(null);
int logoHeight = logo.getHeight(null) > twodimensioncode.getHeight()*2 /10 ? (twodimensioncode.getHeight()*2 /10) : logo.getHeight(null);
//设置logo图片放置位置
//中心
int x = (twodimensioncode.getWidth() - logoWidth) / 2;
int y = (twodimensioncode.getHeight() - logoHeight) / 2;
//右下角,15为调整值
// int x = twodimensioncode.getWidth() - logoWidth-15;
// int y = twodimensioncode.getHeight() - logoHeight-15;
//开始合并绘制图片
g.drawImage(logo, x, y, logoWidth, logoHeight, null);
g.drawRoundRect(x, y, logoWidth, logoHeight, 15 ,15);
//logo边框大小
g.setStroke(new BasicStroke(2));
//logo边框颜色
g.setColor(java.awt.Color.WHITE);
g.drawRect(x, y, logoWidth, logoHeight);
g.dispose();
logo.flush();
twodimensioncode.flush();
}catch(Exception e){
System.out.println("二维码绘制logo失败");
}
return twodimensioncode;
}
/**
* 从Image中解析二维码
*/
public static String toDecode(Image image) {
BufferedImage bimage = SwingFXUtils.fromFXImage(image, null);
return toDecode(bimage);
}
/**
* 从BufferedImage中解析二维码
*/
public static String toDecode(BufferedImage bimage) {
try {
LuminanceSource source = new BufferedImageLuminanceSource(bimage);
Binarizer binarizer = new HybridBinarizer(source);
BinaryBitmap binaryBitmap = new BinaryBitmap(binarizer);
Result result = new MultiFormatReader().decode(binaryBitmap, dhints);// 对图像进行解码
return result.getText();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* @Title: toDecode
* @Description: 从文件总解析二维码
*/
public static String toDecode(File file) {
try {
BufferedImage image = ImageIO.read(file);
LuminanceSource source = new BufferedImageLuminanceSource(image);
Binarizer binarizer = new HybridBinarizer(source);
BinaryBitmap binaryBitmap = new BinaryBitmap(binarizer);
Result result = new MultiFormatReader().decode(binaryBitmap, dhints);// 对图像进行解码
return result.getText();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 将二维码图片输出到一个流中
*
* @param content
* 二维码内容
* @param stream
* 输出流
* @param width
* 宽
* @param height
* 高
*/
public static void writeToStream(String content, OutputStream stream, int width, int height)
throws WriterException, IOException {
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
// MatrixToImageConfig config = new MatrixToImageConfig(java.awt.Color.GREEN.getRGB(), java.awt.Color.RED.getRGB());
// MatrixToImageWriter.writeToStream(bitMatrix, format, stream,config);
MatrixToImageWriter.writeToStream(bitMatrix, format, stream);
}
/**
* 生成二维码图片文件
*
* @param content
* 二维码内容
* @param path
* 文件保存路径
* @param width
* 宽
* @param height
* 高
*/
public static void createQRCode(String content, String path, int width, int height)
throws WriterException, IOException {
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
// toPath() 方法由 jdk1.7 及以上提供
MatrixToImageWriter.writeToPath(bitMatrix, format, new File(path).toPath());
}
}
This diff is collapsed.
package com.xwintop.xJavaFxTool.view.littleTools;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author Eve
* @email mengmengeve@gmail.com
* @create 2021/6/5
*/
@Data
@EqualsAndHashCode(callSuper=false)
public class PeopleInfo {
private String userName;
private String userMobile;
private String userRole;
private String userIdNo;
/**
* 将输入的用户信息组装成实体
* @param name
* @param mobile
* @param roleName
* @return
*/
public static PeopleInfo assemblePeopleInfo(String name,String mobile,String idNo,String roleName){
PeopleInfo peopleInfo = new PeopleInfo();
peopleInfo.setUserName(name);
peopleInfo.setUserMobile(mobile);
peopleInfo.setUserRole(roleName);
peopleInfo.setUserIdNo(idNo);
return peopleInfo;
}
}
package com.xwintop.xJavaFxTool.view.littleTools;
import com.jfoenix.controls.JFXSlider;
import com.xwintop.xJavaFxTool.utils.CorrectionLevel;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.ColorPicker;
import javafx.scene.control.DatePicker;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.control.TitledPane;
import javafx.scene.image.ImageView;
public abstract class QRCodeBuilderView implements Initializable {
@FXML
protected Button builderButton;
@FXML
protected Button snapshotButton;
@FXML
protected TextArea contentTextField;
/**
* 案件名称
*/
@FXML
protected TextField caseName;
/**
* 案件号-第二次录入
*/
@FXML
protected TextField caseNum1;
/**
* 受案号
*/
@FXML
protected TextField caseNum;
/**
* 简要案情
*/
@FXML
protected TextArea caseDetail;
/**
* 承办人名字
*/
@FXML
protected TextField undertaker;
/**
* 承办人电话
*/
@FXML
protected TextField undertakerMobile;
/**
* 当事人
*/
@FXML
protected TextField peopleName;
/**
* 当事人电话
*/
@FXML
protected TextField peopleMobile;
/**
* 当事人身份证号
*/
@FXML
protected TextField peopleIdNo;
/**
* 强制措施
*/
@FXML
protected TextField coerciveMeasures;
/**
* 受理审结日期
*/
@FXML
protected DatePicker acceptanceDate;
/**
* 办结日期
*/
@FXML
protected DatePicker completeDate;
/**
* 案件比
*/
@FXML
protected TextField caseQuality;
/**
* 律师
*/
@FXML
protected TextField lower;
/**
* 律师电话
*/
@FXML
protected TextField lowerMobile;
/**
* 代理人
*/
@FXML
protected TextField agent;
/**
* 代理人电话
*/
@FXML
protected TextField agentMobile;
@FXML
protected ChoiceBox<String> codeFormatChoiceBox;
@FXML
protected ImageView codeImageView;
@FXML
protected ImageView codeImageView1;
@FXML
protected ColorPicker onColorColorPicker;
@FXML
protected ColorPicker offColorColorPicker;
@FXML
protected ChoiceBox<CorrectionLevel> errorCorrectionLevelChoiceBox;
@FXML
protected Button saveButton;
@FXML
protected Button logoButton;
@FXML
protected Button snapshotDesktopButton;
@FXML
protected ChoiceBox<Integer> marginChoiceBox;
@FXML
protected ChoiceBox<String> formatImageChoiceBox;
@FXML
protected CheckBox logoCheckBox;
@FXML
protected JFXSlider logoSlider;
@FXML
protected TitledPane first;
@FXML
protected TitledPane second;
}
package com.xwintop.xJavaFxTool.view.littleTools;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* @author Eve
* @email mengmengeve@gmail.com
* @create 2021/6/5
*/
@Data
@EqualsAndHashCode(callSuper=false)
public class QRContent {
//第二次录入生成的json信息
/**
* 受案号
*/
public String caseNum;
/**
* 案件名
*/
public String caseName;
/**
* 强制措施
*/
public String coerciveMeasures;
/**
* 受理审结时间
*/
public String acceptanceDate;
/**
* 办结日期
*/
public String completeDate;
/**
* 案件比
*/
public String caseQuality;
/**
* 案件相关人员信息
* 包括:
* 当事人
* 律师
* 受理人
*/
public List<PeopleInfo> peopleInfo;
}
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXSlider?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.control.ColorPicker?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.TitledPane?>
<?import javafx.scene.control.Tooltip?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.DatePicker?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.Accordion?>
<AnchorPane xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="com.xwintop.xJavaFxTool.controller.littleTools.QRCodeBuilderController">
<children>
<BorderPane layoutX="24.0" layoutY="17.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0"
AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0" >
<left>
<VBox prefWidth="350.0" spacing="2">
<TitledPane fx:id="first" collapsible="true" text="第一次录入">
<VBox spacing="10">
<HBox spacing="5">
<VBox spacing="5">
<Label text="受案号:"/>
<TextField fx:id="caseNum" prefWidth="350" />
</VBox>
</HBox>
<HBox spacing="5">
<VBox spacing="5">
<Label text="承办人:"/>
<TextField fx:id="undertaker" />
</VBox>
<VBox spacing="5">
<Label text="联系电话:"/>
<TextField fx:id="undertakerMobile" />
</VBox>
</HBox>
<HBox spacing="5">
<VBox spacing="5">
<Label text="简要案情(限150个字):"/>
<TextArea fx:id="caseDetail" prefHeight="350" wrapText="true"/>
</VBox>
</HBox>
</VBox>
</TitledPane>
<TitledPane fx:id="second" expanded="false" collapsible="true" text="第二次录入">
<VBox spacing="10">
<HBox spacing="5">
<VBox spacing="5">
<Label text="受案号:"/>
<TextField fx:id="caseNum1" prefWidth="350" />
</VBox>
</HBox>
<HBox spacing="5">
<VBox spacing="5">
<Label text="案件名:"/>
<TextField fx:id="caseName" prefWidth="350" />
</VBox>
</HBox>
<HBox spacing="5">
<VBox spacing="5">
<Label text="当事人:"/>
<TextField fx:id="peopleName" />
</VBox>
<VBox spacing="5">
<Label text="联系电话:"/>
<TextField fx:id="peopleMobile" />
</VBox>
</HBox>
<HBox spacing="5">
<VBox spacing="5">
<Label text="当事人身份证号:"/>
<TextField fx:id="peopleIdNo" prefWidth="350" />
</VBox>
</HBox>
<HBox spacing="5">
<VBox spacing="5">
<Label text="强制措施"/>
<TextField fx:id="coerciveMeasures" prefWidth="350" />
</VBox>
</HBox>
<HBox spacing="5">
<VBox spacing="5">
<Label text="受理审结日期:"/>
<DatePicker fx:id="acceptanceDate" />
</VBox>
<VBox spacing="5">
<Label text="办结日期:"/>
<DatePicker fx:id="completeDate" />
</VBox>
</HBox>
<HBox spacing="5">
<VBox spacing="5">
<Label text="案件比:"/>
<TextField fx:id="caseQuality" />
</VBox>
</HBox>
<HBox spacing="5">
<VBox spacing="5">
<Label text="律师:"/>
<TextField fx:id="lower" />
</VBox>
<VBox spacing="5">
<Label text="联系电话:"/>
<TextField fx:id="lowerMobile" />
</VBox>
</HBox>
<HBox spacing="5">
<VBox spacing="5">
<Label text="代理人:"/>
<TextField fx:id="agent" />
</VBox>
<VBox spacing="5">
<Label text="联系电话:"/>
<TextField fx:id="agentMobile" />
</VBox>
</HBox>
</VBox>
</TitledPane>
</VBox>
</left>
<center>
<VBox>
<VBox alignment="CENTER" >
<padding>
<Insets top="155" left="155" right="155"/>
</padding>
<HBox spacing="20.0">
<ImageView fitWidth="320" fitHeight="320" fx:id="codeImageView" pickOnBounds="true" preserveRatio="true"/>
<ImageView fitWidth="320" fitHeight="320" fx:id="codeImageView1" pickOnBounds="true" preserveRatio="true"/>
</HBox>
</VBox>
<VBox >
<padding>
<Insets left="260" top="145"/>
</padding>
<HBox spacing="5.0">
<Button fx:id="builderButton" onAction="#builderAction" text="生成"/>
<Button fx:id="saveButton" onAction="#saveAction" text="保存"/>
</HBox>
</VBox>
</VBox>
</center>
</BorderPane>
</children>
</AnchorPane>
<?xml version="1.0" encoding="UTF-8"?>
<root>
<ToolFxmlLoaderConfiguration title="littleTools" menuId="p-littleTools" menuParentId="moreToolsMenu" isMenu="true" />
<ToolFxmlLoaderConfiguration>
<url>/com/xwintop/xJavaFxTool/fxmlView/littleTools/QRCodeBuilder.fxml</url>
<resourceBundleName>locale.QRCodeBuilder</resourceBundleName>
<className></className>
<title>Title</title>
<iconPath>/images/QRCodeBuilderIcon.png</iconPath>
<isDefaultShow></isDefaultShow>
<menuId></menuId>
<menuParentId>p-littleTools</menuParentId>
<controllerType>Node</controllerType>
</ToolFxmlLoaderConfiguration>
</root>
\ No newline at end of file
# Dorian.properties\u662F\u9ED8\u8BA4\u7684"Dorian"\u8D44\u6E90\u675F\u6587\u4EF6\u3002
# \u4F5C\u4E3A\u4E2D\u56FD\u4EBA,\u6211\u7528\u81EA\u5DF1\u7684\u5730\u533A\u4F5C\u4E3A\u9ED8\u8BA4
Title=\u4E8C\u7EF4\u7801\u751F\u6210\u5DE5\u5177
\ No newline at end of file
# 文件Dorian_en_US.properties,是美国地区的资源束
# 它覆盖了默认资源束
Title=QRCodeBuilder
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment