├── .gitattributes ├── .github ├── stale.yml └── workflows │ └── maven.yml ├── .gitignore ├── LICENSE ├── README.md ├── deploy.bat ├── pmd.xml ├── pom.xml ├── src ├── main │ └── java │ │ └── com │ │ └── nepxion │ │ └── banner │ │ ├── AbstractBanner.java │ │ ├── BannerConstant.java │ │ ├── Description.java │ │ ├── DescriptionBanner.java │ │ ├── LogoBanner.java │ │ ├── NepxionBanner.java │ │ └── VersionBanner.java └── test │ ├── java │ └── com │ │ └── nepxion │ │ └── banner │ │ └── test │ │ ├── BannerTest.java │ │ └── NepxionBannerTest.java │ └── resources │ └── com │ └── nepxion │ └── banner │ └── resource │ ├── logo-all.txt │ ├── logo-arthas.txt │ ├── logo-halo-1.txt │ ├── logo-halo-2.txt │ ├── logo-permission.txt │ └── version.txt └── version.bat /.gitattributes: -------------------------------------------------------------------------------- 1 | # Declare files that will always have UNIX line endings on checkout. 2 | *.sh text eol=lf -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # General configuration 2 | # Number of days of inactivity before an issue becomes stale 3 | daysUntilStale: 60 4 | # Issues with these labels will never be considered stale 5 | exemptLabels: 6 | - good first issue 7 | - contribution welcome 8 | - bug 9 | - discussion 10 | - enhancement 11 | - feature 12 | - feature request 13 | - help wanted 14 | - info 15 | - need investigation 16 | - tips 17 | 18 | # Set to true to ignore issues in a project (defaults to false) 19 | exemptProjects: true 20 | # Set to true to ignore issues in a milestone (defaults to false) 21 | exemptMilestones: true 22 | # Set to true to ignore issues with an assignee (defaults to false) 23 | exemptAssignees: true 24 | # Label to use when marking an issue as stale 25 | staleLabel: stale 26 | 27 | # Pull request specific configuration 28 | pulls: 29 | # Number of days of inactivity before a stale Issue or Pull Request is closed. 30 | # Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale. 31 | daysUntilClose: 30 32 | # Comment to post when marking as stale. Set to `false` to disable 33 | markComment: > 34 | This pull request has been automatically marked as stale because it has not had activity 35 | in the last 90 days. It will be closed in 30 days if no further activity occurs. Please 36 | feel free to give a status update now, ping for review, or re-open when it's ready. 37 | Thank you for your contributions! 38 | # Comment to post when closing a stale Issue or Pull Request. 39 | closeComment: > 40 | This pull request has been automatically closed because it has not had 41 | activity in the last 30 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. 42 | Thank you for your contributions! 43 | # Limit the number of actions per hour, from 1-30. Default is 30 44 | limitPerRun: 1 45 | 46 | # Issue specific configuration 47 | issues: 48 | # Number of days of inactivity before a stale Issue or Pull Request is closed. 49 | daysUntilClose: 14 50 | # Comment to post when marking as stale. Set to `false` to disable 51 | markComment: > 52 | This issue has been automatically marked as stale because it has not had activity in the 53 | last 90 days. It will be closed in 14 days unless it is tagged "help wanted" or other activity 54 | occurs. Thank you for your contributions. 55 | # Comment to post when closing a stale Issue or Pull Request. 56 | closeComment: > 57 | This issue has been automatically closed because it has not had activity in the 58 | last 14 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted". 59 | Thank you for your contributions. 60 | # Limit the number of actions per hour, from 1-30. Default is 30 61 | limitPerRun: 1 -------------------------------------------------------------------------------- /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven 3 | 4 | name: build 5 | 6 | on: 7 | push: 8 | branches: [ master ] 9 | pull_request: 10 | branches: [ master ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Set up JDK 8 20 | uses: actions/setup-java@v2 21 | with: 22 | java-version: '8' 23 | distribution: 'adopt' 24 | - name: Build with Maven 25 | run: mvn -B package --file pom.xml -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | .classpath 4 | .springBeans 5 | .factorypath 6 | # Mobile Tools for Java (J2ME) 7 | .mtj.tmp/ 8 | 9 | *.class 10 | *.classpath 11 | *.project 12 | *.springBeans 13 | bin/ 14 | log/ 15 | test-output/ 16 | 17 | # Package Files # 18 | *.jar 19 | *.war 20 | *.ear 21 | *.zip 22 | *.tar.gz 23 | *.rar 24 | *.swp 25 | *.log 26 | *.ctxt 27 | # nodejs local modules 28 | .tags* 29 | .idea/ 30 | *.iml 31 | .gradle/ 32 | .settings/ 33 | target/ 34 | hs_err_pid* -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Nepxion/Banner/254a9a1549ea9c5b015b336e55bad899c5268a8e/README.md -------------------------------------------------------------------------------- /deploy.bat: -------------------------------------------------------------------------------- 1 | @echo on 2 | @echo ============================================================= 3 | @echo $ $ 4 | @echo $ Nepxion Banner $ 5 | @echo $ $ 6 | @echo $ $ 7 | @echo $ $ 8 | @echo $ Nepxion Studio All Right Reserved $ 9 | @echo $ Copyright (C) 2017-2050 $ 10 | @echo $ $ 11 | @echo ============================================================= 12 | @echo. 13 | @echo off 14 | 15 | @title Nepxion Banner 16 | @color 0a 17 | 18 | call mvn clean deploy -DskipTests -e -P release 19 | 20 | pause -------------------------------------------------------------------------------- /pmd.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | Exclude noisy rules. 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | com.nepxion 5 | banner 6 | Nepxion Banner 7 | jar 8 | 4.0.0 9 | 1.0.2 10 | Nepxion Banner is a colorful banner display component 11 | http://www.nepxion.com 12 | 13 | 14 | 2.5 15 | 0.0.2 16 | 1.8 17 | UTF-8 18 | 19 | 20 | 21 | 22 | commons-io 23 | commons-io 24 | ${commons.io.version} 25 | 26 | 27 | 28 | com.taobao.text 29 | text-ui 30 | ${taobao.text.version} 31 | 32 | 33 | 34 | 35 | 36 | 37 | org.apache.maven.plugins 38 | maven-compiler-plugin 39 | 40 | ${project.build.sourceEncoding} 41 | ${java.version} 42 | ${java.version} 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | release 52 | 53 | 54 | 55 | org.sonatype.plugins 56 | nexus-staging-maven-plugin 57 | 1.6.3 58 | true 59 | 60 | oss 61 | https://oss.sonatype.org/ 62 | true 63 | 64 | 65 | 66 | org.apache.maven.plugins 67 | maven-gpg-plugin 68 | 1.6 69 | 70 | 71 | verify 72 | 73 | sign 74 | 75 | 76 | 77 | 78 | 79 | org.apache.maven.plugins 80 | maven-source-plugin 81 | 3.0.1 82 | 83 | 84 | package 85 | 86 | jar-no-fork 87 | 88 | 89 | 90 | 91 | 92 | org.apache.maven.plugins 93 | maven-javadoc-plugin 94 | 2.9.1 95 | 96 | 97 | package 98 | 99 | jar 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | oss 110 | https://oss.sonatype.org/content/repositories/snapshots/ 111 | 112 | 113 | oss 114 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | The Apache Software License, Version 2.0 123 | http://www.apache.org/licenses/LICENSE-2.0.txt 124 | 125 | 126 | 127 | 128 | https://github.com/Nepxion/Zxing 129 | scm:git:https://github.com/Nepxion/Zxing.git 130 | scm:git:https://github.com/Nepxion/Zxing.git 131 | v${project.version} 132 | 133 | 134 | 135 | Nepxion 136 | http://www.nepxion.com 137 | 138 | 139 | 140 | 141 | Haojun Ren 142 | 1394997@qq.com 143 | http://www.nepxion.com 144 | 145 | 146 | -------------------------------------------------------------------------------- /src/main/java/com/nepxion/banner/AbstractBanner.java: -------------------------------------------------------------------------------- 1 | package com.nepxion.banner; 2 | 3 | /** 4 | *

