diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..56df50cd --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = false +indent_style = space +indent_size = 4 + +[*.{html, xml, yaml, fxml}] +indent_size = 2 + +[*.java] +ij_any_blank_lines_around_field = 1 \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..0aacdeaa --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +# Default ignored files +#/.gitignore +.idea/ +*.iml + +logs/ +target/ +libs/ +devLibs + +system_plugin_list.json +RUNNING_PID +#gradle +.gradle +build +out +.murphy.yml +./config + diff --git a/CNAME b/CNAME new file mode 100644 index 00000000..10505de0 --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +xjavafxtool.xwintop.com \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..b14292bb --- /dev/null +++ b/LICENSE @@ -0,0 +1,127 @@ + 木兰宽松许可证, 第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) [2019] [xufeng] + [xJavaFxTool] 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) [2019] [xufeng] + [xJavaFxTool] 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. \ No newline at end of file diff --git a/README.md b/README.md index a23cc655..8d172110 100644 --- a/README.md +++ b/README.md @@ -1,195 +1,185 @@ -#### 项目简介: -**gitee地址:**[xJavaFxTool](https://gitee.com/xwintop/xJavaFxTool) - -**GitHub地址:**[xJavaFxTool](https://github.com/864381832/xJavaFxTool) - -**xJavaFxTool交流QQ群:== [387473650](https://jq.qq.com/?_wv=1027&k=59UDEAD) ==** - -xJavaFxTool是使用javaFx开发的实用小工具集,目前项目刚刚建立,利用业余时间把工作中遇到的一些问题总结起来,打包进小工具集中,供大家参考和使用,里面包含了javaFx的一些功能的示例,如布局、国际化、第三方UI库(controlsfx、JFoenix等)、外部jar包加载(插件机制)等一些常用功能,想学习javaFx的同学可以参考参考。 - -由于SpringBoot的火热,项目已经出SpringBoot-javafx版本,[xJavaFxTool-spring](https://gitee.com/xwintop/xJavaFxTool-spring) 欢迎参考,谢谢。 - -下载试用地址: - -(可直接下载安装使用,不需要任何第三方环境,兼容xp、windows7、8、10等系统)[xJavaFxTool-0.1.4.exe](http://files.git.oschina.net/group1/M00/02/EA/PaAvDFp8eByATSAzBhUKCsTbpUc258.exe?token=3020a95a8a5f6509f5fa9575090d54db&ts=1518139040&attname=xJavaFxTool-install.exe) - -(本地需要有jdk1.8环境)[xJavaFxTool-0.1.4.jar](http://files.git.oschina.net/group1/M00/02/EA/PaAvDFp8_Q-AETFIBCfy93hiJyo600.jar?token=e668b2e779efabf8e7414f9dd8e3f0a6&ts=1518140688&attname=xJavaFxTool-0.1.4.jar)(可直接运行的jar包) - -(本地需要有jdk1.8环境)[xJavaFxTool-windows-x64-0.1.4.exe](http://files.git.oschina.net/group1/M00/02/EA/PaAvDFp8cFOAZmzcBCy8AHMtHjA024.exe?token=0317b8fc5268c42d110e1d008db28760&ts=1518139040&attname=xJavaFxTool-windows-x64-0.1.4.exe) (Windows平台64位运行包) - -(本地需要有jdk1.8环境)[xJavaFxTool-windows-x86-0.1.4.exe](http://files.git.oschina.net/group1/M00/02/EA/PaAvDFp8ckuAejoZBCw6AG93rus326.exe?token=9ee4902139bcf39c0c8c6cdb30f87194&ts=1518139040&attname=xJavaFxTool-windows-x86-0.1.4.exe) (Windows平台32位运行包) - -支持插件开发,将插件jar包放至根目录libs下即可自动加载(插件开发示例见[开源项目xJavaFxPlugIn](https://gitee.com/xwintop/xJavaFxPlugIn),目前刚刚搭建,后续会持续更新); - -#### 环境搭建说明: -- 开发环境为jdk1.8,基于maven构建; - -- 本项目使用了lombok,在查看本项目时如果您没有下载lombok 插件,请先安装,不然找不到get/set方法; - -- 依赖的[xcore包](https://gitee.com/xwintop/xcore)已上传至git托管的maven平台,git托管maven可参考教程。[教程地址:点击进入](http://blog.csdn.net/u011747754/article/details/78574026) - -#### 目前集成的小工具有: -1、FileCopy:文件复制(支持自动调度拷贝功能); - -2、CronExpBuilder:Cron表达式生成器; - -3、CharacterConverter:编码转换; - -4、EncryptAndDecrypt:加密解密(Ascii、Hex、Base64、Base32、URL、MD5、SHA、文件加密DM5、文件加密SHA1、摩斯密码); - -5、TimeTool:Time转换(常用格式转换、计算时间差、时间叠加计算); - -6、LinuxPathToWindowsPath:路径转换; - -7、QRCodeBuilder:二维码生成工具(自动生成、加入logo、截图识别、自定义格式); - -8、IdCardGenerator:身份证生成器; - -9、RegexTester:正则表达式生成工具; - -10、ShortURL:网址缩短(目前支持百度、新浪、缩我等短网址缩短); - -11、EscapeCharacter:转义字符(支持Html、XML、Java、JavaScript、CSV、Sql); - -12、ZHConverter:字符串转换(使用hanlp开源工具,实现拼音、简体-繁体、简体-臺灣正體、简体-香港繁體、繁體-臺灣正體、繁體-香港繁體、香港繁體-臺灣正體、数字金额-大写金额等直接的转换); - -13、Mq调试工具(目前仅支持ActiveMq); - -14、Http调试工具(支持自定义发送数据、header和cookie); - -15、json格式化编辑工具; - -16、IconTool:图标生成工具; - -17、RedisTool:Redis连接工具; - -18、WebSourcesTool:网页源码下载工具; - -19、SwitchHostsTool:切换Hosts工具; - -20、FtpServer:Ftp服务器(快速搭建本地Ftp服务); - -21、CmdTool:Cmd调试工具; - -22、FtpClientTool:Ftp客户端调试工具(批量上传、下载、删除文件及文件夹); - -23、PdfConvertTool:Pdf转换工具(目前仅支持pdf转图片、pdf转text功能); - -24、DirectoryTreeTool:文件列表生成器; - -25、ImageTool:图片压缩工具(批量压缩、修改尺寸、转换格式); - -26、AsciiPicTool:图片转码工具(包括图片生成banner码、图片转Base64码); - -27、KafkaTool:Kafka调试工具(未完善); - -28、EmailTool:Email群发工具(支持自定义群发模版); - -29、ColorCodeConverterTool:颜色代码转换工具(包括16进制、RGB、ARGB、RGBA、HSL、HSV等代码之间转换); - -30、SmsTool:短信群发工具(目前支持中国移动、中国电信、腾讯云、阿里云、梦网云通讯等平台); - -31、ScriptEngineTool:脚本引擎调试工具(目前支持JavaScript、Groovy、Python、Lua等脚本); - -32、FileRenameTool:文件重命名工具(未完善); - -33、JsonConvertTool:Json转换工具(目前支持Json转Xml、Json转Java实体类、Json转C#实体类、Json转Excel、Json转Yaml); - -34、WechatJumpGameTool:微信跳一跳助手; - -35、TextToSpeechTool:语音转换工具(调用百度语音转换api); - -项目开发中,以后会陆续添加新工具,欢迎大家参与其中,多提提意见,谢谢。 - - -#### 项目结构 - -``` -xJavaFxTool -├─ images 项目截图 -├─ lib 外部引用jar包存放 -├─ libs 插件jar包存放 -├─ pom.xml maven配置文件 -├─ README.md 说明文件 -├─ src -│  ├─ main -│  │  ├─ java -│  │  │  └─ com -│  │  │  └─ xwintop -│  │  │  └─ xJavaFxTool -│  │  │  ├─ common 第三方工具类 -│  │  │  ├─ config springBoot配置类 -│  │  │  ├─ controller javafx控制层 -│  │  │  │  ├─ codeTools Code工具控制层 -│  │  │  │  ├─ debugTools 调试工具控制层 -│  │  │  │  ├─ developTools 开发工具控制层 -│  │  │  │  ├─ epmsTools epms工具控制层 -│  │  │  │  ├─ javaFxTools javaFx工具控制层 -│  │  │  │  ├─ littleTools 小工具控制层 -│  │  │  │  └─ webTools html工具控制层 -│  │  │  ├─ job 定时任务处理job -│  │  │  ├─ main 主函数包 -│  │  │  ├─ manager 管理层 -│  │  │  ├─ model 基础bean类层 -│  │  │  ├─ services 工具服务层 -│  │  │  │  ├─ codeTools Code工具服务层 -│  │  │  │  ├─ debugTools 调试工具服务层 -│  │  │  │  ├─ developTools 开发工具服务层 -│  │  │  │  ├─ epmsTools epms工具服务层 -│  │  │  │  ├─ javaFxTools javaFx工具服务层 -│  │  │  │  ├─ littleTools 小工具服务层 -│  │  │  │  └─ webTools html工具服务层 -│  │  │  ├─ utils 系统工具类 -│  │  │  ├─ view javafx视图层 -│  │  │  │ ├─ codeTools Code工具视图层 -│  │  │  │ ├─ debugTools 调试工具视图层 -│  │  │  │ ├─ developTools 开发工具视图层 -│  │  │  │ ├─ littleTools 小工具视图层 -│  │  │  │ └─ webTools html工具视图层 -│  │  │  └─ web web控制视图层 -│  │  └─ resources -│  │  ├─ com -│  │  │  ├─ melloware -│  │  │  │  └─ jintellitype JIntellitype工具lib -│  │  │  └─ xwintop -│  │  │  └─ xJavaFxTool -│  │  │  └─ fxmlView .fxml文件 -│  │  ├─ config 配置文件 -│  │  │  ├─ log4j.properties log4j配置文件 -│  │  │  └─ toolFxmlLoaderConfiguration.xml 系统菜单加载配置文件 -│  │  ├─ css 样式资源 -│  │  ├─ data 数据资源 -│  │  ├─ images 图片资源 -│  │  ├─ locale 国际化 -│  │  └─ web html工具 -│  └─ test 测试类 -│  ├─ java -│  └─ resources -├─ xJavaFxTool.jar 直接运行程序包 - -``` - -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/文件复制.png "文件复制.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/邮件发送工具.png "邮件发送工具.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/Cron表达式生成器.png "Cron表达式生成器.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/Mq调试工具.png "Mq调试工具.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/正则表达式生成工具.png "正则表达式生成工具.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/二维码生成工具.png "二维码生成工具.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/json格式化编辑工具.png "json格式化编辑工具.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/网址缩短.png "网址缩短.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/字符串转换.png "字符串转换.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/Http调试工具.png "Http调试工具.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/编码转换.png "编码转换.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/转义字符.png "转义字符.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/加密解密.png "加密解密.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/Time转换.png "Time转换.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/图标生成工具.png "图标生成工具.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/Redis连接工具.png "Redis连接工具.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/Ftp服务器.png "Ftp服务器.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/文件列表生成器.png "文件列表生成器.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/图片压缩工具.png "图片压缩工具.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/Ftp客户端调试工具.png "Ftp客户端调试工具.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/Pdf转换工具.png "Pdf转换工具.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/图片转码工具.png "图片转码工具.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/Cmd调试工具.png "Cmd调试工具.png") -![输入图片说明](https://git.oschina.net/xwintop/xJavaFxTool/raw/master/images/短信群发工具.png "短信群发工具.png") +**gitee地址:**[xJavaFxTool](https://gitee.com/xwintop/xJavaFxTool) + +**GitHub地址:**[xJavaFxTool](https://github.com/864381832/xJavaFxTool) + +[![](https://img.shields.io/:license-apache-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) +[![](https://img.shields.io/badge/JDK-17+-green.svg)](https://www.oracle.com/technetwork/java/javase/downloads/index.html) +[![](https://img.shields.io/badge/maven-v3.6.3-blue)](https://maven.apache.org) +[![](https://gitee.com/xwintop/xJavaFxTool/badge/star.svg?theme=dark)](https://gitee.com/xwintop/xJavaFxTool/stargazers) +[![](https://img.shields.io/github/stars/864381832/xJavaFxTool.svg?style=social)](https://github.com/864381832/xJavaFxTool) +[![](https://img.shields.io/badge/IntelliJ%20IDEA-提供支持-blue.svg)](https://www.jetbrains.com/?from=xJavaFxTool) +![系统](https://img.shields.io/badge/系统-win%20%7C%20mac%20%7C%20linux-007EC6) + +[英文说明/English Documentation](README_EN.md) + +**xJavaFxTool交流QQ群: [![](https://img.shields.io/badge/QQ-387473650-green.svg?logo=tencent%20qq)](https://jq.qq.com/?_wv=1027&k=59UDEAD) 或加群②(已满)[![](https://img.shields.io/badge/QQ-1104780992-green.svg?logo=tencent%20qq)](https://jq.qq.com/?_wv=1027&k=bhAdkju9) 或加群③[![](https://img.shields.io/badge/QQ-235011461-green.svg?logo=tencent%20qq)](https://jq.qq.com/?_wv=1027&k=zXUFDNuE)** + +**xJavaFxTool吐个槽:== [进来吐槽](https://support.qq.com/product/127577) ==** + +#### 项目简介: +xJavaFxTool是使用javaFx开发的实用小工具集,利用业余时间把工作中遇到的一些问题总结起来,打包进小工具集中,供大家参考和使用,里面包含了javaFx的一些功能的示例,如布局、国际化、第三方UI库[controlsfx](https://github.com/controlsfx/controlsfx)、[JFoenix](https://github.com/sshahine/JFoenix)等、外部jar包加载(插件机制)等一些常用功能,想学习javaFx的同学可以参考参考,学习javaFx的资料参考[https://openjfx.cn/](https://openjfx.cn/) + +由于SpringBoot的火热,项目已经出SpringBoot-javafx版本,[xJavaFxTool-spring](https://gitee.com/xwintop/xJavaFxTool-spring) 欢迎参考,谢谢。 + +#### 下载地址: +- Linux amd64 [xJavaFxTool-1.0.1-linux-amd64.deb](https://github.com/864381832/xJavaFxTool/releases/download/v1.0.1/xJavaFxTool-1.0.1-linux-amd64.deb) +- Linux amd64 [xJavaFxTool-1.0.1-linux-amd64.rpm](https://github.com/864381832/xJavaFxTool/releases/download/v1.0.1/xJavaFxTool-1.0.1-linux-amd64.rpm) +- Mac OS aarch64 [xJavaFxTool-1.0.1-macos-x64.dmg](https://github.com/864381832/xJavaFxTool/releases/download/v1.0.1/xJavaFxTool-1.0.1-macos-aarch64.dmg) +- Mac OS aarch64 [xJavaFxTool-1.0.1-macos-x64.pkg](https://github.com/864381832/xJavaFxTool/releases/download/v1.0.1/xJavaFxTool-1.0.1-macos-aarch64.pkg) +- Windows x64 [xJavaFxTool-1.0.1-windows-x64.exe](https://github.com/864381832/xJavaFxTool/releases/download/v1.0.1/xJavaFxTool-1.0.1-windows-x64.exe) +- Windows x64 [xJavaFxTool-1.0.1-windows-x64.msi](https://github.com/864381832/xJavaFxTool/releases/download/v1.0.1/xJavaFxTool-1.0.1-windows-x64.msi) +- 更多下载地址见123云盘链接:[https://www.123865.com/s/L5LA-tna7A?pwd=java#](https://www.123865.com/s/L5LA-tna7A?pwd=java#) 提取码:java + +#### 支持插件开发: +插件开发及示例见[开源项目xJavaFxTool-plugin](https://gitee.com/xwintop/xJavaFxTool-plugin) +目前已将小工具拆分至各模块插件中按需加载,减小jar包的大小,将插件jar包放至根目录libs下即可自动加载; +- [调试相关工具](https://gitee.com/xwintop/xJavaFxTool-debugTools) +- [小工具](https://gitee.com/xwintop/xJavaFxTool-littleTools) +- [相关小游戏](https://gitee.com/xwintop/xJavaFxTool-Games) + +#### 环境搭建说明: +- 开发环境为jdk17,基于gradle8.5构建 +- 使用eclipase或Intellij Idea开发,推荐使用[Intellij Idea](https://www.jetbrains.com/idea/?from=xJavaFxTool) +- 本项目使用了[lombok](https://projectlombok.org/),在查看本项目时如果您没有下载lombok 插件,请先安装,不然找不到get/set等方法 +- 使用jpackager插件进行打包操作,可打包windows(需安装WiX)、Linux(需安装rpm-build)、Mac安装包. +- jdk11启动需添加参数java --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens jdk.zipfs/jdk.nio.zipfs=ALL-UNNAMED -jar xJavaFxTool.jar [参考](https://blog.csdn.net/fighting_boss/article/details/91043555) + +#### 目前集成的小工具有(点击中文名可进入对应小工具的开源地址): +| 序号 | 英文名 | 中文名 | 简介 | +|----|---------------------------------|-----------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| 1 | FileCopy | [文件复制](https://gitee.com/xwintop/x-FileCopy) | 进行系统文件之间快速复制、移动操作,支持自动调度拷贝功能,使用[quartz](https://www.quartz-scheduler.org/)工具 | +| 2 | CronExpBuilder | [Cron表达式生成器](https://gitee.com/xwintop/x-CronExpBuilder) | cron表达式快速生成及解析测试工具 | +| 3 | CharacterConverter | [编码转换](https://gitee.com/xwintop/x-CharacterConverter) | 常用字符集编码及进制之间转换工具 | +| 4 | EncryptAndDecrypt | [加密解密](https://gitee.com/xwintop/x-EncryptAndDecrypt) | Ascii、Hex、Base64、Base32、URL、MD5、SHA、AES、DES、文件加密DM5、文件加密SHA1、摩斯密码、Druid加密,使用[commons-codec](http://commons.apache.org/codec/)工具类 | +| 5 | TimeTool | [Time转换](https://gitee.com/xwintop/x-TimeTool) | 常用格式转换(含时区)、计算时间差、时间叠加计算 | +| 6 | LinuxPathToWindowsPath | [路径转换](https://gitee.com/xwintop/x-LinuxPathToWindowsPath) | 进行linux与Windows系统之间路径格式转换,使用[oshi](https://github.com/oshi/oshi)工具 | +| 7 | QRCodeBuilder | [二维码生成工具](https://gitee.com/xwintop/x-QRCodeBuilder) | 自动生成、加入logo、截图识别、自定义格式,使用[google.zxing](https://github.com/zxing/zxing)、[jkeymaster](https://github.com/tulskiy/jkeymaster)等工具 +| 8 | IdCardGenerator | [ID证生成器](https://gitee.com/xwintop/x-IdCardGenerator) | id证序号自动生成器 | +| 9 | RegexTester | [正则表达式生成工具](https://gitee.com/xwintop/x-RegexTester) | 正则表达式快速生成与测试验证工具 | +| 10 | ShortURL | [网址缩短工具](https://gitee.com/xwintop/x-ShortURL) | 目前支持百度、新浪、缩我等短网址缩短 | +| 11 | EscapeCharacter | [转义字符](https://gitee.com/xwintop/x-EscapeCharacter) | 支持Html、XML、Java、JavaScript、CSV、Sql之间的转换,使用[commons-lang3](https://commons.apache.org/lang)工具 | +| 12 | ZHConverter | [字符串转换](https://gitee.com/xwintop/x-ZHConverter) | 实现拼音、简体-繁体、简体-臺灣正體、简体-香港繁體、繁體-臺灣正體、繁體-香港繁體、香港繁體-臺灣正體、数字金额-大写金额等直接的转换,使用[hanlp](http://hanlp.com/)开源工具 | +| 13 | ActiveMqTool | [Mq调试工具](https://gitee.com/xwintop/x-ActiveMqTool) | 目前仅支持[ActiveMq](http://activemq.apache.org) +| 14 | HttpTool | [Http调试工具](https://gitee.com/xwintop/x-HttpTool) | 支持自定义发送数据、header和cookie,使用[okhttp](https://square.github.io/okhttp/) | +| 15 | jsonEditor | json格式化编辑工具 | 快速对json文件格式化处理 | +| 16 | IconTool | [图标生成工具](https://gitee.com/xwintop/x-IconTool) | 快速生成常用大小的图标,支持添加水印、圆角处理,使用[thumbnailator](https://github.com/coobird/thumbnailator)工具 | +| 17 | RedisTool | [Redis连接工具](https://gitee.com/xwintop/x-RedisTool) | redis连接工具,完成redis的基本增删改查功能 | +| 18 | WebSourcesTool | [网页源码下载工具](https://gitee.com/xwintop/x-WebSourcesTool) | 可根据网址下载对应网页相关内容及资源 | +| 19 | SwitchHostsTool | [切换Hosts工具](https://gitee.com/xwintop/x-SwitchHostsTool) | 可快速编辑hosts文件内容,使用[richtextfx](https://github.com/FXMisc/RichTextFX)工具 | +| 20 | FtpServer | [Ftp服务器](https://gitee.com/xwintop/x-FtpServer) | 快速搭建本地Ftp服务,基于[apache.ftpserver](https://mina.apache.org/ftpserver-project) | +| 21 | CmdTool | [Cmd调试工具](https://gitee.com/xwintop/x-CmdTool) | 进行cmd命令操作测试及调度执行 | +| 22 | FtpClientTool | [Ftp客户端调试工具](https://gitee.com/xwintop/x-FtpClientTool) | 进行ftp(s)/Sftp批量上传、下载、删除文件及文件夹,支持implicit/explicit SSL/TLS协议,使用[jsch](http://www.jcraft.com/jsch) 、[commons-io](http://commons.apache.org/io/) 等工具 | +| 23 | PdfConvertTool | [Pdf转换工具](https://gitee.com/xwintop/x-PdfConvertTool) | 目前仅支持pdf转图片、pdf转text功能,使用[pdfbox](https://pdfbox.apache.org/)工具 | +| 24 | DirectoryTreeTool | [文件列表生成器](https://gitee.com/xwintop/x-DirectoryTreeTool) | 快速生成目录结构图片,用于项目展示说明使用 | +| 25 | ImageTool | [图片压缩工具](https://gitee.com/xwintop/x-ImageTool) | 支持对图片进行批量压缩、修改尺寸、转换格式等功能 | +| 26 | AsciiPicTool | [图片转码工具](https://gitee.com/xwintop/x-AsciiPicTool) | 支持图片生成banner码、图片转Base64码、图片转Excel表 | +| 27 | KafkaTool | [Kafka调试工具](https://gitee.com/xwintop/x-KafkaTool) | (未完善),使用了[kafka-clients](http://kafka.apache.org/) | +| 28 | EmailTool | [邮件发送工具](https://gitee.com/xwintop/x-EmailTool) | 支持各种协议的邮件发送及自定义群发模版,使用[commons-email](https://commons.apache.org/email)工具 | +| 29 | ColorCodeConverterTool | [颜色代码转换工具](https://gitee.com/xwintop/x-ColorCodeConverterTool) | 对颜色包括16进制、RGB、ARGB、RGBA、HSL、HSV等代码之间转换 | +| 30 | SmsTool | [短信群发工具](https://gitee.com/xwintop/x-SmsTool) | 进行短信批量发送,目前支持中国移动、中国电信、腾讯云、阿里云、梦网云通讯等平台 | +| 31 | ScriptEngineTool | [脚本引擎调试工具](https://gitee.com/xwintop/x-ScriptEngineTool) | 执行各种脚本命令,目前支持JavaScript、Groovy、Python、Lua等脚本,使用[groovy](http://groovy-lang.org)、[jython](https://jython.org)、[luaj](http://www.luaj.org/luaj.html) 等工具 | +| 32 | FileRenameTool | [文件重命名工具](https://gitee.com/xwintop/x-FileRenameTool) | 对文件进行自定义快捷重命名操作 | +| 33 | JsonConvertTool | [Json转换工具](https://gitee.com/xwintop/x-JsonConvertTool) | 目前支持Json转Xml、Json转Java实体类、Json转C#实体类、Json转Excel、Json转Yaml、Properties转Yaml、Yaml转Properties,使用[fastjson](https://github.com/alibaba/fastjson)、[snakeyaml](https://bitbucket.org/asomov/snakeyaml)、[dom4j](https://dom4j.github.io) | 等工具| +| 34 | WechatJumpGameTool | [微信跳一跳助手](https://gitee.com/xwintop/x-WechatJumpGameTool) | 对微信跳一跳游戏的辅助 | +| 35 | TextToSpeechTool | [语音转换工具](https://gitee.com/xwintop/x-TextToSpeechTool) | 调用[百度语音](https://ai.baidu.com/tech/speech/tts)转换api将字符串转换为语音格式并朗读 | +| 36 | 2048 | 小游戏2048 | 小游戏2048javafx版本 | +| 37 | SocketTool | [Socket调试工具](https://gitee.com/xwintop/x-SocketTool) | 使用[Apache Mina](http://mina.apache.org) | 实现Tcp、Udp服务端和Client端| +| 38 | ImageAnalysisTool | [图片解析工具](https://gitee.com/xwintop/x-ImageAnalysisTool) | 1、.atlas文件反解析2、图片快速拆分工具 | +| 39 | DecompilerWxApkgTool | [微信小程序反编译工具](https://gitee.com/xwintop/x-DecompilerWxApkgTool) | 一键反编译微信小程序包 | +| 40 | ZookeeperTool | [Zookeeper工具](https://gitee.com/xwintop/x-ZookeeperTool) | 方便对zookeeper的一系列操作,包括新增、修改、删除(包括子文件) 、重命名、复制、添加变更通知 | +| 41 | ExcelSplitTool | [Excel拆分工具](https://gitee.com/xwintop/x-ExcelSplitTool) | 支持对xls、xlsx、csv及文件进行拆分操作,使用[commons-csv](http://commons.apache.org/csv)工具 | +| 42 | PathWatchTool | [文件夹监控工具](https://gitee.com/xwintop/x-PathWatchTool) | 支持对文件夹进行监控操作,包括新增、修改、删除操作的监听 | +| 43 | CharsetDetectTool | [文件编码检测工具](https://gitee.com/xwintop/x-CharsetDetectTool) | 对文件编码进行检测识别,使用[juniversalchardet](https://github.com/albfernandez/juniversalchardet)工具 | +| 44 | TransferTool | [传输工具](https://gitee.com/xwintop/x-TransferTool) | 集成各种传输协议,使用自定义定时任务(简单模式、cron表达式模式),分为Receiver接收器、Filter处理器、Sender发送器 | +| 45 | ScanPortTool | [端口扫描工具](https://gitee.com/xwintop/x-ScanPortTool) | 快速测试常用端口及自定义端口的联通性 | +| 46 | FileMergeTool | [文件合并工具](https://gitee.com/xwintop/x-FileMergeTool) | 支持对xls、xlsx、csv及文件进行合并操作,使用[apache.poi](http://poi.apache.org/)工具 | +| 47 | SedentaryReminderTool | [久坐提醒工具](https://gitee.com/xwintop/x-SedentaryReminderTool) | 自定义时长倒计时提醒功能 | +| 48 | RandomGeneratorTool | [随机数生成工具](https://gitee.com/xwintop/x-RandomGeneratorTool) | 快速生成各种类型的随机数,使用[hutool](https://hutool.cn)工具 | +| 49 | ClipboardHistoryTool | [剪贴板历史工具](https://gitee.com/xwintop/x-ClipboardHistoryTool) | 记录剪贴板历史功能 | +| 50 | FileSearchTool | [文件搜索工具](https://gitee.com/xwintop/x-FileSearchTool) | 快速建立磁盘文件索引,达到快速搜索的功能,使用[lucene](https://lucene.apache.org/)搜索引擎 | +| 51 | Mp3ConvertTool | [Mp3转换工具](https://gitee.com/xwintop/x-Mp3ConvertTool) | 目前支持网易云音乐.ncm、QQ音乐.qmc转换为mp3格式,使用[jaudiotagger](http://www.jthink.net/jaudiotagger)工具 | +| 52 | SealBuilderTool | [印章生成工具](https://gitee.com/xwintop/x-SealBuilderTool) | 快速生成多种风格、多种字体的个性化印章 | +| 53 | BullsAndCowsGame | 猜数字游戏 | 古老的的密码破译类益智类小游戏 | +| 54 | FileUnicodeTransformationTool | [文件编码转换工具](https://gitee.com/xwintop/x-FileUnicodeTransformationTool) | 快速实现文件编码批量转换 | +| 55 | FileCompressTool | [文件解压缩工具](https://gitee.com/xwintop/x-FileCompressTool) | 对文件进行解压缩处理,目前支持ar、zip、tar、jar、cpio、7z、gz、rar、bzip2、xz、lzma、pack200、deflate、snappy-framed、lz4-block、lz4-framed、zstd等格式解压缩 | +| 56 | IdiomDataTool | [成语字典工具](https://gitee.com/xwintop/x-IdiomDataTool) | 可多种模式快速对成语进行索引,使用[h2](http://www.h2database.com)数据库存储数据字典 | +| 57 | Sudoku | 数独游戏 | 益智类数独游戏javafx版本 | +| 58 | LiteappCode | 小程序码生成工具 | 快速生成小程序码 | +| 59 | RdbmsSyncTool | [关系型数据库同步工具](https://gitee.com/xwintop/x-RdbmsSyncTool) | 完成关系型数据库表结构获取,快捷执行一些常用数据库脚本,支持多种类型数据库直接数据转移,同步 | +| 60 | FileBuildTool | [文件生成工具](https://gitee.com/xwintop/x-FileBuildTool) | 根据自定义模板快速批量生成文件,用于测试使用 | +| 61 | LuytenTool | [Java反编译工具](https://gitee.com/xwintop/x-LuytenTool) | 对jar包进行反编译操作,使用开源项目[luyten](https://github.com/deathmarine/Luyten) | +| 62 | JavaService | [Java服务安装工具](https://gitee.com/xwintop/x-JavaService) | 将java程序安装到windows服务中,引用服务,使用开源项目[winsw](https://github.com/winsw/winsw) | +| 63 | ElementaryArithmeticProblemTool | [小学生算数题生成工具](https://gitee.com/xwintop/x-ElementaryArithmeticProblemTool) | 小学生混合运算加减乘除数学训练题出题答案生成工具 | +| 64 | CoordinateTransformTool | [坐标系转换工具](https://gitee.com/xwintop/x-CoordinateTransformTool) | 提供了百度坐标(BD09)、国测局坐标(火星坐标,GCJ02)、和WGS84坐标系之间的转换 | +| 65 | HdfsTool | [hdfs管理工具](https://gitee.com/xwintop/x-HdfsTool) | hdfs可视化管理工具,支持上传、下载、重命名、复制、移动和删除等功能 | +| 66 | JavaFxXmlToObjectCode | [javaFxFxml转换代码](https://gitee.com/xwintop/x-JavaFxXmlToObjectCode) | 根据.fxml文件生成相应的java代码,可生成插件模版 | +| 67 | KeyTool | [KeyTool](https://gitee.com/xwintop/x-KeyTool) | license生成工具 | +| 68 | RelationshipCalculator | [亲戚关系计算器](https://gitee.com/xwintop/x-RelationshipCalculator) | 通过亲戚关系链计算称呼的功能 | +| 69 | ExpressionParserTool | [表达式解析器调试工具](https://gitee.com/xwintop/x-ExpressionParserTool) | 一款表达式解析器调试工具,目前支持SpringEL、Velocity 、FreeMarker、StringTemplate、Mvel、Aviator、commons-jexl 、BeanShell、QLExpress等表达式引擎 | +| 70 | mybatis-generator-gui | [Mybatis代码生成工具](https://gitee.com/zhuifeng335/mybatis-generator-gui) | 本工具可以使你非常容易及快速生成Mybatis的Java POJO文件及数据库Mapping文件 | +| 71 | SftpServer | Sftp服务器 | 快速搭建本地Sftp服务,基于[apache.sshd](https://mina.apache.org/sshd-project/) + +项目开发中,以后会陆续添加新工具,欢迎大家参与其中,多提提意见,谢谢。 + +#### 项目结构 + +``` +xJavaFxTool +├─ images 项目截图 +├─ pom.xml maven配置文件 +├─ README.md 说明文件 +├─ src +│ ├─ main +│ │ ├─ java +│ │ │ └─ com +│ │ │ └─ xwintop +│ │ │ └─ xJavaFxTool +│ │ │ ├─ common 第三方工具类 +│ │ │ ├─ controller javafx控制层 +│ │ │ │ └─ index 首页控制层 +│ │ │ ├─ model 基础bean类层 +│ │ │ ├─ services 工具服务层 +│ │ │ │ └─ index 首页工具服务层 +│ │ │ ├─ utils 系统工具类 +│ │ │ └─ view javafx视图层 +│ │ │ └─ index 首页工具视图层 +│ │ └─ resources +│ │ ├─ com +│ │ │ └─ xwintop +│ │ │ └─ xJavaFxTool +│ │ │ └─ fxmlView .fxml文件 +│ │ ├─ config 配置文件 +│ │ │ └─ toolFxmlLoaderConfiguration.xml 系统菜单加载配置文件 +│ │ ├─ css 样式资源 +│ │ ├─ images 图片资源 +│ │ ├─ locale 国际化 +│ │ ├─ banner.txt 启动banner图片 +│ │ └─ logback.xml logback日志配置文件 +│ └─ test 测试类 +│ ├─ java +│ └─ resources + +``` + +##### 📈 趋势 +[![Giteye chart](https://chart.giteye.net/gitee/xwintop/xJavaFxTool/2ZF6FD8R.png)](https://giteye.net/chart/2ZF6FD8R) +##### 🍚 贡献 +[![Giteye chart](https://chart.giteye.net/gitee/xwintop/xJavaFxTool/K3ZV48G2.png)](https://giteye.net/chart/K3ZV48G2) + +#### 特别感谢 +在一个人还年轻的时候,我觉得,就应该着手致力做一些对社会有意义的事情,一如开源。至此,感谢以下贡献者(排名不分先后): ++ [李柱](https://gitee.com/loyalty521) ++ [luming](https://gitee.com/jeeweb) ++ [码志](https://gitee.com/dazer1992) ++ [三叔](https://gitee.com/bejson) + +#### 后续计划 +不定期添加汇总开发过程中需求的痛点工具,大家有工作上的痛点处可进群讨论,后期可能就会出相应的工具解决方案,谢谢大家的支持。 + +#### 项目截图如下: + +![传输工具.gif](images/传输工具.gif) +![Cron表达式生成器](images/Cron表达式生成器.gif) +![加密解密](images/加密解密.gif) +![正则表达式生成工具](images/正则表达式生成工具.gif) +![二维码生成工具](images/二维码生成工具.gif) \ No newline at end of file diff --git a/README_EN.md b/README_EN.md new file mode 100644 index 00000000..5f240edb --- /dev/null +++ b/README_EN.md @@ -0,0 +1,216 @@ +**Gidee address:**[xJavaFxTool](https://gitee.com/xwintop/xJavaFxTool) + +**GitHub address:**[xJavaFxTool](https://github.com/864381832/xJavaFxTool) + +[![](https://img.shields.io/:license-apache-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) +[![](https://img.shields.io/badge/JDK-17+-green.svg)](https://www.oracle.com/technetwork/java/javase/downloads/index.html) +[![](https://img.shields.io/badge/maven-v3.6.3-blue)](https://maven.apache.org) +[![](https://gitee.com/xwintop/xJavaFxTool/badge/star.svg?theme=dark)](https://gitee.com/xwintop/xJavaFxTool/stargazers) +[![](https://img.shields.io/github/stars/864381832/xJavaFxTool.svg?style=social)](https://github.com/864381832/xJavaFxTool) +[![](https://img.shields.io/badge/IntelliJ%20IDEA-提供支持-blue.svg)](https://www.jetbrains.com/?from=xJavaFxTool) + +[中文说明/Chinese Documentation](README.md) + +**xJavaFxTool exchange QQ group:== [387473650](https://jq.qq.com/?_wv=1027&k=59UDEAD) ==** + +#### Project Description: +xJavaFxTool is a practical gadget set developed by javaFx. It uses some time to summarize some problems encountered in the work, packaged into a small tool set for your reference and use. It contains some examples of javaFx functions, such as layout, Internationalization, third-party UI library ( [controlsfx](https://github.com/controlsfx/controlsfx) , [JFoenix](https://github.com/sshahine/JFoenix), etc.), external jar package loading (plug-in mechanism) and other common functions, students who want to learn javaFx can refer to the reference, learn javaFx data reference [https://openjfx.cn/](https://openjfx.cn/) + +Due to the hot SpringBoot, the project has been released SpringBoot-javafx version, [xJavaFxTool-spring](https://gitee.com/xwintop/xJavaFxTool-spring) welcome reference, thank you. + +#### Download trial address: +- Linux amd64 [xJavaFxTool-1.0.1-linux-amd64.deb](https://github.com/864381832/xJavaFxTool/releases/download/v1.0.1/xJavaFxTool-1.0.1-linux-amd64.deb) +- Linux amd64 [xJavaFxTool-1.0.1-linux-amd64.rpm](https://github.com/864381832/xJavaFxTool/releases/download/v1.0.1/xJavaFxTool-1.0.1-linux-amd64.rpm) +- Mac OS aarch64 [xJavaFxTool-1.0.1-macos-x64.dmg](https://github.com/864381832/xJavaFxTool/releases/download/v1.0.1/xJavaFxTool-1.0.1-macos-aarch64.dmg) +- Mac OS aarch64 [xJavaFxTool-1.0.1-macos-x64.pkg](https://github.com/864381832/xJavaFxTool/releases/download/v1.0.1/xJavaFxTool-1.0.1-macos-aarch64.pkg) +- Windows x64 [xJavaFxTool-1.0.1-windows-x64.exe](https://github.com/864381832/xJavaFxTool/releases/download/v1.0.1/xJavaFxTool-1.0.1-windows-x64.exe) +- Windows x64 [xJavaFxTool-1.0.1-windows-x64.msi](https://github.com/864381832/xJavaFxTool/releases/download/v1.0.1/xJavaFxTool-1.0.1-windows-x64.msi) +- 123cloud link:[https://www.123865.com/s/L5LA-tna7A?pwd=java#](https://www.123865.com/s/L5LA-tna7A?pwd=java#) extraction code:java + +#### Support plug-in development: +the plug-in jar package can be automatically loaded under the root directory libs (see the open source project [xJavaFxTool-plugin](https://gitee.com/xwintop/xJavaFxTool-plugin) for plug-in development examples , and the next step is to split the gadget into each plug-in and load it as needed. Currently, the plug-in function is not perfect, follow-up Split each function into modules and load them as needed to reduce the size of the jar package); + +#### Environmental construction instructions: +- The development environment is jdk17, based on gradle8.5 build +- Developed with eclipase or Intellij Idea (Recommended to use [Intellij Idea](https://www.jetbrains.com/idea/) ) +- This project uses [lombok](https://projectlombok.org/) . If you have not downloaded the lombok plugin when viewing this project, please install it first, otherwise you can't find the get/set method. +- Package using the [javapackager](https://github.com/fvarrui/JavaPackager) (can be packaged for windows, Linux, Mac installation packages) +- Use [InnoSetup](http://www.jrsoftware.org/) to make windows installation packages + +#### The currently integrated gadgets are: +1. FileCopy: File Copy (supports automatic scheduled copy function) (using the [quartz](https://www.quartz-scheduler.org/) tool) +2. CronExpBuilder: Cron Expression Builder +3. CharacterConverter: code conversion +4. EncryptAndDecrypt: Encryption and decryption (Ascii, Hex, Base64, Base32, URL, MD5, SHA, AES, DES, file encryption DM5, file encryption SHA1, Morse password, Druid encryption) (using the [commons-codec](http://commons.apache.org/codec/) tool) +5. TimeTool: Time conversion (common format conversion (including time zone), calculation time difference, time superposition calculation) +6. LinuxPathToWindowsPath: path conversion (using the [oshi](https://github.com/oshi/oshi) tool) +7. QRCodeBuilder: QR code generation tool (automatically generate, add logo, screenshot recognition, custom format) (using [google.zxing](https://github.com/zxing/zxing) , [jkeymaster](https://github.com/tulskiy/jkeymaster), etc.) +8. IdCardGenerator: ID Generator +9. RegexTester: Regular Expression Generation Tool +10. ShortURL: URL shortening (currently support Baidu, Sina, shrink me and other short URL shortening) +11. EscapeCharacter: escape characters (supports Html, XML, Java, JavaScript, CSV, Sql) (using the [commons-lang3](https://commons.apache.org/lang) tool) +12. ZHConverter: string conversion (using [hanlp](http://hanlp.com/) open source tools, to achieve pinyin, simplified - traditional, simplified - Taiwanese body, simplified - Hong Kong traditional, traditional - Taiwanese body, traditional - Hong Kong traditional, Hong Kong traditional - Taiwanese body, digital amount - capital amount, etc. Direct conversion) +13. ActiveMqTool: Mq debugging tool (currently only supports [ActiveMq](http://activemq.apache.org) ) +14. HttpTool: Http debugging tool (supports custom send data, header and cookie) (using [okhttp](https://square.github.io/okhttp/) ) +15. jsonEditor: json format editing tool +16. IconTool: Icon Generation Tool (using the [thumbnailator](https://github.com/coobird/thumbnailator) tool) +17. RedisTool: Redis connection tool (using the [jedis](https://github.com/xetorthio/jedis) tool) +18. WebSourcesTool: web source download tool +19. SwitchHostsTool: Switch the Hosts tool (using the [richtextfx](https://github.com/FXMisc/RichTextFX) tool) +20. FtpServer: Ftp server (quickly build local Ftp service) (based on [apache.ftpserver](https://mina.apache.org/ftpserver-project) ) +21. CmdTool: Cmd debugging tool +22. FtpClientTool: Ftp(s)/Sftp client debugging tool (batch upload, download, delete files and folders) (implicit/explicit SSL/TLS) (using [jsch](http://www.jcraft.com/jsch) , [commons-io](http://commons.apache.org/io/), etc.) +23. PdfConvertTool: Pdf conversion tool (currently only supports pdf to image, pdf to text function) (using [pdfbox](https://pdfbox.apache.org/) tool) +24. DirectoryTreeTool: File List Generator +25. ImageTool: Image compression tool (bulk compression, resizing, conversion format) +26. AsciiPicTool: Image transcoding tool (including image generation banner code, picture to Base64 code, picture to Excel table) +27. KafkaTool: Kafka debugging tool (not perfect) (using [kafka-clients](http://kafka.apache.org/) ) +28. EmailTool: Email bulk tool (supports custom bulk template) (using the [commons-email](https://commons.apache.org/email) tool) +29. ColorCodeConverterTool: color code conversion tool (including conversion between hexadecimal, RGB, ARGB, RGBA, HSL, HSV, etc.) +30. SmsTool: SMS group sending tool (currently supports China Mobile, China Telecom, Tencent Cloud, Alibaba Cloud, Monternet Cloud Communication and other platforms) +31. ScriptEngineTool: script engine debugging tool (currently supports scripts such as JavaScript, Groovy, Python, Lua, etc.) (using tools such as [groovy](http://groovy-lang.org),[jython](https://jython.org),[luaj](http://www.luaj.org/luaj.html), etc.) +32. FileRenameTool: File Rename Tool +33. JsonConvertTool: Json conversion tool (currently supports Json to Xml, Json to Java entity class, Json to C# entity class, Json to Excel, Json to Yaml, Properties to Yaml, Yaml to Properties) (using [fastjson](https://github.com/alibaba/fastjson), [snakeyaml](https://bitbucket.org/asomov/snakeyaml), [dom4j](https://dom4j.github.io), etc.) +34. WechatJumpGameTool: WeChat Jumping Assistant +35. TextToSpeechTool: Voice Conversion Tool (call [Baidu Voice Conversion](https://ai.baidu.com/tech/speech/tts) API) +36. 2048: Small game 2048 +37. SocketTool: Socket debugging tool (using [Apache Mina](http://mina.apache.org) to implement Tcp, Udp server and client) +38. ImageAnalysisTool: Image parsing tool (1. Atlas file anti-parsing 2, image quick split tool) +39. DecompilerWxApkgTool: WeChat applet decompilation tool (one-click decompilation WeChat small package) +40. ZooKeeperTool: Zookeeper Tool (a convenient operation for ZooKeeper, including adding, modifying, deleting (including subfiles), renaming, copying, adding change notifications) (using the [zkclient](https://github.com/sgroschupf/zkclient) tool) +41. ExcelSplitTool: Excel split tool (supports splitting xls, xlsx, csv and files) (using the [commons-csv](http://commons.apache.org/csv) tool) +42. PathWatchTool: Folder Monitoring Tool +43. CharsetDetectTool: File Encoding Detection Tool (using the [juniversalchardet](https://github.com/albfernandez/juniversalchardet) tool) +44. TransferTool: Transfer tool (integrated with various transport protocols, using custom timing tasks (simple mode, cron expression mode), divided into Receiver receiver, Filter processor, Sender transmitter) +45. ScanPortTool: Port Scanning Tool +46. FileMergeTool: File Merge Tool (supports merging xls, xlsx, csv, and files) (using the [apache.poi](http://poi.apache.org/) tool) +47. SedentaryReminderTool: Sedentary Reminder Tool +48. RandomGeneratorTool: random number generation tool (using [hutool](https://hutool.cn) tool) +49. ClipboardHistoryTool: Clipboard History Tool +50. FileSearchTool: File Search Tool (using the [lucene](https://lucene.apache.org/) search engine) +51. Mp3ConvertTool: Mp3 conversion tool (currently supports NetEase cloud music.ncm, QQ music.qmc converted to mp3 format) (using [jaudiotagger](http://www.jthink.net/jaudiotagger/) tool) +52. SealBuilderTool: Stamp Generation Tool +53. BullsAndCowsGame: A number guessing game +54. FileUnicodeTransformationTool: File encoding conversion tool +55. FileCompressTool: File decompression tool (currently supports ar, zip, tar, jar, cpio, 7z, gz, rar, bzip2, xz, lzma, pack200, deflate, snappy-framed, lz4-block, lz4-framed, ZSTD, etc.) +56. IdiomDataTool:IdiomDataTool(Use the [h2](http://www.h2database.com) database to store the data dictionary) +57. Sudoku:Sudoku Game +58. LiteappCode +59. RdbmsSyncTool +60. FileBuildTool +61. LuytenTool:Java decompilation tool, use open source project[luyten](https://github.com/deathmarine/Luyten) +62. JavaService:Java Service installation tools, use open source project[winsw](https://github.com/winsw/winsw) +63. ElementaryArithmeticProblemTool:Elementary Arithmetic Problem Tool +64. CoordinateTransformTool:[CoordinateTransformTool](https://gitee.com/xwintop/x-CoordinateTransformTool),Conversion between Baidu coordinates (BD09), National Survey Bureau coordinates (Mars coordinates, GCJ02), and WGS84 coordinates is provided +65. HdfsTool:[HdfsTool](https://gitee.com/xwintop/x-HdfsTool),Support uploading, downloading, renaming, copying, moving and deleting functions +66. JavaFxXmlToObjectCode: Generates corresponding Java code based on .fxml files, can generate plugin templates +67. KeyTool: License generation tool +68. RelationshipCalculator: Calculates appellations through relative relationship chains +69. ExpressionParserTool: An expression parser debugging tool that currently supports SpringEL, Velocity, FreeMarker, StringTemplate, Mvel, Aviator, commons-jexl, BeanShell, QLExpress expression engines +70. mybatis-generator-gui: This tool makes it very easy and quick to generate MyBatis Java POJO files and database mapping files +71. SftpServer: Quickly builds local SFTP service, based on apache.sshd + +#### In the development of the project, new tools will be added in the future. Welcome everyone to participate and give more comments, thank you. +#### Plan to add features: +- [ ] Monitoring function (folder depth, number of Ftp/Ftps/sftp files, mq depth) +- [ ] Convert excel to sql insert statement +- [ ] Record keyboard usage gadget +- [ ] Random file generator (with template engine) + +#### Project structure + +``` +xJavaFxTool +├─ project ImagesRF Royalty Free Screenshot +├─ external storage jar package lib reference +├─ libs plugin jar package store +├─ pom.xml maven profile +├─ README.md documentation +├─ src +│ ├─ main +│ │ ├─ the Java +│ │ │ └ com +│ │ │ └ ─ xwintop +│ │ │ └ ─ ─ xJavaFxTool +│ │ │ ├─ common third-party tools +│ │ │ ├─ config springBoot configuration class +│ │ │ ├─ controller javafx control layer +│ │ │ │ ├─ assistTools Auxiliary Tool Control Layer +│ │ │ │ ├ ─ codeTools Code Tool Control Layer +│ │ │ │ ├─ debugTools Debug Tool Control Layer +│ │ │ │ ├─ developTools Development Tool Control Layer +│ │ │ │ ├─ epmsTools epms Tool Control Layer +│ │ │ │ ├─ javaFxTools javaFx tool control layer +│ │ │ │ ├─ littleTools gadget control layer +│ │ │ │ └ ─ webTools html tool control layer +│ │ │ ├─ job timed task processing job +│ │ │ ├─ main main function package +│ │ │ ├─ manager management +│ │ │ ├─ model basic bean class layer +│ │ │ ├─ services tool service layer +│ │ │ │ ├─ assistTools auxiliary tool service layer +│ │ │ │ ├─ codeTools Code tool service layer +│ │ │ │ ├─ debugTools debugging tool service layer +│ │ │ │ ├─ developTools development tool service layer +│ │ │ │ ├─ epmsTools epms tool service layer +│ │ │ │ ├─ javaFxTools javaFx tool service layer +│ │ │ │ ├─ littleTools gadgets service layer +│ │ │ │ └─ webTools html tool service layer +│ │ │ ├─ Utils system tools class +│ │ │ ├─ view javafx view layer +│ │ │ │ ├─ assistTools auxiliary tool view layer +│ │ │ │ ├─ codeTools Code tool view layer +│ │ │ │ ├─ debugTools debugging tool View layer +│ │ │ │ ├─ developTools development tools view layer +│ │ │ │ ├─ javaFxTools javaFx tool view layer +│ │ │ │ ├─ littleTools widget view layer +│ │ │ │ └─ webTools html tool view layer +│ │ │ └ ─ web web control view layer +│ │ └ ─ resources +│ │ ├ com +│ │ │ └ ─ xwintop +│ │ │ └─ xJavaFxTool +│ │ │ └─ fxmlView .fxml file +│ │ ├─ Config configuration file +│ │ │ └─ toolFxmlLoaderConfiguration.xml system menu loading configuration file +│ │ ├─ css style resource +│ │ ├─ data data resource +│ │ ├─ images image resource +│ │ ├─ locale internationalization +│ │ ├─ web html tools +│ │ ├─ application.yaml SpringBoot configuration file +│ │ ├─ banner.txt start banner pictures +│ │ └─ logback.xml logback log configuration file +│ └─ test test class +│ ├─ java +│ └─ resources +├─ xJavaFxTool.jar run the package directly + +``` + +#### Special thanks to +When a person is still young, I feel that I should start to do something that is meaningful to society, just like open source. At this point, thanks to the following contributors (in no particular order): ++ [Li Zhu](https://gitee.com/loyalty521) ++ [luming](https://gitee.com/jeeweb) ++ [Code](https://gitee.com/dazer1992) ++ Your goddess ++ [bejson](https://gitee.com/bejson) + +#### Follow-up plan +From time to time, add the pain points tool that summarizes the requirements in the development process. Everyone has a pain point at work and can enter the group discussion. Later, there may be corresponding tool solutions. Thank you for your support. + +#### The project screenshot is as follows: + +![输入图片说明](images/传输工具.gif "传输工具.gif") +![输入图片说明](images/邮件发送工具.gif "邮件发送工具.png") +![输入图片说明](images/Cron表达式生成器.gif "Cron表达式生成器.gif") +![输入图片说明](images/加密解密.gif "加密解密.png") +![输入图片说明](images/正则表达式生成工具.gif "正则表达式生成工具.png") +![输入图片说明](images/二维码生成工具.gif "二维码生成工具.png") +![输入图片说明](images/随机数生成工具.gif "随机数生成工具.png") +![输入图片说明](images/Redis连接工具.gif "Redis连接工具.png") +![输入图片说明](images/图片压缩工具.gif "图片压缩工具.png") +![输入图片说明](images/图片转码工具.gif "图片转码工具.png") +![输入图片说明](images/短信群发工具.gif "短信群发工具.png") +![输入图片说明](images/文件重命名工具.gif "文件重命名工具.png") +![输入图片说明](images/成语字典工具.gif "成语字典工具.png") diff --git a/src/main/resources/images/icon.jpg b/assets/linux/xJavaFxTool.png similarity index 100% rename from src/main/resources/images/icon.jpg rename to assets/linux/xJavaFxTool.png diff --git a/assets/mac/xJavaFxTool.icns b/assets/mac/xJavaFxTool.icns new file mode 100644 index 00000000..9c433da2 Binary files /dev/null and b/assets/mac/xJavaFxTool.icns differ diff --git a/assets/windows/xJavaFxTool.ico b/assets/windows/xJavaFxTool.ico new file mode 100644 index 00000000..0c93826a Binary files /dev/null and b/assets/windows/xJavaFxTool.ico differ diff --git a/assistTools/x-DecompilerWxApkgTool/.gitignore b/assistTools/x-DecompilerWxApkgTool/.gitignore new file mode 100644 index 00000000..ee851474 --- /dev/null +++ b/assistTools/x-DecompilerWxApkgTool/.gitignore @@ -0,0 +1,6 @@ +# Default ignored files +#/.gitignore +/x-DecompilerWxApkgTool.iml +/log/ +/target/ +.idea \ No newline at end of file diff --git a/assistTools/x-DecompilerWxApkgTool/LICENSE b/assistTools/x-DecompilerWxApkgTool/LICENSE new file mode 100644 index 00000000..9e32cdef --- /dev/null +++ b/assistTools/x-DecompilerWxApkgTool/LICENSE @@ -0,0 +1,127 @@ + 木兰宽松许可证, 第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. diff --git a/assistTools/x-DecompilerWxApkgTool/README.md b/assistTools/x-DecompilerWxApkgTool/README.md new file mode 100644 index 00000000..eb32eda1 --- /dev/null +++ b/assistTools/x-DecompilerWxApkgTool/README.md @@ -0,0 +1,15 @@ +DecompilerWxApkgTool 微信小程序反编译工具 + +#### 项目简介: +DecompilerWxApkgTool是使用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) \ No newline at end of file diff --git a/assistTools/x-DecompilerWxApkgTool/README_EN.md b/assistTools/x-DecompilerWxApkgTool/README_EN.md new file mode 100644 index 00000000..68d246eb --- /dev/null +++ b/assistTools/x-DecompilerWxApkgTool/README_EN.md @@ -0,0 +1 @@ +DecompilerWxApkgTool \ No newline at end of file diff --git a/assistTools/x-DecompilerWxApkgTool/build.gradle b/assistTools/x-DecompilerWxApkgTool/build.gradle new file mode 100644 index 00000000..212970b6 --- /dev/null +++ b/assistTools/x-DecompilerWxApkgTool/build.gradle @@ -0,0 +1,7 @@ +dependencies { + api project(':xcore') +} + +group = 'com.xwintop' +version = '0.0.1' +description = 'x-DecompilerWxApkgTool' diff --git "a/assistTools/x-DecompilerWxApkgTool/images/\345\276\256\344\277\241\345\260\217\347\250\213\345\272\217\345\217\215\347\274\226\350\257\221\345\267\245\345\205\267.png" "b/assistTools/x-DecompilerWxApkgTool/images/\345\276\256\344\277\241\345\260\217\347\250\213\345\272\217\345\217\215\347\274\226\350\257\221\345\267\245\345\205\267.png" new file mode 100644 index 00000000..8e30e9d8 Binary files /dev/null and "b/assistTools/x-DecompilerWxApkgTool/images/\345\276\256\344\277\241\345\260\217\347\250\213\345\272\217\345\217\215\347\274\226\350\257\221\345\267\245\345\205\267.png" differ diff --git a/assistTools/x-DecompilerWxApkgTool/src/main/java/com/xwintop/xJavaFxTool/DecompilerWxApkgToolMain.java b/assistTools/x-DecompilerWxApkgTool/src/main/java/com/xwintop/xJavaFxTool/DecompilerWxApkgToolMain.java new file mode 100644 index 00000000..872a990b --- /dev/null +++ b/assistTools/x-DecompilerWxApkgTool/src/main/java/com/xwintop/xJavaFxTool/DecompilerWxApkgToolMain.java @@ -0,0 +1,51 @@ +package com.xwintop.xJavaFxTool; + +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.stage.Stage; +import javafx.stage.WindowEvent; +import lombok.extern.slf4j.Slf4j; + +import java.net.URL; +import java.util.ResourceBundle; + +@Slf4j +public class DecompilerWxApkgToolMain extends Application { + public static void main(String[] args) { + try { + launch(args); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void start(Stage primaryStage) throws Exception { + FXMLLoader fXMLLoader = DecompilerWxApkgToolMain.getFXMLLoader(); + ResourceBundle resourceBundle = fXMLLoader.getResources(); + Parent root = fXMLLoader.load(); + primaryStage.setResizable(true); + primaryStage.setTitle(resourceBundle.getString("Title")); +// primaryStage.getIcons().add(new Image("/images/icon.jpg")); + double[] screenSize = JavaFxSystemUtil.getScreenSizeByScale(0.74D, 0.8D); + primaryStage.setScene(new Scene(root, screenSize[0], screenSize[1])); + primaryStage.show(); + primaryStage.setOnCloseRequest(new EventHandler() { + @Override + public void handle(WindowEvent event) { + System.exit(0); + } + }); + } + + public static FXMLLoader getFXMLLoader() { + ResourceBundle resourceBundle = ResourceBundle.getBundle("locale.DecompilerWxApkgTool"); + URL url = Object.class.getResource("/com/xwintop/xJavaFxTool/fxmlView/assistTools/DecompilerWxApkgTool.fxml"); + FXMLLoader fXMLLoader = new FXMLLoader(url, resourceBundle); + return fXMLLoader; + } +} \ No newline at end of file diff --git a/assistTools/x-DecompilerWxApkgTool/src/main/java/com/xwintop/xJavaFxTool/controller/assistTools/DecompilerWxApkgToolController.java b/assistTools/x-DecompilerWxApkgTool/src/main/java/com/xwintop/xJavaFxTool/controller/assistTools/DecompilerWxApkgToolController.java new file mode 100644 index 00000000..e68bcf30 --- /dev/null +++ b/assistTools/x-DecompilerWxApkgTool/src/main/java/com/xwintop/xJavaFxTool/controller/assistTools/DecompilerWxApkgToolController.java @@ -0,0 +1,67 @@ +package com.xwintop.xJavaFxTool.controller.assistTools; + +import com.xwintop.xJavaFxTool.view.assistTools.DecompilerWxApkgToolView; +import com.xwintop.xJavaFxTool.services.assistTools.DecompilerWxApkgToolService; +import com.xwintop.xcore.util.javafx.FileChooserUtil; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +import java.io.File; +import java.net.URL; +import java.util.ResourceBundle; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; + +/** + * @ClassName: DecompilerWxApkgToolController + * @Description: 微信小程序反编译工具 + * @author: xufeng + * @date: 2018/7/4 14:44 + */ +@Getter +@Setter +@Slf4j +public class DecompilerWxApkgToolController extends DecompilerWxApkgToolView { + private DecompilerWxApkgToolService decompilerWxApkgToolService = new DecompilerWxApkgToolService(this); + + @Override + public void initialize(URL location, ResourceBundle resources) { + initView(); + initEvent(); + initService(); + } + + private void initView() { + } + + private void initEvent() { + FileChooserUtil.setOnDrag(packageFileTextField, FileChooserUtil.FileType.FILE); + FileChooserUtil.setOnDrag(decompilePathTextField, FileChooserUtil.FileType.FOLDER); + } + + private void initService() { + } + + @FXML + private void packageFileButtonAction(ActionEvent event) { + File file = FileChooserUtil.chooseFile(); + if (file != null) { + packageFileTextField.setText(file.getPath()); + } + } + + @FXML + private void decompilePathButtonAction(ActionEvent event) { + File file = FileChooserUtil.chooseDirectory(); + if (file != null) { + decompilePathTextField.setText(file.getPath()); + } + } + + @FXML + private void decompileButtonAction(ActionEvent event) throws Exception { + decompilerWxApkgToolService.decompileButtonAction(); + } +} \ No newline at end of file diff --git a/assistTools/x-DecompilerWxApkgTool/src/main/java/com/xwintop/xJavaFxTool/services/assistTools/DecompilerWxApkgToolService.java b/assistTools/x-DecompilerWxApkgTool/src/main/java/com/xwintop/xJavaFxTool/services/assistTools/DecompilerWxApkgToolService.java new file mode 100644 index 00000000..bc9b52f7 --- /dev/null +++ b/assistTools/x-DecompilerWxApkgTool/src/main/java/com/xwintop/xJavaFxTool/services/assistTools/DecompilerWxApkgToolService.java @@ -0,0 +1,126 @@ +package com.xwintop.xJavaFxTool.services.assistTools; + +import com.xwintop.xJavaFxTool.controller.assistTools.DecompilerWxApkgToolController; +import com.xwintop.xcore.util.javafx.TooltipUtil; +import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang3.StringUtils; + +import java.io.*; + +/** + * @ClassName: DecompilerWxApkgToolService + * @Description: 微信小程序反编译工具 + * @author: xufeng + * @date: 2018/7/4 14:44 + */ + +@Getter +@Setter +@Slf4j +public class DecompilerWxApkgToolService { + private DecompilerWxApkgToolController decompilerWxApkgToolController; + + private DataInputStream in;//in 流 + private WxFile wxFile;//当前文件 + private WxFile currentWxFile;//当前文件 + private int count;//当前文件 + + public void decompileButtonAction() throws Exception { + String filePath = decompilerWxApkgToolController.getPackageFileTextField().getText(); + if (StringUtils.isBlank(filePath)) { + TooltipUtil.showToast("原包路径未填写。"); + return; + } + String decompilePath = decompilerWxApkgToolController.getDecompilePathTextField().getText(); + if (StringUtils.isBlank(decompilePath)) { + decompilePath = FilenameUtils.getFullPath(filePath) + FilenameUtils.getBaseName(filePath); + FileUtils.forceMkdir(new File(decompilePath + "\\")); + } + decompilePath = StringUtils.appendIfMissing(decompilePath, "/", "/", "\\"); + this.in = new DataInputStream(new FileInputStream(filePath)); + decodeWxFile(this.in); + while (currentWxFile != null) { + String name = currentWxFile.getName(); + File file = new File(decompilePath, name); + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + OutputStream o = new FileOutputStream(file); + this.readWxFile(o); + o.close(); + } + if (in != null) { + in.close(); + } + TooltipUtil.showToast("反编译成功,文件保存在:" + decompilePath + "目录下。"); + } + + public DecompilerWxApkgToolService(DecompilerWxApkgToolController decompilerWxApkgToolController) { + this.decompilerWxApkgToolController = decompilerWxApkgToolController; + } + + /** + * 解码文件名区域 + * + * @param in in + */ + private void decodeWxFile(DataInputStream in) throws IOException { + in.readByte(); //标识 + in.readInt(); //未知 + in.readInt(); //文件名域长度 + in.readInt(); //内容域长度 + in.readByte(); //未知 + count = in.readInt(); //文件数量 + if (count > 0) { + WxFile nextWxFile = null; + for (int i = 0; i < count; i++) { + byte[] name = new byte[in.readInt()]; //文件名长度 + int j = in.read(name); + int offset = in.readInt(); //偏移 + int length = in.readInt(); //内容长度 + WxFile currentWxFile = new WxFile(); + currentWxFile.setName(new String(name, "UTF-8")); + currentWxFile.setOffset(offset); + currentWxFile.setLength(length); + if (nextWxFile == null) { + nextWxFile = currentWxFile; + wxFile = nextWxFile; + } else { + nextWxFile.setNext(currentWxFile); + nextWxFile = currentWxFile; + } + } + } + currentWxFile = wxFile; //当前处理的文件 + } + + /** + * @param out 输出流 + */ + public void readWxFile(OutputStream out) throws IOException { + if (currentWxFile == null) { + throw new IOException("no more files"); + } + int length = currentWxFile.getLength(); + byte[] buffer = new byte[length]; + int readSize; + while (length > 0 && (readSize = in.read(buffer)) != -1) { + length -= readSize; + out.write(buffer, 0, readSize); + } + currentWxFile = currentWxFile.getNext(); + } + + @Data + public class WxFile { + private String name;//文件名称 + private int offset;//偏移量 + private int length;//文件长度 + private WxFile next;//文件长度 + } +} \ No newline at end of file diff --git a/assistTools/x-DecompilerWxApkgTool/src/main/java/com/xwintop/xJavaFxTool/view/assistTools/DecompilerWxApkgToolView.java b/assistTools/x-DecompilerWxApkgTool/src/main/java/com/xwintop/xJavaFxTool/view/assistTools/DecompilerWxApkgToolView.java new file mode 100644 index 00000000..1e6ab0a0 --- /dev/null +++ b/assistTools/x-DecompilerWxApkgTool/src/main/java/com/xwintop/xJavaFxTool/view/assistTools/DecompilerWxApkgToolView.java @@ -0,0 +1,31 @@ +package com.xwintop.xJavaFxTool.view.assistTools; + +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.Button; +import javafx.scene.control.TextField; +import lombok.Getter; +import lombok.Setter; + +/** + * @ClassName: DecompilerWxApkgToolView + * @Description: 微信小程序反编译工具 + * @author: xufeng + * @date: 2018/7/4 14:44 + */ + +@Getter +@Setter +public abstract class DecompilerWxApkgToolView implements Initializable { + @FXML + protected TextField packageFileTextField; + @FXML + protected Button packageFileButton; + @FXML + protected TextField decompilePathTextField; + @FXML + protected Button decompilePathButton; + @FXML + protected Button decompileButton; + +} \ No newline at end of file diff --git a/assistTools/x-DecompilerWxApkgTool/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/assistTools/DecompilerWxApkgTool.fxml b/assistTools/x-DecompilerWxApkgTool/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/assistTools/DecompilerWxApkgTool.fxml new file mode 100644 index 00000000..950342ca --- /dev/null +++ b/assistTools/x-DecompilerWxApkgTool/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/assistTools/DecompilerWxApkgTool.fxml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + +
+
+
diff --git a/assistTools/x-DecompilerWxApkgTool/src/main/resources/config/toolFxmlLoaderConfiguration.xml b/assistTools/x-DecompilerWxApkgTool/src/main/resources/config/toolFxmlLoaderConfiguration.xml new file mode 100644 index 00000000..df50bc60 --- /dev/null +++ b/assistTools/x-DecompilerWxApkgTool/src/main/resources/config/toolFxmlLoaderConfiguration.xml @@ -0,0 +1,14 @@ + + + + + /com/xwintop/xJavaFxTool/fxmlView/assistTools/DecompilerWxApkgTool.fxml + locale.DecompilerWxApkgTool + + Title + + + p-assistTools + Node + + \ No newline at end of file diff --git a/assistTools/x-DecompilerWxApkgTool/src/main/resources/locale/DecompilerWxApkgTool.properties b/assistTools/x-DecompilerWxApkgTool/src/main/resources/locale/DecompilerWxApkgTool.properties new file mode 100644 index 00000000..04d156b6 --- /dev/null +++ b/assistTools/x-DecompilerWxApkgTool/src/main/resources/locale/DecompilerWxApkgTool.properties @@ -0,0 +1,3 @@ +# 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=\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u53CD\u7F16\u8BD1\u5DE5\u5177 \ No newline at end of file diff --git a/assistTools/x-DecompilerWxApkgTool/src/main/resources/locale/DecompilerWxApkgTool_en_US.properties b/assistTools/x-DecompilerWxApkgTool/src/main/resources/locale/DecompilerWxApkgTool_en_US.properties new file mode 100644 index 00000000..e7ce9ae3 --- /dev/null +++ b/assistTools/x-DecompilerWxApkgTool/src/main/resources/locale/DecompilerWxApkgTool_en_US.properties @@ -0,0 +1,3 @@ +# 文件Dorian_en_US.properties,是美国地区的资源束 +# 它覆盖了默认资源束 +Title=DecompilerWxApkgTool \ No newline at end of file diff --git a/assistTools/x-IdiomDataTool/.gitignore b/assistTools/x-IdiomDataTool/.gitignore new file mode 100644 index 00000000..cc487de9 --- /dev/null +++ b/assistTools/x-IdiomDataTool/.gitignore @@ -0,0 +1,6 @@ +# Default ignored files +#/.gitignore +/x-IdiomDataTool.iml +/log/ +/target/ +.idea \ No newline at end of file diff --git a/assistTools/x-IdiomDataTool/LICENSE b/assistTools/x-IdiomDataTool/LICENSE new file mode 100644 index 00000000..9e32cdef --- /dev/null +++ b/assistTools/x-IdiomDataTool/LICENSE @@ -0,0 +1,127 @@ + 木兰宽松许可证, 第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. diff --git a/assistTools/x-IdiomDataTool/README.md b/assistTools/x-IdiomDataTool/README.md new file mode 100644 index 00000000..7f68f6c6 --- /dev/null +++ b/assistTools/x-IdiomDataTool/README.md @@ -0,0 +1,16 @@ +IdiomDataTool 成语字典工具 + +#### 项目简介: +IdiomDataTool是使用javafx开发的一款成语字典工具,使用[h2](http://www.h2database.com)数据库存储数据字典。 + +**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) \ No newline at end of file diff --git a/assistTools/x-IdiomDataTool/README_EN.md b/assistTools/x-IdiomDataTool/README_EN.md new file mode 100644 index 00000000..065a66d3 --- /dev/null +++ b/assistTools/x-IdiomDataTool/README_EN.md @@ -0,0 +1 @@ +IdiomDataTool \ No newline at end of file diff --git a/assistTools/x-IdiomDataTool/build.gradle b/assistTools/x-IdiomDataTool/build.gradle new file mode 100644 index 00000000..ed39d2ff --- /dev/null +++ b/assistTools/x-IdiomDataTool/build.gradle @@ -0,0 +1,15 @@ +dependencies { + api project(':xcore') + implementation 'org.springframework:spring-jdbc:5.1.5.RELEASE' + implementation 'com.h2database:h2:1.4.200' +} + +group = 'com.xwintop' +version = '0.0.1' +description = 'x-IdiomDataTool' +//打jar包需要包含依赖的配置 +jar { + from { configurations.compileClasspath.findAll { it.name.contains("spring-jdbc") + || it.name.contains("h2") + }.collect { zipTree(it) } } +} diff --git a/assistTools/x-IdiomDataTool/file/IdiomDirty.mv.db b/assistTools/x-IdiomDataTool/file/IdiomDirty.mv.db new file mode 100644 index 00000000..78f44b48 Binary files /dev/null and b/assistTools/x-IdiomDataTool/file/IdiomDirty.mv.db differ diff --git "a/assistTools/x-IdiomDataTool/images/\346\210\220\350\257\255\345\255\227\345\205\270\345\267\245\345\205\267.gif" "b/assistTools/x-IdiomDataTool/images/\346\210\220\350\257\255\345\255\227\345\205\270\345\267\245\345\205\267.gif" new file mode 100644 index 00000000..4b5b6bb3 Binary files /dev/null and "b/assistTools/x-IdiomDataTool/images/\346\210\220\350\257\255\345\255\227\345\205\270\345\267\245\345\205\267.gif" differ diff --git "a/assistTools/x-IdiomDataTool/images/\346\210\220\350\257\255\345\255\227\345\205\270\345\267\245\345\205\267.png" "b/assistTools/x-IdiomDataTool/images/\346\210\220\350\257\255\345\255\227\345\205\270\345\267\245\345\205\267.png" new file mode 100644 index 00000000..f264787c Binary files /dev/null and "b/assistTools/x-IdiomDataTool/images/\346\210\220\350\257\255\345\255\227\345\205\270\345\267\245\345\205\267.png" differ diff --git a/assistTools/x-IdiomDataTool/src/main/java/com/xwintop/xJavaFxTool/IdiomDataToolApplication.java b/assistTools/x-IdiomDataTool/src/main/java/com/xwintop/xJavaFxTool/IdiomDataToolApplication.java new file mode 100644 index 00000000..6e56012a --- /dev/null +++ b/assistTools/x-IdiomDataTool/src/main/java/com/xwintop/xJavaFxTool/IdiomDataToolApplication.java @@ -0,0 +1,43 @@ +package com.xwintop.xJavaFxTool; + +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.stage.Stage; +import javafx.stage.WindowEvent; +import lombok.extern.slf4j.Slf4j; + +import java.net.URL; +import java.util.ResourceBundle; + +@Slf4j +public class IdiomDataToolApplication extends Application { + @Override + public void start(Stage primaryStage) throws Exception { + FXMLLoader fXMLLoader = IdiomDataToolApplication.getFXMLLoader(); + ResourceBundle resourceBundle = fXMLLoader.getResources(); + Parent root = fXMLLoader.load(); + primaryStage.setResizable(true); + primaryStage.setTitle(resourceBundle.getString("Title")); +// primaryStage.getIcons().add(new Image("/images/icon.jpg")); + double[] screenSize = JavaFxSystemUtil.getScreenSizeByScale(0.74D, 0.8D); + primaryStage.setScene(new Scene(root, screenSize[0], screenSize[1])); + primaryStage.show(); + primaryStage.setOnCloseRequest(new EventHandler() { + @Override + public void handle(WindowEvent event) { + System.exit(0); + } + }); + } + + public static FXMLLoader getFXMLLoader() { + ResourceBundle resourceBundle = ResourceBundle.getBundle("locale.IdiomDataTool"); + URL url = IdiomDataToolApplication.class.getClassLoader().getResource("com/xwintop/xJavaFxTool/fxmlView/assistTools/IdiomDataTool.fxml"); + FXMLLoader fXMLLoader = new FXMLLoader(url, resourceBundle); + return fXMLLoader; + } +} \ No newline at end of file diff --git a/assistTools/x-IdiomDataTool/src/main/java/com/xwintop/xJavaFxTool/IdiomDataToolMain.java b/assistTools/x-IdiomDataTool/src/main/java/com/xwintop/xJavaFxTool/IdiomDataToolMain.java new file mode 100644 index 00000000..8af24568 --- /dev/null +++ b/assistTools/x-IdiomDataTool/src/main/java/com/xwintop/xJavaFxTool/IdiomDataToolMain.java @@ -0,0 +1,12 @@ +package com.xwintop.xJavaFxTool; + +import javafx.application.Application; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class IdiomDataToolMain { + public static void main(String[] args) { + Application.launch(IdiomDataToolApplication.class, args); + } + +} \ No newline at end of file diff --git a/assistTools/x-IdiomDataTool/src/main/java/com/xwintop/xJavaFxTool/controller/assistTools/IdiomDataToolController.java b/assistTools/x-IdiomDataTool/src/main/java/com/xwintop/xJavaFxTool/controller/assistTools/IdiomDataToolController.java new file mode 100644 index 00000000..4afd6bbb --- /dev/null +++ b/assistTools/x-IdiomDataTool/src/main/java/com/xwintop/xJavaFxTool/controller/assistTools/IdiomDataToolController.java @@ -0,0 +1,87 @@ +package com.xwintop.xJavaFxTool.controller.assistTools; + +import cn.hutool.core.map.MapUtil; +import com.xwintop.xJavaFxTool.services.assistTools.IdiomDataToolService; +import com.xwintop.xJavaFxTool.view.assistTools.IdiomDataToolView; +import com.xwintop.xcore.util.javafx.AlertUtil; +import com.xwintop.xcore.util.javafx.JavaFxViewUtil; +import com.xwintop.xcore.util.javafx.TooltipUtil; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.ActionEvent; +import javafx.event.Event; +import javafx.fxml.FXML; +import javafx.scene.input.MouseButton; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +import java.net.URL; +import java.util.Map; +import java.util.ResourceBundle; + +/** + * @ClassName: IdiomDataToolController + * @Description: 成语字典工具 + * @author: xufeng + * @date: 2019/11/10 0010 22:06 + */ + +@Getter +@Setter +@Slf4j +public class IdiomDataToolController extends IdiomDataToolView { + private IdiomDataToolService idiomDataToolService = new IdiomDataToolService(this); + private ObservableList> idiomDataTableData = FXCollections.observableArrayList(); + + @Override + public void initialize(URL location, ResourceBundle resources) { + initView(); + initEvent(); + initService(); + } + + private void initView() { + JavaFxViewUtil.setTableColumnMapValueFactory(wordTableColumn, "word"); + JavaFxViewUtil.setTableColumnMapValueFactory(pinyinTableColumn, "pinyin"); + JavaFxViewUtil.setTableColumnMapValueFactory(explanationTableColumn, "explanation"); + JavaFxViewUtil.setTableColumnMapValueFactory(derivationTableColumn, "derivation"); + JavaFxViewUtil.setTableColumnMapValueFactory(exampleTableColumn, "example"); + idiomDataTableView.setItems(idiomDataTableData); + } + + private void initEvent() { + idiomDataTableView.setOnMouseClicked(event -> { + if (event.getButton() == MouseButton.PRIMARY) { + Map map = idiomDataTableView.getSelectionModel().getSelectedItem(); + if (MapUtil.isNotEmpty(map)) { + String message = "发音:" + map.get("pinyin") + "\n\n释义:" + map.get("explanation") + "\n\n出处:" + map.get("derivation"); + AlertUtil.showInfoAlert(map.get("word"), message); + } + } + }); + } + + private void initService() { + idiomDataToolService.initIdiomData(); + } + + @FXML + private void selectAction() { + try { + idiomDataToolService.selectAction(); + } catch (Exception e) { + log.error("查询错误:", e); + TooltipUtil.showToast("查询发生错误:" + e.getMessage()); + } + } + + @FXML + private void clearAction(ActionEvent event) { + idiomDataToolService.clearAction(); + } + + public void onCloseRequest(Event event) throws Exception { + idiomDataToolService.destroy(); + } +} \ No newline at end of file diff --git a/assistTools/x-IdiomDataTool/src/main/java/com/xwintop/xJavaFxTool/services/assistTools/IdiomDataToolService.java b/assistTools/x-IdiomDataTool/src/main/java/com/xwintop/xJavaFxTool/services/assistTools/IdiomDataToolService.java new file mode 100644 index 00000000..4a9f2960 --- /dev/null +++ b/assistTools/x-IdiomDataTool/src/main/java/com/xwintop/xJavaFxTool/services/assistTools/IdiomDataToolService.java @@ -0,0 +1,130 @@ +package com.xwintop.xJavaFxTool.services.assistTools; + +import cn.hutool.http.HttpUtil; +import com.xwintop.xJavaFxTool.controller.assistTools.IdiomDataToolController; +import com.xwintop.xcore.util.ConfigureUtil; +import com.xwintop.xcore.util.javafx.TooltipUtil; +import javafx.application.Platform; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.h2.jdbcx.JdbcDataSource; +import org.springframework.jdbc.core.JdbcTemplate; + +import java.io.File; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @ClassName: IdiomDataToolService + * @Description: 成语字典工具 + * @author: xufeng + * @date: 2019/11/10 0010 22:06 + */ + +@Getter +@Setter +@Slf4j +public class IdiomDataToolService { + public static final String DICT_URL = "https://xwintop.gitee.io/x-idiomdatatool/file/IdiomDirty.mv.db"; + + public static final String LOCAL_DICT_FILE = "file/IdiomDirty.mv.db"; + + private IdiomDataToolController idiomDataToolController; + + private JdbcTemplate jdbcTemplate; + + public IdiomDataToolService(IdiomDataToolController idiomDataToolController) { + this.idiomDataToolController = idiomDataToolController; + } + + public void initIdiomData() { + Platform.runLater(() -> { + File localDictFile = ConfigureUtil.getConfigureFile(LOCAL_DICT_FILE); + try { + if (!localDictFile.exists()) { + TooltipUtil.showToast("第一次使用,需下载成语字典数据,请稍后..."); + FileUtils.touch(localDictFile); + HttpUtil.downloadFile(DICT_URL, localDictFile); + log.info("成语字典数据下载完成!"); + TooltipUtil.showToast("成语字典数据下载完成!"); + } + if (jdbcTemplate == null) { +// DruidDataSource dataSource = new DruidDataSource(); + JdbcDataSource dataSource = new JdbcDataSource(); + dataSource.setUrl("jdbc:h2:" + ConfigureUtil.getConfigurePath("file/IdiomDirty")); +// dataSource.setDriverClassName("org.h2.Driver"); +// dataSource.setTestWhileIdle(false); +// dataSource.init(); + dataSource.getConnection(); + jdbcTemplate = new JdbcTemplate(dataSource); + } + } catch (Exception e) { + localDictFile.delete(); + log.error("数据源初始化错误:", e); + } + }); + } + + public void selectAction() throws Exception { + String sql = "SELECT * FROM Idiom_dirty WHERE word like ? or abbreviation like ?"; + String sqlArgs = ""; + if (StringUtils.isEmpty(idiomDataToolController.getSelectWordTextField().getText())) { + String[] indexString = new String[]{ + idiomDataToolController.getIndex1TextField().getText(), + idiomDataToolController.getIndex2TextField().getText(), + idiomDataToolController.getIndex3TextField().getText(), + idiomDataToolController.getIndex4TextField().getText() + }; + for (int i = 0; i < 4; i++) { + if (StringUtils.isEmpty(indexString[i])) { + sqlArgs += "_"; + } else { + sqlArgs += indexString[i]; + } + } + + } else { + sqlArgs = "%" + idiomDataToolController.getSelectWordTextField().getText() + "%"; + } + List> list = new ArrayList<>(); + if (jdbcTemplate == null) { + TooltipUtil.showToast("成语词典数据未准备好,请稍后重试..."); + } else { + list = jdbcTemplate.queryForList(sql, sqlArgs, sqlArgs); + } + idiomDataToolController.getIdiomDataTableData().clear(); + for (Map stringObjectMap : list) { + Map dataRow = new HashMap(); + dataRow.put("word", stringObjectMap.get("word").toString()); + dataRow.put("pinyin", stringObjectMap.get("pinyin").toString()); + dataRow.put("explanation", stringObjectMap.get("explanation").toString()); + dataRow.put("derivation", stringObjectMap.get("derivation").toString()); + dataRow.put("example", stringObjectMap.get("example").toString()); + idiomDataToolController.getIdiomDataTableData().add(dataRow); + } + } + + public void clearAction() { + idiomDataToolController.getIndex1TextField().setText(null); + idiomDataToolController.getIndex2TextField().setText(null); + idiomDataToolController.getIndex3TextField().setText(null); + idiomDataToolController.getIndex4TextField().setText(null); + idiomDataToolController.getSelectWordTextField().setText(null); + } + + public void destroy() { + if (jdbcTemplate != null) { + try { + jdbcTemplate.getDataSource().getConnection().close(); + } catch (SQLException e) { + log.error("关闭数据源出错", e); + } + } + } +} diff --git a/assistTools/x-IdiomDataTool/src/main/java/com/xwintop/xJavaFxTool/view/assistTools/IdiomDataToolView.java b/assistTools/x-IdiomDataTool/src/main/java/com/xwintop/xJavaFxTool/view/assistTools/IdiomDataToolView.java new file mode 100644 index 00000000..6c556402 --- /dev/null +++ b/assistTools/x-IdiomDataTool/src/main/java/com/xwintop/xJavaFxTool/view/assistTools/IdiomDataToolView.java @@ -0,0 +1,51 @@ +package com.xwintop.xJavaFxTool.view.assistTools; + +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.Button; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.TextField; +import lombok.Getter; +import lombok.Setter; + +import java.util.Map; + +/** + * @ClassName: IdiomDataToolView + * @Description: 成语字典工具 + * @author: xufeng + * @date: 2019/11/10 0010 22:06 + */ + +@Getter +@Setter +public abstract class IdiomDataToolView implements Initializable { + @FXML + protected TextField index1TextField; + @FXML + protected TextField index2TextField; + @FXML + protected TextField index3TextField; + @FXML + protected TextField index4TextField; + @FXML + protected TextField selectWordTextField; + @FXML + protected Button selectButton; + @FXML + protected Button clearButton; + @FXML + protected TableView> idiomDataTableView; + @FXML + protected TableColumn, String> wordTableColumn; + @FXML + protected TableColumn, String> pinyinTableColumn; + @FXML + protected TableColumn, String> explanationTableColumn; + @FXML + protected TableColumn, String> derivationTableColumn; + @FXML + protected TableColumn, String> exampleTableColumn; + +} \ No newline at end of file diff --git a/assistTools/x-IdiomDataTool/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/assistTools/IdiomDataTool.fxml b/assistTools/x-IdiomDataTool/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/assistTools/IdiomDataTool.fxml new file mode 100644 index 00000000..a9b4ec4c --- /dev/null +++ b/assistTools/x-IdiomDataTool/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/assistTools/IdiomDataTool.fxml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
diff --git a/games/x-BullsAndCowsGame/src/main/resources/config/toolFxmlLoaderConfiguration.xml b/games/x-BullsAndCowsGame/src/main/resources/config/toolFxmlLoaderConfiguration.xml new file mode 100644 index 00000000..3fcbeee3 --- /dev/null +++ b/games/x-BullsAndCowsGame/src/main/resources/config/toolFxmlLoaderConfiguration.xml @@ -0,0 +1,14 @@ + + + + + /com/xwintop/xJavaFxTool/fxmlView/games/BullsAndCowsGame.fxml + locale.BullsAndCowsGame + + Title + + + p-games + Node + + \ No newline at end of file diff --git a/games/x-BullsAndCowsGame/src/main/resources/locale/BullsAndCowsGame.properties b/games/x-BullsAndCowsGame/src/main/resources/locale/BullsAndCowsGame.properties new file mode 100644 index 00000000..40803022 --- /dev/null +++ b/games/x-BullsAndCowsGame/src/main/resources/locale/BullsAndCowsGame.properties @@ -0,0 +1,3 @@ +# 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=\u731C\u6570\u5B57\u6E38\u620F \ No newline at end of file diff --git a/games/x-BullsAndCowsGame/src/main/resources/locale/BullsAndCowsGame_en_US.properties b/games/x-BullsAndCowsGame/src/main/resources/locale/BullsAndCowsGame_en_US.properties new file mode 100644 index 00000000..d09562b1 --- /dev/null +++ b/games/x-BullsAndCowsGame/src/main/resources/locale/BullsAndCowsGame_en_US.properties @@ -0,0 +1,3 @@ +# 文件Dorian_en_US.properties,是美国地区的资源束 +# 它覆盖了默认资源束 +Title=BullsAndCowsGame \ No newline at end of file diff --git a/games/x-ChineseChess/.gitignore b/games/x-ChineseChess/.gitignore new file mode 100644 index 00000000..58569db8 --- /dev/null +++ b/games/x-ChineseChess/.gitignore @@ -0,0 +1,6 @@ +# Default ignored files +#/.gitignore +/x-ChineseChess.iml +/log/ +/target/ +.idea \ No newline at end of file diff --git a/games/x-ChineseChess/LICENSE b/games/x-ChineseChess/LICENSE new file mode 100644 index 00000000..9e32cdef --- /dev/null +++ b/games/x-ChineseChess/LICENSE @@ -0,0 +1,127 @@ + 木兰宽松许可证, 第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. diff --git a/games/x-ChineseChess/README.md b/games/x-ChineseChess/README.md new file mode 100644 index 00000000..a771698c --- /dev/null +++ b/games/x-ChineseChess/README.md @@ -0,0 +1,16 @@ +ChineseChess 中国象棋小游戏 + +#### 项目简介: + +使用javafx开发的中国象棋小游戏 + +![中国象棋.png](images/中国象棋.png) + +**xJavaFxTool交流QQ群:== [387473650](https://jq.qq.com/?_wv=1027&k=59UDEAD) ==** + +#### 环境搭建说明: +- 开发环境为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) \ No newline at end of file diff --git a/games/x-ChineseChess/README_EN.md b/games/x-ChineseChess/README_EN.md new file mode 100644 index 00000000..81182370 --- /dev/null +++ b/games/x-ChineseChess/README_EN.md @@ -0,0 +1 @@ +ChineseChess \ No newline at end of file diff --git a/games/x-ChineseChess/build.gradle b/games/x-ChineseChess/build.gradle new file mode 100644 index 00000000..3e648db5 --- /dev/null +++ b/games/x-ChineseChess/build.gradle @@ -0,0 +1,7 @@ +dependencies { + api project(':xcore') +} + +group = 'com.xwintop' +version = '0.0.1' +description = 'x-ChineseChess' diff --git "a/games/x-ChineseChess/images/\344\270\255\345\233\275\350\261\241\346\243\213.png" "b/games/x-ChineseChess/images/\344\270\255\345\233\275\350\261\241\346\243\213.png" new file mode 100644 index 00000000..3fe93cba Binary files /dev/null and "b/games/x-ChineseChess/images/\344\270\255\345\233\275\350\261\241\346\243\213.png" differ diff --git a/games/x-ChineseChess/src/main/java/com/xwintop/xJavaFxTool/ChineseChessMain.java b/games/x-ChineseChess/src/main/java/com/xwintop/xJavaFxTool/ChineseChessMain.java new file mode 100644 index 00000000..29bcd18b --- /dev/null +++ b/games/x-ChineseChess/src/main/java/com/xwintop/xJavaFxTool/ChineseChessMain.java @@ -0,0 +1,52 @@ +package com.xwintop.xJavaFxTool; + +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; + +import java.net.URL; +import java.util.ResourceBundle; + +@Slf4j +public class ChineseChessMain extends Application { + public static void main(String[] args) { + try { + launch(args); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void start(Stage primaryStage) throws Exception { + FXMLLoader fXMLLoader = ChineseChessMain.getFXMLLoader(); + ResourceBundle resourceBundle = fXMLLoader.getResources(); + Parent root = fXMLLoader.load(); + primaryStage.setResizable(true); + primaryStage.setTitle(resourceBundle.getString("Title")); + primaryStage.getIcons().add(new Image("/images/ChineseChessIcon.png")); +// double[] screenSize = JavaFxSystemUtil.getScreenSizeByScale(0.74, 0.8); + primaryStage.setScene(new Scene(root, 500, 660)); + primaryStage.show(); + primaryStage.setOnCloseRequest(new EventHandler() { + @Override + public void handle(WindowEvent event) { + System.exit(0); + } + }); + } + + public static FXMLLoader getFXMLLoader() { + ResourceBundle resourceBundle = ResourceBundle.getBundle("locale.ChineseChess"); + URL url = Object.class.getResource("/com/xwintop/xJavaFxTool/fxmlView/games/ChineseChess.fxml"); + FXMLLoader fXMLLoader = new FXMLLoader(url, resourceBundle); + return fXMLLoader; + } +} \ No newline at end of file diff --git a/games/x-ChineseChess/src/main/java/com/xwintop/xJavaFxTool/controller/games/ChineseChessController.java b/games/x-ChineseChess/src/main/java/com/xwintop/xJavaFxTool/controller/games/ChineseChessController.java new file mode 100644 index 00000000..aba88667 --- /dev/null +++ b/games/x-ChineseChess/src/main/java/com/xwintop/xJavaFxTool/controller/games/ChineseChessController.java @@ -0,0 +1,63 @@ +package com.xwintop.xJavaFxTool.controller.games; + +import com.xwintop.xJavaFxTool.view.games.ChineseChessView; +import com.xwintop.xJavaFxTool.services.games.ChineseChessService; +import javafx.scene.input.MouseEvent; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +import java.net.URL; +import java.util.ResourceBundle; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; + +@Getter +@Setter +@Slf4j +public class ChineseChessController extends ChineseChessView { + private ChineseChessService chineseChessService = new ChineseChessService(this); + + @Override + public void initialize(URL location, ResourceBundle resources) { + initView(); + initEvent(); + initService(); + } + + private void initView() { + chineseChessService.initialize(); + } + + private void initEvent() { + } + + private void initService() { + } + + @FXML + private void StartButtonOnAction(ActionEvent event) { + chineseChessService.StartButtonOnAction(); + } + + @FXML + private void restartButtonOnAction(ActionEvent event) {//重新开始按钮的响应函数 + chineseChessService.initialize(); + } + + @FXML + private void showRecordButtonOnAction(ActionEvent event) { + chineseChessService.showRecordButtonOnAction(); + } + + @FXML + private void saveRecordButtonOnAction(ActionEvent event) throws Exception { + chineseChessService.saveRecordButtonOnAction(); + } + + @FXML + private void checkerBoardOnPressed(MouseEvent e) { //画布的鼠标点击响应函数 + chineseChessService.checkerBoardOnPressed(e); + } +} \ No newline at end of file diff --git a/games/x-ChineseChess/src/main/java/com/xwintop/xJavaFxTool/services/games/CheckerBoard.java b/games/x-ChineseChess/src/main/java/com/xwintop/xJavaFxTool/services/games/CheckerBoard.java new file mode 100644 index 00000000..d842b611 --- /dev/null +++ b/games/x-ChineseChess/src/main/java/com/xwintop/xJavaFxTool/services/games/CheckerBoard.java @@ -0,0 +1,32 @@ +package com.xwintop.xJavaFxTool.services.games; + +class CheckerBoard { + //棋盘的一些常量 + static final int UNIT = 55;//一个棋格大小 + static final int LEFT_X = 30;//距左边界 + static final int RIGHT_X = LEFT_X + 8 * UNIT;//距右边界 + static final int TOP_Y = 30;//距上边界 + static final int BOTTOM_Y = TOP_Y + 9 * UNIT;//距下边界 + + //将棋盘上的坐标转化为像素值 + static double xToPx(int x) { + return LEFT_X + x * UNIT; + } + + static double yToPx(int y) { + return TOP_Y + y * UNIT; + } + + //将像素值转化为最近的坐标值 + static int pxToX(double x_Px) { + Double t = (x_Px - LEFT_X) / UNIT; + long ans = Math.round(t); + return (int) ans; + } + + static int pxToY(double y_Px) { + Double t = (y_Px - TOP_Y) / UNIT; + long ans = Math.round(t); + return (int) ans; + } +} diff --git a/games/x-ChineseChess/src/main/java/com/xwintop/xJavaFxTool/services/games/ChineseChessService.java b/games/x-ChineseChess/src/main/java/com/xwintop/xJavaFxTool/services/games/ChineseChessService.java new file mode 100644 index 00000000..2d92d999 --- /dev/null +++ b/games/x-ChineseChess/src/main/java/com/xwintop/xJavaFxTool/services/games/ChineseChessService.java @@ -0,0 +1,316 @@ +package com.xwintop.xJavaFxTool.services.games; + +import com.xwintop.xJavaFxTool.controller.games.ChineseChessController; +import javafx.scene.control.Alert; +import javafx.scene.input.MouseButton; +import javafx.scene.input.MouseEvent; +import javafx.scene.media.AudioClip; +import javafx.scene.shape.Line; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; + +@Getter +@Setter +@Slf4j +public class ChineseChessService { + private ChineseChessController chineseChessController; + + static Piece[][] points; + static boolean isRedTurn = true;//黑红双方轮流下棋 + static Piece selectedPiece = null;//记录当前选中的棋子名称 + static ArrayList allPieces = new ArrayList<>(); + private String record;//棋谱 + + public void initialize() { + chineseChessController.getCheckerBoard().getChildren().removeAll(); + allPieces.clear(); + record = ""; + chineseChessController.getCheckerBoard().getChildren().clear(); + for (Piece[] pieces : points = new Piece[9][10]) { + pieces = null; + } + isRedTurn = true; + selectedPiece = null; + drawLines(); + initPutPieces(); + StartButtonOnAction(); + }//初始化 + + private String printRecord(int startX, int startY, int dstX, int dstY) //棋谱记录 + { + String step = selectedPiece.name; + String start; + start = getRoad(startX); + + String action, dst; + if (startY == dstY) { + action = "平"; + dst = getRoad(dstX); + } else { + if (selectedPiece.isRed) + dst = getChineseNumber(Math.abs(startY - dstY)); + else + dst = Integer.toString(Math.abs(startY - dstY)); + if ((selectedPiece.isRed && dstY < startY) || (!selectedPiece.isRed && dstY > startY)) { + action = "进"; + } else action = "退"; + + } + return step + start + action + dst; + } + + String getChineseNumber(int x) //棋谱记录 + { + String ret = null; + switch (x) { + case 1: + ret = "一"; + break; + case 2: + ret = "二"; + break; + case 3: + ret = "三"; + break; + case 4: + ret = "四"; + break; + case 5: + ret = "五"; + break; + case 6: + ret = "六"; + break; + case 7: + ret = "七"; + break; + case 8: + ret = "八"; + break; + case 9: + ret = "九"; + break; + default: + } + return ret; + } + + private static String getRoad(int x) //棋谱记录 + { + String road = null; + if (selectedPiece.isRed) { + switch (x) { + case 8: + road = "一"; + break; + case 7: + road = "二"; + break; + case 6: + road = "三"; + break; + case 5: + road = "四"; + break; + case 4: + road = "五"; + break; + case 3: + road = "六"; + break; + case 2: + road = "七"; + break; + case 1: + road = "八"; + break; + case 0: + road = "九"; + break; + default: + } + } else { + road = Integer.toString(x + 1); + } + return road; + } + + private void initPutPieces() //初始化摆放棋子 + { + //将 + Jiang redShuai = new Jiang(4, 9, true); + Jiang blackJiang = new Jiang(4, 0, false); + //马 + Ma redMa1 = new Ma(1, 9, true); + Ma redMa2 = new Ma(7, 9, true); + Ma blackMa1 = new Ma(1, 0, false); + Ma blackMa2 = new Ma(7, 0, false); + //象 + Xiang redXiang1 = new Xiang(2, 9, true); + Xiang redXiang2 = new Xiang(6, 9, true); + Xiang blackXiang1 = new Xiang(2, 0, false); + Xiang blackXiang2 = new Xiang(6, 0, false); + //炮 + Pao redPao1 = new Pao(1, 7, true); + Pao redPao2 = new Pao(7, 7, true); + Pao blackPao1 = new Pao(1, 2, false); + Pao blackPao2 = new Pao(7, 2, false); + //兵 + Bing redbing1 = new Bing(0, 6, true); + Bing redbing2 = new Bing(2, 6, true); + Bing redbing3 = new Bing(4, 6, true); + Bing redbing4 = new Bing(6, 6, true); + Bing redbing5 = new Bing(8, 6, true); + Bing blackbing1 = new Bing(0, 3, false); + Bing blackbing2 = new Bing(2, 3, false); + Bing blackbing3 = new Bing(4, 3, false); + Bing blackbing4 = new Bing(6, 3, false); + Bing blackbing5 = new Bing(8, 3, false); + //车 + Ju redJu1 = new Ju(0, 9, true); + Ju redJu2 = new Ju(8, 9, true); + Ju blackJu1 = new Ju(0, 0, false); + Ju blackJu2 = new Ju(8, 0, false); + //士 + Shi redShi1 = new Shi(3, 9, true); + Shi redShi2 = new Shi(5, 9, true); + Shi blackShi1 = new Shi(3, 0, false); + Shi blackShi2 = new Shi(5, 0, false); + chineseChessController.getCheckerBoard().getChildren().addAll(allPieces); + } + + private void drawLines() //绘制棋盘线 + { + final int UNIT = CheckerBoard.UNIT; + final int RIGHT_X = CheckerBoard.RIGHT_X; + final int LEFT_X = CheckerBoard.LEFT_X; + final int TOP_Y = CheckerBoard.TOP_Y; + final int BOTTOM_Y = CheckerBoard.BOTTOM_Y; + for (int i = TOP_Y; i <= BOTTOM_Y; i += UNIT) { + Line newLine = new Line(); + newLine.setStartX(LEFT_X); + newLine.setStartY(i); + newLine.setEndX(RIGHT_X); + newLine.setEndY(i); + chineseChessController.getCheckerBoard().getChildren().add(newLine); + } + + for (int i = LEFT_X; i <= RIGHT_X; i += UNIT) { + Line newtopLine = new Line(); + newtopLine.setStartY(TOP_Y); + newtopLine.setStartX(i); + newtopLine.setEndY(TOP_Y + 4 * UNIT); + newtopLine.setEndX(i); + Line newbottomLine = new Line(); + newbottomLine.setStartY(TOP_Y + 5 * UNIT); + newbottomLine.setStartX(i); + newbottomLine.setEndY(BOTTOM_Y); + newbottomLine.setEndX(i); + chineseChessController.getCheckerBoard().getChildren().addAll(newtopLine, newbottomLine); + } + Line line = new Line(LEFT_X, TOP_Y + 4 * UNIT, LEFT_X, TOP_Y + 5 * UNIT); + chineseChessController.getCheckerBoard().getChildren().add(line); + line = new Line(RIGHT_X, TOP_Y + 4 * UNIT, RIGHT_X, TOP_Y + 5 * UNIT); + chineseChessController.getCheckerBoard().getChildren().add(line); + + Line crossLine1 = new Line(LEFT_X + 3 * UNIT, TOP_Y, LEFT_X + 5 * UNIT, TOP_Y + 2 * UNIT); + Line crossLine2 = new Line(LEFT_X + 3 * UNIT, TOP_Y + 2 * UNIT, LEFT_X + 5 * UNIT, TOP_Y); + chineseChessController.getCheckerBoard().getChildren().addAll(crossLine1, crossLine2); + crossLine1 = new Line(LEFT_X + 3 * UNIT, BOTTOM_Y, LEFT_X + 5 * UNIT, BOTTOM_Y - 2 * UNIT); + crossLine2 = new Line(LEFT_X + 3 * UNIT, BOTTOM_Y - 2 * UNIT, LEFT_X + 5 * UNIT, BOTTOM_Y); + chineseChessController.getCheckerBoard().getChildren().addAll(crossLine1, crossLine2); + } + + public void checkerBoardOnPressed(MouseEvent e) //画布的鼠标点击响应函数 + { + if (selectedPiece != null) { + if (e.getButton().equals(MouseButton.SECONDARY)) { //右键取消选中 + selectedPiece.cancelSelected(); + return; + } + int startX = selectedPiece.x; + int startY = selectedPiece.y; + int targetX = CheckerBoard.pxToX(e.getX()); + int targetY = CheckerBoard.pxToY(e.getY()); //计算目标像素值 + if (selectedPiece.isRed == isRedTurn) { + try { + selectedPiece.moveTo(targetX, targetY); + record = record + printRecord(startX, startY, targetX, targetY) + "\t"; + if (!isRedTurn) + record = record + "\n"; + isRedTurn = !isRedTurn; //回合交替 + selectedPiece.cancelSelected(); //移动后取消选定 + playMusic1(); + } catch (Piece.CanNotMoveToException ex) { + //if() + // playMusic2(); + //selectedPiece.cancelSelected();//否则无法选中 执行完moveto后直接抛出异常cancel掉 + //if() + } + } else { + playMusic2(); + selectedPiece.cancelSelected(); + } + } + } + + static void playMusic1() {// 背景音乐播放 + try { + AudioClip ac = new AudioClip(Object.class.getResource("/chessAudio/setpiece.wav").toString()); + ac.play(1.0); + } catch (Exception e) { + e.printStackTrace(); + } + } + + static void playMusic2() {// 背景音乐播放 + try { + AudioClip ac = new AudioClip(Object.class.getResource("/chessAudio/can'tmove.wav").toString()); + ac.play(1.0); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void saveRecordButtonOnAction() throws IOException //保存棋谱的响应函数 + { + Date date = new Date(); + SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd-hh-mm"); + File file = new File(ft.format(date) + ".txt"); + synchronized (file) { + FileWriter fw = new FileWriter(file.getName()); + fw.write(record); + fw.close(); + } + + } + + public void showRecordButtonOnAction() //显示棋谱的响应函数 + { + Alert rec = new Alert(Alert.AlertType.INFORMATION); + rec.setTitle("棋谱"); + rec.setGraphic(null); + rec.setHeaderText(null); + rec.setContentText(record); + rec.show(); + } + + public void StartButtonOnAction() //开始游戏 + { + for (Piece i : allPieces) { + i.setVisible(true); + } + } + + public ChineseChessService(ChineseChessController chineseChessController) { + this.chineseChessController = chineseChessController; + } +} \ No newline at end of file diff --git a/games/x-ChineseChess/src/main/java/com/xwintop/xJavaFxTool/services/games/Piece.java b/games/x-ChineseChess/src/main/java/com/xwintop/xJavaFxTool/services/games/Piece.java new file mode 100644 index 00000000..c9548c5c --- /dev/null +++ b/games/x-ChineseChess/src/main/java/com/xwintop/xJavaFxTool/services/games/Piece.java @@ -0,0 +1,629 @@ +package com.xwintop.xJavaFxTool.services.games; + +import javafx.scene.control.Alert; +import javafx.scene.image.Image; +import javafx.scene.paint.ImagePattern; +import javafx.scene.shape.Rectangle; + +abstract class Piece extends Rectangle { + Piece(int x, int y, boolean colorIsRed) { + setWidth(4.0 * CheckerBoard.UNIT / 5.0); + setHeight(4.0 * CheckerBoard.UNIT / 5.0); + this.x = x; + this.y = y; + isRed = colorIsRed; + setX(CheckerBoard.xToPx(x) - getWidth() / 2); + setY(CheckerBoard.yToPx(y) - getHeight() / 2); + ChineseChessService.points[x][y] = this; + ChineseChessService.allPieces.add(this); + setVisible(false); + } //所有棋子构造时都应调用父类的这个构造函数 + + int x; + int y; //x,y都是棋盘上的坐标 + boolean isRed; //true为红色 + boolean isSelected = false; + String name; + + protected void die() { + ChineseChessService.points[x][y] = null; + setVisible(false); + setDisable(true); + } + + protected abstract void moveTo(int dstX, int dstY) throws CanNotMoveToException; + + protected abstract void loadImage(); + + void beSelected() { + isSelected = true; + ChineseChessService.selectedPiece = this; + loadImage(); + } + + void cancelSelected() { + isSelected = false; + ChineseChessService.selectedPiece = null; + loadImage(); + } + + static class CanNotMoveToException extends Exception { + } +} + +class Jiang extends Piece { + + + Jiang(int x, int y, boolean colorIsRed) { + super(x, y, colorIsRed); //构造 + if (colorIsRed) { + name = "帅"; + } else { + name = "将"; + } + + loadImage(); //加载图片 + setOnMousePressed(e -> { //被点击的事件处理 + if (ChineseChessService.selectedPiece == null) { + beSelected(); + this.getParent().requestFocus(); + } + }); + } + + @Override + protected void die() { + super.die(); + String winner; + if (this.isRed) + winner = "黑"; + else + winner = "红"; + Alert gameOverAlert = new Alert(Alert.AlertType.CONFIRMATION); + gameOverAlert.setTitle("游戏结束"); + gameOverAlert.setHeaderText(null); + gameOverAlert.setContentText(winner + "方获胜"); + gameOverAlert.setGraphic(null); + gameOverAlert.showAndWait(); + } + + @Override + protected void moveTo(int dstX, int dstY) throws CanNotMoveToException { + //移动到目标点 + if (Math.abs(dstX - x) + Math.abs(dstY - y) != 1) + throw new CanNotMoveToException(); + if (dstX < 3 || dstX > 5) + throw new CanNotMoveToException(); + if (isRed && dstY < 7) + throw new CanNotMoveToException(); + if (!isRed && dstY > 2) + throw new CanNotMoveToException(); //判断能否移动,不能则抛出异常 + if (ChineseChessService.points[dstX][dstY] != null) { //目标点是否有棋子 + if (ChineseChessService.points[dstX][dstY].isRed == this.isRed) + throw new CanNotMoveToException(); + ChineseChessService.points[x][y].die(); //目标棋子死亡 + } + + + ChineseChessService.points[x][y] = null; + ChineseChessService.points[dstX][dstY] = this; + x = dstX; + y = dstY; + //目标点变成当前棋子 + this.setX(CheckerBoard.xToPx(dstX) - getWidth() / 2); + this.setY(CheckerBoard.yToPx(dstY) - getHeight() / 2); + } + + @Override + protected void loadImage() { + Image image; + if (!isSelected) { + if (isRed) + image = new Image("chessImages/RK.GIF"); + else + image = new Image("chessImages/BK.GIF"); + } else { + if (isRed) + image = new Image("chessImages/RKS.GIF"); + else + image = new Image("chessImages/BKS.GIF"); + } + setFill(new ImagePattern(image)); + } //加载正确的图片 + +} + +class Shi extends Piece { + Shi(int x, int y, boolean colorIsRed) { + super(x, y, colorIsRed); + if (colorIsRed) { + name = "仕"; + } else { + name = "士"; + } + loadImage(); + setOnMousePressed(e -> { + if (ChineseChessService.selectedPiece == null) { + beSelected(); + this.getParent().requestFocus(); + } + }); + } + + @Override + protected void die() { + super.die(); + } + + @Override + protected void moveTo(int dstX, int dstY) throws CanNotMoveToException { + if (Math.abs(dstX - x) + Math.abs(dstY - y) != 2) + throw new CanNotMoveToException(); + if (dstX < 3 || dstX > 5) + throw new CanNotMoveToException(); + if (isRed && dstY < 7) + throw new CanNotMoveToException(); + if (!isRed && dstY > 2) + throw new CanNotMoveToException(); + if (ChineseChessService.points[dstX][dstY] != null) { + if (ChineseChessService.points[dstX][dstY].isRed == this.isRed) + throw new CanNotMoveToException(); + ChineseChessService.points[dstX][dstY].die(); + } + ChineseChessService.points[x][y] = null; + ChineseChessService.points[dstX][dstY] = this; + x = dstX; + y = dstY; + this.setX(CheckerBoard.xToPx(dstX) - getWidth() / 2); + this.setY(CheckerBoard.yToPx(dstY) - getHeight() / 2); + } + + @Override + protected void loadImage() { + Image image; + if (!isSelected) { + if (isRed) + image = new Image("chessImages/RA.GIF"); + else + image = new Image("chessImages/BA.GIF"); + } else { + if (isRed) + image = new Image("chessImages/RAS.GIF"); + else + image = new Image("chessImages/BAS.GIF"); + } + setFill(new ImagePattern(image)); + } +} + +class Xiang extends Piece { + Xiang(int x, int y, boolean colorIsRed) { + super(x, y, colorIsRed); + if (colorIsRed) { + name = "相"; + } else { + name = "象"; + } + loadImage(); + setOnMousePressed(e -> { + if (ChineseChessService.selectedPiece == null) { + beSelected(); + this.getParent().requestFocus(); + } + }); + } + + @Override + protected void moveTo(int dstX, int dstY) throws CanNotMoveToException { + int midx = (dstX + x) / 2; + int midy = (dstY + y) / 2; + if (dstX < 0 || dstX > 8 || dstY < 0 || dstY > 9)//越界 + { + throw new CanNotMoveToException(); + } else if (ChineseChessService.points[dstX][dstY] != null && ChineseChessService.points[dstX][dstY].isRed == isRed)//同色 + { + throw new CanNotMoveToException(); + }//符合要求 + else if ((Math.abs(dstX - x) == 2) && (Math.abs(dstY - y) == 2) && (ChineseChessService.points[midx][midy] == null) + && ((isRed && dstY >= 5) || (!isRed && dstY <= 4))) { + if (ChineseChessService.points[dstX][dstY] != null) { + ChineseChessService.points[dstX][dstY].die(); + } + ChineseChessService.points[x][y] = null; + ChineseChessService.points[dstX][dstY] = this; + x = dstX; + y = dstY; + this.setX(CheckerBoard.xToPx(dstX) - getWidth() / 2); + this.setY(CheckerBoard.yToPx(dstY) - getHeight() / 2); + }//不符合要求 + else { + throw new CanNotMoveToException(); + } + } + + @Override + protected void loadImage() { + Image image; + if (!isSelected) { + if (isRed) + image = new Image("chessImages/RB.GIF"); + else + image = new Image("chessImages/BB.GIF"); + } else { + if (isRed) + image = new Image("chessImages/RBS.GIF"); + else + image = new Image("chessImages/BBS.GIF"); + } + setFill(new ImagePattern(image)); + } +} + +class Ma extends Piece { + Ma(int x, int y, boolean colorIsRed) { + super(x, y, colorIsRed); + name = "马"; + loadImage(); + setOnMousePressed(e -> { + if (ChineseChessService.selectedPiece == null) { + beSelected(); + this.getParent().requestFocus(); + } + }); + } + + @Override + protected void die() { + super.die(); + } + + @Override + protected void moveTo(int dstX, int dstY) throws CanNotMoveToException { + + boolean ans = false; + if (dstX < 0 || dstX > 8 || dstY < 0 || dstY > 9) { + throw new CanNotMoveToException(); + } else if (ChineseChessService.points[dstX][dstY] != null && ChineseChessService.points[dstX][dstY].isRed == isRed) { + throw new CanNotMoveToException(); + } else if (((Math.abs(dstX - x) == 2 && Math.abs(dstY - y) == 1) || + (Math.abs(dstX - x) == 1 && Math.abs(dstY - y) == 2))) { + if (Math.abs(dstX - x) == 2 && Math.abs(dstY - y) == 1) { + if (dstX > x && ChineseChessService.points[x + 1][y] == null) { + ans = true; + } else if (dstX < x && ChineseChessService.points[x - 1][y] == null) { + ans = true; + } + } else { + + if (dstY > y && ChineseChessService.points[x][y + 1] == null) { + ans = true; + } else if (dstY < y && ChineseChessService.points[x][y - 1] == null) { + ans = true; + } + } + } + if (ans) { + if (ChineseChessService.points[dstX][dstY] != null) { + ChineseChessService.points[dstX][dstY].die(); + } + ChineseChessService.points[x][y] = null; + ChineseChessService.points[dstX][dstY] = this; + x = dstX; + y = dstY; + this.setX(CheckerBoard.xToPx(dstX) - getWidth() / 2); + this.setY(CheckerBoard.yToPx(dstY) - getHeight() / 2); + } + if (!ans) { + throw new CanNotMoveToException(); + } + } + + @Override + protected void loadImage() { + Image image; + if (!isSelected) { + if (isRed) + image = new Image("chessImages/RN.GIF"); + else + image = new Image("chessImages/BN.GIF"); + } else { + if (isRed) + image = new Image("chessImages/RNS.GIF"); + else + image = new Image("chessImages/BNS.GIF"); + } + setFill(new ImagePattern(image)); + } +} + +class Ju extends Piece { + Ju(int x, int y, boolean colorIsRed) { + super(x, y, colorIsRed); + name = "车"; + loadImage(); + setOnMousePressed(e -> { + if (ChineseChessService.selectedPiece == null) { + beSelected(); + this.getParent().requestFocus(); + } + }); + } + + @Override + protected void die() { + super.die(); + } + + @Override + protected void moveTo(int dstX, int dstY) throws CanNotMoveToException { + int count = 0; + //没有移动 + if (dstX == this.x && dstY == this.y) + count = 1; + //对角线移动 + if (dstX != this.x && dstY != this.y) + count = 1; + //判断中间有子。情况一 + if (dstX > this.x && dstY == this.y) { + for (int temp = this.x + 1; temp < dstX; temp++) { + if (ChineseChessService.points[temp][y] != null) + count = 1; + } + } + //情况二 + if (dstX < this.x && dstY != this.y) { + for (int temp = this.x - 1; temp > dstX; temp--) { + if (ChineseChessService.points[temp][y] != null) + count = 1; + } + } + //情况三 + if (dstX == this.x && dstY > this.y) { + for (int temp = this.y + 1; temp < dstY; temp++) { + if (ChineseChessService.points[x][temp] != null) + count = 1; + } + } + //情况四 + if (dstX == this.x && dstY < this.y) { + for (int temp = this.y - 1; temp > dstY; temp--) { + if (ChineseChessService.points[x][temp] != null) + count = 1; + } + } + //count==0,可以移动,且目标点不为己方子 + if (count == 0 && ChineseChessService.points[dstX][dstY] != null && ChineseChessService.points[dstX][dstY].isRed != this.isRed) { + ChineseChessService.points[dstX][dstY].die(); + ChineseChessService.points[x][y] = null; + ChineseChessService.points[dstX][dstY] = this; + x = dstX; + y = dstY; + this.setX(CheckerBoard.xToPx(dstX) - getWidth() / 2); + this.setY(CheckerBoard.yToPx(dstY) - getHeight() / 2); + } else if (count == 0 && ChineseChessService.points[dstX][dstY] == null) { + ChineseChessService.points[x][y] = null; + ChineseChessService.points[dstX][dstY] = this; + x = dstX; + y = dstY; + this.setX(CheckerBoard.xToPx(dstX) - getWidth() / 2); + this.setY(CheckerBoard.yToPx(dstY) - getHeight() / 2); + } else + throw new CanNotMoveToException(); + + } + + + @Override + protected void loadImage() { + Image image; + if (!isSelected) { + if (isRed) + image = new Image("chessImages/RR.GIF"); + else + image = new Image("chessImages/BR.GIF"); + } else { + if (isRed) + image = new Image("chessImages/RRS.GIF"); + else + image = new Image("chessImages/BRS.GIF"); + } + setFill(new ImagePattern(image)); + } +} + +class Pao extends Piece { + Pao(int x, int y, boolean colorIsRed) { + super(x, y, colorIsRed); //构造 + name = "炮"; + loadImage(); //加载图片 + setOnMousePressed(e -> { //被点击的事件处理 + if (ChineseChessService.selectedPiece == null) { + beSelected(); + this.getParent().requestFocus(); + } + }); + } + + @Override + protected void die() { + super.die(); + } + + @Override + protected void moveTo(int dstX, int dstY) throws CanNotMoveToException { + int count = 0;//记录两点之间棋子个数 + //下列为6种情况 + if (dstX == this.x && dstY == this.y) + throw new CanNotMoveToException(); + if (dstX != this.x && dstY != this.y) + throw new CanNotMoveToException(); + if (dstX == this.x && dstY > this.y) { + for (int tem = this.y + 1; tem < dstY; tem++) { + if (ChineseChessService.points[x][tem] != null) { + count++; + } + } + } + if (dstX == this.x && dstY < this.y) { + for (int tem = dstY + 1; tem < this.y; tem++) { + if (ChineseChessService.points[x][tem] != null) { + count++; + } + } + } + if (dstY == this.y && dstX > this.x) { + for (int tem = this.x + 1; tem < dstX; tem++) { + if (ChineseChessService.points[tem][y] != null) { + count++; + } + } + + } + if (dstY == this.y && dstX < this.x) { + for (int tem = dstX + 1; tem < this.x; tem++) { + if (ChineseChessService.points[tem][y] != null) { + count++; + } + } + } + if (ChineseChessService.points[dstX][dstY] == null) {//目的地是否有棋子以及是否为己方棋子 + if (count != 0) + throw new CanNotMoveToException(); + } else { + if (count != 1 || ChineseChessService.points[dstX][dstY].isRed == this.isRed) + throw new CanNotMoveToException(); + else + ChineseChessService.points[dstX][dstY].die(); + } + count = 0; + ChineseChessService.points[x][y] = null; + ChineseChessService.points[dstX][dstY] = this; + x = dstX; + y = dstY; + this.setX(CheckerBoard.xToPx(dstX) - getWidth() / 2); + this.setY(CheckerBoard.yToPx(dstY) - getHeight() / 2); + } + + @Override + protected void loadImage() { + Image image; + if (!isSelected) { + if (isRed) + image = new Image("chessImages/RC.GIF"); + else + image = new Image("chessImages/BC.GIF"); + } else { + if (isRed) + image = new Image("chessImages/RCS.GIF"); + else + image = new Image("chessImages/BCS.GIF"); + } + setFill(new ImagePattern(image)); + } //加载正确的图片 +} + + +class Bing extends Piece { + Bing(int x, int y, boolean colorIsRed) { + super(x, y, colorIsRed); //构造 + if (colorIsRed) { + name = "兵"; + } else { + name = "卒"; + } + loadImage(); //加载图片 + setOnMousePressed(e -> { //被点击的事件处理 + if (ChineseChessService.selectedPiece == null) { + beSelected(); + this.getParent().requestFocus(); + } + }); + } + + @Override + protected void die() { + super.die(); + } + + @Override + protected void moveTo(int dstX, int dstY) throws CanNotMoveToException { + if (this.isRed) {//红兵 + if (this.y >= 5) {//没过河 + if (dstX != this.x) + throw new CanNotMoveToException(); + else if (dstY != this.y - 1) + throw new CanNotMoveToException(); + if (ChineseChessService.points[dstX][dstY] != null) { + if (ChineseChessService.points[dstX][dstY].isRed == this.isRed) + throw new CanNotMoveToException(); + else + ChineseChessService.points[dstX][dstY].die(); + } + } else {//过了河 + if (Math.abs(x - dstX) + Math.abs(y - dstY) != 1) { + throw new CanNotMoveToException(); + } else if (dstY == this.y + 1) { + throw new CanNotMoveToException(); + } else { + if (ChineseChessService.points[dstX][dstY] != null) { + if (ChineseChessService.points[dstX][dstY].isRed == this.isRed) + throw new CanNotMoveToException(); + else + ChineseChessService.points[dstX][dstY].die(); + } + } + } + } else {//黑卒 + if (this.y <= 4) {//没过河 + if (dstX != this.x) + throw new CanNotMoveToException(); + else if (dstY != this.y + 1) + throw new CanNotMoveToException(); + if (ChineseChessService.points[dstX][dstY] != null) { + if (ChineseChessService.points[dstX][dstY].isRed == this.isRed) + throw new CanNotMoveToException(); + else + ChineseChessService.points[dstX][dstY].die(); + } + } else {//过了河 + if (Math.abs(x - dstX) + Math.abs(y - dstY) != 1) { + throw new CanNotMoveToException(); + } else if (dstY == this.y - 1) { + throw new CanNotMoveToException(); + } else { + if (ChineseChessService.points[dstX][dstY] != null) { + if (ChineseChessService.points[dstX][dstY].isRed == this.isRed) + throw new CanNotMoveToException(); + else + ChineseChessService.points[dstX][dstY].die(); + } + } + } + } + ChineseChessService.points[x][y] = null; + ChineseChessService.points[dstX][dstY] = this; + x = dstX; + y = dstY; + this.setX(CheckerBoard.xToPx(dstX) - getWidth() / 2); + this.setY(CheckerBoard.yToPx(dstY) - getHeight() / 2); + } + + + @Override + protected void loadImage() { + Image image; + if (!isSelected) { + if (isRed) + image = new Image("chessImages/RP.GIF"); + else + image = new Image("chessImages/BP.GIF"); + } else { + if (isRed) + image = new Image("chessImages/RPS.GIF"); + else + image = new Image("chessImages/BPS.GIF"); + } + setFill(new ImagePattern(image)); + } //加载正确的图片 + +} diff --git a/games/x-ChineseChess/src/main/java/com/xwintop/xJavaFxTool/view/games/ChineseChessView.java b/games/x-ChineseChess/src/main/java/com/xwintop/xJavaFxTool/view/games/ChineseChessView.java new file mode 100644 index 00000000..cae3f3f2 --- /dev/null +++ b/games/x-ChineseChess/src/main/java/com/xwintop/xJavaFxTool/view/games/ChineseChessView.java @@ -0,0 +1,30 @@ +package com.xwintop.xJavaFxTool.view.games; + +import lombok.Getter; +import lombok.Setter; +import javafx.fxml.Initializable; +import javafx.fxml.FXML; + +import java.lang.*; + +import javafx.geometry.*; +import javafx.scene.control.*; +import javafx.geometry.Insets; +import javafx.scene.control.Button; +import javafx.scene.layout.*; + +@Getter +@Setter +public abstract class ChineseChessView implements Initializable { + @FXML + protected Pane checkerBoard;//棋盘画布对象 + @FXML + protected Button startButton; + @FXML + protected Button reStartButton; + @FXML + protected Button showRecordButton; + @FXML + protected Button saveRecordButton; + +} \ No newline at end of file diff --git a/games/x-ChineseChess/src/main/resources/chessAudio/can'tmove.wav b/games/x-ChineseChess/src/main/resources/chessAudio/can'tmove.wav new file mode 100644 index 00000000..27181393 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessAudio/can'tmove.wav differ diff --git a/games/x-ChineseChess/src/main/resources/chessAudio/setpiece.wav b/games/x-ChineseChess/src/main/resources/chessAudio/setpiece.wav new file mode 100644 index 00000000..d10568b0 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessAudio/setpiece.wav differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/BA.GIF b/games/x-ChineseChess/src/main/resources/chessImages/BA.GIF new file mode 100644 index 00000000..8d479377 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/BA.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/BAS.GIF b/games/x-ChineseChess/src/main/resources/chessImages/BAS.GIF new file mode 100644 index 00000000..906abc34 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/BAS.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/BB.GIF b/games/x-ChineseChess/src/main/resources/chessImages/BB.GIF new file mode 100644 index 00000000..06be4228 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/BB.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/BBS.GIF b/games/x-ChineseChess/src/main/resources/chessImages/BBS.GIF new file mode 100644 index 00000000..5cfb6f54 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/BBS.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/BC.GIF b/games/x-ChineseChess/src/main/resources/chessImages/BC.GIF new file mode 100644 index 00000000..fb94f171 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/BC.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/BCS.GIF b/games/x-ChineseChess/src/main/resources/chessImages/BCS.GIF new file mode 100644 index 00000000..15657f8d Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/BCS.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/BK.GIF b/games/x-ChineseChess/src/main/resources/chessImages/BK.GIF new file mode 100644 index 00000000..eca23866 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/BK.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/BKM.GIF b/games/x-ChineseChess/src/main/resources/chessImages/BKM.GIF new file mode 100644 index 00000000..b6ec8ba9 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/BKM.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/BKS.GIF b/games/x-ChineseChess/src/main/resources/chessImages/BKS.GIF new file mode 100644 index 00000000..55734cd9 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/BKS.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/BN.GIF b/games/x-ChineseChess/src/main/resources/chessImages/BN.GIF new file mode 100644 index 00000000..4f34cb33 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/BN.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/BNS.GIF b/games/x-ChineseChess/src/main/resources/chessImages/BNS.GIF new file mode 100644 index 00000000..2f8c3bec Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/BNS.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/BP.GIF b/games/x-ChineseChess/src/main/resources/chessImages/BP.GIF new file mode 100644 index 00000000..edc5993e Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/BP.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/BPS.GIF b/games/x-ChineseChess/src/main/resources/chessImages/BPS.GIF new file mode 100644 index 00000000..02cd7cda Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/BPS.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/BR.GIF b/games/x-ChineseChess/src/main/resources/chessImages/BR.GIF new file mode 100644 index 00000000..28996bf5 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/BR.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/BRS.GIF b/games/x-ChineseChess/src/main/resources/chessImages/BRS.GIF new file mode 100644 index 00000000..ab250626 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/BRS.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/OO.GIF b/games/x-ChineseChess/src/main/resources/chessImages/OO.GIF new file mode 100644 index 00000000..37dd89c9 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/OO.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/OOS.GIF b/games/x-ChineseChess/src/main/resources/chessImages/OOS.GIF new file mode 100644 index 00000000..2ee9c7d6 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/OOS.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/RA.GIF b/games/x-ChineseChess/src/main/resources/chessImages/RA.GIF new file mode 100644 index 00000000..9661b13e Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/RA.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/RAS.GIF b/games/x-ChineseChess/src/main/resources/chessImages/RAS.GIF new file mode 100644 index 00000000..deb4543f Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/RAS.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/RB.GIF b/games/x-ChineseChess/src/main/resources/chessImages/RB.GIF new file mode 100644 index 00000000..f700cfc3 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/RB.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/RBS.GIF b/games/x-ChineseChess/src/main/resources/chessImages/RBS.GIF new file mode 100644 index 00000000..23f374b1 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/RBS.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/RC.GIF b/games/x-ChineseChess/src/main/resources/chessImages/RC.GIF new file mode 100644 index 00000000..851131e6 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/RC.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/RCS.GIF b/games/x-ChineseChess/src/main/resources/chessImages/RCS.GIF new file mode 100644 index 00000000..6a05ffd4 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/RCS.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/RK.GIF b/games/x-ChineseChess/src/main/resources/chessImages/RK.GIF new file mode 100644 index 00000000..607443b6 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/RK.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/RKM.GIF b/games/x-ChineseChess/src/main/resources/chessImages/RKM.GIF new file mode 100644 index 00000000..3c292e81 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/RKM.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/RKS.GIF b/games/x-ChineseChess/src/main/resources/chessImages/RKS.GIF new file mode 100644 index 00000000..8b721235 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/RKS.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/RN.GIF b/games/x-ChineseChess/src/main/resources/chessImages/RN.GIF new file mode 100644 index 00000000..359f9cbf Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/RN.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/RNS.GIF b/games/x-ChineseChess/src/main/resources/chessImages/RNS.GIF new file mode 100644 index 00000000..b55db7c1 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/RNS.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/RP.GIF b/games/x-ChineseChess/src/main/resources/chessImages/RP.GIF new file mode 100644 index 00000000..b09ad78a Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/RP.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/RPS.GIF b/games/x-ChineseChess/src/main/resources/chessImages/RPS.GIF new file mode 100644 index 00000000..aa99bcda Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/RPS.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/RR.GIF b/games/x-ChineseChess/src/main/resources/chessImages/RR.GIF new file mode 100644 index 00000000..71f0df30 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/RR.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/RRS.GIF b/games/x-ChineseChess/src/main/resources/chessImages/RRS.GIF new file mode 100644 index 00000000..00c8ee39 Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/RRS.GIF differ diff --git a/games/x-ChineseChess/src/main/resources/chessImages/icon.png b/games/x-ChineseChess/src/main/resources/chessImages/icon.png new file mode 100644 index 00000000..8438937b Binary files /dev/null and b/games/x-ChineseChess/src/main/resources/chessImages/icon.png differ diff --git a/games/x-ChineseChess/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/games/ChineseChess.fxml b/games/x-ChineseChess/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/games/ChineseChess.fxml new file mode 100644 index 00000000..5be2dd29 --- /dev/null +++ b/games/x-ChineseChess/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/games/ChineseChess.fxml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ diff --git a/games/x-X2048/src/main/resources/config/toolFxmlLoaderConfiguration.xml b/games/x-X2048/src/main/resources/config/toolFxmlLoaderConfiguration.xml new file mode 100644 index 00000000..35b1b11f --- /dev/null +++ b/games/x-X2048/src/main/resources/config/toolFxmlLoaderConfiguration.xml @@ -0,0 +1,14 @@ + + + + + /com/xwintop/xJavaFxTool/fxmlView/games/X2048.fxml + locale.X2048 + + Title + + + p-games + Node + + \ No newline at end of file diff --git a/games/x-X2048/src/main/resources/locale/X2048.properties b/games/x-X2048/src/main/resources/locale/X2048.properties new file mode 100644 index 00000000..0f20155a --- /dev/null +++ b/games/x-X2048/src/main/resources/locale/X2048.properties @@ -0,0 +1,3 @@ +# 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=2048 \ No newline at end of file diff --git a/games/x-X2048/src/main/resources/locale/X2048_en_US.properties b/games/x-X2048/src/main/resources/locale/X2048_en_US.properties new file mode 100644 index 00000000..0ba7d886 --- /dev/null +++ b/games/x-X2048/src/main/resources/locale/X2048_en_US.properties @@ -0,0 +1,3 @@ +# \u6587\u4EF6Dorian_en_US.properties\uFF0C\u662F\u7F8E\u56FD\u5730\u533A\u7684\u8D44\u6E90\u675F +# \u5B83\u8986\u76D6\u4E86\u9ED8\u8BA4\u8D44\u6E90\u675F +Title=2048 \ No newline at end of file diff --git a/games/x-pet/.gitignore b/games/x-pet/.gitignore new file mode 100644 index 00000000..e9e4b10b --- /dev/null +++ b/games/x-pet/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +#/.gitignore +/x-pet.iml +/log/ +/target/ \ No newline at end of file diff --git a/games/x-pet/LICENSE b/games/x-pet/LICENSE new file mode 100644 index 00000000..9e32cdef --- /dev/null +++ b/games/x-pet/LICENSE @@ -0,0 +1,127 @@ + 木兰宽松许可证, 第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. diff --git a/games/x-pet/README.md b/games/x-pet/README.md new file mode 100644 index 00000000..4e34cdef --- /dev/null +++ b/games/x-pet/README.md @@ -0,0 +1 @@ +pet 桌面宠物 \ No newline at end of file diff --git a/games/x-pet/README_EN.md b/games/x-pet/README_EN.md new file mode 100644 index 00000000..99610e4a --- /dev/null +++ b/games/x-pet/README_EN.md @@ -0,0 +1 @@ +pet \ No newline at end of file diff --git a/games/x-pet/build.gradle b/games/x-pet/build.gradle new file mode 100644 index 00000000..a2d212a9 --- /dev/null +++ b/games/x-pet/build.gradle @@ -0,0 +1,7 @@ +dependencies { + api project(':xcore') +} + +group = 'com.xwintop' +version = '0.0.1' +description = 'x-pet' diff --git a/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/controller/games/petController.java b/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/controller/games/petController.java new file mode 100644 index 00000000..f6952587 --- /dev/null +++ b/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/controller/games/petController.java @@ -0,0 +1,45 @@ +package com.xwintop.xJavaFxTool.controller.games; + +import com.xwintop.xJavaFxTool.services.games.Main; +import com.xwintop.xJavaFxTool.view.games.petView; +import com.xwintop.xJavaFxTool.services.games.petService; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +import java.net.URL; +import java.util.ResourceBundle; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; + +@Getter +@Setter +@Slf4j +public class petController extends petView { + private petService petService = new petService(this); + + @Override + public void initialize(URL location, ResourceBundle resources) { + initView(); + initEvent(); + initService(); + } + + private void initView() { + } + + private void initEvent() { + } + + private void initService() { + } + + @FXML + private void openPetAction(ActionEvent event) { + System.out.println("dd"); +// Main.main(new String[]{}); + petService.showPet(); + } + +} \ No newline at end of file diff --git a/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/petMain.java b/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/petMain.java new file mode 100644 index 00000000..792a362a --- /dev/null +++ b/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/petMain.java @@ -0,0 +1,52 @@ +package com.xwintop.xJavaFxTool; + +import com.xwintop.xJavaFxTool.services.games.Main; +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.stage.Stage; +import javafx.stage.WindowEvent; +import lombok.extern.slf4j.Slf4j; + +import java.net.URL; +import java.util.ResourceBundle; + +@Slf4j +public class petMain extends Application { + public static void main(String[] args) { + try { + launch(args); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void start(Stage primaryStage) throws Exception { + FXMLLoader fXMLLoader = petMain.getFXMLLoader(); + ResourceBundle resourceBundle = fXMLLoader.getResources(); + Parent root = fXMLLoader.load(); + primaryStage.setResizable(true); + primaryStage.setTitle(resourceBundle.getString("Title")); +// primaryStage.getIcons().add(new Image("/images/icon.jpg")); + double[] screenSize = JavaFxSystemUtil.getScreenSizeByScale(0.74, 0.8); + primaryStage.setScene(new Scene(root, screenSize[0], screenSize[1])); + primaryStage.show(); + primaryStage.setOnCloseRequest(new EventHandler() { + @Override + public void handle(WindowEvent event) { + System.exit(0); + } + }); + } + + public static FXMLLoader getFXMLLoader() { + ResourceBundle resourceBundle = ResourceBundle.getBundle("locale.pet"); + URL url = Object.class.getResource("/com/xwintop/xJavaFxTool/fxmlView/games/pet.fxml"); + FXMLLoader fXMLLoader = new FXMLLoader(url, resourceBundle); + return fXMLLoader; + } +} \ No newline at end of file diff --git a/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/services/games/EventListener.java b/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/services/games/EventListener.java new file mode 100644 index 00000000..774bf0e7 --- /dev/null +++ b/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/services/games/EventListener.java @@ -0,0 +1,135 @@ +package com.xwintop.xJavaFxTool.services.games; + +import javafx.animation.KeyFrame; +import javafx.animation.Timeline; +import javafx.event.EventHandler; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.input.MouseEvent; +import javafx.util.Duration; + +public class EventListener implements EventHandler { + private ImageView imageView; + int gifID = 0;//图片编号 + int petID = 0;//宠物ID + double time = 3;//播放动画的时间 + public EventListener(ImageView imgView, int pet) { + imageView=imgView; + petID = pet; + } + public void handle(MouseEvent e) { + if(gifID!=0) return; //如果动作没做完,就不允许再做新的动作 + double x = e.getX(); + double y = e.getY(); +// System.out.println(x+" "+y);//测试眼睛等部位的位置 + //选择动作 + if(petID == 0) lxhBehavior(x,y); + else biuBehavior(x,y); + loadImg(petID,gifID,time);//显示图片 + } + //罗小黑的动作 + public void lxhBehavior(double x,double y) { + //以下的“左”“右”都是相对于用户来说的 + //点击左眼 + if(x>20 & x<42 & y>125 & y<143) { + gifID = 1; + time = 2.8; + } + //点击右眼 + else if(x>63 & x<90 & y>125 & y<143) { + gifID = 2; + time = 3.85; + } + //点击右耳 + else if(x>93 & x<110 & y>80 & y<100) { + gifID = 3; + time = 6.3; + } + //点击身体 + else if(x>110 & x<130 & y>125 & y<155) { + gifID = 4; + time = 3; + } + //点击小小黑 + else if(x>152 & x<175 & y>157 & y<172) { + gifID = 5; + time = 3.5; + } + else { + gifID = 0; + } + } + //比丢的动作 + private void biuBehavior(double x, double y) { + //以下的“左”“右”都是相对于用户来说的 + //点击左眼 + if(x>40 & x<51 & y>60 & y<67) { + gifID = 1; + time = 3.7; + } + //点击右眼 + else if(x>87 & x<100 & y>58 & y<69) { + gifID = 2; + time = 4.45; + } + //点击嘴 + else if(x>62 & x<76 & y>61 & y<69) { + gifID = 3; + time = 5.3; + } + //点击左手 + else if(x>31 & x<49 & y>87 & y<117) { + gifID = 4; + time = 1.75; + } + //点击右手 + else if(x>86 & x<107 & y>85 & y<114) { + gifID = 5; + time = 4; + } + //点击额头 + else if(x>43 & x<94 & y>34 & y<52) { + gifID = 6; + time = 1.8; + } + //点击肚子 + else if(x>64 & x<79 & y>86 & y<130) { + gifID = 7; + time = 4.1; + } + else { + gifID = 0; + } + } + //点击部位后加载图片 + public void loadImg(int petID,int gifID, double time) { + this.gifID = gifID; + if(gifID!=0) { + Image newimage; + if(petID==0) + newimage = new Image(this.getClass().getResourceAsStream("/lxh/罗小黑"+gifID+".gif")); + else + newimage = new Image(this.getClass().getResourceAsStream("/biu/biu"+gifID+".gif")); + + imageView.setImage(newimage); + //中断动图的播放,切换至主图 + new Timeline(new KeyFrame(Duration.seconds(time), ae ->mainimg(this.petID,0))).play(); + } + } + //主图,负责等待时和退出时的动作 + public void mainimg(int pet,int key) { + Image newimage; + if(pet==0) + newimage = new Image(this.getClass().getResourceAsStream("/lxh/罗小黑"+key+".gif")); + else + newimage = new Image(this.getClass().getResourceAsStream("/biu/biu"+key+".gif")); + imageView.setImage(newimage); + //这里是为了保证能做出新的动作,对应于handle方法的if(gifID!=0) return; + //同时也是为了做其他动作时不被“自行走动”和“自娱自乐”打断 + if(key == 0) gifID=0; + } + +// public void setPetID(int id) { +// petID = id; +// } +} diff --git a/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/services/games/Main.java b/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/services/games/Main.java new file mode 100644 index 00000000..5d12bca7 --- /dev/null +++ b/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/services/games/Main.java @@ -0,0 +1,92 @@ +package com.xwintop.xJavaFxTool.services.games; + +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; +import javafx.stage.StageStyle; + + +public class Main extends Application { + private static ImageView imageView; + EventListener listen; + VBox messageBox; + int petID = 1;//宠物ID。罗小黑=0,比丢=1 + double xOffset = 0; + double yOffset = 0; + + public void start(Stage primaryStage) { + try { + /* + * 创建初始的图 + * 加载相对路径的图片要用class.getResource,不然运行jar包时会报错:找不到文件路径! + * 路径中第一个“/”是必需的,它表示类的根目录,类文件夹在此项目中与lxh和biu在同一级 + */ + Image image = new Image(this.getClass().getResourceAsStream("/biu/biu0.gif")); + imageView = new ImageView(image); + imageView.setX(0); + imageView.setY(0); + imageView.setLayoutX(0); + imageView.setLayoutY(50); + //设置图片显示的大小 + imageView.setFitHeight(150); + imageView.setFitWidth(150); + //添加图片的点击事件 + listen = new EventListener(imageView , petID); + imageView.addEventHandler(MouseEvent.MOUSE_CLICKED, listen); + + imageView.setPreserveRatio(true); //保留 width:height的比例 + imageView.setStyle("-fx-background:transparent;");//容器背景设为透明 + + UI ui = new UI(imageView, petID, listen,primaryStage); + ui.addMessageBox("你好吖~"); + + AnchorPane pane = new AnchorPane(ui.getMessageBox(),ui.getImageView()); + + pane.setStyle("-fx-background:transparent;"); + //使窗体能拖动。先获取按下鼠标时的坐标p1,再将窗体坐标设为p1加拖动的位移量 + pane.setOnMousePressed(event -> { + xOffset = event.getSceneX(); + yOffset = event.getSceneY(); + }); + pane.setOnMouseDragged(event -> { + primaryStage.setX(event.getScreenX() - xOffset); + primaryStage.setY(event.getScreenY() - yOffset); + }); + + Scene scene = new Scene(pane,400,400); + scene.setFill(null); + + primaryStage.setScene(scene); + //设置窗体的初始位置 + primaryStage.setX(850); + primaryStage.setY(400); + primaryStage.setAlwaysOnTop(true);//窗口总显示在最前 + //修改任务栏图标 + primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/icon.png"))); + //下句隐藏任务栏图标,但javafx的stage.initStyle(Style)只能有一个起效,只好作罢 +// primaryStage.initStyle(StageStyle.UTILITY); + primaryStage.initStyle(StageStyle.TRANSPARENT);//背景透明 + /* + * 点击任务栏的“关闭窗口”时,播放告别动画,同时使托盘的图标也关闭. + * event.consume()是必需的,这样才能真正阻止Window Close事件的默认处理。 + * 如果仅仅使用System.exit(0);则不需要event.consume(); + */ + primaryStage.setOnCloseRequest( event ->{event.consume(); ui.end();}); + primaryStage.show(); + + ui.setTray(primaryStage);//添加系统托盘 + Thread thread = new Thread(ui); + thread.start(); + } catch(Exception e) { + e.printStackTrace(); + } + } + public static void main(String[] args) { + launch(args); + } +} diff --git a/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/services/games/Move.java b/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/services/games/Move.java new file mode 100644 index 00000000..efea09b0 --- /dev/null +++ b/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/services/games/Move.java @@ -0,0 +1,68 @@ +package com.xwintop.xJavaFxTool.services.games; + +import javafx.geometry.Rectangle2D; +import javafx.scene.image.ImageView; +import javafx.scene.input.MouseEvent; +import javafx.stage.Screen; +import javafx.stage.Stage; + +public class Move extends Thread{ + private long time; + private ImageView imageView; + private int direID; + double x; + double maxx; + double width; + Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds(); + Stage stage; + private EventListener listen; + private int petID; + boolean exit; + + public Move(long time, ImageView imgView, int dire, Stage primaryStage, EventListener el) { + this.time = time; + imageView = imgView; + direID = dire; + stage = primaryStage; + listen = el; + petID = listen.petID;//此petID是调用Move时的petID + } + + public void run() { + //点击就停下 + /*使用listen.petID而不是定义一个变量int petID = listen.petID; + *是因为在运动过程中点击“切换宠物”时实际的petID会改变,所以使用listen.petID就可以做到同步改变。 + *若下面使用listen.mainimg(petID,0)显示的就是点击“切换宠物”前的宠物,这个petID就是旧的petID。 + */ + imageView.addEventHandler(MouseEvent.MOUSE_PRESSED, + e ->{exit = true;listen.mainimg(listen.petID, 0);}); + while(!exit) { + //如果petID!=listen.petID,则已“切换宠物”,此时要结束运动。 + if(petID!=listen.petID) { + exit=true; + return; + } + width = imageView.getBoundsInLocal().getMaxX(); + x = stage.getX(); + maxx = screenBounds.getMaxX(); + double speed=15; + if(x+speed+width >= maxx | x-speed<=0 | time<=0) { + this.interrupt(); + listen.mainimg(listen.petID, 0); + return; + } + if(direID == 0) { //向左走 + stage.setX(x-speed); + } + else if(direID == 1) { //向右走 + stage.setX(x+speed); + } + time -= 300; + try { + Thread.sleep(300); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } +} diff --git a/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/services/games/UI.java b/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/services/games/UI.java new file mode 100644 index 00000000..643e4837 --- /dev/null +++ b/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/services/games/UI.java @@ -0,0 +1,312 @@ +package com.xwintop.xJavaFxTool.services.games; + +import javafx.animation.KeyFrame; +import javafx.animation.Timeline; +import javafx.application.Platform; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.geometry.Rectangle2D; +import javafx.scene.control.Label; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.VBox; +import javafx.scene.paint.Color; +import javafx.scene.shape.Polygon; +import javafx.stage.Screen; +import javafx.stage.Stage; +import javafx.util.Duration; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.Random; + +public class UI implements Runnable { + private ImageView imageView; + private int petID; + private EventListener listen; + private VBox messageBox; + private CheckboxMenuItem itemWalkable; + private CheckboxMenuItem autoPlay; + private CheckboxMenuItem itemSay; + private MenuItem itemSwitch; + private Stage primaryStage; + Thread thread; + double x; + String[] lxhStrings= { + "好无聊。。。", + "陪我玩会儿吧~", + "《罗小黑战记》怎么还没更新", + "想师父了", + "不就是拿了颗珠子嘛,至于把我打回猫形嘛" + }; + String[] biuStrings = { + "想吃东西。。", + "biu~", + "揉揉小肚几", + "比丢这么可爱,怎么可以欺负比丢" + }; + public UI(ImageView view, int pet, EventListener el, Stage s) { + imageView = view; + petID = pet; + listen = el; + primaryStage = s; + } + + //添加系统托盘 + public void setTray(Stage stage) { + SystemTray tray = SystemTray.getSystemTray(); + BufferedImage image;//托盘图标 + try { + // 为托盘添加一个右键弹出菜单 + PopupMenu popMenu = new PopupMenu(); + popMenu.setFont(new Font("微软雅黑", Font.PLAIN,18)); + + itemSwitch = new MenuItem("切换宠物"); + itemSwitch.addActionListener(e -> switchPet()); + + itemWalkable = new CheckboxMenuItem("自行走动"); + autoPlay = new CheckboxMenuItem("自娱自乐"); + itemSay = new CheckboxMenuItem("碎碎念"); + //令"自行走动"、"自娱自乐"和"碎碎念"不能同时生效 + itemWalkable.addItemListener(il -> { + if(itemWalkable.getState()) { + autoPlay.setEnabled(false); + itemSay.setEnabled(false); + } + else { + autoPlay.setEnabled(true); + itemSay.setEnabled(true); + } + }); + autoPlay.addItemListener(il -> { + if(autoPlay.getState()) { + itemWalkable.setEnabled(false); + itemSay.setEnabled(false); + } + else { + itemWalkable.setEnabled(true); + itemSay.setEnabled(true); + } + }); + itemSay.addItemListener(il -> { + if(itemSay.getState()) { + itemWalkable.setEnabled(false); + autoPlay.setEnabled(false); + } + else { + itemWalkable.setEnabled(true); + autoPlay.setEnabled(true); + } + }); + + MenuItem itemShow = new MenuItem("显示"); + itemShow.addActionListener(e -> Platform.runLater(() -> stage.show())); + + MenuItem itemHide = new MenuItem("隐藏"); + //要先setImplicitExit(false),否则stage.hide()会直接关闭stage + //stage.hide()等同于stage.close() + itemHide.addActionListener(e ->{Platform.setImplicitExit(false); + Platform.runLater(() -> stage.hide());}); + + MenuItem itemExit = new MenuItem("退出"); + itemExit.addActionListener(e -> end()); + + popMenu.add(itemSwitch); + popMenu.addSeparator(); + popMenu.add(itemWalkable); + popMenu.add(autoPlay); + popMenu.add(itemSay); + popMenu.addSeparator(); + popMenu.add(itemShow); + popMenu.add(itemHide); + popMenu.add(itemExit); + //设置托盘图标 + image = ImageIO.read(getClass().getResourceAsStream("/icon.png")); + TrayIcon trayIcon = new TrayIcon(image, "桌面宠物", popMenu); + trayIcon.setToolTip("桌面宠物"); + trayIcon.setImageAutoSize(true);//自动调整图片大小。这步很重要,不然显示的是空白 + tray.add(trayIcon); + } catch (IOException | AWTException e) { + e.printStackTrace(); + } + } + + //切换宠物 + private void switchPet() { + imageView.removeEventHandler(MouseEvent.MOUSE_CLICKED, listen);//移除原宠物的事件 + //切换宠物ID + if(petID == 0) { + petID = 1; //切换成比丢 + imageView.setFitHeight(150); + imageView.setFitWidth(150); + } + else { + petID = 0; //切换成罗小黑 + imageView.setFitHeight(200); + imageView.setFitWidth(200); + } +// listen = new EventListener(imageView,petID); + /* + *修改listen.petID是为了修复bug: 在运行三个功能之一时点击切换宠物,图片会切换,但宠物动作不会停止 + *且动作完成后恢复的主图还是上一个宠物,直到下一个动作执行才变正常。 + *原因在于那三个功能调用listen.loadimg()时传递的是旧petID。 + */ + listen.petID = petID; + listen.mainimg(petID,0);//切换至该宠物的主图(图片编号为0) + //因为listen更新了,所以要重新添加点击事件 + imageView.addEventHandler(MouseEvent.MOUSE_CLICKED, listen); + } + //退出程序时展示动画 + void end() { + listen.mainimg(petID,99);//播放宠物的告别动画————编号为99的图片 + double time; + //罗小黑的告别动画1.5秒,比丢的3秒 + if(petID == 0) time = 1.5; + else time = 3; + //要用Platform.runLater,不然会报错Not on FX application thread; + Platform.runLater(() ->setMsg("再见~")); + //动画结束后执行退出 + new Timeline(new KeyFrame( + Duration.seconds(time), +// ae ->System.exit(0))) + ae ->{primaryStage.close();})) + .play(); + } + //添加聊天气泡 + public void addMessageBox(String message) { + Label bubble = new Label(message); + //设置气泡的宽度。如果没有这句,就会根据内容多少来自适应宽度 + bubble.setPrefWidth(100); + bubble.setWrapText(true);//自动换行 + bubble.setStyle("-fx-background-color: DarkTurquoise; -fx-background-radius: 8px;"); + bubble.setPadding(new Insets(7));//标签的内边距的宽度 + bubble.setFont(new javafx.scene.text.Font(14)); + Polygon triangle = new Polygon( + 0.0, 0.0, + 8.0, 10.0, + 16.0, 0.0);//分别设置三角形三个顶点的X和Y + triangle.setFill(Color.DARKTURQUOISE); + messageBox = new VBox(); +// VBox.setMargin(triangle, new Insets(0, 50, 0, 0));//设置三角形的位置,默认居中 + messageBox.getChildren().addAll(bubble, triangle); + messageBox.setAlignment(Pos.BOTTOM_CENTER); + messageBox.setStyle("-fx-background:transparent;"); + //设置相对于父容器的位置 + messageBox.setLayoutX(0); + messageBox.setLayoutY(0); + messageBox.setVisible(true); + //设置气泡的显示时间 + new Timeline(new KeyFrame( + Duration.seconds(8), + ae ->{messageBox.setVisible(false);})) + .play(); + } + +//用多线程来实现 经过随机时间间隔执行“自动行走”“自娱自乐”“碎碎念”的功能 + public void run() { + while(true) { + Random rand = new Random(); + //随机发生自动事件,以下设置间隔为9~24秒。要注意这个时间间隔包含了动画播放的时间 + long time = (rand.nextInt(15)+10)*1000; + System.out.println("Waiting time:"+time); + if(itemWalkable.getState() & listen.gifID == 0) { + walk(); + } + else if(autoPlay.getState() & listen.gifID == 0) { + play(); + } + else if(itemSay.getState() & listen.gifID == 0) { + //随机选择要说的话。因为目前只有两个宠物,所以可以用三目运算符 + String str = (petID == 0) ? lxhStrings[rand.nextInt(5)]:biuStrings[rand.nextInt(4)]; + Platform.runLater(() ->setMsg(str)); + } + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + /* + * 执行"碎碎念"的功能——在宠物上方显示对话气泡 + * 不默认开启是考虑到用户可能不想被打扰 + */ + public void setMsg(String msg) { + + Label lbl = (Label) messageBox.getChildren().get(0); + lbl.setText(msg); + messageBox.setVisible(true); + //设置气泡的显示时间 + new Timeline(new KeyFrame( + Duration.seconds(4), + ae ->{messageBox.setVisible(false);})) + .play(); + } + + /* + * 执行"自行走动"的功能——在水平方向上走动 + * 不默认开启是考虑到用户可能只想宠物安静呆着 + */ + void walk(){ + Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds(); + x = primaryStage.getX();//stage的左边缘坐标 + double maxx = screenBounds.getMaxX();//获取屏幕的大小 + double width = imageView.getBoundsInLocal().getWidth();//获取imageView的宽度,也可使用.getMaxX(); + Random rand = new Random(); + double speed=10;//每次移动的距离 + //如果将要到达屏幕边缘就停下 + if(x+speed+width >= maxx | x-speed<=0) + return; + //随机决定移动的时间,单位微秒ms + long time = (rand.nextInt(4)+3)*1000; + System.out.println("Walking time:"+time); + int direID = rand.nextInt(2);//随机决定方向,0为左,1为右 + //切换至对应方向的行走图 + Image newimage; + if(petID == 0) + newimage = new Image(this.getClass().getResourceAsStream("/lxh/罗小黑w"+direID+".gif")); + else { + newimage = new Image(this.getClass().getResourceAsStream("/biu/biuw"+direID+".gif")); + } + imageView.setImage(newimage); + //移动 + Move move = new Move(time, imageView, direID, primaryStage, listen); + thread = new Thread(move); + thread.start(); + } + /* + * 执行"自娱自乐"的功能——空闲时随机做动作 + * 这样就不用受部位数量的限制,也不会让宠物显得呆板 + * 不默认开启是考虑到用户可能只想宠物安静呆着 + */ + void play() { + Random rand = new Random(); + int gifID; + double time = 4; + //gifID是根据图片文件夹中用途未定义的图片和已设定的动作个数来确定的 + if(petID == 0) { + gifID = rand.nextInt(7)+5; + } + else + gifID = rand.nextInt(7)+7; + listen.loadImg(petID, gifID, time); + } + public ImageView getImageView() { + return imageView; + } + + public void setImageView(ImageView imageView) { + this.imageView = imageView; + } + + public VBox getMessageBox() { + return messageBox; + } + + public void setMessageBox(VBox messageBox) { + this.messageBox = messageBox; + } +} diff --git a/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/services/games/petService.java b/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/services/games/petService.java new file mode 100644 index 00000000..a89321ff --- /dev/null +++ b/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/services/games/petService.java @@ -0,0 +1,92 @@ +package com.xwintop.xJavaFxTool.services.games; + +import com.xwintop.xJavaFxTool.controller.games.petController; +import javafx.scene.Scene; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; +import javafx.stage.StageStyle; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; + +@Getter +@Setter +@Slf4j +public class petService { + private petController petController; + + private static ImageView imageView; + EventListener listen; + VBox messageBox; + int petID = 1;//宠物ID。罗小黑=0,比丢=1 + double xOffset = 0; + double yOffset = 0; + + public petService(petController petController) { + this.petController = petController; + } + + public void showPet(){ + Stage primaryStage = new Stage(); + Image image = new Image(this.getClass().getResourceAsStream("/biu/biu0.gif")); + imageView = new ImageView(image); + imageView.setX(0); + imageView.setY(0); + imageView.setLayoutX(0); + imageView.setLayoutY(50); + //设置图片显示的大小 + imageView.setFitHeight(150); + imageView.setFitWidth(150); + //添加图片的点击事件 + listen = new EventListener(imageView , petID); + imageView.addEventHandler(MouseEvent.MOUSE_CLICKED, listen); + + imageView.setPreserveRatio(true); //保留 width:height的比例 + imageView.setStyle("-fx-background:transparent;");//容器背景设为透明 + + UI ui = new UI(imageView, petID, listen,primaryStage); + ui.addMessageBox("你好吖~"); + + AnchorPane pane = new AnchorPane(ui.getMessageBox(),ui.getImageView()); + + pane.setStyle("-fx-background:transparent;"); + //使窗体能拖动。先获取按下鼠标时的坐标p1,再将窗体坐标设为p1加拖动的位移量 + pane.setOnMousePressed(event -> { + xOffset = event.getSceneX(); + yOffset = event.getSceneY(); + }); + pane.setOnMouseDragged(event -> { + primaryStage.setX(event.getScreenX() - xOffset); + primaryStage.setY(event.getScreenY() - yOffset); + }); + + Scene scene = new Scene(pane,400,400); + scene.setFill(null); + + primaryStage.setScene(scene); + //设置窗体的初始位置 + primaryStage.setX(850); + primaryStage.setY(400); + primaryStage.setAlwaysOnTop(true);//窗口总显示在最前 + //修改任务栏图标 + primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/icon.png"))); + //下句隐藏任务栏图标,但javafx的stage.initStyle(Style)只能有一个起效,只好作罢 +// primaryStage.initStyle(StageStyle.UTILITY); + primaryStage.initStyle(StageStyle.TRANSPARENT);//背景透明 + /* + * 点击任务栏的“关闭窗口”时,播放告别动画,同时使托盘的图标也关闭. + * event.consume()是必需的,这样才能真正阻止Window Close事件的默认处理。 + * 如果仅仅使用System.exit(0);则不需要event.consume(); + */ + primaryStage.setOnCloseRequest( event ->{event.consume(); ui.end();}); + primaryStage.show(); + + ui.setTray(primaryStage);//添加系统托盘 + Thread thread = new Thread(ui); + thread.start(); + } +} \ No newline at end of file diff --git a/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/view/games/petView.java b/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/view/games/petView.java new file mode 100644 index 00000000..753c1953 --- /dev/null +++ b/games/x-pet/src/main/java/com/xwintop/xJavaFxTool/view/games/petView.java @@ -0,0 +1,21 @@ +package com.xwintop.xJavaFxTool.view.games; + +import lombok.Getter; +import lombok.Setter; +import javafx.fxml.Initializable; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.Slider; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Pane; +import javafx.scene.text.Font; + +@Getter +@Setter +public abstract class petView implements Initializable { + @FXML + protected Button btnReset; +} \ No newline at end of file diff --git a/games/x-pet/src/main/resources/biu/biu0.gif b/games/x-pet/src/main/resources/biu/biu0.gif new file mode 100644 index 00000000..f554fe01 Binary files /dev/null and b/games/x-pet/src/main/resources/biu/biu0.gif differ diff --git a/games/x-pet/src/main/resources/biu/biu1.gif b/games/x-pet/src/main/resources/biu/biu1.gif new file mode 100644 index 00000000..70555271 Binary files /dev/null and b/games/x-pet/src/main/resources/biu/biu1.gif differ diff --git a/games/x-pet/src/main/resources/biu/biu10.gif b/games/x-pet/src/main/resources/biu/biu10.gif new file mode 100644 index 00000000..9f483128 Binary files /dev/null and b/games/x-pet/src/main/resources/biu/biu10.gif differ diff --git a/games/x-pet/src/main/resources/biu/biu11.gif b/games/x-pet/src/main/resources/biu/biu11.gif new file mode 100644 index 00000000..fd2b18aa Binary files /dev/null and b/games/x-pet/src/main/resources/biu/biu11.gif differ diff --git a/games/x-pet/src/main/resources/biu/biu12.gif b/games/x-pet/src/main/resources/biu/biu12.gif new file mode 100644 index 00000000..82177abf Binary files /dev/null and b/games/x-pet/src/main/resources/biu/biu12.gif differ diff --git a/games/x-pet/src/main/resources/biu/biu13.gif b/games/x-pet/src/main/resources/biu/biu13.gif new file mode 100644 index 00000000..884e5d42 Binary files /dev/null and b/games/x-pet/src/main/resources/biu/biu13.gif differ diff --git a/games/x-pet/src/main/resources/biu/biu2.gif b/games/x-pet/src/main/resources/biu/biu2.gif new file mode 100644 index 00000000..d28b53ce Binary files /dev/null and b/games/x-pet/src/main/resources/biu/biu2.gif differ diff --git a/games/x-pet/src/main/resources/biu/biu3.gif b/games/x-pet/src/main/resources/biu/biu3.gif new file mode 100644 index 00000000..a8efe53f Binary files /dev/null and b/games/x-pet/src/main/resources/biu/biu3.gif differ diff --git a/games/x-pet/src/main/resources/biu/biu4.gif b/games/x-pet/src/main/resources/biu/biu4.gif new file mode 100644 index 00000000..dfa779ea Binary files /dev/null and b/games/x-pet/src/main/resources/biu/biu4.gif differ diff --git a/games/x-pet/src/main/resources/biu/biu5.gif b/games/x-pet/src/main/resources/biu/biu5.gif new file mode 100644 index 00000000..24877cc6 Binary files /dev/null and b/games/x-pet/src/main/resources/biu/biu5.gif differ diff --git a/games/x-pet/src/main/resources/biu/biu6.gif b/games/x-pet/src/main/resources/biu/biu6.gif new file mode 100644 index 00000000..3d2c0db7 Binary files /dev/null and b/games/x-pet/src/main/resources/biu/biu6.gif differ diff --git a/games/x-pet/src/main/resources/biu/biu7.gif b/games/x-pet/src/main/resources/biu/biu7.gif new file mode 100644 index 00000000..7a82ed0a Binary files /dev/null and b/games/x-pet/src/main/resources/biu/biu7.gif differ diff --git a/games/x-pet/src/main/resources/biu/biu8.gif b/games/x-pet/src/main/resources/biu/biu8.gif new file mode 100644 index 00000000..85dfd3ad Binary files /dev/null and b/games/x-pet/src/main/resources/biu/biu8.gif differ diff --git a/games/x-pet/src/main/resources/biu/biu9.gif b/games/x-pet/src/main/resources/biu/biu9.gif new file mode 100644 index 00000000..0fc8ed76 Binary files /dev/null and b/games/x-pet/src/main/resources/biu/biu9.gif differ diff --git a/games/x-pet/src/main/resources/biu/biu99.gif b/games/x-pet/src/main/resources/biu/biu99.gif new file mode 100644 index 00000000..928a0663 Binary files /dev/null and b/games/x-pet/src/main/resources/biu/biu99.gif differ diff --git a/games/x-pet/src/main/resources/biu/biuw0.gif b/games/x-pet/src/main/resources/biu/biuw0.gif new file mode 100644 index 00000000..ce381890 Binary files /dev/null and b/games/x-pet/src/main/resources/biu/biuw0.gif differ diff --git a/games/x-pet/src/main/resources/biu/biuw1.gif b/games/x-pet/src/main/resources/biu/biuw1.gif new file mode 100644 index 00000000..0aaf27a4 Binary files /dev/null and b/games/x-pet/src/main/resources/biu/biuw1.gif differ diff --git a/games/x-pet/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/games/pet.fxml b/games/x-pet/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/games/pet.fxml new file mode 100644 index 00000000..e74a8108 --- /dev/null +++ b/games/x-pet/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/games/pet.fxml @@ -0,0 +1,14 @@ + + + + + + + + + +
+
+
+
diff --git a/games/x-pet/src/main/resources/config/toolFxmlLoaderConfiguration.xml b/games/x-pet/src/main/resources/config/toolFxmlLoaderConfiguration.xml new file mode 100644 index 00000000..216b6108 --- /dev/null +++ b/games/x-pet/src/main/resources/config/toolFxmlLoaderConfiguration.xml @@ -0,0 +1,14 @@ + + + + + /com/xwintop/xJavaFxTool/fxmlView/games/pet.fxml + locale.pet + + Title + + + p-javaFxTools + Node + + \ No newline at end of file diff --git a/games/x-pet/src/main/resources/icon.png b/games/x-pet/src/main/resources/icon.png new file mode 100644 index 00000000..483f052a Binary files /dev/null and b/games/x-pet/src/main/resources/icon.png differ diff --git a/games/x-pet/src/main/resources/locale/pet.properties b/games/x-pet/src/main/resources/locale/pet.properties new file mode 100644 index 00000000..57f0b4e6 --- /dev/null +++ b/games/x-pet/src/main/resources/locale/pet.properties @@ -0,0 +1,3 @@ +# Dorian.properties是默认的"Dorian"资源束文件。 +# 作为中国人,我用自己的地区作为默认 +Title=pet \ No newline at end of file diff --git a/games/x-pet/src/main/resources/locale/pet_en_US.properties b/games/x-pet/src/main/resources/locale/pet_en_US.properties new file mode 100644 index 00000000..b4cdd6d2 --- /dev/null +++ b/games/x-pet/src/main/resources/locale/pet_en_US.properties @@ -0,0 +1,3 @@ +# 文件Dorian_en_US.properties,是美国地区的资源束 +# 它覆盖了默认资源束 +Title=pet \ No newline at end of file diff --git "a/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2210.gif" "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2210.gif" new file mode 100644 index 00000000..78c27cd1 Binary files /dev/null and "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2210.gif" differ diff --git "a/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2211.gif" "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2211.gif" new file mode 100644 index 00000000..f38a7c7e Binary files /dev/null and "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2211.gif" differ diff --git "a/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\22110.gif" "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\22110.gif" new file mode 100644 index 00000000..27c40d36 Binary files /dev/null and "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\22110.gif" differ diff --git "a/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\22111.gif" "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\22111.gif" new file mode 100644 index 00000000..f892c0b0 Binary files /dev/null and "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\22111.gif" differ diff --git "a/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2212.gif" "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2212.gif" new file mode 100644 index 00000000..a2e58441 Binary files /dev/null and "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2212.gif" differ diff --git "a/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2213.gif" "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2213.gif" new file mode 100644 index 00000000..240e3b9f Binary files /dev/null and "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2213.gif" differ diff --git "a/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2214.gif" "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2214.gif" new file mode 100644 index 00000000..5a000e7d Binary files /dev/null and "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2214.gif" differ diff --git "a/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2215.gif" "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2215.gif" new file mode 100644 index 00000000..4ac30c93 Binary files /dev/null and "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2215.gif" differ diff --git "a/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2216.gif" "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2216.gif" new file mode 100644 index 00000000..5418b5c3 Binary files /dev/null and "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2216.gif" differ diff --git "a/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2217.gif" "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2217.gif" new file mode 100644 index 00000000..aeb2ef76 Binary files /dev/null and "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2217.gif" differ diff --git "a/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2218.gif" "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2218.gif" new file mode 100644 index 00000000..d3cb5f4b Binary files /dev/null and "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2218.gif" differ diff --git "a/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2219.gif" "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2219.gif" new file mode 100644 index 00000000..6a7990b6 Binary files /dev/null and "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\2219.gif" differ diff --git "a/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\22199.gif" "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\22199.gif" new file mode 100644 index 00000000..f366e9d3 Binary files /dev/null and "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\22199.gif" differ diff --git "a/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\221w0.gif" "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\221w0.gif" new file mode 100644 index 00000000..c0df802d Binary files /dev/null and "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\221w0.gif" differ diff --git "a/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\221w1.gif" "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\221w1.gif" new file mode 100644 index 00000000..62ec45d5 Binary files /dev/null and "b/games/x-pet/src/main/resources/lxh/\347\275\227\345\260\217\351\273\221w1.gif" differ diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..7f93135c Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..1af9e093 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 00000000..1aa94a42 --- /dev/null +++ b/gradlew @@ -0,0 +1,249 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 00000000..93e3f59f --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git "a/images/Cron\350\241\250\350\276\276\345\274\217\347\224\237\346\210\220\345\231\250.gif" "b/images/Cron\350\241\250\350\276\276\345\274\217\347\224\237\346\210\220\345\231\250.gif" new file mode 100644 index 00000000..2477ca11 Binary files /dev/null and "b/images/Cron\350\241\250\350\276\276\345\274\217\347\224\237\346\210\220\345\231\250.gif" differ diff --git "a/images/Cron\350\241\250\350\276\276\345\274\217\347\224\237\346\210\220\345\231\250.png" "b/images/Cron\350\241\250\350\276\276\345\274\217\347\224\237\346\210\220\345\231\250.png" deleted file mode 100644 index 7c0c4c2c..00000000 Binary files "a/images/Cron\350\241\250\350\276\276\345\274\217\347\224\237\346\210\220\345\231\250.png" and /dev/null differ diff --git "a/images/Ftp\345\256\242\346\210\267\347\253\257\350\260\203\350\257\225\345\267\245\345\205\267.png" "b/images/Ftp\345\256\242\346\210\267\347\253\257\350\260\203\350\257\225\345\267\245\345\205\267.png" deleted file mode 100644 index 9836d178..00000000 Binary files "a/images/Ftp\345\256\242\346\210\267\347\253\257\350\260\203\350\257\225\345\267\245\345\205\267.png" and /dev/null differ diff --git "a/images/Http\350\260\203\350\257\225\345\267\245\345\205\267.png" "b/images/Http\350\260\203\350\257\225\345\267\245\345\205\267.png" deleted file mode 100644 index 2df037c3..00000000 Binary files "a/images/Http\350\260\203\350\257\225\345\267\245\345\205\267.png" and /dev/null differ diff --git "a/images/Mq\350\260\203\350\257\225\345\267\245\345\205\267.png" "b/images/Mq\350\260\203\350\257\225\345\267\245\345\205\267.png" deleted file mode 100644 index d548ab1b..00000000 Binary files "a/images/Mq\350\260\203\350\257\225\345\267\245\345\205\267.png" and /dev/null differ diff --git "a/images/Time\350\275\254\346\215\242.png" "b/images/Time\350\275\254\346\215\242.png" deleted file mode 100644 index aaa2ecd5..00000000 Binary files "a/images/Time\350\275\254\346\215\242.png" and /dev/null differ diff --git "a/images/json\346\240\274\345\274\217\345\214\226\347\274\226\350\276\221\345\267\245\345\205\267.gif" "b/images/json\346\240\274\345\274\217\345\214\226\347\274\226\350\276\221\345\267\245\345\205\267.gif" new file mode 100644 index 00000000..c1779fa6 Binary files /dev/null and "b/images/json\346\240\274\345\274\217\345\214\226\347\274\226\350\276\221\345\267\245\345\205\267.gif" differ diff --git "a/images/json\346\240\274\345\274\217\345\214\226\347\274\226\350\276\221\345\267\245\345\205\267.png" "b/images/json\346\240\274\345\274\217\345\214\226\347\274\226\350\276\221\345\267\245\345\205\267.png" index 352c7830..f2fa29dc 100644 Binary files "a/images/json\346\240\274\345\274\217\345\214\226\347\274\226\350\276\221\345\267\245\345\205\267.png" and "b/images/json\346\240\274\345\274\217\345\214\226\347\274\226\350\276\221\345\267\245\345\205\267.png" differ diff --git "a/images/\344\272\214\347\273\264\347\240\201\347\224\237\346\210\220\345\267\245\345\205\267.gif" "b/images/\344\272\214\347\273\264\347\240\201\347\224\237\346\210\220\345\267\245\345\205\267.gif" new file mode 100644 index 00000000..1d2a80b2 Binary files /dev/null and "b/images/\344\272\214\347\273\264\347\240\201\347\224\237\346\210\220\345\267\245\345\205\267.gif" differ diff --git "a/images/\344\272\214\347\273\264\347\240\201\347\224\237\346\210\220\345\267\245\345\205\267.png" "b/images/\344\272\214\347\273\264\347\240\201\347\224\237\346\210\220\345\267\245\345\205\267.png" deleted file mode 100644 index 4fe5f37f..00000000 Binary files "a/images/\344\272\214\347\273\264\347\240\201\347\224\237\346\210\220\345\267\245\345\205\267.png" and /dev/null differ diff --git "a/images/\344\274\240\350\276\223\345\267\245\345\205\267.gif" "b/images/\344\274\240\350\276\223\345\267\245\345\205\267.gif" new file mode 100644 index 00000000..6900526b Binary files /dev/null and "b/images/\344\274\240\350\276\223\345\267\245\345\205\267.gif" differ diff --git "a/images/\345\212\240\345\257\206\350\247\243\345\257\206.gif" "b/images/\345\212\240\345\257\206\350\247\243\345\257\206.gif" new file mode 100644 index 00000000..6c127511 Binary files /dev/null and "b/images/\345\212\240\345\257\206\350\247\243\345\257\206.gif" differ diff --git "a/images/\345\212\240\345\257\206\350\247\243\345\257\206.png" "b/images/\345\212\240\345\257\206\350\247\243\345\257\206.png" deleted file mode 100644 index b7ab3425..00000000 Binary files "a/images/\345\212\240\345\257\206\350\247\243\345\257\206.png" and /dev/null differ diff --git "a/images/\345\233\276\346\240\207\347\224\237\346\210\220\345\267\245\345\205\267.png" "b/images/\345\233\276\346\240\207\347\224\237\346\210\220\345\267\245\345\205\267.png" deleted file mode 100644 index 47fad06e..00000000 Binary files "a/images/\345\233\276\346\240\207\347\224\237\346\210\220\345\267\245\345\205\267.png" and /dev/null differ diff --git "a/images/\345\233\276\347\211\207\350\275\254\347\240\201\345\267\245\345\205\267.png" "b/images/\345\233\276\347\211\207\350\275\254\347\240\201\345\267\245\345\205\267.png" deleted file mode 100644 index 119dcd6a..00000000 Binary files "a/images/\345\233\276\347\211\207\350\275\254\347\240\201\345\267\245\345\205\267.png" and /dev/null differ diff --git "a/images/\345\255\227\347\254\246\344\270\262\350\275\254\346\215\242.png" "b/images/\345\255\227\347\254\246\344\270\262\350\275\254\346\215\242.png" deleted file mode 100644 index 0d4a75bc..00000000 Binary files "a/images/\345\255\227\347\254\246\344\270\262\350\275\254\346\215\242.png" and /dev/null differ diff --git "a/images/\346\226\207\344\273\266\345\244\215\345\210\266.png" "b/images/\346\226\207\344\273\266\345\244\215\345\210\266.png" deleted file mode 100644 index 64c0351b..00000000 Binary files "a/images/\346\226\207\344\273\266\345\244\215\345\210\266.png" and /dev/null differ diff --git "a/images/\346\226\207\344\273\266\347\274\226\347\240\201\346\243\200\346\265\213\345\267\245\345\205\267.png" "b/images/\346\226\207\344\273\266\347\274\226\347\240\201\346\243\200\346\265\213\345\267\245\345\205\267.png" new file mode 100644 index 00000000..e67cf505 Binary files /dev/null and "b/images/\346\226\207\344\273\266\347\274\226\347\240\201\346\243\200\346\265\213\345\267\245\345\205\267.png" differ diff --git "a/images/\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217\347\224\237\346\210\220\345\267\245\345\205\267.gif" "b/images/\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217\347\224\237\346\210\220\345\267\245\345\205\267.gif" new file mode 100644 index 00000000..9292b4f1 Binary files /dev/null and "b/images/\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217\347\224\237\346\210\220\345\267\245\345\205\267.gif" differ diff --git "a/images/\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217\347\224\237\346\210\220\345\267\245\345\205\267.png" "b/images/\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217\347\224\237\346\210\220\345\267\245\345\205\267.png" deleted file mode 100644 index 8ecd01f2..00000000 Binary files "a/images/\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217\347\224\237\346\210\220\345\267\245\345\205\267.png" and /dev/null differ diff --git "a/images/\347\214\234\346\225\260\345\255\227\346\270\270\346\210\217.png" "b/images/\347\214\234\346\225\260\345\255\227\346\270\270\346\210\217.png" new file mode 100644 index 00000000..046df2da Binary files /dev/null and "b/images/\347\214\234\346\225\260\345\255\227\346\270\270\346\210\217.png" differ diff --git "a/images/\347\274\226\347\240\201\346\243\200\346\265\213\345\267\245\345\205\267.gif" "b/images/\347\274\226\347\240\201\346\243\200\346\265\213\345\267\245\345\205\267.gif" new file mode 100644 index 00000000..d7774e12 Binary files /dev/null and "b/images/\347\274\226\347\240\201\346\243\200\346\265\213\345\267\245\345\205\267.gif" differ diff --git "a/images/\347\275\221\345\235\200\347\274\251\347\237\255.png" "b/images/\347\275\221\345\235\200\347\274\251\347\237\255.png" deleted file mode 100644 index 6a51e12c..00000000 Binary files "a/images/\347\275\221\345\235\200\347\274\251\347\237\255.png" and /dev/null differ diff --git "a/images/\350\275\254\344\271\211\345\255\227\347\254\246.png" "b/images/\350\275\254\344\271\211\345\255\227\347\254\246.png" deleted file mode 100644 index 785717c4..00000000 Binary files "a/images/\350\275\254\344\271\211\345\255\227\347\254\246.png" and /dev/null differ diff --git "a/images/\351\202\256\344\273\266\345\217\221\351\200\201\345\267\245\345\205\267.png" "b/images/\351\202\256\344\273\266\345\217\221\351\200\201\345\267\245\345\205\267.png" deleted file mode 100644 index b5244ebc..00000000 Binary files "a/images/\351\202\256\344\273\266\345\217\221\351\200\201\345\267\245\345\205\267.png" and /dev/null differ diff --git a/javaFxTools/x-JavaFxXmlToObjectCode/.gitignore b/javaFxTools/x-JavaFxXmlToObjectCode/.gitignore new file mode 100644 index 00000000..319c40bb --- /dev/null +++ b/javaFxTools/x-JavaFxXmlToObjectCode/.gitignore @@ -0,0 +1,6 @@ +# Default ignored files +#/.gitignore +/x-JavaFxXmlToObjectCode.iml +/log/ +/target/ +.idea \ No newline at end of file diff --git a/javaFxTools/x-JavaFxXmlToObjectCode/LICENSE b/javaFxTools/x-JavaFxXmlToObjectCode/LICENSE new file mode 100644 index 00000000..9e32cdef --- /dev/null +++ b/javaFxTools/x-JavaFxXmlToObjectCode/LICENSE @@ -0,0 +1,127 @@ + 木兰宽松许可证, 第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. diff --git a/javaFxTools/x-JavaFxXmlToObjectCode/README.md b/javaFxTools/x-JavaFxXmlToObjectCode/README.md new file mode 100644 index 00000000..386ecc5c --- /dev/null +++ b/javaFxTools/x-JavaFxXmlToObjectCode/README.md @@ -0,0 +1,21 @@ +JavaFxXmlToObjectCode javaFxFxml转换代码 + +#### 项目简介: +JavaFxXmlToObjectCode是使用javafx开发的一款javaFxFxml转换代码,根据.fxml文件生成相应的java代码,可生成插件模版。 + +**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) + +![javaFxFxml转换代码.png](images/javaFxFxml转换代码.png) + +#### 版本记录 +- 0.0.1 + 1. 完成基本功能配置(根据.fxml文件生成相应的java代码) +- 0.0.2 2020-04-19 + 1. 添加生成插件模版功能 diff --git a/javaFxTools/x-JavaFxXmlToObjectCode/README_EN.md b/javaFxTools/x-JavaFxXmlToObjectCode/README_EN.md new file mode 100644 index 00000000..6405b251 --- /dev/null +++ b/javaFxTools/x-JavaFxXmlToObjectCode/README_EN.md @@ -0,0 +1 @@ +JavaFxXmlToObjectCode \ No newline at end of file diff --git a/javaFxTools/x-JavaFxXmlToObjectCode/build.gradle b/javaFxTools/x-JavaFxXmlToObjectCode/build.gradle new file mode 100644 index 00000000..05958465 --- /dev/null +++ b/javaFxTools/x-JavaFxXmlToObjectCode/build.gradle @@ -0,0 +1,7 @@ +dependencies { + api project(':xcore') +} + +group = 'com.xwintop' +version = '0.0.2' +description = 'x-JavaFxXmlToObjectCode' diff --git "a/javaFxTools/x-JavaFxXmlToObjectCode/images/javaFxFxml\350\275\254\346\215\242\344\273\243\347\240\201.png" "b/javaFxTools/x-JavaFxXmlToObjectCode/images/javaFxFxml\350\275\254\346\215\242\344\273\243\347\240\201.png" new file mode 100644 index 00000000..0b17223c Binary files /dev/null and "b/javaFxTools/x-JavaFxXmlToObjectCode/images/javaFxFxml\350\275\254\346\215\242\344\273\243\347\240\201.png" differ diff --git a/javaFxTools/x-JavaFxXmlToObjectCode/src/main/java/com/xwintop/xJavaFxTool/JavaFxXmlToObjectCodeMain.java b/javaFxTools/x-JavaFxXmlToObjectCode/src/main/java/com/xwintop/xJavaFxTool/JavaFxXmlToObjectCodeMain.java new file mode 100644 index 00000000..a05953bc --- /dev/null +++ b/javaFxTools/x-JavaFxXmlToObjectCode/src/main/java/com/xwintop/xJavaFxTool/JavaFxXmlToObjectCodeMain.java @@ -0,0 +1,51 @@ +package com.xwintop.xJavaFxTool; + +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.stage.Stage; +import javafx.stage.WindowEvent; +import lombok.extern.slf4j.Slf4j; + +import java.net.URL; +import java.util.ResourceBundle; + +@Slf4j +public class JavaFxXmlToObjectCodeMain extends Application { + public static void main(String[] args) { + try { + launch(args); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void start(Stage primaryStage) throws Exception { + FXMLLoader fXMLLoader = JavaFxXmlToObjectCodeMain.getFXMLLoader(); + ResourceBundle resourceBundle = fXMLLoader.getResources(); + Parent root = fXMLLoader.load(); + primaryStage.setResizable(true); + primaryStage.setTitle(resourceBundle.getString("Title")); +// primaryStage.getIcons().add(new Image("/images/icon.jpg")); + double[] screenSize = JavaFxSystemUtil.getScreenSizeByScale(0.74, 0.8); + primaryStage.setScene(new Scene(root, screenSize[0], screenSize[1])); + primaryStage.show(); + primaryStage.setOnCloseRequest(new EventHandler() { + @Override + public void handle(WindowEvent event) { + System.exit(0); + } + }); + } + + public static FXMLLoader getFXMLLoader() { + ResourceBundle resourceBundle = ResourceBundle.getBundle("locale.JavaFxXmlToObjectCode"); + URL url = Object.class.getResource("/com/xwintop/xJavaFxTool/fxmlView/javaFxTools/JavaFxXmlToObjectCode.fxml"); + FXMLLoader fXMLLoader = new FXMLLoader(url, resourceBundle); + return fXMLLoader; + } +} \ No newline at end of file diff --git a/javaFxTools/x-JavaFxXmlToObjectCode/src/main/java/com/xwintop/xJavaFxTool/controller/javaFxTools/JavaFxXmlToObjectCodeController.java b/javaFxTools/x-JavaFxXmlToObjectCode/src/main/java/com/xwintop/xJavaFxTool/controller/javaFxTools/JavaFxXmlToObjectCodeController.java new file mode 100644 index 00000000..aa1d3a59 --- /dev/null +++ b/javaFxTools/x-JavaFxXmlToObjectCode/src/main/java/com/xwintop/xJavaFxTool/controller/javaFxTools/JavaFxXmlToObjectCodeController.java @@ -0,0 +1,88 @@ +package com.xwintop.xJavaFxTool.controller.javaFxTools; + +import com.xwintop.xJavaFxTool.services.javaFxTools.JavaFxXmlToObjectCodeService; +import com.xwintop.xJavaFxTool.view.javaFxTools.JavaFxXmlToObjectCodeView; +import com.xwintop.xcore.util.javafx.FileChooserUtil; +import com.xwintop.xcore.util.javafx.JavaFxViewUtil; +import com.xwintop.xcore.util.javafx.TooltipUtil; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.TextArea; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; + +import java.io.File; +import java.net.URL; +import java.util.ResourceBundle; + +/** + * @ClassName: JavaFxXmlToObjectCodeController + * @Description: javaFx Xml转对象工具 + * @author: xufeng + * @date: 2019/4/25 0025 23:24 + */ + +@Getter +@Setter +@Slf4j +public class JavaFxXmlToObjectCodeController extends JavaFxXmlToObjectCodeView { + private JavaFxXmlToObjectCodeService javaFxXmlToObjectCodeService = new JavaFxXmlToObjectCodeService(this); + + @Override + public void initialize(URL location, ResourceBundle resources) { + initView(); + initEvent(); + initService(); + } + + private void initView() { + } + + private void initEvent() { + FileChooserUtil.setOnDrag(codeFileOutputPathTextField, FileChooserUtil.FileType.FOLDER); + } + + private void initService() { + } + + @FXML + private void xmlToCodeOnAction(ActionEvent event) throws Exception { + if (StringUtils.isEmpty(textArea1.getText())) { + TooltipUtil.showToast("请输入fxml内容!"); + return; + } + String[] string = javaFxXmlToObjectCodeService.xmlToCode(textArea1.getText()); + textArea2.setText(string[0]); + textArea3.setText(string[1]); + textArea4.setText(string[2]); + } + + @FXML + private void buildCodeFileAction(ActionEvent event) throws Exception { + javaFxXmlToObjectCodeService.buildCodeFileAction(); + } + + @FXML + private void showExampleCodeAction(ActionEvent event) throws Exception { + URL url = Object.class.getResource("/com/xwintop/xJavaFxTool/fxmlView/javaFxTools/JavaFxXmlToObjectCode.fxml"); + TextArea textArea = new TextArea(FileUtils.readFileToString(new File(url.toURI()), "utf-8")); + textArea.setWrapText(true); + JavaFxViewUtil.openNewWindow("JavaFxXmlToObjectCode.fxml", textArea); + } + + @FXML + private void buildPluginProjectAction(ActionEvent event) throws Exception { + javaFxXmlToObjectCodeService.buildPluginProjectAction(); + } + + @FXML + private void selectCodeFileOutputPathAction(ActionEvent event) throws Exception { + File file = FileChooserUtil.chooseDirectory(); + if (file != null) { + codeFileOutputPathTextField.setText(file.getPath()); + } + } +} diff --git a/javaFxTools/x-JavaFxXmlToObjectCode/src/main/java/com/xwintop/xJavaFxTool/services/javaFxTools/JavaFxXmlToObjectCodeService.java b/javaFxTools/x-JavaFxXmlToObjectCode/src/main/java/com/xwintop/xJavaFxTool/services/javaFxTools/JavaFxXmlToObjectCodeService.java new file mode 100644 index 00000000..b398cbcf --- /dev/null +++ b/javaFxTools/x-JavaFxXmlToObjectCode/src/main/java/com/xwintop/xJavaFxTool/services/javaFxTools/JavaFxXmlToObjectCodeService.java @@ -0,0 +1,210 @@ +package com.xwintop.xJavaFxTool.services.javaFxTools; + +import cn.hutool.core.util.StrUtil; +import com.xwintop.xJavaFxTool.controller.javaFxTools.JavaFxXmlToObjectCodeController; +import com.xwintop.xJavaFxTool.utils.PluginProgectPomBuildTool; +import com.xwintop.xcore.util.javafx.AlertUtil; +import com.xwintop.xcore.util.javafx.TooltipUtil; +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.dom4j.*; + +import java.io.File; +import java.util.List; + +/** + * @ClassName: JavaFxXmlToObjectCodeService + * @Description: JavaFxXml生成代码工具类 + * @author: xufeng + * @date: 2017年11月10日 下午5:41:35 + */ + +@Getter +@Setter +@Slf4j +public class JavaFxXmlToObjectCodeService { + private JavaFxXmlToObjectCodeController javaFxXmlToObjectCodeController; + + public JavaFxXmlToObjectCodeService(JavaFxXmlToObjectCodeController javaFxXmlToObjectCodeController) { + this.javaFxXmlToObjectCodeController = javaFxXmlToObjectCodeController; + } + + //将转换后代码存放至文件中 + public void buildCodeFileAction() throws Exception { + if (StringUtils.isEmpty(javaFxXmlToObjectCodeController.getTextArea1().getText())) { + TooltipUtil.showToast("请输入fxml内容!"); + return; + } + String[] codeStrings = xmlToCode(javaFxXmlToObjectCodeController.getTextArea1().getText()); + String codeFileOutputPath = StringUtils.defaultIfEmpty(javaFxXmlToObjectCodeController.getCodeFileOutputPathTextField().getText(), "./executor"); + File controllerFile = new File(codeFileOutputPath, codeStrings[3] + "Controller.java"); + FileUtils.writeStringToFile(controllerFile, codeStrings[0], "utf-8"); + File viewFile = new File(codeFileOutputPath, codeStrings[3] + "View.java"); + FileUtils.writeStringToFile(viewFile, codeStrings[1], "utf-8"); + File serviceFile = new File(codeFileOutputPath, codeStrings[3] + "Service.java"); + FileUtils.writeStringToFile(serviceFile, codeStrings[2], "utf-8"); + TooltipUtil.showToast("生成代码成功,存放在:" + controllerFile.getAbsolutePath()); + } + + //将转换后代码加上插件结构存放至文件中 + public void buildPluginProjectAction() throws Exception { + if (StringUtils.isEmpty(javaFxXmlToObjectCodeController.getTextArea1().getText())) { + TooltipUtil.showToast("请输入fxml内容!"); + return; + } + String[] codeStrings = xmlToCode(javaFxXmlToObjectCodeController.getTextArea1().getText()); + String codeFileOutputPath = StringUtils.defaultIfEmpty(javaFxXmlToObjectCodeController.getCodeFileOutputPathTextField().getText(), "./executor"); + String projectTypeName = StringUtils.defaultIfEmpty(javaFxXmlToObjectCodeController.getProjectTypeNameTextField().getText(), "javaFxTools"); + codeFileOutputPath = StringUtils.appendIfMissing(codeFileOutputPath, "/", "/", "\\"); + String pluginProgectName = StringUtils.defaultIfEmpty(javaFxXmlToObjectCodeController.getProjectNameTextField().getText(), "testJavaFx"); + if (codeStrings != null) { + pluginProgectName = codeStrings[3]; + projectTypeName = codeStrings[4]; + } + String pluginProgectPath = codeFileOutputPath + "x-" + pluginProgectName; + File pluginProgectNameFile = new File(pluginProgectPath); + if (pluginProgectNameFile.exists()) { + boolean isTrue = AlertUtil.showConfirmAlert("该项目已经存在,是否覆盖代码?"); + if (!isTrue) { + return; + } + } + pluginProgectNameFile.mkdirs(); + String resources = "resources/com/xwintop/xJavaFxTool/"; +// String xmlPath = "javaFxTools/"; + String srcPath = "java/com/xwintop/xJavaFxTool/"; + pluginProgectPath = pluginProgectPath + "/src/main/"; + + if (StringUtils.isNotEmpty(javaFxXmlToObjectCodeController.getTextArea1().getText())) { + File controllerFile = new File(pluginProgectPath + srcPath + "controller/" + projectTypeName, codeStrings[3] + "Controller.java"); + FileUtils.writeStringToFile(controllerFile, codeStrings[0], "utf-8"); + File viewFile = new File(pluginProgectPath + srcPath + "view/" + projectTypeName, codeStrings[3] + "View.java"); + FileUtils.writeStringToFile(viewFile, codeStrings[1], "utf-8"); + File serviceFile = new File(pluginProgectPath + srcPath + "services/" + projectTypeName, codeStrings[3] + "Service.java"); + FileUtils.writeStringToFile(serviceFile, codeStrings[2], "utf-8"); + File fxmlFile = new File(pluginProgectPath + resources + "fxmlView/" + projectTypeName, codeStrings[3] + ".fxml"); + FileUtils.writeStringToFile(fxmlFile, javaFxXmlToObjectCodeController.getTextArea1().getText(), "utf-8"); + TooltipUtil.showToast("生成代码成功,存放在:" + controllerFile.getAbsolutePath()); + } + + FileUtils.writeStringToFile(new File(pluginProgectNameFile, "pom.xml"), PluginProgectPomBuildTool.getPom_xml(pluginProgectName), "utf-8"); + FileUtils.writeStringToFile(new File(pluginProgectNameFile, "README.md"), pluginProgectName, "utf-8"); + FileUtils.writeStringToFile(new File(pluginProgectNameFile, "README_EN.md"), pluginProgectName, "utf-8"); + FileUtils.writeStringToFile(new File(pluginProgectNameFile, ".gitignore"), PluginProgectPomBuildTool.getGitignore(pluginProgectName), "utf-8"); + FileUtils.writeStringToFile(new File(pluginProgectPath + srcPath + pluginProgectName + "Main.java"), PluginProgectPomBuildTool.getMain_java(pluginProgectName, projectTypeName), "utf-8"); + new File(pluginProgectPath + srcPath + "job").mkdirs(); + new File(pluginProgectPath + srcPath + "manager").mkdirs(); + new File(pluginProgectPath + srcPath + "model").mkdirs(); + new File(pluginProgectPath + srcPath + "utils").mkdirs(); + + FileUtils.writeStringToFile(new File(pluginProgectPath + "resources/config/toolFxmlLoaderConfiguration.xml"), PluginProgectPomBuildTool.getToolFxmlLoaderConfiguration_xml(pluginProgectName, projectTypeName), "utf-8"); + FileUtils.writeStringToFile(new File(pluginProgectPath + "resources/locale/" + pluginProgectName + ".properties"), PluginProgectPomBuildTool.getLocal_properties(pluginProgectName), "utf-8"); + FileUtils.writeStringToFile(new File(pluginProgectPath + "resources/locale/" + pluginProgectName + "_en_US.properties"), PluginProgectPomBuildTool.getLocal_en_US_properties(pluginProgectName), "utf-8"); + + } + + //将fxml文件转换为java代码 + public String[] xmlToCode(String xmlStr) throws Exception { + StringBuilder attrStrBuilder = new StringBuilder();// 创建属性值获取 + StringBuilder funStrBuilder = new StringBuilder();// 创建方法值获取 + StringBuilder classNameStrBuilder = new StringBuilder();// 创建类值获取 + Document document = DocumentHelper.parseText(xmlStr); + Element root = document.getRootElement(); + getCodeByElement(root, attrStrBuilder, funStrBuilder, classNameStrBuilder); + + String[] packageString = classNameStrBuilder.toString().split("controller"); + + String[] packageStringSplit = packageString[1].split("\\."); + String classNameString = packageStringSplit[packageStringSplit.length - 1].split("Controller")[0]; + String classNameStringLoCase = StrUtil.upperFirst(classNameString); + String viewPackage = packageString[1].substring(0, packageString[1].lastIndexOf(".")); + + StringBuilder controllerClassStrBuilder = new StringBuilder();//控制层类字符串 + controllerClassStrBuilder.append("package com.xwintop.xJavaFxTool.controller" + viewPackage + ";\n"); + controllerClassStrBuilder.append("import com.xwintop.xJavaFxTool.view" + viewPackage + "." + classNameString + "View;\n"); + controllerClassStrBuilder.append("import com.xwintop.xJavaFxTool.services" + viewPackage + "." + classNameString + "Service;\n"); + controllerClassStrBuilder.append("import lombok.Getter;\n"); + controllerClassStrBuilder.append("import lombok.Setter;\n"); + controllerClassStrBuilder.append("import lombok.extern.slf4j.Slf4j;\n"); + controllerClassStrBuilder.append("import java.net.URL;\n"); + controllerClassStrBuilder.append("import java.util.ResourceBundle;\n"); + controllerClassStrBuilder.append("import javafx.event.ActionEvent;\n"); + controllerClassStrBuilder.append("import javafx.fxml.FXML;\n"); + controllerClassStrBuilder.append("@Getter\n@Setter\n@Slf4j\n"); + controllerClassStrBuilder.append("public class " + classNameString + "Controller extends " + classNameString + "View {\n"); + controllerClassStrBuilder.append("private " + classNameString + "Service " + classNameStringLoCase + "Service = new " + classNameString + "Service(this);\n"); +// @Override +// public void initialize(URL location, ResourceBundle resources) { +// } + controllerClassStrBuilder.append("\n@Override\npublic void initialize(URL location, ResourceBundle resources) {\n"); + controllerClassStrBuilder.append("initView();\n"); + controllerClassStrBuilder.append("initEvent();\n"); + controllerClassStrBuilder.append("initService();\n"); + controllerClassStrBuilder.append("}"); + controllerClassStrBuilder.append("\n private void initView() {}"); + controllerClassStrBuilder.append("\n private void initEvent() {}"); + controllerClassStrBuilder.append("\n private void initService() {}"); + controllerClassStrBuilder.append(funStrBuilder.toString()); + controllerClassStrBuilder.append("}"); + + + StringBuilder classStrBuilder = new StringBuilder();//视图view类字符串 + classStrBuilder.append("package com.xwintop.xJavaFxTool.view" + viewPackage + ";\n"); + classStrBuilder.append("import lombok.Getter;\n"); + classStrBuilder.append("import lombok.Setter;\n"); + classStrBuilder.append("import javafx.fxml.Initializable;\n"); + classStrBuilder.append("import javafx.fxml.FXML;\n"); + List importList = document.content(); + for (Node node : importList) { + if ("import".equals(node.getName())) { + classStrBuilder.append("import " + node.getText() + ";\n"); + } + } + classStrBuilder.append("@Getter\n@Setter\n"); + classStrBuilder.append("public abstract class " + classNameString + "View implements Initializable {\n"); + classStrBuilder.append(attrStrBuilder.toString()); + classStrBuilder.append("\n}"); + + StringBuilder serviceClassStrBuilder = new StringBuilder();//控制层类字符串 + serviceClassStrBuilder.append("package com.xwintop.xJavaFxTool.services" + viewPackage + ";\n"); + serviceClassStrBuilder.append("import com.xwintop.xJavaFxTool.controller" + viewPackage + "." + classNameString + "Controller;\n"); + serviceClassStrBuilder.append("import lombok.Getter;\n"); + serviceClassStrBuilder.append("import lombok.Setter;\n"); + serviceClassStrBuilder.append("import lombok.extern.slf4j.Slf4j;\n"); + serviceClassStrBuilder.append("@Getter\n@Setter\n@Slf4j\n"); + serviceClassStrBuilder.append("public class " + classNameString + "Service{\n"); + serviceClassStrBuilder.append("private " + classNameString + "Controller " + classNameStringLoCase + "Controller;\n"); + serviceClassStrBuilder.append("public " + classNameString + "Service(" + classNameString + "Controller " + classNameStringLoCase + "Controller) {\n"); + serviceClassStrBuilder.append("this." + classNameStringLoCase + "Controller = " + classNameStringLoCase + "Controller;\n}\n"); + serviceClassStrBuilder.append("}"); + + return new String[]{controllerClassStrBuilder.toString(), classStrBuilder.toString(), serviceClassStrBuilder.toString(), classNameString, viewPackage.substring(1)}; + } + + private void getCodeByElement(Element root, StringBuilder attrStrBuilder, StringBuilder funStrBuilder, StringBuilder classNameStrBuilder) { + List rootAttrList = root.attributes(); + for (Attribute rootAttr : rootAttrList) { + if ("id".equals(rootAttr.getName())) { +// @FXML +// private TextField textField1; + attrStrBuilder.append("@FXML\nprotected "); + attrStrBuilder.append(root.getName()).append(" "); + attrStrBuilder.append(rootAttr.getValue()).append(";\n"); + } else if ("onAction".equals(rootAttr.getName())) { +// @FXML +// private void xmlToSql(ActionEvent event){} + funStrBuilder.append("\n@FXML\nprivate void "); + funStrBuilder.append(rootAttr.getValue().substring(1)).append("(ActionEvent event){\n}\n"); + } else if ("controller".equals(rootAttr.getName())) { + classNameStrBuilder.append(rootAttr.getValue()); + } + } + List rootElementList = root.elements(); + for (Element rootElement : rootElementList) { + getCodeByElement(rootElement, attrStrBuilder, funStrBuilder, classNameStrBuilder); + } + } +} diff --git a/javaFxTools/x-JavaFxXmlToObjectCode/src/main/java/com/xwintop/xJavaFxTool/utils/PluginProgectPomBuildTool.java b/javaFxTools/x-JavaFxXmlToObjectCode/src/main/java/com/xwintop/xJavaFxTool/utils/PluginProgectPomBuildTool.java new file mode 100644 index 00000000..3563d69e --- /dev/null +++ b/javaFxTools/x-JavaFxXmlToObjectCode/src/main/java/com/xwintop/xJavaFxTool/utils/PluginProgectPomBuildTool.java @@ -0,0 +1,205 @@ +package com.xwintop.xJavaFxTool.utils; + +/** + * @ClassName: PluginProgectPomBuildTool + * @Description: 插件项目生成模版 + * @author: xufeng + * @date: 2020/4/9 17:05 + */ + +public class PluginProgectPomBuildTool { + public static String getPom_xml(String projectName) { + return "\n" + + "\t4.0.0\n" + + "\n" + + "\tcom.xwintop\n" + + "\tx-" + projectName + "\n" + + "\t0.0.1\n" + + "\tjar\n" + + "\tx-" + projectName + "\n" + + "\n" + + "\t\n" + + "\t\tUTF-8\n" + + "\t\n" + + "\n" + + "\t\n" + + "\t\t\n" + + "\t\t\taliyunmaven\n" + + "\t\t\thttp://maven.aliyun.com/nexus/content/groups/public/\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\txwintop-maven\n" + + "\t\t\thttps://864381832.github.io/maven/repository\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\tspring-snapshots\n" + + "\t\t\thttp://repo.spring.io/snapshot\n" + + "\t\t\t\n" + + "\t\t\t\ttrue\n" + + "\t\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\tspring-milestones\n" + + "\t\t\thttp://repo.spring.io/milestone\n" + + "\t\t\n" + + "\t\n" + + "\n" + + "\t\n" + + "\t\t\n" + + "\t\t\tjunit\n" + + "\t\t\tjunit\n" + + "\t\t\t4.12\n" + + "\t\t\ttest\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\tcom.xwintop\n" + + "\t\t\txcore\n" + + "\t\t\t0.0.6\n" + + "\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\torg.projectlombok\n" + + "\t\t\tlombok\n" + + "\t\t\t1.18.12\n" + + "\t\t\tprovided\n" + + "\t\t\n" + + "\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\t\n" + + "\t\t\t\n" + + "\t\t\t\torg.apache.maven.plugins\n" + + "\t\t\t\tmaven-assembly-plugin\n" + + "\t\t\t\t2.5.5\n" + + "\t\t\t\t\n" + + "\t\t\t\t\tfalse\n" + + "\t\t\t\t\tutf-8\n" + + "\t\t\t\t\t\n" + + "\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\tcom.xwintop.xJavaFxTool." + projectName + "Main\n" + + "\t\t\t\t\t\t\n" + + "\t\t\t\t\t\n" + + "\t\t\t\t\t\n" + + "\t\t\t\t\t\tjar-with-dependencies\n" + + "\t\t\t\t\t\n" + + "\t\t\t\t\n" + + "\t\t\t\t\n" + + "\t\t\t\t\t\n" + + "\t\t\t\t\t\tmake-assembly\n" + + "\t\t\t\t\t\tpackage\n" + + "\t\t\t\t\t\t\n" + + "\t\t\t\t\t\t\tsingle\n" + + "\t\t\t\t\t\t\n" + + "\t\t\t\t\t\n" + + "\t\t\t\t\n" + + "\t\t\t\n" + + "\t\t\n" + + "\t\n" + + "\n"; + } + + public static String getGitignore(String projectName) { + return "# Default ignored files\n" + + "#/.gitignore\n" + + "/x-" + projectName + ".iml\n" + + "/log/\n" + + "/target/\n"+ + ".idea"; + } + + public static String getMain_java(String projectName, String xmlPath) { + return "package com.xwintop.xJavaFxTool;\n" + + "\n" + + "import com.xwintop.xcore.util.javafx.JavaFxSystemUtil;\n" + + "import javafx.application.Application;\n" + + "import javafx.event.EventHandler;\n" + + "import javafx.fxml.FXMLLoader;\n" + + "import javafx.scene.Parent;\n" + + "import javafx.scene.Scene;\n" + + "import javafx.stage.Stage;\n" + + "import javafx.stage.WindowEvent;\n" + + "import lombok.extern.slf4j.Slf4j;\n" + + "\n" + + "import java.net.URL;\n" + + "import java.util.ResourceBundle;\n" + + "\n" + + "@Slf4j\n" + + "public class " + projectName + "Main extends Application {\n" + + " public static void main(String[] args) {\n" + + " try {\n" + + " launch(args);\n" + + " } catch (Exception e) {\n" + + " e.printStackTrace();\n" + + " }\n" + + " }\n" + + "\n" + + " @Override\n" + + " public void start(Stage primaryStage) throws Exception {\n" + + " FXMLLoader fXMLLoader = " + projectName + "Main.getFXMLLoader();\n" + + " ResourceBundle resourceBundle = fXMLLoader.getResources();\n" + + " Parent root = fXMLLoader.load();\n" + + " primaryStage.setResizable(true);\n" + + " primaryStage.setTitle(resourceBundle.getString(\"Title\"));\n" + + "// primaryStage.getIcons().add(new Image(\"/images/icon.jpg\"));\n" + + " double[] screenSize = JavaFxSystemUtil.getScreenSizeByScale(0.74, 0.8);\n" + + " primaryStage.setScene(new Scene(root, screenSize[0], screenSize[1]));\n" + + " primaryStage.show();\n" + + " primaryStage.setOnCloseRequest(new EventHandler() {\n" + + " @Override\n" + + " public void handle(WindowEvent event) {\n" + + " System.exit(0);\n" + + " }\n" + + " });\n" + + " }\n" + + "\n" + + " public static FXMLLoader getFXMLLoader() {\n" + + " ResourceBundle resourceBundle = ResourceBundle.getBundle(\"locale." + projectName + "\");\n" + + " URL url = Object.class.getResource(\"/com/xwintop/xJavaFxTool/fxmlView/" + xmlPath + "/" + projectName + ".fxml\");\n" + + " FXMLLoader fXMLLoader = new FXMLLoader(url, resourceBundle);\n" + + " return fXMLLoader;\n" + + " }\n" + + "}"; + } + + public static String getToolFxmlLoaderConfiguration_xml(String projectName, String xmlPath) { + return "\n" + + "\n" + + "\t\n" + + "\t\n" + + "\t\t/com/xwintop/xJavaFxTool/fxmlView/" + xmlPath + "/" + projectName + ".fxml\n" + + "\t\tlocale." + projectName + "\n" + + "\t\t\n" + + "\t\tTitle\n" + + "\t\t\n" + + "\t\t\n" + + "\t\tp-" + xmlPath + "\n" + + "\t\tNode\n" + + "\t\n" + + ""; + } + + public static String getPluginList_Json(String projectName, String xmlPath) { + return "{\n" + + " \"name\": \"" + projectName + "\",\n" + + " \"synopsis\": \"\",\n" + + " \"jarName\": \"x-" + projectName + "\",\n" + + " \"version\": \"0.0.1\",\n" + + " \"versionNumber\": 1,\n" + + " \"downloadUrl\": \"https://xwintop.gitee.io/xjavafxtool-plugin/plugin-libs/" + xmlPath + "x-" + projectName + "-0.0.1.jar\"\n" + + " },"; + } + + public static String getLocal_properties(String projectName) { + return "# Dorian.properties是默认的\"Dorian\"资源束文件。 \n" + + "# 作为中国人,我用自己的地区作为默认 \n" + + "Title=" + projectName; + } + + public static String getLocal_en_US_properties(String projectName) { + return "# 文件Dorian_en_US.properties,是美国地区的资源束 \n" + + "# 它覆盖了默认资源束 \n" + + "Title=" + projectName; + } +} diff --git a/javaFxTools/x-JavaFxXmlToObjectCode/src/main/java/com/xwintop/xJavaFxTool/view/javaFxTools/JavaFxXmlToObjectCodeView.java b/javaFxTools/x-JavaFxXmlToObjectCode/src/main/java/com/xwintop/xJavaFxTool/view/javaFxTools/JavaFxXmlToObjectCodeView.java new file mode 100644 index 00000000..80f1aa7b --- /dev/null +++ b/javaFxTools/x-JavaFxXmlToObjectCode/src/main/java/com/xwintop/xJavaFxTool/view/javaFxTools/JavaFxXmlToObjectCodeView.java @@ -0,0 +1,43 @@ +package com.xwintop.xJavaFxTool.view.javaFxTools; + +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.Button; +import javafx.scene.control.TextArea; +import javafx.scene.control.TextField; +import lombok.Getter; +import lombok.Setter; + +/** + * @ClassName: JavaFxXmlToObjectCodeView + * @Description: javafx代码生成工具 + * @author: xufeng + * @date: 2020/4/9 15:03 + */ + +@Getter +@Setter +public abstract class JavaFxXmlToObjectCodeView implements Initializable { + @FXML + protected TextArea textArea1; + @FXML + protected TextArea textArea2; + @FXML + protected TextArea textArea3; + @FXML + protected TextArea textArea4; + @FXML + protected Button xmlToCodeButton; + @FXML + protected Button buildCodeFileButton; + @FXML + protected Button buildPluginProjectButton; + @FXML + protected TextField projectTypeNameTextField; + @FXML + protected TextField projectNameTextField; + @FXML + protected TextField codeFileOutputPathTextField; + @FXML + protected Button selectCodeFileOutputPathButton; +} diff --git a/javaFxTools/x-JavaFxXmlToObjectCode/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/javaFxTools/JavaFxXmlToObjectCode.fxml b/javaFxTools/x-JavaFxXmlToObjectCode/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/javaFxTools/JavaFxXmlToObjectCode.fxml new file mode 100644 index 00000000..a6d7b7db --- /dev/null +++ b/javaFxTools/x-JavaFxXmlToObjectCode/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/javaFxTools/JavaFxXmlToObjectCode.fxml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/littleTools/x-SedentaryReminderTool/src/main/resources/config/toolFxmlLoaderConfiguration.xml b/littleTools/x-SedentaryReminderTool/src/main/resources/config/toolFxmlLoaderConfiguration.xml new file mode 100644 index 00000000..fd1f7809 --- /dev/null +++ b/littleTools/x-SedentaryReminderTool/src/main/resources/config/toolFxmlLoaderConfiguration.xml @@ -0,0 +1,14 @@ + + + + + /com/xwintop/xJavaFxTool/fxmlView/littleTools/SedentaryReminderTool.fxml + locale.SedentaryReminderTool + + Title + + + p-littleTools + Node + + \ No newline at end of file diff --git a/littleTools/x-SedentaryReminderTool/src/main/resources/locale/SedentaryReminderTool.properties b/littleTools/x-SedentaryReminderTool/src/main/resources/locale/SedentaryReminderTool.properties new file mode 100644 index 00000000..a82cc769 --- /dev/null +++ b/littleTools/x-SedentaryReminderTool/src/main/resources/locale/SedentaryReminderTool.properties @@ -0,0 +1,3 @@ +# 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=\u4E45\u5750\u63D0\u9192\u5DE5\u5177 \ No newline at end of file diff --git a/littleTools/x-SedentaryReminderTool/src/main/resources/locale/SedentaryReminderTool_en_US.properties b/littleTools/x-SedentaryReminderTool/src/main/resources/locale/SedentaryReminderTool_en_US.properties new file mode 100644 index 00000000..27bd30c5 --- /dev/null +++ b/littleTools/x-SedentaryReminderTool/src/main/resources/locale/SedentaryReminderTool_en_US.properties @@ -0,0 +1,3 @@ +# 文件Dorian_en_US.properties,是美国地区的资源束 +# 它覆盖了默认资源束 +Title=SedentaryReminderTool \ No newline at end of file diff --git a/littleTools/x-SmsTool/.gitignore b/littleTools/x-SmsTool/.gitignore new file mode 100644 index 00000000..b8a81862 --- /dev/null +++ b/littleTools/x-SmsTool/.gitignore @@ -0,0 +1,6 @@ +# Default ignored files +#/.gitignore +/x-SmsTool.iml +/log/ +/target/ +.idea \ No newline at end of file diff --git a/littleTools/x-SmsTool/LICENSE b/littleTools/x-SmsTool/LICENSE new file mode 100644 index 00000000..9e32cdef --- /dev/null +++ b/littleTools/x-SmsTool/LICENSE @@ -0,0 +1,127 @@ + 木兰宽松许可证, 第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. diff --git a/littleTools/x-SmsTool/README.md b/littleTools/x-SmsTool/README.md new file mode 100644 index 00000000..bc384ba4 --- /dev/null +++ b/littleTools/x-SmsTool/README.md @@ -0,0 +1,16 @@ +SmsTool 短信群发工具 + +#### 项目简介: +SmsTool是使用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) diff --git a/littleTools/x-SmsTool/README_EN.md b/littleTools/x-SmsTool/README_EN.md new file mode 100644 index 00000000..a1fa7994 --- /dev/null +++ b/littleTools/x-SmsTool/README_EN.md @@ -0,0 +1 @@ +SmsTool \ No newline at end of file diff --git a/littleTools/x-SmsTool/build.gradle b/littleTools/x-SmsTool/build.gradle new file mode 100644 index 00000000..e2a040e6 --- /dev/null +++ b/littleTools/x-SmsTool/build.gradle @@ -0,0 +1,7 @@ +dependencies { + api project(':xcore') +} + +group = 'com.xwintop' +version = '0.0.1' +description = 'x-SmsTool' diff --git "a/littleTools/x-SmsTool/images/\347\237\255\344\277\241\347\276\244\345\217\221\345\267\245\345\205\267.gif" "b/littleTools/x-SmsTool/images/\347\237\255\344\277\241\347\276\244\345\217\221\345\267\245\345\205\267.gif" new file mode 100644 index 00000000..dbc64411 Binary files /dev/null and "b/littleTools/x-SmsTool/images/\347\237\255\344\277\241\347\276\244\345\217\221\345\267\245\345\205\267.gif" differ diff --git "a/images/\347\237\255\344\277\241\347\276\244\345\217\221\345\267\245\345\205\267.png" "b/littleTools/x-SmsTool/images/\347\237\255\344\277\241\347\276\244\345\217\221\345\267\245\345\205\267.png" similarity index 100% rename from "images/\347\237\255\344\277\241\347\276\244\345\217\221\345\267\245\345\205\267.png" rename to "littleTools/x-SmsTool/images/\347\237\255\344\277\241\347\276\244\345\217\221\345\267\245\345\205\267.png" diff --git a/littleTools/x-SmsTool/src/main/java/com/xwintop/xJavaFxTool/SmsToolMain.java b/littleTools/x-SmsTool/src/main/java/com/xwintop/xJavaFxTool/SmsToolMain.java new file mode 100644 index 00000000..c2868438 --- /dev/null +++ b/littleTools/x-SmsTool/src/main/java/com/xwintop/xJavaFxTool/SmsToolMain.java @@ -0,0 +1,51 @@ +package com.xwintop.xJavaFxTool; + +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.stage.Stage; +import javafx.stage.WindowEvent; +import lombok.extern.slf4j.Slf4j; + +import java.net.URL; +import java.util.ResourceBundle; + +@Slf4j +public class SmsToolMain extends Application { + public static void main(String[] args) { + try { + launch(args); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void start(Stage primaryStage) throws Exception { + FXMLLoader fXMLLoader = SmsToolMain.getFXMLLoader(); + ResourceBundle resourceBundle = fXMLLoader.getResources(); + Parent root = fXMLLoader.load(); + primaryStage.setResizable(true); + primaryStage.setTitle(resourceBundle.getString("Title")); +// primaryStage.getIcons().add(new Image("/images/icon.jpg")); + double[] screenSize = JavaFxSystemUtil.getScreenSizeByScale(0.74D, 0.8D); + primaryStage.setScene(new Scene(root, screenSize[0], screenSize[1])); + primaryStage.show(); + primaryStage.setOnCloseRequest(new EventHandler() { + @Override + public void handle(WindowEvent event) { + System.exit(0); + } + }); + } + + public static FXMLLoader getFXMLLoader() { + ResourceBundle resourceBundle = ResourceBundle.getBundle("locale.SmsTool"); + URL url = Object.class.getResource("/com/xwintop/xJavaFxTool/fxmlView/littleTools/SmsTool.fxml"); + FXMLLoader fXMLLoader = new FXMLLoader(url, resourceBundle); + return fXMLLoader; + } +} \ No newline at end of file diff --git a/src/main/java/com/xwintop/xJavaFxTool/controller/littleTools/SmsToolController.java b/littleTools/x-SmsTool/src/main/java/com/xwintop/xJavaFxTool/controller/littleTools/SmsToolController.java similarity index 87% rename from src/main/java/com/xwintop/xJavaFxTool/controller/littleTools/SmsToolController.java rename to littleTools/x-SmsTool/src/main/java/com/xwintop/xJavaFxTool/controller/littleTools/SmsToolController.java index e592909f..ced4fdae 100644 --- a/src/main/java/com/xwintop/xJavaFxTool/controller/littleTools/SmsToolController.java +++ b/littleTools/x-SmsTool/src/main/java/com/xwintop/xJavaFxTool/controller/littleTools/SmsToolController.java @@ -1,32 +1,37 @@ package com.xwintop.xJavaFxTool.controller.littleTools; -import com.xwintop.xJavaFxTool.model.EmailToolTableBean; import com.xwintop.xJavaFxTool.model.SmsToolTableBean; import com.xwintop.xJavaFxTool.services.littleTools.SmsToolService; import com.xwintop.xJavaFxTool.view.littleTools.SmsToolView; -import com.xwintop.xcore.util.HttpClientUtil; +import com.xwintop.xcore.util.javafx.JavaFxSystemUtil; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Button; -import javafx.scene.control.TableColumn.CellEditEvent; import javafx.scene.control.ContentDisplay; import javafx.scene.control.TableCell; -import javafx.scene.control.TableColumn; +import javafx.scene.control.TableColumn.CellEditEvent; import javafx.scene.control.cell.CheckBoxTableCell; import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.control.cell.TextFieldTableCell; import lombok.Getter; import lombok.Setter; -import lombok.extern.log4j.Log4j; +import lombok.extern.slf4j.Slf4j; import java.net.URL; import java.util.ResourceBundle; +/** + * @ClassName: SmsToolController + * @Description: 短信群发工具 + * @author: xufeng + * @date: 2019/4/25 0025 23:26 + */ + @Getter @Setter -@Log4j +@Slf4j public class SmsToolController extends SmsToolView { private SmsToolService smsToolService = new SmsToolService(this); private ObservableList tableData = FXCollections.observableArrayList(); @@ -133,26 +138,26 @@ private void monyunSendAction(ActionEvent event) { @FXML private void registerAliyunAction(ActionEvent event) { - HttpClientUtil.openBrowseURL("https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=vt7aiwvr&utm_source=vt7aiwvr"); + JavaFxSystemUtil.openBrowseURL("https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=vt7aiwvr&utm_source=vt7aiwvr"); } @FXML private void registerCmccAction(ActionEvent event) { - HttpClientUtil.openBrowseURL("http://www.openservice.com.cn"); + JavaFxSystemUtil.openBrowseURL("http://www.openservice.com.cn"); } @FXML private void registerOpen189Action(ActionEvent event) { - HttpClientUtil.openBrowseURL("http://open.189.cn"); + JavaFxSystemUtil.openBrowseURL("http://open.189.cn"); } @FXML private void registerTencentAction(ActionEvent event) { - HttpClientUtil.openBrowseURL("https://cloud.tencent.com/redirect.php?redirect=1005&cps_key=f312970b0318dd604cd33405d2c6d697"); + JavaFxSystemUtil.openBrowseURL("https://cloud.tencent.com/redirect.php?redirect=1005&cps_key=f312970b0318dd604cd33405d2c6d697"); } @FXML private void registerMonyunAction(ActionEvent event) { - HttpClientUtil.openBrowseURL("http://www.monyun.cn/?rsdlx7ba"); + JavaFxSystemUtil.openBrowseURL("http://www.monyun.cn/?rsdlx7ba"); } } \ No newline at end of file diff --git a/src/main/java/com/xwintop/xJavaFxTool/model/SmsToolTableBean.java b/littleTools/x-SmsTool/src/main/java/com/xwintop/xJavaFxTool/model/SmsToolTableBean.java similarity index 100% rename from src/main/java/com/xwintop/xJavaFxTool/model/SmsToolTableBean.java rename to littleTools/x-SmsTool/src/main/java/com/xwintop/xJavaFxTool/model/SmsToolTableBean.java diff --git a/src/main/java/com/xwintop/xJavaFxTool/services/littleTools/SmsToolService.java b/littleTools/x-SmsTool/src/main/java/com/xwintop/xJavaFxTool/services/littleTools/SmsToolService.java similarity index 81% rename from src/main/java/com/xwintop/xJavaFxTool/services/littleTools/SmsToolService.java rename to littleTools/x-SmsTool/src/main/java/com/xwintop/xJavaFxTool/services/littleTools/SmsToolService.java index 3b5e93c5..9480ba1c 100644 --- a/src/main/java/com/xwintop/xJavaFxTool/services/littleTools/SmsToolService.java +++ b/littleTools/x-SmsTool/src/main/java/com/xwintop/xJavaFxTool/services/littleTools/SmsToolService.java @@ -1,18 +1,17 @@ package com.xwintop.xJavaFxTool.services.littleTools; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; +import cn.hutool.crypto.SecureUtil; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; import com.xwintop.xJavaFxTool.controller.littleTools.SmsToolController; import com.xwintop.xJavaFxTool.model.SmsToolTableBean; -import com.xwintop.xcore.util.HttpClientUtil; import com.xwintop.xcore.util.javafx.FileChooserUtil; import com.xwintop.xcore.util.javafx.TooltipUtil; import javafx.collections.ObservableList; import lombok.Getter; import lombok.Setter; -import lombok.extern.log4j.Log4j; -import org.apache.commons.codec.digest.DigestUtils; -import org.apache.commons.codec.digest.HmacUtils; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.StringUtils; @@ -21,9 +20,16 @@ import java.io.File; import java.util.*; +/** + * @ClassName: SmsToolService + * @Description: 短信群发工具 + * @author: xufeng + * @date: 2019/4/25 0025 23:35 + */ + @Getter @Setter -@Log4j +@Slf4j public class SmsToolService { private SmsToolController smsToolController; @@ -36,7 +42,7 @@ public void runAllAction() { } if (!smsToolTableBeanArrayList.isEmpty()) { runAction(smsToolTableBeanArrayList.toArray(new SmsToolTableBean[0])); - }else{ + } else { TooltipUtil.showToast("未选择联系人!!!"); } } @@ -74,10 +80,10 @@ public void cmccSendAction(SmsToolTableBean... smsToolTableBeans) { String needReceipt = smsToolController.getCmccNeedReceiptCheckBox().isSelected() ? "1" : "0";//是否回执 1:回执0:不回执 String message = smsToolController.getCmccMessageTextArea().getText(); String receiptNotificationURL = smsToolController.getCmccReceiptNotificationUrlTextField().getText();//回调地址 - for(SmsToolTableBean smsToolTableBean:smsToolTableBeans) { + for (SmsToolTableBean smsToolTableBean : smsToolTableBeans) { // String destAddr = "18356971618";//目标地址 String destAddr = smsToolTableBean.getToPhone();//目标地址 - Map map = new HashMap<>(); + Map map = new HashMap<>(); map.put("destAddr", destAddr); map.put("apiKey", apiKey); map.put("secretKey", secretKey); @@ -86,7 +92,8 @@ public void cmccSendAction(SmsToolTableBean... smsToolTableBeans) { if ("1".equals(needReceipt)) { map.put("receiptNotificationURL", receiptNotificationURL); } - String resJson = HttpClientUtil.getHttpDataByPost(url, "http://www.openservice.com.cn", JSON.toJSONString(map)); + String resJson = HttpUtil.post(url, map); +// String resJson = HttpClientUtil.getHttpDataByPost(url, "http://www.openservice.com.cn", JSON.toJSONString(map)); log.info("中国移动短信发送返回:" + resJson); if ("200".equals(JSON.parseObject(resJson).getString("resultCode"))) { TooltipUtil.showToast("中国移动发送短信成功!!!"); @@ -106,20 +113,20 @@ public void open189SendAction(SmsToolTableBean... smsToolTableBeans) { String template_id = smsToolController.getOpen189TemplateIdTextField().getText();//短信模板ID String template_param = smsToolController.getOpen189TemplateParamTextArea().getText();//模板匹配参数,参数格式为(json对象字符串): {参数名:参数值,参数名:参数值} - for(SmsToolTableBean smsToolTableBean:smsToolTableBeans) { + for (SmsToolTableBean smsToolTableBean : smsToolTableBeans) { // String acceptor_tel = "18356971618";//接收方号码 String acceptor_tel = smsToolTableBean.getToPhone();//接收方号码 String access_token = ""; - Map map = new HashMap<>(); + Map map = new HashMap<>(); map.put("app_id", app_id); map.put("app_secret", app_secret); map.put("grant_type", "client_credentials"); - String resJson = HttpClientUtil.getHttpDataByPost("https://oauth.api.189.cn/emp/oauth2/v3/access_token", "https://oauth.api.189.cn", map); +// String resJson = HttpClientUtil.getHttpDataByPost("https://oauth.api.189.cn/emp/oauth2/v3/access_token", "https://oauth.api.189.cn", map); + String resJson = HttpUtil.post("https://oauth.api.189.cn/emp/oauth2/v3/access_token", map); log.info("中国电信短信获取Token返回:" + resJson); access_token = JSON.parseObject(resJson).getString("access_token"); - String timestamp = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");//时间戳 - TreeMap map2 = new TreeMap<>(); + TreeMap map2 = new TreeMap<>(); map2.put("app_id", app_id); map2.put("access_token", access_token); map2.put("acceptor_tel", acceptor_tel); @@ -127,7 +134,8 @@ public void open189SendAction(SmsToolTableBean... smsToolTableBeans) { map2.put("template_param", template_param); map2.put("timestamp", timestamp); try { - resJson = HttpClientUtil.getHttpDataByPost(url, "http://api.189.cn", map2); +// resJson = HttpClientUtil.getHttpDataByPost(url, "http://api.189.cn", map2); + resJson = HttpUtil.post(url, map2); log.info("中国电信短信发送返回:" + resJson); String res_message = JSON.parseObject(resJson).getString("res_message"); if ("Success".equals(res_message)) { @@ -154,12 +162,12 @@ public void tencentSendAction(SmsToolTableBean... smsToolTableBeans) { String params = smsToolController.getTencentParamsTextArea().getText(); ArrayList phoneNumbers = new ArrayList(); // phoneNumbers.add("18356971618"); - for(SmsToolTableBean smsToolTableBean:smsToolTableBeans){ + for (SmsToolTableBean smsToolTableBean : smsToolTableBeans) { phoneNumbers.add(smsToolTableBean.getToPhone()); } try { - long random = RandomUtils.nextInt(0,999999)+100000; - long curTime = System.currentTimeMillis()/1000; + long random = RandomUtils.nextInt(0, 999999) + 100000; + long curTime = System.currentTimeMillis() / 1000; Map data = new HashMap(); ArrayList tel = new ArrayList(); @@ -169,35 +177,36 @@ public void tencentSendAction(SmsToolTableBean... smsToolTableBeans) { telElement.put("nationcode", "86"); telElement.put("mobile", phoneNumbers.get(i)); tel.add(telElement); - }while (++i phoneNumbers = new ArrayList(); - for(SmsToolTableBean smsToolTableBean:smsToolTableBeans){ + for (SmsToolTableBean smsToolTableBean : smsToolTableBeans) { phoneNumbers.add(smsToolTableBean.getToPhone()); } String accessKeyId = smsToolController.getAliyunAccessKeyIdTextField().getText(); @@ -222,13 +231,13 @@ public void aliyunSendAction(SmsToolTableBean... smsToolTableBeans) { paras.put("SignatureNonce", java.util.UUID.randomUUID().toString()); paras.put("AccessKeyId", accessKeyId); paras.put("SignatureVersion", "1.0"); - paras.put("Timestamp", DateFormatUtils.format(new Date(),"yyyy-MM-dd'T'HH:mm:ss'Z'",new SimpleTimeZone(0, "GMT"))); + paras.put("Timestamp", DateFormatUtils.format(new Date(), "yyyy-MM-dd'T'HH:mm:ss'Z'", new SimpleTimeZone(0, "GMT"))); paras.put("Format", "JSON"); // 2. 业务API参数 paras.put("Action", "SendSms"); paras.put("Version", "2017-05-25"); paras.put("RegionId", "cn-hangzhou"); - paras.put("PhoneNumbers", StringUtils.join(phoneNumbers,",")); + paras.put("PhoneNumbers", StringUtils.join(phoneNumbers, ",")); //必填:短信签名-可在短信控制台中找到 paras.put("SignName", signName); //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时 @@ -252,10 +261,11 @@ public void aliyunSendAction(SmsToolTableBean... smsToolTableBeans) { stringToSign.append("GET").append("&"); stringToSign.append(specialUrlEncode("/")).append("&"); stringToSign.append(specialUrlEncode(sortedQueryString)); - String sign = org.apache.commons.codec.binary.Base64.encodeBase64String(HmacUtils.hmacSha1(accessKeySecret + "&", stringToSign.toString())); + String sign = SecureUtil.hmacSha1(accessKeySecret + "&").digestBase64(stringToSign.toString(), false); String signature = specialUrlEncode(sign); String url = "http://dysmsapi.aliyuncs.com/?Signature=" + signature + sortQueryStringTmp; - String resJson = HttpClientUtil.getHttpDataAsUTF_8(url,url); +// String resJson = HttpClientUtil.getHttpDataAsUTF_8(url, url); + String resJson = HttpUtil.get(url); log.info("阿里云短信发送返回:" + resJson); if ("OK".equals(JSON.parseObject(resJson).getString("Code"))) { TooltipUtil.showToast("阿里云发送短信成功!!!"); @@ -264,14 +274,14 @@ public void aliyunSendAction(SmsToolTableBean... smsToolTableBeans) { } } catch (Exception e) { TooltipUtil.showToast("阿里云发送短信失败:" + e.getMessage()); - log.error("阿里云发送短信失败:"+e.getMessage()); + log.error("阿里云发送短信失败:" + e.getMessage()); } } /** * 梦网云通讯短信发送 */ - public void monyunSendAction(SmsToolTableBean... smsToolTableBeans){ + public void monyunSendAction(SmsToolTableBean... smsToolTableBeans) { try { String url = smsToolController.getMonyunUrlTextField().getText();//Url String userid = smsToolController.getMonyunUseridTextField().getText();//发送账号 @@ -283,34 +293,36 @@ public void monyunSendAction(SmsToolTableBean... smsToolTableBeans){ String svrtype = smsToolController.getMonyunSvrtypeTextField().getText();//业务类型 String exno = smsToolController.getMonyunExnoTextField().getText();//扩展号 ArrayList phoneNumbers = new ArrayList(); - for(SmsToolTableBean smsToolTableBean:smsToolTableBeans){ + for (SmsToolTableBean smsToolTableBean : smsToolTableBeans) { phoneNumbers.add(smsToolTableBean.getToPhone()); } Map params = new HashMap<>(); if (StringUtils.isBlank(apikey)) { - pwd = DigestUtils.md5Hex(userid.toUpperCase() + "00000000" + pwd + timestamp); + pwd = SecureUtil.md5(userid.toUpperCase() + "00000000" + pwd + timestamp); params.put("userid", userid.toUpperCase()); params.put("pwd", pwd); } else { params.put("apikey", apikey); } params.put("timestamp", timestamp); - params.put("mobile", StringUtils.join(phoneNumbers,",")); + params.put("mobile", StringUtils.join(phoneNumbers, ",")); params.put("content", java.net.URLEncoder.encode(content, "GBK")); params.put("svrtype", svrtype); params.put("exno", exno); - String resultStr = HttpClientUtil.getHttpDataByPost(url+"batch_send", url, JSON.toJSONString(params), "text/json; charset=utf-8"); - log.info("梦网云通讯短信发送返回:"+resultStr); - if(JSON.parseObject(resultStr).getInteger("result") == 0){ +// String resultStr = HttpClientUtil.getHttpDataByPost(url + "batch_send", url, JSON.toJSONString(params), "text/json; charset=utf-8"); + String resultStr = HttpUtil.post(url, params); + log.info("梦网云通讯短信发送返回:" + resultStr); + if (JSON.parseObject(resultStr).getInteger("result") == 0) { TooltipUtil.showToast("梦网云通讯发送短信成功!!!"); - }else{ - TooltipUtil.showToast("梦网云通讯发送短信失败:"+resultStr); + } else { + TooltipUtil.showToast("梦网云通讯发送短信失败:" + resultStr); } - }catch (Exception e){ - log.error(e.getMessage()); - TooltipUtil.showToast("梦网云通讯发送短信失败:"+e.getMessage()); + } catch (Exception e) { + log.error("梦网云通讯发送短信失败:", e); + TooltipUtil.showToast("梦网云通讯发送短信失败:" + e.getMessage()); } } + /** * 导入联系人号码 */ diff --git a/src/main/java/com/xwintop/xJavaFxTool/view/littleTools/SmsToolView.java b/littleTools/x-SmsTool/src/main/java/com/xwintop/xJavaFxTool/view/littleTools/SmsToolView.java similarity index 84% rename from src/main/java/com/xwintop/xJavaFxTool/view/littleTools/SmsToolView.java rename to littleTools/x-SmsTool/src/main/java/com/xwintop/xJavaFxTool/view/littleTools/SmsToolView.java index 5287cc2c..708bb7a9 100644 --- a/src/main/java/com/xwintop/xJavaFxTool/view/littleTools/SmsToolView.java +++ b/littleTools/x-SmsTool/src/main/java/com/xwintop/xJavaFxTool/view/littleTools/SmsToolView.java @@ -1,25 +1,11 @@ package com.xwintop.xJavaFxTool.view.littleTools; -import com.xwintop.xJavaFxTool.model.EmailToolTableBean; import com.xwintop.xJavaFxTool.model.SmsToolTableBean; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.*; import lombok.Getter; import lombok.Setter; -import javafx.fxml.Initializable; -import javafx.fxml.FXML; -import javafx.geometry.Insets; -import javafx.scene.control.Button; -import javafx.scene.control.CheckBox; -import javafx.scene.control.Label; -import javafx.scene.control.Tab; -import javafx.scene.control.TabPane; -import javafx.scene.control.TableColumn; -import javafx.scene.control.TableView; -import javafx.scene.control.TextArea; -import javafx.scene.control.TextField; -import javafx.scene.layout.AnchorPane; -import javafx.scene.layout.BorderPane; -import javafx.scene.layout.HBox; -import javafx.scene.layout.VBox; @Getter @Setter diff --git a/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/littleTools/SmsTool.fxml b/littleTools/x-SmsTool/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/littleTools/SmsTool.fxml similarity index 99% rename from src/main/resources/com/xwintop/xJavaFxTool/fxmlView/littleTools/SmsTool.fxml rename to littleTools/x-SmsTool/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/littleTools/SmsTool.fxml index f4d4f81c..9cdabb19 100644 --- a/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/littleTools/SmsTool.fxml +++ b/littleTools/x-SmsTool/src/main/resources/com/xwintop/xJavaFxTool/fxmlView/littleTools/SmsTool.fxml @@ -23,7 +23,7 @@