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.controller.littleTools;
import com.alibaba.fastjson.JSON;
import com.tulskiy.keymaster.common.Provider;
import com.xwintop.xJavaFxTool.utils.CommonUtils;
import com.xwintop.xJavaFxTool.utils.CorrectionLevel;
import com.xwintop.xJavaFxTool.utils.QRCodeUtil;
import com.xwintop.xJavaFxTool.utils.ScreenShoter;
import com.xwintop.xJavaFxTool.view.littleTools.PeopleInfo;
import com.xwintop.xJavaFxTool.view.littleTools.QRCodeBuilderView;
import com.xwintop.xJavaFxTool.view.littleTools.QRContent;
import com.xwintop.xcore.javafx.FxApp;
import com.xwintop.xcore.javafx.helper.ChoiceBoxHelper;
import com.xwintop.xcore.util.javafx.FileChooserUtil;
import com.xwintop.xcore.util.javafx.TooltipUtil;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.event.InputEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import javafx.application.Platform;
import javafx.embed.swing.SwingFXUtils;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.stage.FileChooser;
import javafx.stage.WindowEvent;
import javax.imageio.ImageIO;
import javax.swing.KeyStroke;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
/**
* 二维码生成工具
*
* @author xufeng
* @since 2019/4/25 0025 23:26
*/
@Slf4j
public class QRCodeBuilderController extends QRCodeBuilderView {
private Provider provider;
@Override
public void initialize(URL location, ResourceBundle resources) {
initView();
initEvent();
}
private void initView() {
// initChoiceBox();
// codeFormatChoiceBox.getItems().addAll("utf-8", "gb2312", "ISO-8859-1", "US-ASCII", "utf-16");
// codeFormatChoiceBox.setValue("utf-8");
// onColorColorPicker.setValue(Color.BLACK);
// offColorColorPicker.setValue(Color.WHITE);
// marginChoiceBox.getItems().addAll(1, 2, 3, 4);
// marginChoiceBox.setValue(1);
// formatImageChoiceBox.getItems().addAll("png", "jpg", "gif", "jpeg", "bmp");
// formatImageChoiceBox.setValue("png");
}
/*
private void initChoiceBox() {
errorCorrectionLevelChoiceBox.getSelectionModel().selectedItemProperty()
.addListener((_o, _v, newValue) -> logoSlider.setMax(newValue.getMaxOverlay()));
ChoiceBoxHelper.setContentDisplay(
errorCorrectionLevelChoiceBox, CorrectionLevel.class, CorrectionLevel::getName
);
errorCorrectionLevelChoiceBox.setValue(CorrectionLevel.H);
}
*/
private void initEvent() {
FxApp.primaryStage.addEventHandler(WindowEvent.WINDOW_SHOWN, event -> {
try {
provider = Provider.getCurrentProvider(false);
provider.register(KeyStroke.getKeyStroke('S', InputEvent.ALT_DOWN_MASK), hotKey -> {
snapshotAction(null);
});
// TooltipUtil.showToast("按alt+s可快速截图识别!!!");
} catch (Exception e) {
log.error("热键注册失败", e);
}
});
//以下是监听代码,当录入第一次时清空第二次录入框中的数据,反之亦同
caseNum1.textProperty().addListener((_ob, _old, _new) -> Platform.runLater(() -> {
caseNum.setText("");
undertaker.setText("");
undertakerMobile.setText("");
caseDetail.setText("");
}));
caseNum.textProperty().addListener((_ob, _old, _new) -> Platform.runLater(() -> {
caseNum1.setText("");
caseName.setText("");
peopleName.setText("");
peopleMobile.setText("");
peopleIdNo.setText("");
acceptanceDate.getEditor().clear();
completeDate.getEditor().clear();
caseQuality.setText("");
lower.setText("");
lowerMobile.setText("");
agent.setText("");
agentMobile.setText("");
}));
//点击第一次录入收起第二次录入的内容框,反之亦然
first.expandedProperty().addListener((_ob, _old, _new) -> Platform.runLater(() ->
second.expandedProperty().set(false)
));
second.expandedProperty().addListener((_ob, _old, _new) -> Platform.runLater(() ->
first.expandedProperty().set(false)
));
}
@FXML
private void builderAction(ActionEvent event) {
JSONObject json = new JSONObject();
//标志是第几次录入
int num =0;
Map<String, Object> case1 = new HashMap<>();
if (StringUtils.isNotEmpty(undertaker.getText())) {
case1.put("caseNum",caseNum.getText());
case1.put("undertaker",undertaker.getText());
case1.put("undertakerMobile",undertakerMobile.getText());
//输入的案件详情内容太多会影响二维码的识别率,因此超过部分用省略号代替
String detail = caseDetail.getText();
if(detail.length()>150){
detail = detail.substring(0,150)+"......";
}
case1.put("caseDetail",detail);
num = 1;
}else{
//第二次录入的内容
case1.put("caseNum",caseNum1.getText());
case1.put("caseName",caseName.getText());
case1.put("peopleName",peopleName.getText());
case1.put("peopleMobile",peopleMobile.getText());
case1.put("peopleIdNo",peopleIdNo.getText());
case1.put("coerciveMeasures",coerciveMeasures.getText());
case1.put("acceptanceDate",acceptanceDate.getEditor().getText());
case1.put("completeDate",completeDate.getEditor().getText());
case1.put("caseQuality",caseQuality.getText());
case1.put("lower",lower.getText());
case1.put("lowerMobile",lowerMobile.getText());
case1.put("agent",agent.getText());
case1.put("agentMobile",agentMobile.getText());
num = 2;
}
String codeContent1 = CommonUtils.ifInputContainNull(case1);
if(StringUtils.isNotBlank(codeContent1)){
TooltipUtil.showToast(codeContent1);
return;
}
if(num ==2){
QRContent dto= JSON.parseObject(JSON.toJSONString(case1), QRContent.class);
List<PeopleInfo> peopleInfoList = new ArrayList<>();
PeopleInfo lowerInfo = PeopleInfo.assemblePeopleInfo(lower.getText(),lowerMobile.getText(),"","律师");
PeopleInfo agentInfo = PeopleInfo.assemblePeopleInfo(agent.getText(),agentMobile.getText(),"","代理人");
PeopleInfo litigant = PeopleInfo.assemblePeopleInfo(peopleName.getText(),peopleMobile.getText(),peopleIdNo.getText(),"当事人");
peopleInfoList.add(lowerInfo);
peopleInfoList.add(agentInfo);
peopleInfoList.add(litigant);
dto.setPeopleInfo(peopleInfoList);
json = JSONObject.fromObject(dto);
} else{
json = JSONObject.fromObject(case1);
}
System.out.println("json:"+json.toString());
try {
Image image = QRCodeUtil.toImage(json.toString(), (int) codeImageView.getFitWidth(),
(int) codeImageView.getFitHeight());
codeImageView.setImage(image);
} catch (Exception e) {
log.error("生成图片失败", e);
}
}
@FXML
private void builderActionBack(ActionEvent event) {
if (StringUtils.isEmpty(undertaker.getText())) {
return;
}
try {
Image image = QRCodeUtil.toImage(undertaker.getText(), (int) codeImageView.getFitWidth(),
(int) codeImageView.getFitHeight(), codeFormatChoiceBox.getValue(),
errorCorrectionLevelChoiceBox.getValue().getErrorCorrectionLevel(),
marginChoiceBox.getValue(), onColorColorPicker.getValue(),
offColorColorPicker.getValue(), formatImageChoiceBox.getValue());
codeImageView.setImage(image);
if (logoCheckBox.isSelected() && codeImageView1.getImage() != null) {
Image image1 = QRCodeUtil.encodeImgLogo(image, codeImageView1.getImage(), (int) logoSlider.getValue());
codeImageView.setImage(image1);
}
} catch (Exception e) {
log.error("生成图片失败", e);
}
}
@FXML
private void snapshotAction(ActionEvent event) {
// 默认情况下,Fx运行时会在最后一个stage的close(或hide)后自动关闭,即自动调用Application.stop()
// 除非通过Platform.setImplicitExit(false)取消这个默认行为。这样,即使所有Fx窗口关闭(或隐藏),Fx运行时还在正常运行
Platform.setImplicitExit(false);
if (FxApp.primaryStage.isShowing()) {
Platform.runLater(() -> {
FxApp.primaryStage.hide();
});
}
new ScreenShoter(this);
}
@FXML
private void snapshotDesktopAction(ActionEvent event) throws Exception {
Platform.setImplicitExit(false);
try {
FxApp.primaryStage.hide();
Dimension SCREEN_SIZE = Toolkit.getDefaultToolkit().getScreenSize();
Robot robot = new Robot();
BufferedImage screenImg = robot.createScreenCapture(
new Rectangle(0, 0, SCREEN_SIZE.width, SCREEN_SIZE.height));
FxApp.primaryStage.show();
String code = QRCodeUtil.toDecode(screenImg);
if (StringUtils.isNotEmpty(code)) {
contentTextField.setText(code);
} else {
Platform.runLater(() -> {
TooltipUtil.showToast("未识别到二维码。");
});
}
} catch (Exception e) {
TooltipUtil.showToast("发生异常:" + e.getMessage());
} finally {
Platform.setImplicitExit(true);
}
}
@FXML
private void saveAction(ActionEvent event) throws Exception {
String fileName =
"x" + new SimpleDateFormat("yyyyMMddHHmm").format(new Date()) + "." + formatImageChoiceBox.getValue();
File file = FileChooserUtil.chooseSaveFile(fileName, new FileChooser.ExtensionFilter("All Images", "*.*"),
new FileChooser.ExtensionFilter("JPG", "*.jpg"), new FileChooser.ExtensionFilter("PNG", "*.png"),
new FileChooser.ExtensionFilter("gif", "*.gif"), new FileChooser.ExtensionFilter("jpeg", "*.jpeg"),
new FileChooser.ExtensionFilter("bmp", "*.bmp"));
if (file != null) {
String[] fileType = file.getPath().split("\\.");
ImageIO.write(SwingFXUtils.fromFXImage(codeImageView.getImage(), null), fileType[fileType.length - 1],
file);
TooltipUtil.showToast("保存图片成功,图片在:" + file.getPath());
}
}
@FXML
private void logoAction(ActionEvent event) throws Exception {
File file = FileChooserUtil.chooseFile(new FileChooser.ExtensionFilter("All Images", "*.*"),
new FileChooser.ExtensionFilter("JPG", "*.jpg"), new FileChooser.ExtensionFilter("PNG", "*.png"),
new FileChooser.ExtensionFilter("gif", "*.gif"), new FileChooser.ExtensionFilter("jpeg", "*.jpeg"),
new FileChooser.ExtensionFilter("bmp", "*.bmp"));
if (file != null) {
Image image = SwingFXUtils.toFXImage(ImageIO.read(file), null);
codeImageView1.setImage(image);
}
}
public void snapshotActionCallBack(Image image) {
Platform.runLater(() -> {
FxApp.primaryStage.show();
});
codeImageView1.setImage(image);
String code = QRCodeUtil.toDecode(image);
if (StringUtils.isNotEmpty(code)) {
contentTextField.setText(code);
}
Platform.setImplicitExit(true);
}
/**
* 父控件被移除前调用
*/
public void onCloseRequest(javafx.event.Event event) {
try {
if (provider != null) {
provider.reset();
provider.stop();
}
} catch (Exception e) {
log.error("停止快捷键监听失败:", e);
}
}
}
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());
}
}
package com.xwintop.xJavaFxTool.utils;
import com.xwintop.xJavaFxTool.controller.littleTools.QRCodeBuilderController;
import javafx.embed.swing.SwingFXUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
public class ScreenShoter extends JFrame {
private static final long serialVersionUID = 2824099274822727350L;
public ScreenShoter(QRCodeBuilderController codeBuilderController) {
setSize(SShoterConfig.SCREEN_SIZE);
setUndecorated(true);
setLocation(0, 0);
setLocationRelativeTo(null);
JPanel pane = new Shoter(codeBuilderController, this);
setContentPane(pane);
setVisible(true);
}
}
class Shoter extends JPanel {
private static final long serialVersionUID = 6749535851395089903L;
private QRCodeBuilderController codeBuilderController;
private JFrame shoter;
BufferedImage screenImg = null;
private Point _start = new Point(0, 0);
private Point _end = new Point(1, 1);
private JPanel buttons = null;
private JButton buttonSave = null;
private JButton buttonCancel = null;
private JButton buttonExit = null;
private int operationStatus = SShoterConfig.MOUSE_DRAG;
private Point _moveStart = new Point();
private Dimension rectSize;
private Point buttonsPosition;
public Shoter(QRCodeBuilderController codeBuilderController, JFrame shoter) {
snapshot();
this.shoter = shoter;
this.codeBuilderController = codeBuilderController;
setLayout(null);
setBackground(new Color(200, 200, 200));
this.addMouseListener(new RectListener());
this.addMouseMotionListener(new RectDragListener());
add(getButtons());
buttons.setSize(SShoterConfig.BUTTONS_PANEL_SIZE);
buttons.setVisible(false);
setVisible(true);
}
public void snapshot() {
try {
Robot robot = new Robot();
screenImg = robot.createScreenCapture(
new Rectangle(0, 0, SShoterConfig.SCREEN_SIZE.width, SShoterConfig.SCREEN_SIZE.height));
} catch (AWTException e) {
e.printStackTrace();
}
}
public JPanel getButtons() {
buttons = new JPanel();
buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
buttons.setBackground(new Color(200, 200, 200));
buttonSave = new JButton("Save");
// buttonSave
buttonSave.setSize(SShoterConfig.BUTTONS_SIZE);
ActionListener buttonSaveLis = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
// ImageIO.write(getNewImage(), fileExtension, file);
codeBuilderController.snapshotActionCallBack(SwingFXUtils.toFXImage(getNewImage(), null));
buttons.setVisible(false);
_start = new Point(0, 0);
_end = new Point(0, 0);
shoter.setVisible(false);
shoter.dispose();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
};
buttons.add(buttonSave);
buttonSave.addActionListener(buttonSaveLis);
buttonSave.registerKeyboardAction(buttonSaveLis, KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK),
JComponent.WHEN_IN_FOCUSED_WINDOW);
buttonCancel = new JButton("Cancel");
buttonCancel.setSize(SShoterConfig.BUTTONS_SIZE);
ActionListener cancelLis = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
_start = new Point(0, 0);
_end = new Point(0, 0);
buttons.setVisible(false);
Shoter.this.setCursor(SShoterConfig.CURSOR_NORMAL);
operationStatus = SShoterConfig.MOUSE_DRAG;
Shoter.this.repaint();
}
};
buttonCancel.addActionListener(cancelLis);
buttonCancel.registerKeyboardAction(cancelLis, KeyStroke.getKeyStroke(KeyEvent.VK_D, KeyEvent.CTRL_DOWN_MASK),
JComponent.WHEN_IN_FOCUSED_WINDOW);
buttons.add(buttonCancel);
// exit
buttonExit = new JButton("Exit");
buttonExit.setSize(SShoterConfig.BUTTONS_SIZE);
buttons.add(buttonExit);
ActionListener buttonExitLis = new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
codeBuilderController.snapshotActionCallBack(null);
shoter.setVisible(false);
shoter.dispose();
}
};
buttonExit.addActionListener(buttonExitLis);
buttonExit.registerKeyboardAction(buttonExitLis, KeyStroke.getKeyStroke(KeyEvent.VK_Q, KeyEvent.CTRL_DOWN_MASK),
JComponent.WHEN_IN_FOCUSED_WINDOW);
return buttons;
}
@Override
public void paintComponent(Graphics comp) {
Graphics2D comp2D = (Graphics2D) comp;
comp2D.drawImage(screenImg, 0, 0, this);
comp2D.setColor(new Color(0, 0, 0, 100));
comp2D.fill(new Rectangle(0, 0, SShoterConfig.SCREEN_SIZE.width, SShoterConfig.SCREEN_SIZE.height));
/*
* comp2D.setColor(new Color( 0, 0, 0)); BasicStroke stroke = new
* BasicStroke(1f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER);
* comp2D.setStroke(stroke);
*
* Rectangle _rect = new Rectangle(_start, new Dimension(_end.x - _start.x,
* _end.y - _start.y)); comp2D.draw(_rect); Color ColorFill = new Color(255,
* 255, 255, 0); comp2D.setColor(ColorFill); comp2D.fill(_rect);
* comp2D.drawImage(getNewImage(), _start.x, _start.y, this);
*/
if (_end.x - _start.x > 0 && _end.y - _start.y > 0) {
comp2D.drawImage(getNewImage(), _start.x, _start.y, this);
}
}
private class RectListener extends MouseAdapter {
@Override
public void mousePressed(MouseEvent e) {
if (operationStatus == SShoterConfig.MOUSE_MOVE) {
_moveStart = new Point((int) (e.getX() - _start.getX()), (int) (e.getY() - _start.getY()));
buttons.setVisible(true);
} else if (operationStatus == SShoterConfig.MOUSE_DRAG) {
_start = e.getPoint();
_end = e.getPoint();
// hidden the buttons
buttons.setVisible(false);
}
}
@Override
public void mouseReleased(MouseEvent e) {
if (operationStatus == SShoterConfig.MOUSE_DRAG) {
_end = e.getPoint();
rectSize = new Dimension((int) (_end.getX() - _start.getX()), (int) (_end.getY() - _start.getY()));
setButtonsPosition();
buttons.setVisible(true);
operationStatus = SShoterConfig.MOUSE_NORMAL;
Shoter.this.repaint();
}
}
}
/**
* Mouse Move Listener
*/
private class RectDragListener implements MouseMotionListener {
@Override
public void mouseDragged(MouseEvent e) {
if (operationStatus == SShoterConfig.MOUSE_DRAG) {
_end = e.getPoint();
} else if (operationStatus == SShoterConfig.MOUSE_MOVE) {
// _moveTemp = _moveStart;
// _moveEnd = e.getPoint();
if (e.getX() - _moveStart.getX() >= 0
&& e.getX() - _moveStart.x + rectSize.width <= SShoterConfig.SCREEN_SIZE.width) {
_start.x = e.getX() - _moveStart.x;
_end.x = _start.x + rectSize.width;
} else if (e.getX() - _moveStart.getX() < 0) {
_start.x = 0;
} else if (e.getX() - _moveStart.x + rectSize.width > SShoterConfig.SCREEN_SIZE.width) {
_end.x = SShoterConfig.SCREEN_SIZE.width;
}
if (e.getY() - _moveStart.getY() >= 0
&& e.getY() - _moveStart.y + rectSize.height <= SShoterConfig.SCREEN_SIZE.height) {
_start.y = e.getY() - _moveStart.y;
_end.y = _start.y + rectSize.height;
} else if (e.getY() - _moveStart.getY() < 0) {
_start.y = 0;
} else if (e.getY() - _moveStart.y + rectSize.height > SShoterConfig.SCREEN_SIZE.height) {
_end.y = SShoterConfig.SCREEN_SIZE.height;
}
// rectSize.setSize((int) (_end.getX() - _start.getX() ), (int)(_end.getY() -
// _start.getY() ));
} else if (operationStatus == SShoterConfig.MOUSE_MOVE_W) {
_start.x = e.getX();
rectSize.setSize((int) (_end.getX() - _start.getX()), (int) (_end.getY() - _start.getY()));
} else if (operationStatus == SShoterConfig.MOUSE_MOVE_N) {
_start.y = e.getY();
rectSize.setSize((int) (_end.getX() - _start.getX()), (int) (_end.getY() - _start.getY()));
} else if (operationStatus == SShoterConfig.MOUSE_MOVE_E) {
_end.x = e.getX();
rectSize.setSize((int) (_end.getX() - _start.getX()), (int) (_end.getY() - _start.getY()));
} else if (operationStatus == SShoterConfig.MOUSE_MOVE_S) {
_end.y = e.getY();
rectSize.setSize((int) (_end.getX() - _start.getX()), (int) (_end.getY() - _start.getY()));
}
setButtonsPosition();
Shoter.this.repaint();
}
@Override
public void mouseMoved(MouseEvent e) {
if (operationStatus == SShoterConfig.MOUSE_DRAG) {
return;
}
// in the sub image
if (e.getX() > _start.getX() + SShoterConfig.MOVE_EDGE && e.getX() < _end.getX() - SShoterConfig.MOVE_EDGE
&& e.getY() > _start.getY() + SShoterConfig.MOVE_EDGE
&& e.getY() < _end.getY() - SShoterConfig.MOVE_EDGE) {
Shoter.this.setCursor(SShoterConfig.CURSOR_MOVE);
operationStatus = SShoterConfig.MOUSE_MOVE;
// out the sub image
} else if (e.getX() < _start.getX() || e.getX() > _end.getX() || e.getY() < _start.getY()
|| e.getY() > _end.getY()) {
Shoter.this.setCursor(SShoterConfig.CURSOR_NORMAL);
// in the sub image edge area
} else {
if (e.getX() >= _start.getX() && e.getX() <= _start.getX() + SShoterConfig.MOVE_EDGE) {
if (e.getY() >= _start.getY() && e.getY() <= _start.getY() + SShoterConfig.MOVE_EDGE) {
operationStatus = SShoterConfig.MOUSE_MOVE_WN;
Shoter.this.setCursor(SShoterConfig.NW_RESIZE_CURSOR);
} else if (e.getY() >= _start.getY() + SShoterConfig.MOVE_EDGE
&& e.getY() <= _end.getY() - SShoterConfig.MOVE_EDGE) {
operationStatus = SShoterConfig.MOUSE_MOVE_W;
Shoter.this.setCursor(SShoterConfig.W_RESIZE_CURSOR);
} else if (e.getY() >= _end.getY() - SShoterConfig.MOVE_EDGE && e.getY() <= _end.getY()) {
operationStatus = SShoterConfig.MOUSE_MOVE_WS;
Shoter.this.setCursor(SShoterConfig.SW_RESIZE_CURSOR);
}
} else if (e.getX() > _start.getX() + SShoterConfig.MOVE_EDGE
&& e.getX() < _end.getX() - SShoterConfig.MOVE_EDGE) {
if (e.getY() >= _start.getY() && e.getY() <= _start.getY() + SShoterConfig.MOVE_EDGE) {
operationStatus = SShoterConfig.MOUSE_MOVE_N;
Shoter.this.setCursor(SShoterConfig.N_RESIZE_CURSOR);
} else {
operationStatus = SShoterConfig.MOUSE_MOVE_S;
Shoter.this.setCursor(SShoterConfig.S_RESIZE_CURSOR);
}
} else {
if (e.getY() >= _start.getY() && e.getY() <= _start.getY() + SShoterConfig.MOVE_EDGE) {
operationStatus = SShoterConfig.MOUSE_MOVE_WS;
Shoter.this.setCursor(SShoterConfig.NE_RESIZE_CURSOR);
} else if (e.getY() >= _start.getY() + SShoterConfig.MOVE_EDGE
&& e.getY() <= _end.getY() - SShoterConfig.MOVE_EDGE) {
operationStatus = SShoterConfig.MOUSE_MOVE_E;
Shoter.this.setCursor(SShoterConfig.E_RESIZE_CURSOR);
} else if (e.getY() >= _end.getY() - SShoterConfig.MOVE_EDGE && e.getY() <= _end.getY()) {
operationStatus = SShoterConfig.MOUSE_MOVE_ES;
Shoter.this.setCursor(SShoterConfig.SE_RESIZE_CURSOR);
}
}
}
}
}
public void setButtonsPosition() {
buttonsPosition = new Point();
if (_end.y + SShoterConfig.BUTTONS_PANEL_SIZE.getHeight() < SShoterConfig.SCREEN_SIZE.getHeight()) {
buttonsPosition.y = (int) _end.getY();
} else {
buttonsPosition.y = (int) (_end.y - SShoterConfig.BUTTONS_PANEL_SIZE.getHeight());
}
if (_end.getX() - SShoterConfig.BUTTONS_PANEL_SIZE.getWidth() >= SShoterConfig.BUTTONS_PANEL_SIZE.getWidth()) {
buttonsPosition.x = (int) (_end.x - SShoterConfig.BUTTONS_PANEL_SIZE.getWidth());
} else {
buttonsPosition.x = (int) _start.getX();
}
buttons.setLocation(buttonsPosition);
}
public BufferedImage getNewImage() {
return this.screenImg.getSubimage((int) _start.getX(), (int) _start.getY(), (int) (_end.getX() - _start.getX()),
(int) (_end.getY() - _start.getY()));
}
}
class SShoterConfig {
// screen size
public static final Dimension SCREEN_SIZE = Toolkit.getDefaultToolkit().getScreenSize();
// frame button size
public static final Dimension FRAME_BUTTON_SIZE = new Dimension(60, 20);
public static final Dimension FRAME_LABEL_SIZE = new Dimension(200, 30);
// buttons
// buttons panel
public static final Dimension BUTTONS_PANEL_SIZE = new Dimension(210, 40);
public static final Dimension BUTTONS_SIZE = new Dimension(60, 20);
// the status of the operation
public static final int MOUSE_DRAG = 0;
public static final int MOUSE_MOVE = 1;
public static final int MOUSE_NORMAL = 2;
// move state
public static final int MOUSE_MOVE_W = 11;
public static final int MOUSE_MOVE_WN = 12;
public static final int MOUSE_MOVE_WS = 13;
public static final int MOUSE_MOVE_E = 14;
public static final int MOUSE_MOVE_EN = 15;
public static final int MOUSE_MOVE_ES = 16;
public static final int MOUSE_MOVE_N = 17;
public static final int MOUSE_MOVE_S = 18;
// the edge of the move
public static final int MOVE_EDGE = 10;
// the default image type
public static final String DEFAULT_IMAGE_EXTENSION = "png";
// cursors
public static final Cursor CURSOR_NORMAL = new Cursor(Cursor.DEFAULT_CURSOR);
public static final Cursor CURSOR_MOVE = new Cursor(Cursor.MOVE_CURSOR);
public static final Cursor NW_RESIZE_CURSOR = new Cursor(Cursor.NW_RESIZE_CURSOR);
public static final Cursor W_RESIZE_CURSOR = new Cursor(Cursor.W_RESIZE_CURSOR);
public static final Cursor SW_RESIZE_CURSOR = new Cursor(Cursor.SW_RESIZE_CURSOR);
public static final Cursor N_RESIZE_CURSOR = new Cursor(Cursor.N_RESIZE_CURSOR);
public static final Cursor S_RESIZE_CURSOR = new Cursor(Cursor.S_RESIZE_CURSOR);
public static final Cursor NE_RESIZE_CURSOR = new Cursor(Cursor.NE_RESIZE_CURSOR);
public static final Cursor E_RESIZE_CURSOR = new Cursor(Cursor.E_RESIZE_CURSOR);
public static final Cursor SE_RESIZE_CURSOR = new Cursor(Cursor.SE_RESIZE_CURSOR);
}
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