Title: Nepxion Banner

5 | *

Description: Nepxion Banner

6 | *

Copyright: Copyright (c) 2017-2050

7 | *

Company: Nepxion

8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import java.io.InputStream; 13 | 14 | import org.apache.commons.io.IOUtils; 15 | 16 | import com.taobao.text.util.RenderUtil; 17 | 18 | public abstract class AbstractBanner { 19 | // Resource类 20 | protected Class resourceClass; 21 | 22 | // Resource位置 23 | protected String resourceLocation; 24 | 25 | // 默认旗标文本 26 | protected String defaultBanner; 27 | 28 | // 最终旗标文本 29 | protected String banner; 30 | 31 | public AbstractBanner(Class resourceClass, String resourceLocation, String defaultBanner) { 32 | this.resourceClass = resourceClass; 33 | this.resourceLocation = resourceLocation; 34 | this.defaultBanner = defaultBanner; 35 | } 36 | 37 | protected void initialize() { 38 | InputStream inputStream = null; 39 | String bannerText = null; 40 | try { 41 | if (resourceLocation != null) { 42 | inputStream = resourceClass.getResourceAsStream(resourceLocation); 43 | bannerText = IOUtils.toString(inputStream, BannerConstant.ENCODING_UTF_8); 44 | } 45 | } catch (Exception e) { 46 | 47 | } finally { 48 | banner = generateBanner(bannerText); 49 | 50 | if (inputStream != null) { 51 | IOUtils.closeQuietly(inputStream); 52 | } 53 | } 54 | } 55 | 56 | public String getBanner() { 57 | return banner; 58 | } 59 | 60 | // 显示成非ansi模式 61 | public String getPlainBanner() { 62 | return RenderUtil.ansiToPlainText(banner); 63 | } 64 | 65 | protected abstract String generateBanner(String bannerText); 66 | } -------------------------------------------------------------------------------- /src/main/java/com/nepxion/banner/BannerConstant.java: -------------------------------------------------------------------------------- 1 | package com.nepxion.banner; 2 | 3 | /** 4 | *

Title: Nepxion Banner

5 | *

Description: Nepxion Banner

6 | *

Copyright: Copyright (c) 2017-2050

7 | *

Company: Nepxion

8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | public class BannerConstant { 13 | public static final String ENCODING_UTF_8 = "UTF-8"; 14 | 15 | public static final String BANNER_SHOWN = "nepxion.banner.shown"; 16 | public static final String BANNER_SHOWN_ANSI_MODE = "nepxion.banner.shown.ansi.mode"; 17 | public static final String VERSION = "Version"; 18 | public static final String PLUGIN = "Plugin"; 19 | public static final String SITE = "Site"; 20 | public static final String NEPXION_SITE = "http://www.nepxion.com"; 21 | public static final String GITHUB = "Github"; 22 | public static final String NEPXION_GITHUB = "https://github.com/Nepxion"; 23 | } -------------------------------------------------------------------------------- /src/main/java/com/nepxion/banner/Description.java: -------------------------------------------------------------------------------- 1 | package com.nepxion.banner; 2 | 3 | /** 4 | *

Title: Nepxion Banner

5 | *

Description: Nepxion Banner

6 | *

Copyright: Copyright (c) 2017-2050

7 | *

Company: Nepxion

8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | public class Description { 13 | private String name; 14 | private String description; 15 | private int leftCellPadding = 0; 16 | private int rightCellPadding = 1; 17 | 18 | public Description() { 19 | 20 | } 21 | 22 | public Description(String name, String description, int leftCellPadding, int rightCellPadding) { 23 | this.name = name; 24 | this.description = description; 25 | this.leftCellPadding = leftCellPadding; 26 | this.rightCellPadding = rightCellPadding; 27 | } 28 | 29 | public String getName() { 30 | return name; 31 | } 32 | 33 | public void setName(String name) { 34 | this.name = name; 35 | } 36 | 37 | public String getDescription() { 38 | return description; 39 | } 40 | 41 | public void setDescription(String description) { 42 | this.description = description; 43 | } 44 | 45 | public int getLeftCellPadding() { 46 | return leftCellPadding; 47 | } 48 | 49 | public void setLeftCellPadding(int leftCellPadding) { 50 | this.leftCellPadding = leftCellPadding; 51 | } 52 | 53 | public int getRightCellPadding() { 54 | return rightCellPadding; 55 | } 56 | 57 | public void setRightCellPadding(int rightCellPadding) { 58 | this.rightCellPadding = rightCellPadding; 59 | } 60 | } -------------------------------------------------------------------------------- /src/main/java/com/nepxion/banner/DescriptionBanner.java: -------------------------------------------------------------------------------- 1 | package com.nepxion.banner; 2 | 3 | /** 4 | *

Title: Nepxion Banner

5 | *

Description: Nepxion Banner

6 | *

Copyright: Copyright (c) 2017-2050

7 | *

Company: Nepxion

8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import java.util.List; 13 | 14 | import com.taobao.text.ui.TableElement; 15 | import com.taobao.text.util.RenderUtil; 16 | 17 | public class DescriptionBanner { 18 | public String getBanner(List descriptions) { 19 | TableElement table = new TableElement(); 20 | for (Description description : descriptions) { 21 | table.leftCellPadding(description.getLeftCellPadding()).rightCellPadding(description.getRightCellPadding()).row(description.getName(), description.getDescription()); 22 | } 23 | 24 | return RenderUtil.render(table); 25 | } 26 | } -------------------------------------------------------------------------------- /src/main/java/com/nepxion/banner/LogoBanner.java: -------------------------------------------------------------------------------- 1 | package com.nepxion.banner; 2 | 3 | /** 4 | *

Title: Nepxion Banner

5 | *

Description: Nepxion Banner

6 | *

Copyright: Copyright (c) 2017-2050

7 | *

Company: Nepxion

8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import static com.taobao.text.ui.Element.label; 13 | 14 | import com.taobao.text.Color; 15 | import com.taobao.text.Decoration; 16 | import com.taobao.text.ui.LabelElement; 17 | import com.taobao.text.ui.TableElement; 18 | import com.taobao.text.util.RenderUtil; 19 | 20 | public class LogoBanner extends AbstractBanner { 21 | // Logo元素的总个数 22 | private int elementCount; 23 | 24 | // Logo元素的单个占行数 25 | private int elementLineCount; 26 | 27 | // Logo元素的颜色数组 28 | private Color[] elementColors; 29 | 30 | // Logo字体是否发亮 31 | private boolean boldOff; 32 | 33 | public LogoBanner(Class resourceClass, String resourceLocation, String defaultBanner, int elementCount, int elementLineCount, Color[] elementColors, boolean boldOff) { 34 | super(resourceClass, resourceLocation, defaultBanner); 35 | 36 | this.elementCount = elementCount; 37 | this.elementLineCount = elementLineCount; 38 | this.elementColors = elementColors; 39 | this.boldOff = boldOff; 40 | 41 | initialize(); 42 | } 43 | 44 | @Override 45 | protected String generateBanner(String bannerText) { 46 | if (bannerText != null) { 47 | StringBuilder stringBuilder = new StringBuilder(); 48 | String[] elementTexts = new String[elementCount]; // Logo元素的总个数 49 | int i = 0, j = 0; 50 | for (String line : bannerText.split("\n")) { 51 | stringBuilder.append(line); 52 | stringBuilder.append("\n"); 53 | if (i++ == elementLineCount - 1) { // Logo元素的单个占行数减1 54 | elementTexts[j++] = stringBuilder.toString(); 55 | i = 0; 56 | stringBuilder.setLength(0); 57 | } 58 | } 59 | 60 | LabelElement[] labelElements = new LabelElement[elementCount]; 61 | for (int k = 0; k < elementCount; k++) { 62 | if (boldOff) { 63 | labelElements[k] = label(elementTexts[k]).style(Decoration.bold_off.fg(elementColors[k])); 64 | } else { 65 | labelElements[k] = label(elementTexts[k]).style(Decoration.bold.fg(elementColors[k])); 66 | } 67 | } 68 | 69 | TableElement tableElement = new TableElement(); 70 | tableElement.row(labelElements); 71 | 72 | return RenderUtil.render(tableElement); 73 | } else { 74 | return defaultBanner; 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /src/main/java/com/nepxion/banner/NepxionBanner.java: -------------------------------------------------------------------------------- 1 | package com.nepxion.banner; 2 | 3 | /** 4 | *

Title: Nepxion Banner

5 | *

Description: Nepxion Banner

6 | *

Copyright: Copyright (c) 2017-2050

7 | *

Company: Nepxion

8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | public class NepxionBanner { 16 | public static void show(LogoBanner logoBanner, Description... descriptionList) { 17 | String bannerShown = System.getProperty(BannerConstant.BANNER_SHOWN, "true"); 18 | if (!Boolean.valueOf(bannerShown)) { 19 | return; 20 | } 21 | 22 | System.out.println(""); 23 | String bannerShownAnsiMode = System.getProperty(BannerConstant.BANNER_SHOWN_ANSI_MODE, "false"); 24 | if (Boolean.valueOf(bannerShownAnsiMode)) { 25 | System.out.println(logoBanner.getBanner()); 26 | } else { 27 | System.out.println(logoBanner.getPlainBanner()); 28 | } 29 | 30 | List descriptions = new ArrayList(); 31 | for (Description description : descriptionList) { 32 | descriptions.add(description); 33 | } 34 | descriptions.add(new Description(BannerConstant.SITE + ":", BannerConstant.NEPXION_SITE, 0, 1)); 35 | 36 | DescriptionBanner descriptionBanner = new DescriptionBanner(); 37 | System.out.println(descriptionBanner.getBanner(descriptions)); 38 | } 39 | } -------------------------------------------------------------------------------- /src/main/java/com/nepxion/banner/VersionBanner.java: -------------------------------------------------------------------------------- 1 | package com.nepxion.banner; 2 | 3 | /** 4 | *

Title: Nepxion Banner

5 | *

Description: Nepxion Banner

6 | *

Copyright: Copyright (c) 2017-2050

7 | *

Company: Nepxion

8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | public class VersionBanner extends AbstractBanner { 13 | public VersionBanner(Class resourceClass, String resourceLocation, String defaultBanner) { 14 | super(resourceClass, resourceLocation, defaultBanner); 15 | 16 | initialize(); 17 | } 18 | 19 | @Override 20 | protected String generateBanner(String bannerText) { 21 | if (bannerText == null) { 22 | String implementationVersion = resourceClass.getPackage().getImplementationVersion(); 23 | if (implementationVersion != null) { 24 | return implementationVersion; 25 | } else { 26 | return defaultBanner; 27 | } 28 | } else { 29 | return bannerText; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/test/java/com/nepxion/banner/test/BannerTest.java: -------------------------------------------------------------------------------- 1 | package com.nepxion.banner.test; 2 | 3 | /** 4 | *

Title: Nepxion Banner

5 | *

Description: Nepxion Banner

6 | *

Copyright: Copyright (c) 2017-2050

7 | *

Company: Nepxion

8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import java.io.IOException; 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | import com.nepxion.banner.Description; 17 | import com.nepxion.banner.DescriptionBanner; 18 | import com.nepxion.banner.LogoBanner; 19 | import com.nepxion.banner.VersionBanner; 20 | import com.taobao.text.Color; 21 | 22 | public class BannerTest { 23 | public static void main(String[] args) { 24 | LogoBanner logoBanner1 = new LogoBanner(BannerTest.class, "/com/nepxion/banner/resource/logo-halo-1.txt", "Welcome to Nepxion", 4, 7, new Color[] { Color.red, Color.yellow, Color.cyan, Color.magenta }, false); 25 | System.out.println(logoBanner1.getBanner()); 26 | System.out.println(logoBanner1.getPlainBanner()); 27 | 28 | LogoBanner logoBanner2 = new LogoBanner(BannerTest.class, "/com/nepxion/banner/resource/logo-halo-2.txt", "Welcome to Nepxion", 4, 5, new Color[] { Color.red, Color.yellow, Color.cyan, Color.magenta }, false); 29 | System.out.println(logoBanner2.getBanner()); 30 | System.out.println(logoBanner2.getPlainBanner()); 31 | 32 | LogoBanner logoBanner3 = new LogoBanner(BannerTest.class, "/com/nepxion/banner/resource/logo-arthas.txt", "Welcome to Nepxion", 6, 5, new Color[] { Color.red, Color.yellow, Color.cyan, Color.magenta, Color.green, Color.blue }, true); 33 | System.out.println(logoBanner3.getBanner()); 34 | System.out.println(logoBanner3.getPlainBanner()); 35 | 36 | VersionBanner versionBanner = new VersionBanner(BannerTest.class, "/com/nepxion/banner/resource/version.txt", "Unknown Version"); 37 | 38 | List descriptions = new ArrayList(); 39 | descriptions.add(new Description("Version:", versionBanner.getBanner(), 0, 10)); 40 | descriptions.add(new Description("Site:", "http://www.nepxion.com", 0, 10)); 41 | descriptions.add(new Description("Github:", "https://github.com/Nepxion", 0, 10)); 42 | descriptions.add(new Description("Blog:", "https://nepxion.iteye.com", 0, 10)); 43 | 44 | DescriptionBanner descriptionBanner = new DescriptionBanner(); 45 | System.out.println(descriptionBanner.getBanner(descriptions)); 46 | 47 | try { 48 | System.in.read(); 49 | } catch (IOException e) { 50 | e.printStackTrace(); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /src/test/java/com/nepxion/banner/test/NepxionBannerTest.java: -------------------------------------------------------------------------------- 1 | package com.nepxion.banner.test; 2 | 3 | /** 4 | *

Title: Nepxion Banner

5 | *

Description: Nepxion Banner

6 | *

Copyright: Copyright (c) 2017-2050

7 | *

Company: Nepxion

8 | * @author Haojun Ren 9 | * @version 1.0 10 | */ 11 | 12 | import java.io.IOException; 13 | 14 | import com.nepxion.banner.BannerConstant; 15 | import com.nepxion.banner.Description; 16 | import com.nepxion.banner.LogoBanner; 17 | import com.nepxion.banner.NepxionBanner; 18 | import com.taobao.text.Color; 19 | 20 | public class NepxionBannerTest { 21 | public static void main(String[] args) { 22 | System.setProperty(BannerConstant.BANNER_SHOWN, "true"); 23 | System.setProperty(BannerConstant.BANNER_SHOWN_ANSI_MODE, "true"); 24 | 25 | LogoBanner logoBanner = new LogoBanner(NepxionBannerTest.class, "/com/nepxion/banner/resource/logo-permission.txt", "Welcome to Nepxion", 10, 5, new Color[] { Color.red, Color.yellow, Color.cyan, Color.magenta, Color.green, Color.blue, Color.red, Color.yellow, Color.cyan, Color.magenta }, true); 26 | 27 | NepxionBanner.show(logoBanner, new Description(BannerConstant.VERSION + ":", "3.0.5", 0, 1), new Description(BannerConstant.GITHUB + ":", BannerConstant.NEPXION_GITHUB, 0, 1)); 28 | 29 | try { 30 | System.in.read(); 31 | } catch (IOException e) { 32 | e.printStackTrace(); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/test/resources/com/nepxion/banner/resource/logo-all.txt: -------------------------------------------------------------------------------- 1 | 2 | ,--. ,--. ,---. ,--. ,-----. 3 | | '--' | / O \ | | ' .-. ' 4 | | .--. || .-. || | | | | | 5 | | | | || | | || '--.' '-' ' 6 | `--' `--'`--' `--'`-----' `-----' 7 | 8 | 9 | 10 | __ __ ______ __ ______ 11 | /\ \_\ \ /\ __ \ /\ \ /\ __ \ 12 | \ \ __ \ \ \ __ \ \ \ \____ \ \ \/\ \ 13 | \ \_\ \_\ \ \_\ \_\ \ \_____\ \ \_____\ 14 | \/_/\/_/ \/_/\/_/ \/_____/ \/_____/ 15 | 16 | 17 | 18 | 19 | ___ ___ ___ ___ 20 | /\__\ /\ \ /\__\ /\ \ 21 | /:/__/_ /::\ \ /:/ / /::\ \ 22 | /::\/\__\ /::\:\__\ /:/__/ /:/\:\__\ 23 | \/\::/ / \/\::/ / \:\ \ \:\/:/ / 24 | /:/ / /:/ / \:\__\ \::/ / 25 | \/__/ \/__/ \/__/ \/__/ 26 | 27 | 28 | 29 | ,--, 30 | ,--, ,---.'| ,----.. 31 | ,--.'| ,---, | | : / / \ 32 | ,--, | : ' .' \ : : | / . : 33 | ,---.'| : ' / ; '. | ' : . / ;. \ 34 | | | : _' |: : \ ; ; ' . ; / ` ; 35 | : : |.' |: | /\ \ ' | |__ ; | ; \ ; | 36 | | ' ' ; :| : ' ;. : | | :.'|| : | ; | ' 37 | ' | .'. || | ;/ \ \' : ;. | ' ' ' : 38 | | | : | '' : | \ \ ,'| | ./ ' ; \; / | 39 | ' : | : ;| | ' '--' ; : ; \ \ ', / 40 | | | ' ,/ | : : | ,/ ; : / 41 | ; : ;--' | | ,' '---' \ \ .' 42 | | ,/ `--'' `---` 43 | '---' 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/test/resources/com/nepxion/banner/resource/logo-arthas.txt: -------------------------------------------------------------------------------- 1 | ,---. 2 | / O \ 3 | | .-. | 4 | | | | | 5 | `--' `--' 6 | ,------. 7 | | .--. ' 8 | | '--'.' 9 | | |\ \ 10 | `--' '--' 11 | ,--------. 12 | '--. .--' 13 | | | 14 | | | 15 | `--' 16 | ,--. ,--. 17 | | '--' | 18 | | .--. | 19 | | | | | 20 | `--' `--' 21 | ,---. 22 | / O \ 23 | | .-. | 24 | | | | | 25 | `--' `--' 26 | ,---. 27 | ' .-' 28 | `. `-. 29 | .-' | 30 | `-----' -------------------------------------------------------------------------------- /src/test/resources/com/nepxion/banner/resource/logo-halo-1.txt: -------------------------------------------------------------------------------- 1 | ___ 2 | /\__\ 3 | /:/__/_ 4 | /::\/\__\ 5 | \/\::/ / 6 | /:/ / 7 | \/__/ 8 | ___ 9 | /\ \ 10 | /::\ \ 11 | /::\:\__\ 12 | \/\::/ / 13 | /:/ / 14 | \/__/ 15 | ___ 16 | /\__\ 17 | /:/ / 18 | /:/__/ 19 | \:\ \ 20 | \:\__\ 21 | \/__/ 22 | ___ 23 | /\ \ 24 | /::\ \ 25 | /:/\:\__\ 26 | \:\/:/ / 27 | \::/ / 28 | \/__/ -------------------------------------------------------------------------------- /src/test/resources/com/nepxion/banner/resource/logo-halo-2.txt: -------------------------------------------------------------------------------- 1 | ,--. ,--. 2 | | '--' | 3 | | .--. | 4 | | | | | 5 | `--' `--' 6 | ,---. 7 | / O \ 8 | | .-. | 9 | | | | | 10 | `--' `--' 11 | ,--. 12 | | | 13 | | | 14 | | '--. 15 | `-----' 16 | ,-----. 17 | ' .-. ' 18 | | | | | 19 | ' '-' ' 20 | `-----' -------------------------------------------------------------------------------- /src/test/resources/com/nepxion/banner/resource/logo-permission.txt: -------------------------------------------------------------------------------- 1 | ,------. 2 | | .--. ' 3 | | '--' | 4 | | | --' 5 | `--' 6 | ,------. 7 | | .---' 8 | | `--, 9 | | `---. 10 | `------' 11 | ,------. 12 | | .--. ' 13 | | '--'.' 14 | | |\ \ 15 | `--' '--' 16 | ,--. ,--. 17 | | `.' | 18 | | |'.'| | 19 | | | | | 20 | `--' `--' 21 | ,--. 22 | | | 23 | | | 24 | | | 25 | `--' 26 | ,---. 27 | ' .-' 28 | `. `-. 29 | .-' | 30 | `-----' 31 | ,---. 32 | ' .-' 33 | `. `-. 34 | .-' | 35 | `-----' 36 | ,--. 37 | | | 38 | | | 39 | | | 40 | `--' 41 | ,-----. 42 | ' .-. ' 43 | | | | | 44 | ' '-' ' 45 | `-----' 46 | ,--. ,--. 47 | | ,'.| | 48 | | |' ' | 49 | | | ` | 50 | `--' `--' -------------------------------------------------------------------------------- /src/test/resources/com/nepxion/banner/resource/version.txt: -------------------------------------------------------------------------------- 1 | 1.0.0 -------------------------------------------------------------------------------- /version.bat: -------------------------------------------------------------------------------- 1 | @echo on 2 | @echo ============================================================= 3 | @echo $ $ 4 | @echo $ Nepxion Zxing $ 5 | @echo $ $ 6 | @echo $ $ 7 | @echo $ $ 8 | @echo $ Nepxion Studio All Right Reserved $ 9 | @echo $ Copyright (C) 2017-2050 $ 10 | @echo $ $ 11 | @echo ============================================================= 12 | @echo. 13 | @echo off 14 | 15 | @title Nepxion Zxing 16 | @color 0a 17 | 18 | call mvn versions:set -DgenerateBackupPoms=false -DnewVersion=1.0.2 19 | 20 | pause --------------------------------------------------------------------------------