├── settings.gradle
├── .github
├── PULL_REQUEST_TEMPLATE.md
├── CONTRIBUTING.md
├── ISSUE_TEMPLATE
│ ├── custom.md
│ ├── bug_report.md
│ └── feature_request.md
├── workflows
│ └── gradle.yml
└── FUNDING.yml
├── gradle
├── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── testing.gradle
├── grgit.gradle
├── repositories.gradle
├── formatting.gradle
├── packaging.gradle
├── licensing.gradle
├── version-catalog-update.gradle
├── dependencies.gradle
└── publishing.gradle
├── src
├── test
│ ├── resources
│ │ ├── img
│ │ │ └── xmas
│ │ │ │ ├── bell.png
│ │ │ │ ├── stars.png
│ │ │ │ ├── greendices.png
│ │ │ │ ├── verticalImg.jpg
│ │ │ │ └── horizontalImg.jpg
│ │ └── spotless
│ │ │ └── importorder.properties
│ └── java
│ │ └── io
│ │ └── github
│ │ └── astrapi69
│ │ ├── mvc
│ │ ├── TestPanel.java
│ │ ├── TestView.java
│ │ └── TestController.java
│ │ ├── swing
│ │ ├── panel
│ │ │ ├── keypad
│ │ │ │ └── KeyPadPanelTest.java
│ │ │ ├── field
│ │ │ │ ├── LabeledComboboxPanelTest.java
│ │ │ │ ├── ComboListBean.java
│ │ │ │ └── FieldPanelTest.java
│ │ │ ├── login
│ │ │ │ ├── LoginPanelTest.java
│ │ │ │ ├── NewPasswordPanelTest.java
│ │ │ │ ├── PasswordFormPanel.form
│ │ │ │ └── PasswordFormPanel.java
│ │ │ ├── TemplateBasePanel.java
│ │ │ ├── output
│ │ │ │ └── JTextAreaOutputStreamTest.java
│ │ │ ├── network
│ │ │ │ └── NetworkSettingsPanelTest.java
│ │ │ ├── img
│ │ │ │ └── ImagePanelTest.java
│ │ │ └── lottery
│ │ │ │ └── LotteryPanelTest.java
│ │ ├── img
│ │ │ ├── LogoGenerator.java
│ │ │ ├── ImageToPdfExtensionsTest.java
│ │ │ └── ImageIconFactoryTest.java
│ │ ├── filechooser
│ │ │ └── SuffixFileFilterTest.java
│ │ ├── check
│ │ │ └── model
│ │ │ │ ├── CheckListPanelTest.java
│ │ │ │ ├── JCheckBoxWithPropertyModelTest.java
│ │ │ │ ├── CheckListPanelAssertjSwingTest.java
│ │ │ │ └── CheckListPanel.java
│ │ ├── test
│ │ │ ├── TestSwingMvvm.java
│ │ │ └── TestComponentFactory.java
│ │ ├── icon
│ │ │ ├── ShapeIcon.java
│ │ │ └── ShapeIconPaintTest.java
│ │ └── base
│ │ │ ├── PanelDialogExample.java
│ │ │ └── BaseDialogExample.java
│ │ └── layout
│ │ ├── DrawMessageTest.java
│ │ └── DrawMessage.java
└── main
│ ├── java
│ └── io
│ │ └── github
│ │ └── astrapi69
│ │ ├── layout
│ │ └── package-info.java
│ │ ├── mvc
│ │ ├── view
│ │ │ ├── package-info.java
│ │ │ ├── View.java
│ │ │ └── AbstractGenericView.java
│ │ └── controller
│ │ │ ├── package-info.java
│ │ │ └── Controller.java
│ │ └── swing
│ │ ├── panel
│ │ ├── keypad
│ │ │ ├── KeypadModel.java
│ │ │ ├── KeypadView.java
│ │ │ └── KeypadController.java
│ │ ├── login
│ │ │ ├── LoginModel.java
│ │ │ ├── LoginView.java
│ │ │ ├── LoginModelBean.java
│ │ │ ├── LoginDialog.java
│ │ │ ├── pw
│ │ │ │ ├── PasswordBean.java
│ │ │ │ ├── ChangePasswordModelBean.java
│ │ │ │ └── PasswordPanel.java
│ │ │ └── LoginController.java
│ │ ├── img
│ │ │ └── ImagePanel.java
│ │ ├── output
│ │ │ ├── JLabelOutputStream.java
│ │ │ ├── JTextAreaOutputStream.java
│ │ │ └── ConsolePanel.java
│ │ ├── network
│ │ │ └── NetworkSettingsModelBean.java
│ │ ├── lottery
│ │ │ ├── LotteryBox.java
│ │ │ └── LotteryPanel.java
│ │ └── field
│ │ │ └── FieldPanel.java
│ │ ├── img
│ │ ├── SvgImageTranscoder.java
│ │ └── ImageToPdfExtensions.java
│ │ ├── list
│ │ └── JListExtensions.java
│ │ └── paint
│ │ └── PainterExtensions.java
│ └── resources
│ └── LICENSE.txt
├── .idea
└── runConfigurations
│ ├── swing_components__build_.xml
│ ├── swing_components__javadoc_.xml
│ ├── swing_components__publish_.xml
│ ├── swing_components__licenseFormat_.xml
│ ├── swing_components__jacocoTestReport_.xml
│ ├── swing_components__dependencyUpdates_.xml
│ ├── swing_components__jacocoTestCoverageVerification_.xml
│ ├── swing_components__tagRelease_.xml
│ ├── swing_components__spotlessJavaApply_.xml
│ ├── swing_components__publishMavenJavaPublicationToMavenLocal_.xml
│ ├── swing_components__clean_publishMavenJavaPublicationToMavenLocal_publish_.xml
│ ├── swing_components__clean_publishMavenJavaPublicationToMavenLocal_publish_tagRelease_.xml
│ ├── swing_components__clean_.xml
│ ├── swing_components__dependencies_.xml
│ ├── swing_components__spotlessMiscApply_.xml
│ ├── swing_components__versionCatalogFormat_.xml
│ ├── swing_components__versionCatalogUpdate_.xml
│ └── swing_components__build___warning_mode_all_.xml
├── LICENSE
├── .gitignore
├── gradle.properties
└── gradlew.bat
/settings.gradle:
--------------------------------------------------------------------------------
1 |
2 | rootProject.name = "swing-components"
3 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Fixes # .
2 |
3 | Changes proposed in this pull request:
4 |
5 | -
6 |
7 | @astrapi69
8 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/astrapi69/swing-components/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/src/test/resources/img/xmas/bell.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/astrapi69/swing-components/HEAD/src/test/resources/img/xmas/bell.png
--------------------------------------------------------------------------------
/src/test/resources/img/xmas/stars.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/astrapi69/swing-components/HEAD/src/test/resources/img/xmas/stars.png
--------------------------------------------------------------------------------
/src/test/resources/img/xmas/greendices.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/astrapi69/swing-components/HEAD/src/test/resources/img/xmas/greendices.png
--------------------------------------------------------------------------------
/src/test/resources/img/xmas/verticalImg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/astrapi69/swing-components/HEAD/src/test/resources/img/xmas/verticalImg.jpg
--------------------------------------------------------------------------------
/src/test/resources/img/xmas/horizontalImg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/astrapi69/swing-components/HEAD/src/test/resources/img/xmas/horizontalImg.jpg
--------------------------------------------------------------------------------
/src/test/resources/spotless/importorder.properties:
--------------------------------------------------------------------------------
1 | #Organize Import Order
2 | #Fri Dec 02 17:15:08 CET 2022
3 | 0=java
4 | 1=javax
5 | 2=org
6 | 3=com
7 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/layout/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * This package contains helper classes for handle layouts
3 | */
4 | package io.github.astrapi69.layout;
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/mvc/view/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Provides interfaces and classes for the view.
3 | */
4 | package io.github.astrapi69.mvc.view;
5 |
--------------------------------------------------------------------------------
/.github/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to Contribute
2 |
3 | Your are welcome to create pull requests or join in our mailing list for bugfix, doc, example, suggestion or anything else.
4 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/mvc/controller/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Provides interfaces and classes for the controller.
3 | */
4 | package io.github.astrapi69.mvc.controller;
5 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/custom.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Custom issue template
3 | about: Describe this issue template's purpose here.
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 |
11 |
--------------------------------------------------------------------------------
/gradle/testing.gradle:
--------------------------------------------------------------------------------
1 |
2 | test {
3 | useJUnitPlatform()
4 | }
5 |
6 | jacocoTestReport {
7 | reports {
8 | xml.required.set(true)
9 | html.required.set(true)
10 | }
11 | }
12 |
13 | check.dependsOn jacocoTestReport
14 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Feb 14 14:40:08 CET 2020
2 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-rc-1-bin.zip
3 | distributionBase=GRADLE_USER_HOME
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/gradle/grgit.gradle:
--------------------------------------------------------------------------------
1 |
2 | task tagRelease {
3 | description = "Tags the current head with the project\'s version."
4 | doLast {
5 | grgit.tag.add {
6 | name = "RELEASE-${project.version.toString()}"
7 | message = "New release in version ${version}"
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/gradle/repositories.gradle:
--------------------------------------------------------------------------------
1 | repositories {
2 | mavenLocal()
3 | mavenCentral()
4 | maven {
5 | name "$projectRepositoriesReleasesName"
6 | url "$projectRepositoriesReleasesRepoUrl"
7 | mavenContent {
8 | releasesOnly()
9 | }
10 | }
11 | maven {
12 | name "$projectRepositoriesSnapshotsName"
13 | url "$projectRepositoriesSnapshotsRepoUrl"
14 | mavenContent {
15 | snapshotsOnly()
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Additional context**
27 | Add any other context about the problem here.
28 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/gradle/formatting.gradle:
--------------------------------------------------------------------------------
1 |
2 | spotless {
3 |
4 | format "misc", {
5 | // define the files to apply `misc` to
6 | target "*.gradle", "*.md", ".gitignore"
7 |
8 | // define the steps to apply to those files
9 | trimTrailingWhitespace()
10 | indentWithSpaces() // or spaces. Takes an integer argument if you don"t like 4
11 | endWithNewline()
12 | }
13 | java {
14 | // export config file: https://github.com/diffplug/spotless/blob/main/ECLIPSE_SCREENSHOTS.md#creating-spotlessimportorder
15 | importOrderFile('src/test/resources/spotless/importorder.properties') // import order file as exported from eclipse
16 | eclipse("4.21").configFile("src/test/resources/spotless/alpharo-formatter.xml")
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/swing_components__build_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/swing_components__javadoc_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/swing_components__publish_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/swing_components__licenseFormat_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/swing_components__jacocoTestReport_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/swing_components__dependencyUpdates_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/swing_components__jacocoTestCoverageVerification_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/gradle/packaging.gradle:
--------------------------------------------------------------------------------
1 | import java.text.SimpleDateFormat
2 |
3 | jar {
4 | manifest {
5 | attributes(
6 | "Name" : project.name,
7 | "Manifest-Version" : project.version,
8 | "Implementation-Title" : "$groupPackage" + "." + "$rootProject.name",
9 | "Implementation-Version": project.version,
10 | "Implementation-Vendor" : "$projectLeaderName",
11 | "Created-By" : "Gradle ${gradle.gradleVersion}",
12 | "Built-By" : "$projectLeaderName",
13 | "Build-Timestamp" : new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
14 | "Build-Jdk" : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
15 | "Build-OS" : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}")
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/swing_components__tagRelease_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 | true
20 | false
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/swing_components__spotlessJavaApply_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 | true
20 | false
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (C) 2015 Asterios Raptis
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining
6 | a copy of this software and associated documentation files (the
7 | "Software"), to deal in the Software without restriction, including
8 | without limitation the rights to use, copy, modify, merge, publish,
9 | distribute, sublicense, and/or sell copies of the Software, and to
10 | permit persons to whom the Software is furnished to do so, subject to
11 | the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be
14 | included in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/.idea/runConfigurations/swing_components__publishMavenJavaPublicationToMavenLocal_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 | true
20 | false
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/main/resources/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (C) ${year} ${owner}
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining
6 | a copy of this software and associated documentation files (the
7 | "Software"), to deal in the Software without restriction, including
8 | without limitation the rights to use, copy, modify, merge, publish,
9 | distribute, sublicense, and/or sell copies of the Software, and to
10 | permit persons to whom the Software is furnished to do so, subject to
11 | the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be
14 | included in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/gradle/licensing.gradle:
--------------------------------------------------------------------------------
1 |
2 | license {
3 | ext.year="$projectInceptionYear"
4 | ext.owner="$projectLeaderName"
5 | ignoreFailures = true
6 | header rootProject.file("src/main/resources/LICENSE.txt")
7 | excludes(["**/README",
8 | "**/README.md",
9 | "**/LICENSE",
10 | "**/NOTICE",
11 | "**/*.xml",
12 | "**/*.xsl",
13 | "**/*.xsd",
14 | "**/*.dtd",
15 | "**/*.html",
16 | "**/*.jsp",
17 | "**/*.jpa",
18 | "**/*.sql",
19 | "**/*.properties",
20 | "**/*.bat",
21 | "**/*.gradle",
22 | "**/*.MF",
23 | "**/*.txt",
24 | "**/*.vm",
25 | "**/*.log",
26 | "**/*.map",
27 | "**/*.js.map",
28 | "**/*.tmpl",
29 | "**/*.js.tmpl",
30 | "**/*.editorconfig",
31 | "src/test/resources/**",
32 | "src/main/resources/**",
33 | "out/**",
34 | "build/**"])
35 | }
36 | // workhack for license issue #76
37 | gradle.startParameter.excludedTaskNames += "licenseMain"
38 | gradle.startParameter.excludedTaskNames += "licenseTest"
39 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/swing_components__clean_publishMavenJavaPublicationToMavenLocal_publish_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | true
21 | true
22 | false
23 | false
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/swing_components__clean_publishMavenJavaPublicationToMavenLocal_publish_tagRelease_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | true
22 | true
23 | false
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/.github/workflows/gradle.yml:
--------------------------------------------------------------------------------
1 | # This workflow uses actions that are not certified by GitHub.
2 | # They are provided by a third-party and are governed by
3 | # separate terms of service, privacy policy, and support
4 | # documentation.
5 | # This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
6 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
7 |
8 | name: Java CI with Gradle
9 |
10 | on:
11 | push:
12 | branches: [ master, develop ]
13 | pull_request:
14 | branches: [ master, develop ]
15 |
16 | jobs:
17 | build:
18 |
19 | runs-on: ubuntu-latest
20 |
21 | steps:
22 | - name: Checkout sources
23 | uses: actions/checkout@v4
24 | - name: Setup Java
25 | uses: actions/setup-java@v4
26 | with:
27 | java-version: '17'
28 | distribution: 'temurin'
29 | - name: Setup Gradle
30 | uses: gradle/actions/setup-gradle@v3
31 | - name: Execute Gradle build
32 | run: ./gradlew build
33 | env:
34 | ossrhUsername: ${{secrets.OSSRHUSERNAME}}
35 | ossrhPassword: ${{secrets.OSSRHPASSWORD}}
36 | - uses: codecov/codecov-action@v4
37 | with:
38 | token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
39 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/swing_components__clean_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 | true
20 |
21 |
22 |
23 |
24 |
25 | 5.0
26 |
27 |
28 |
29 | false
30 | false
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/swing_components__dependencies_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 | true
20 |
21 |
22 |
23 |
24 |
25 | 5.0
26 |
27 |
28 |
29 | false
30 | false
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/swing_components__spotlessMiscApply_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 | true
20 |
21 |
22 |
23 |
24 |
25 | 5.0
26 |
27 |
28 |
29 | false
30 | false
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/swing_components__versionCatalogFormat_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 | true
20 |
21 |
22 |
23 |
24 |
25 | 5.0
26 |
27 |
28 |
29 | false
30 | false
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/swing_components__versionCatalogUpdate_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 | true
20 |
21 |
22 |
23 |
24 |
25 | 5.0
26 |
27 |
28 |
29 | false
30 | false
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/swing_components__build___warning_mode_all_.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | true
19 | true
20 |
21 |
22 |
23 |
24 |
25 | 5.0
26 |
27 |
28 |
29 | false
30 | false
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/panel/keypad/KeypadModel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.keypad;
26 |
27 | import io.github.astrapi69.model.GenericModel;
28 |
29 | public class KeypadModel extends GenericModel
30 | {
31 |
32 | private static final long serialVersionUID = 1828404750933192250L;
33 |
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/mvc/TestPanel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.mvc;
26 |
27 | import javax.swing.JPanel;
28 |
29 | /**
30 | * The class TestPanel.
31 | */
32 | public class TestPanel extends JPanel
33 | {
34 |
35 | /** The Constant serialVersionUID. */
36 | private static final long serialVersionUID = 1L;
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/panel/login/LoginModel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.login;
26 |
27 | import io.github.astrapi69.model.GenericModel;
28 |
29 | public class LoginModel extends GenericModel
30 | {
31 |
32 | /**
33 | *
34 | */
35 | private static final long serialVersionUID = -7923815348599190631L;
36 |
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/gradle/version-catalog-update.gradle:
--------------------------------------------------------------------------------
1 | versionCatalogUpdate {
2 | // sort the catalog by key (default is true)
3 | sortByKey = true
4 | // Referenced that are pinned are not automatically updated.
5 | // They are also not automatically kept however (use keep for that).
6 | pin {
7 | // pins all libraries and plugins using the given versions
8 | // versions = ["my-version-name", "other-version"]
9 | // pins specific libraries that are in the version catalog
10 | // libraries = [libs.my.library.reference, libs.my.other.library.reference]
11 | // pins specific plugins that are in the version catalog
12 | // plugins = [libs.plugins.my.plugin, libs.plugins.my.other.plugin]
13 | // pins all libraries (not plugins) for the given groups
14 | // groups = ["com.somegroup", "com.someothergroup"]
15 | }
16 | keep {
17 | // keep has the same options as pin to keep specific entries
18 | // note that for versions it will ONLY keep the specified version, not all
19 | // entries that reference it.
20 | // versions = ["my-version-name", "other-version"]
21 | // libraries = [libs.my.library.reference, libs.my.other.library.reference]
22 | // plugins = [libs.plugins.my.plugin, libs.plugins.my.other.plugin]
23 | // groups = ["com.somegroup", "com.someothergroup"]
24 |
25 | // keep versions without any library or plugin reference
26 | keepUnusedVersions = true
27 | // keep all libraries that aren't used in the project
28 | keepUnusedLibraries = true
29 | // keep all plugins that aren't used in the project
30 | keepUnusedPlugins = true
31 | }
32 | }
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/mvc/TestView.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.mvc;
26 |
27 | import io.github.astrapi69.mvc.view.AbstractGenericView;
28 |
29 |
30 | /**
31 | * The class TestView.
32 | */
33 | public abstract class TestView extends AbstractGenericView
34 | {
35 |
36 | /**
37 | * Instantiates a new test view.
38 | *
39 | * @param controller
40 | * the controller
41 | */
42 | public TestView(final TestController controller)
43 | {
44 | super(controller);
45 | controller.setView(this);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ##################
2 | # Compiled files #
3 | ##################
4 | *.class
5 |
6 | ##################
7 | # intellij files #
8 | ##################
9 | *.iws
10 | *.iml
11 | *.ipr
12 | !.idea/runConfigurations
13 | .idea/inspectionProfiles
14 | .idea/sonarlint
15 | .idea/libraries
16 | .idea/codeStyles
17 | .idea/shelf
18 | .idea/*.*
19 |
20 | #################
21 | # eclipse files #
22 | #################
23 | /.project
24 | /.classpath
25 | /.settings
26 | /.tern-project
27 |
28 | #########################
29 | # maven generated files #
30 | #########################
31 | /target
32 |
33 | #############
34 | # Zip files #
35 | #############
36 | *.tar
37 | *.zip
38 | *.7z
39 | *.dmg
40 | *.gz
41 | *.iso
42 | *.jar
43 | *.rar
44 |
45 | ##############
46 | # Logs files #
47 | ##############
48 | *.log
49 |
50 | #################
51 | # test-ng files #
52 | #################
53 | /test-output
54 |
55 | ############################
56 | # Binaries generated files #
57 | ############################
58 | /bin
59 |
60 | ################
61 | # gradle files #
62 | ################
63 | /build
64 | /.gradle
65 | /gradle
66 | /out
67 | # Ignore Gradle GUI config
68 | gradle-app.setting
69 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
70 | !/gradle/wrapper/gradle-wrapper.jar
71 | !/gradle/wrapper/gradle-wrapper.properties
72 | # Cache of project
73 | .gradletasknamecache
74 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
75 | # gradle/wrapper/gradle-wrapper.properties
76 |
77 | ##############################################################
78 | # virtual machine crash logs #
79 | # see http://www.java.com/en/download/help/error_hotspot.xml #
80 | ##############################################################
81 | hs_err_pid*
82 | /.attach_pid*
83 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/mvc/TestController.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.mvc;
26 |
27 | import java.awt.event.ActionEvent;
28 | import java.io.File;
29 |
30 | import io.github.astrapi69.model.GenericModel;
31 | import io.github.astrapi69.mvc.controller.AbstractGenericController;
32 |
33 |
34 | /**
35 | * The class TestController.
36 | */
37 | public class TestController extends AbstractGenericController, TestView>
38 | {
39 |
40 | @Override
41 | public void process(final ActionEvent event)
42 | {
43 | // Here comes the logic...
44 |
45 | }
46 |
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/panel/keypad/KeyPadPanelTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.keypad;
26 |
27 | import java.awt.Frame;
28 |
29 | import io.github.astrapi69.awt.window.adapter.CloseWindow;
30 |
31 | public class KeyPadPanelTest
32 | {
33 |
34 | public static void main(final String[] args)
35 | {
36 | final Frame frame = new Frame("KeyPadPanel");
37 | frame.addWindowListener(new CloseWindow());
38 | final KeypadView keypadView = new KeypadView(new KeypadController());
39 | frame.add(keypadView.getComponent());
40 | frame.pack();
41 | frame.setVisible(true);
42 | }
43 |
44 | }
--------------------------------------------------------------------------------
/gradle/dependencies.gradle:
--------------------------------------------------------------------------------
1 | dependencies {
2 | compileOnly libs.lombok
3 | annotationProcessor libs.lombok
4 | testCompileOnly libs.lombok
5 | testAnnotationProcessor libs.lombok
6 |
7 | implementation libs.javahelp
8 | implementation libs.swingx.all
9 | implementation libs.imgscalr.lib
10 | implementation libs.batik.transcoder
11 | implementation libs.batik.codec
12 | implementation libs.itextpdf
13 | implementation libs.miglayout.swing
14 | implementation libs.commons.lang3
15 | implementation libs.silly.collection
16 | implementation libs.silly.bean
17 | implementation libs.randomizer
18 | implementation libs.state
19 | implementation libs.observer
20 | implementation libs.model.data
21 | implementation libs.jobj.core
22 | implementation libs.throwable
23 | implementation libs.silly.math
24 | implementation libs.menu.action
25 | implementation libs.swing.base.components
26 | implementation libs.icon.img.extensions
27 | implementation libs.swing.renderer
28 | implementation libs.component.model
29 | implementation libs.swing.model.components
30 |
31 | testImplementation libs.awt.extensions
32 | testImplementation libs.silly.io
33 | testImplementation libs.beansbinding
34 | testImplementation libs.crypt.api
35 | testImplementation libs.file.worker
36 | testImplementation libs.test.objects
37 | testImplementation libs.tango.icon.theme
38 | testImplementation libs.silk.icon.theme
39 | testImplementation libs.zip4j
40 | testImplementation libs.assertj.swing
41 | testImplementation libs.meanbean
42 | testImplementation libs.junit.jupiter.extensions
43 | testImplementation libs.swing.mvvm
44 | // Note: use of bundles...
45 | testImplementation libs.bundles.unit.testing
46 | testRuntimeOnly libs.junit.platform.launcher
47 | }
48 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/panel/field/LabeledComboboxPanelTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.field;
26 |
27 | import java.awt.Frame;
28 |
29 | import io.github.astrapi69.awt.window.adapter.CloseWindow;
30 |
31 | public class LabeledComboboxPanelTest
32 | {
33 |
34 |
35 | /**
36 | * Test init layout.
37 | *
38 | * @param args
39 | * the arguments
40 | */
41 | public static void main(final String[] args)
42 | {
43 | final Frame frame = new Frame("ComboboxPanel");
44 | frame.addWindowListener(new CloseWindow());
45 | frame.add(new LabeledComboboxPanel());
46 | frame.pack();
47 | frame.setVisible(true);
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/panel/login/LoginView.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.login;
26 |
27 | import io.github.astrapi69.mvc.view.AbstractGenericView;
28 |
29 | public class LoginView extends AbstractGenericView
30 | {
31 |
32 | private LoginPanel loginPanel;
33 |
34 | public LoginView(final LoginController controller)
35 | {
36 | super(controller);
37 | controller.setView(this);
38 | }
39 |
40 | @Override
41 | protected void initialize()
42 | {
43 | loginPanel = new LoginPanel();
44 | setComponent(loginPanel);
45 | loginPanel.getBtnCancel().addActionListener(getController());
46 | loginPanel.getBtnLogin().addActionListener(getController());
47 | }
48 |
49 | }
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/panel/login/LoginPanelTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.login;
26 |
27 | import java.awt.Dialog.ModalityType;
28 | import java.awt.Frame;
29 |
30 | import io.github.astrapi69.awt.window.adapter.CloseWindow;
31 |
32 | public class LoginPanelTest
33 | {
34 |
35 | public static void main(final String[] args)
36 | {
37 | final Frame frame = new Frame();
38 | frame.addWindowListener(new CloseWindow());
39 | frame.setTitle("Login Frame");
40 | final LoginDialog loginDialog = new LoginDialog(frame, "Login Dialog",
41 | ModalityType.TOOLKIT_MODAL);
42 | loginDialog.pack();
43 | loginDialog.setVisible(true);
44 | frame.setSize(300, 300);
45 | frame.setVisible(true);
46 | }
47 |
48 | }
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/panel/field/ComboListBean.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.field;
26 |
27 | import java.io.Serializable;
28 | import java.util.List;
29 |
30 | import lombok.AllArgsConstructor;
31 | import lombok.Builder;
32 | import lombok.EqualsAndHashCode;
33 | import lombok.Getter;
34 | import lombok.NoArgsConstructor;
35 | import lombok.Setter;
36 | import lombok.ToString;
37 |
38 | @Getter
39 | @Setter
40 | @EqualsAndHashCode
41 | @ToString
42 | @NoArgsConstructor
43 | @AllArgsConstructor
44 | @Builder(toBuilder = true)
45 | public class ComboListBean implements Serializable
46 | {
47 |
48 | private static final long serialVersionUID = 1L;
49 |
50 | List comboList;
51 |
52 | String selectedItem;
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/img/LogoGenerator.java:
--------------------------------------------------------------------------------
1 | package io.github.astrapi69.swing.img;
2 |
3 | import java.awt.*;
4 | import java.awt.geom.Ellipse2D;
5 |
6 | import javax.swing.*;
7 |
8 | public class LogoGenerator extends JPanel
9 | {
10 |
11 | @Override
12 | protected void paintComponent(Graphics g)
13 | {
14 | super.paintComponent(g);
15 | Graphics2D g2d = (Graphics2D)g;
16 |
17 | int width = getWidth();
18 | int height = getHeight();
19 |
20 | // Background color
21 | g2d.setColor(Color.WHITE);
22 | g2d.fillRect(0, 0, width, height);
23 |
24 | // Anti-aliasing for smoother graphics
25 | g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
26 |
27 | // Draw the circle
28 | int circleRadius = Math.min(width, height) / 2 - 40;
29 | int circleX = (width - 2 * circleRadius) / 2;
30 | int circleY = (height - 2 * circleRadius) / 2;
31 |
32 | g2d.setColor(new Color(255, 165, 0)); // Orange color
33 | g2d.setStroke(new BasicStroke(10));
34 | g2d.draw(new Ellipse2D.Double(circleX, circleY, 2 * circleRadius, 2 * circleRadius));
35 |
36 | // Draw the number 69
37 | g2d.setFont(new Font("Orbitron", Font.PLAIN, 150)); // Futuristic font
38 | FontMetrics fm = g2d.getFontMetrics();
39 | String text = "69";
40 | int textWidth = fm.stringWidth(text);
41 | int textHeight = fm.getAscent();
42 |
43 | int textX = (width - textWidth) / 2;
44 | int textY = (height + textHeight) / 2 - 20;
45 |
46 | g2d.setColor(new Color(173, 216, 230)); // Light blue color
47 | g2d.drawString(text, textX, textY);
48 | }
49 |
50 | private static void createAndShowGUI()
51 | {
52 | JFrame frame = new JFrame("Logo Generator");
53 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
54 | frame.setSize(400, 400);
55 | frame.add(new LogoGenerator());
56 | frame.setVisible(true);
57 | }
58 |
59 | public static void main(String[] args)
60 | {
61 | SwingUtilities.invokeLater(() -> createAndShowGUI());
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/panel/login/LoginModelBean.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.login;
26 |
27 | import java.io.Serializable;
28 |
29 | public class LoginModelBean implements Serializable
30 | {
31 |
32 | /**
33 | *
34 | */
35 | private static final long serialVersionUID = -1018790761657962672L;
36 |
37 | private String password;
38 |
39 | private String username;
40 |
41 | public String getPassword()
42 | {
43 | return password;
44 | }
45 |
46 | public void setPassword(final String password)
47 | {
48 | this.password = password;
49 | }
50 |
51 | public String getUsername()
52 | {
53 | return username;
54 | }
55 |
56 | public void setUsername(final String username)
57 | {
58 | this.username = username;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/panel/TemplateBasePanel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel;
26 |
27 | import io.github.astrapi69.model.BaseModel;
28 | import io.github.astrapi69.model.api.IModel;
29 | import io.github.astrapi69.swing.base.BasePanel;
30 |
31 | public class TemplateBasePanel extends BasePanel
32 | {
33 |
34 | private static final long serialVersionUID = 1L;
35 |
36 | public TemplateBasePanel()
37 | {
38 | this(BaseModel.of());
39 | }
40 |
41 | public TemplateBasePanel(final IModel model)
42 | {
43 | super(model);
44 | }
45 |
46 | @Override
47 | protected void onInitializeComponents()
48 | {
49 | super.onInitializeComponents();
50 | }
51 |
52 | @Override
53 | protected void onInitializeLayout()
54 | {
55 | super.onInitializeLayout();
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/panel/output/JTextAreaOutputStreamTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.output;
26 |
27 | import java.awt.BorderLayout;
28 | import java.awt.Dimension;
29 |
30 | import javax.swing.JFrame;
31 | import javax.swing.JLabel;
32 |
33 | import io.github.astrapi69.swing.test.TestComponentFactory;
34 |
35 | public class JTextAreaOutputStreamTest
36 | {
37 | public static void main(String[] args) throws InterruptedException
38 | {
39 | final JFrame frame = TestComponentFactory.newTestJFrameWithComponent("ConsolePanel",
40 | new ConsolePanel(), new Dimension(600, 400));
41 | frame.add(new JLabel(" Console"), BorderLayout.NORTH);
42 | frame.setVisible(true);
43 |
44 | for (int i = 0; i < 1000; i++)
45 | {
46 | System.out.println(i);
47 | Thread.sleep(50);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/panel/network/NetworkSettingsPanelTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.network;
26 |
27 | import java.awt.Rectangle;
28 | import java.io.IOException;
29 |
30 | import javax.swing.JFrame;
31 |
32 | import io.github.astrapi69.swing.test.TestComponentFactory;
33 |
34 | public class NetworkSettingsPanelTest
35 | {
36 |
37 | /**
38 | * The main method.
39 | *
40 | * @param args
41 | * the arguments
42 | * @throws IOException
43 | * Signals that an I/O exception has occurred.
44 | */
45 | public static void main(final String[] args) throws IOException
46 | {
47 | final JFrame frame = TestComponentFactory.newTestJFrameWithComponent("NetworkSettingsPanel",
48 | new NetworkSettingsPanel(), new Rectangle(0, 0, 1020, 420));
49 | frame.setVisible(true);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | #
2 | # The MIT License
3 | #
4 | # Copyright (C) 2015 Asterios Raptis
5 | #
6 | # Permission is hereby granted, free of charge, to any person obtaining
7 | # a copy of this software and associated documentation files (the
8 | # "Software"), to deal in the Software without restriction, including
9 | # without limitation the rights to use, copy, modify, merge, publish,
10 | # distribute, sublicense, and/or sell copies of the Software, and to
11 | # permit persons to whom the Software is furnished to do so, subject to
12 | # the following conditions:
13 | #
14 | # The above copyright notice and this permission notice shall be
15 | # included in all copies or substantial portions of the Software.
16 | #
17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | #
25 |
26 | # These are supported funding model platforms
27 |
28 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
29 | patreon: # Replace with a single Patreon username
30 | open_collective: asterios-raptis # Replace with a single Open Collective username
31 | ko_fi: astrapi69 # Replace with a single Ko-fi username
32 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
33 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
34 | liberapay: # Replace with a single Liberapay username
35 | issuehunt: # Replace with a single IssueHunt username
36 | otechie: # Replace with a single Otechie username
37 | custom: ['https://flattr.com/@astrapi69', 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GVBTWLRAZ7HB8']# Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
38 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/filechooser/SuffixFileFilterTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.filechooser;
26 |
27 | import java.awt.Frame;
28 |
29 | import javax.swing.JButton;
30 | import javax.swing.JFileChooser;
31 |
32 | import io.github.astrapi69.awt.window.adapter.CloseWindow;
33 |
34 | public class SuffixFileFilterTest
35 | {
36 | public static void main(final String[] arguments)
37 | {
38 | JFileChooser fileChooser;
39 | fileChooser = new JFileChooser();
40 | fileChooser.setFileFilter(new SuffixFileFilter(".foo"));
41 | final Frame frame = new Frame("SuffixFileFilterTest");
42 | frame.addWindowListener(new CloseWindow());
43 | JButton button = new JButton("Browse...");
44 | button.addActionListener(actionEvent -> {
45 | fileChooser.showSaveDialog(frame);
46 | });
47 | frame.add(button);
48 | frame.pack();
49 | frame.setVisible(true);
50 | }
51 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | ######################
2 | # project properties #
3 | ######################
4 | projectVersion=9.1-SNAPSHOT
5 | groupPackage=io.github.astrapi69
6 | projectSourceCompatibility=17
7 | projectInceptionYear=2015
8 | projectHolderUsername=astrapi69
9 | projectLeaderName=Asterios Raptis
10 | slash=/
11 | colon=:
12 | issuesPath=/issues
13 | projectDescription=Provides several swing components and utilities
14 | projectScmProviderDomain=github.com
15 | projectScmProviderUrl=https://github.com/
16 | projectScmGitUrlPrefix=scm:git:git:@
17 | projectScmGitUrlSuffix=.git
18 | projectLicenseName=MIT License
19 | projectLicenseUrl=https://www.opensource.org/licenses/mit-license.php
20 | projectOrganizationName=Asterios Raptis
21 | projectOrganizationUrl=https://astrapi69.github.io/
22 | projectLicenseDistribution=repo
23 | projectIssueManagementSystem=GitHub
24 | projectRepositoriesReleasesRepoUrl=https://oss.sonatype.org/service/local/staging/deploy/maven2/
25 | projectRepositoriesSnapshotsRepoUrl=https://oss.sonatype.org/content/repositories/snapshots
26 | projectRepositoriesUserNameKey=ossrhUsername
27 | projectRepositoriesPasswordKey=ossrhPassword
28 | projectRepositoriesReleasesName=Sonatype Nexus Releases
29 | projectRepositoriesSnapshotsName=Sonatype Nexus Snapshots
30 | projectRepositoriesMavenUrl=https://plugins.gradle.org/m2/
31 | ##########################
32 | # for deploy on sonatype #
33 | ##########################
34 | systemProp.org.gradle.internal.publish.checksums.insecure=true
35 | #############################
36 | # gradle related properties #
37 | #############################
38 | # Enable the Gradle daemon
39 | org.gradle.daemon=true
40 | # Enable the build cache
41 | org.gradle.caching=true
42 | # Enable parallel execution
43 | org.gradle.parallel=true
44 | # Run Gradle in offline mode
45 | org.gradle.offline=false
46 | # Configure console output
47 | org.gradle.console=auto
48 | # Set the warning mode
49 | org.gradle.warning.mode=summary
50 | # Enable Configure on Demand to improve configuration time
51 | org.gradle.configureondemand=true
52 | # Enable VFS watching for better performance
53 | org.gradle.vfs.watch=true
54 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/img/SvgImageTranscoder.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.img;
26 |
27 | import java.awt.image.BufferedImage;
28 |
29 | import org.apache.batik.transcoder.TranscoderOutput;
30 | import org.apache.batik.transcoder.image.ImageTranscoder;
31 |
32 | import lombok.Getter;
33 |
34 | /**
35 | * The class {@link SvgImageTranscoder} can transcode a svg image
36 | */
37 | public class SvgImageTranscoder extends ImageTranscoder
38 | {
39 | /**
40 | * The {@link BufferedImage} object
41 | */
42 | @Getter
43 | private BufferedImage image;
44 |
45 | /**
46 | * {@inheritDoc}
47 | */
48 | @Override
49 | public BufferedImage createImage(int width, int height)
50 | {
51 | image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
52 | return image;
53 | }
54 |
55 | /**
56 | * {@inheritDoc}
57 | */
58 | @Override
59 | public void writeImage(BufferedImage img, TranscoderOutput out)
60 | {
61 | }
62 |
63 | }
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/panel/img/ImagePanel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.img;
26 |
27 | import java.awt.Graphics;
28 | import java.awt.image.BufferedImage;
29 |
30 | import io.github.astrapi69.model.api.IModel;
31 | import io.github.astrapi69.swing.base.BasePanel;
32 |
33 | /**
34 | * The class {@link ImagePanel}.
35 | */
36 | public class ImagePanel extends BasePanel
37 | {
38 |
39 | /** The Constant serialVersionUID. */
40 | private static final long serialVersionUID = 1L;
41 |
42 |
43 | /**
44 | * Instantiates a new {@link ImagePanel}.
45 | *
46 | * @param model
47 | * the model
48 | */
49 | public ImagePanel(final IModel model)
50 | {
51 | super(model);
52 | }
53 |
54 | /**
55 | * {@inheritDoc}
56 | */
57 | @Override
58 | protected void paintComponent(final Graphics g)
59 | {
60 | super.paintComponent(g);
61 | g.drawImage(getModelObject(), 0, 0, this);
62 | }
63 | }
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/panel/login/LoginDialog.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.login;
26 |
27 | import java.awt.Dimension;
28 | import java.awt.Toolkit;
29 | import java.awt.Window;
30 |
31 | import javax.swing.JDialog;
32 |
33 | public class LoginDialog extends JDialog
34 | {
35 |
36 | /**
37 | *
38 | */
39 | private static final long serialVersionUID = -5068861094604228659L;
40 | private final LoginView loginView;
41 |
42 | public LoginDialog(final Window owner, final String title, final ModalityType modalityType)
43 | {
44 | super(owner, title, modalityType);
45 | loginView = new LoginView(new LoginController(this));
46 | this.add(loginView.getComponent());
47 | final Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
48 | setLocation(dim.width / 3, dim.height / 3);
49 | setSize(dim.width / 3, dim.height / 3);
50 | }
51 |
52 | @Override
53 | public void dispose()
54 | {
55 | super.dispose();
56 | }
57 |
58 | }
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/panel/login/pw/PasswordBean.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.login.pw;
26 |
27 | import java.io.Serializable;
28 |
29 | import lombok.AllArgsConstructor;
30 | import lombok.Builder;
31 | import lombok.EqualsAndHashCode;
32 | import lombok.Getter;
33 | import lombok.NoArgsConstructor;
34 | import lombok.Setter;
35 | import lombok.ToString;
36 |
37 | /**
38 | * The Class {@link PasswordBean} captures the data for set the password.
39 | *
40 | * @author Asterios Raptis
41 | */
42 | @Getter
43 | @Setter
44 | @EqualsAndHashCode
45 | @ToString
46 | @NoArgsConstructor
47 | @AllArgsConstructor
48 | @Builder(toBuilder = true)
49 | public class PasswordBean implements Serializable
50 | {
51 |
52 | /**
53 | * The serialVersionUID.
54 | */
55 | private static final long serialVersionUID = 1L;
56 |
57 | /** The password */
58 | private String password;
59 |
60 | /** The repeated password */
61 | private String repeatPassword;
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/panel/field/FieldPanelTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.field;
26 |
27 | import java.awt.Frame;
28 |
29 | import javax.swing.DefaultComboBoxModel;
30 |
31 | import io.github.astrapi69.swing.test.TestComponentFactory;
32 |
33 | /**
34 | * The test class for {@link FieldPanel}.
35 | */
36 | public class FieldPanelTest
37 | {
38 |
39 | /**
40 | * Test init layout.
41 | *
42 | * @param args
43 | * the arguments
44 | */
45 | public static void main(final String[] args)
46 | {
47 | final Frame frame = TestComponentFactory.newTestFrame("FieldPanel");
48 | frame.add(new FieldPanel()
49 | {
50 |
51 | /** The Constant serialVersionUID. */
52 | private static final long serialVersionUID = 1L;
53 |
54 | @Override
55 | protected DefaultComboBoxModel newTypeModel()
56 | {
57 | return new DefaultComboBoxModel<>(
58 | new String[] { "Item 1", "Item 2", "Item 3", "Item 4" });
59 | }
60 | });
61 | frame.pack();
62 | frame.setVisible(true);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/panel/img/ImagePanelTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.img;
26 |
27 | import java.awt.Rectangle;
28 | import java.awt.image.BufferedImage;
29 | import java.io.IOException;
30 |
31 | import javax.imageio.ImageIO;
32 | import javax.swing.JFrame;
33 |
34 | import io.github.astrapi69.lang.ClassExtensions;
35 | import io.github.astrapi69.model.BaseModel;
36 | import io.github.astrapi69.swing.test.TestComponentFactory;
37 |
38 | public class ImagePanelTest
39 | {
40 |
41 |
42 | /**
43 | * The main method.
44 | *
45 | * @param args
46 | * the arguments
47 | * @throws IOException
48 | * Signals that an I/O exception has occurred
49 | */
50 | public static void main(final String[] args) throws IOException
51 | {
52 | final BufferedImage img1 = ImageIO
53 | .read(ClassExtensions.getResourceAsStream("img/xmas/bell.png"));
54 | final ImagePanel pnlIconPanel = new ImagePanel(BaseModel.of(img1));
55 |
56 | final JFrame frame = TestComponentFactory.newTestJFrameWithComponent("ImagePanelTest",
57 | pnlIconPanel, new Rectangle(0, 0, 820, 820));
58 | frame.setVisible(true);
59 | }
60 |
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/check/model/CheckListPanelTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.check.model;
26 |
27 | import java.awt.Frame;
28 |
29 | import io.github.astrapi69.awt.window.adapter.CloseWindow;
30 | import io.github.astrapi69.component.model.check.CheckableItem;
31 | import io.github.astrapi69.component.model.check.CheckableListModel;
32 | import io.github.astrapi69.component.model.check.CheckableValue;
33 | import io.github.astrapi69.model.BaseModel;
34 | import io.github.astrapi69.model.api.IModel;
35 | import io.github.astrapi69.swing.list.JListExtensions;
36 |
37 | public class CheckListPanelTest
38 | {
39 | public static void main(String[] args)
40 | {
41 | final Frame frame = new Frame("CheckListPanel");
42 | String[] strs = { "root", "home", "kde", "mint", "ubuntu" };
43 | CheckableItem[] checkableItems = JListExtensions.newCheckableItems(strs);
44 | IModel model = BaseModel.of(
45 | CheckableListModel.builder().values(JListExtensions.newCheckableItems(strs)).build());
46 | frame.add(new CheckListPanel(model));
47 | frame.addWindowListener(new CloseWindow());
48 | frame.setSize(300, 200);
49 | frame.setVisible(true);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/mvc/view/View.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.mvc.view;
26 |
27 | import java.awt.Component;
28 |
29 | /**
30 | * The Interface View.
31 | *
32 | * @param
33 | * the generic type of the controller
34 | * @param
35 | * the generic type of the component
36 | */
37 | public interface View
38 | {
39 |
40 | /**
41 | * Gets the component.
42 | *
43 | * @return the component
44 | */
45 | COMP getComponent();
46 |
47 | /**
48 | * Sets the component.
49 | *
50 | * @param component
51 | * the new component
52 | */
53 | void setComponent(final COMP component);
54 |
55 | /**
56 | * Gets the controller.
57 | *
58 | * @return the controller
59 | */
60 | C getController();
61 |
62 | /**
63 | * Sets the controller.
64 | *
65 | * @param controller
66 | * the new controller
67 | */
68 | void setController(final C controller);
69 |
70 | /**
71 | * Gets the parent.
72 | *
73 | * @return the parent
74 | */
75 | View, ?> getParent();
76 |
77 | /**
78 | * Checks for parent.
79 | *
80 | * @return true, if successful
81 | */
82 | boolean hasParent();
83 |
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/panel/output/JLabelOutputStream.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.output;
26 |
27 | import javax.swing.JComponent;
28 | import javax.swing.JLabel;
29 |
30 | public class JLabelOutputStream extends AbstractComponentOutputStream
31 | {
32 |
33 | private final StringBuilder sb = new StringBuilder();
34 |
35 | public JLabelOutputStream(JLabel component)
36 | {
37 | super(component);
38 | }
39 |
40 | public JLabelOutputStream(JLabel component, int maxLines)
41 | {
42 | super(component, maxLines);
43 | }
44 |
45 | @Override
46 | protected void append(JComponent swingComponent, String text)
47 | {
48 | sb.append(text);
49 | redrawTextOf(swingComponent);
50 | }
51 |
52 | protected void redrawTextOf(JComponent swingComponent)
53 | {
54 | ((JLabel)swingComponent).setText(sb.toString());
55 | }
56 |
57 | @Override
58 | protected void replaceRange(JComponent swingComponent, String text, int start, int end)
59 | {
60 | sb.replace(start, end, text);
61 | redrawTextOf(swingComponent);
62 | }
63 |
64 | @Override
65 | protected void setText(JComponent swingComponent, String text)
66 | {
67 | sb.delete(0, sb.length());
68 | append(swingComponent, text);
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/panel/output/JTextAreaOutputStream.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.output;
26 |
27 | import javax.swing.JComponent;
28 | import javax.swing.JTextArea;
29 |
30 | public class JTextAreaOutputStream extends AbstractComponentOutputStream
31 | {
32 |
33 | private final StringBuilder sb = new StringBuilder();
34 |
35 | public JTextAreaOutputStream(JTextArea component)
36 | {
37 | super(component);
38 | }
39 |
40 | public JTextAreaOutputStream(JTextArea component, int maxLines)
41 | {
42 | super(component, maxLines);
43 | }
44 |
45 | @Override
46 | protected void append(JComponent swingComponent, String text)
47 | {
48 | sb.append(text);
49 | redrawTextOf(swingComponent);
50 | }
51 |
52 | protected void redrawTextOf(JComponent swingComponent)
53 | {
54 | ((JTextArea)swingComponent).setText(sb.toString());
55 | }
56 |
57 | @Override
58 | protected void replaceRange(JComponent swingComponent, String text, int start, int end)
59 | {
60 | sb.replace(start, end, text);
61 | redrawTextOf(swingComponent);
62 | }
63 |
64 | @Override
65 | protected void setText(JComponent swingComponent, String text)
66 | {
67 | sb.delete(0, sb.length());
68 | append(swingComponent, text);
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/check/model/JCheckBoxWithPropertyModelTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.check.model;
26 |
27 | import java.awt.Frame;
28 | import java.awt.GridBagLayout;
29 |
30 | import javax.swing.JButton;
31 | import javax.swing.JCheckBox;
32 |
33 | import io.github.astrapi69.awt.window.adapter.CloseWindow;
34 | import io.github.astrapi69.model.PropertyModel;
35 |
36 | public class JCheckBoxWithPropertyModelTest
37 | {
38 | public static void main(String[] args)
39 | {
40 | // Bind legacy JCheckBox with a property model
41 | JCheckBox checkBox;
42 | checkBox = new JCheckBox("a checkbox");
43 | final PropertyModel propertyModel = PropertyModel.of(checkBox, "model.selected");
44 |
45 | final Frame frame = new Frame("JCheckBoxWithPropertyModelTest");
46 | JButton buttonCheck = new JButton("Toogle");
47 | buttonCheck.addActionListener(e -> {
48 | Boolean object = propertyModel.getObject();
49 | checkBox.setSelected(!checkBox.isSelected());
50 | object = propertyModel.getObject();
51 | System.err.println(object);
52 | });
53 | frame.addWindowListener(new CloseWindow());
54 |
55 | frame.setLayout(new GridBagLayout());
56 | frame.add(buttonCheck);
57 | frame.add(checkBox);
58 | frame.setSize(200, 200);
59 | frame.setVisible(true);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/panel/output/ConsolePanel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.output;
26 |
27 | import java.awt.BorderLayout;
28 | import java.io.PrintStream;
29 |
30 | import javax.swing.JPanel;
31 | import javax.swing.JScrollPane;
32 | import javax.swing.JTextArea;
33 |
34 | /**
35 | * The class {@link ConsolePanel} provides a {@link JTextArea} that prints the output from system
36 | * out and error output stream
37 | */
38 | public class ConsolePanel extends JPanel
39 | {
40 | private static final long serialVersionUID = 1L;
41 |
42 | final JScrollPane jScrollPane;
43 | final JTextArea textArea;
44 |
45 | public ConsolePanel()
46 | {
47 | super(new BorderLayout());
48 | textArea = newJTextArea();
49 | jScrollPane = new JScrollPane(textArea);
50 | add(jScrollPane);
51 | }
52 |
53 | /**
54 | * Factory method that creates a new {@link JTextArea} that prints the output from system out
55 | * and error output stream. For custom
56 | *
57 | * @return the JX text area
58 | */
59 | protected JTextArea newJTextArea()
60 | {
61 | JTextArea textArea = new JTextArea();
62 | JTextAreaOutputStream taout = new JTextAreaOutputStream(textArea, 60);
63 | PrintStream ps = new PrintStream(taout);
64 | System.setOut(ps);
65 | System.setErr(ps);
66 | return textArea;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/panel/login/pw/ChangePasswordModelBean.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.login.pw;
26 |
27 | import java.io.Serializable;
28 |
29 | import lombok.AllArgsConstructor;
30 | import lombok.Builder;
31 | import lombok.EqualsAndHashCode;
32 | import lombok.Getter;
33 | import lombok.NoArgsConstructor;
34 | import lombok.Setter;
35 | import lombok.ToString;
36 |
37 | /**
38 | * The Class {@link ChangePasswordModelBean} captures the data for change the password of a user.
39 | *
40 | * @author Asterios Raptis
41 | */
42 | @Getter
43 | @Setter
44 | @EqualsAndHashCode
45 | @ToString
46 | @NoArgsConstructor
47 | @AllArgsConstructor
48 | @Builder(toBuilder = true)
49 | public class ChangePasswordModelBean implements Serializable
50 | {
51 |
52 | /**
53 | * The serialVersionUID.
54 | */
55 | private static final long serialVersionUID = 1L;
56 |
57 | /** The current password of a user. */
58 | @Builder.Default
59 | private String currentPassword = "";
60 |
61 | /** The new password of a user. */
62 | @Builder.Default
63 | private String newPassword = "";
64 |
65 | /** The repeated new password of a user. */
66 | @Builder.Default
67 | private String repeatNewPassword = "";
68 |
69 | /** The users name of a user. */
70 | @Builder.Default
71 | private String username = "";
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/panel/network/NetworkSettingsModelBean.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.network;
26 |
27 | import java.io.Serializable;
28 |
29 | import lombok.AllArgsConstructor;
30 | import lombok.Builder;
31 | import lombok.EqualsAndHashCode;
32 | import lombok.Getter;
33 | import lombok.NoArgsConstructor;
34 | import lombok.Setter;
35 | import lombok.ToString;
36 |
37 | /**
38 | * The class {@link NetworkSettingsModelBean}.
39 | */
40 | @Getter
41 | @Setter
42 | @EqualsAndHashCode
43 | @ToString
44 | @NoArgsConstructor
45 | @AllArgsConstructor
46 | @Builder(toBuilder = true)
47 | public class NetworkSettingsModelBean implements Serializable
48 | {
49 |
50 | /**
51 | * The Constant serialVersionUID.
52 | */
53 | private static final long serialVersionUID = 3097232755356031060L;
54 |
55 | /** The host. */
56 | private String host;
57 |
58 | /** The password. */
59 | private String password;
60 |
61 | /** The port. */
62 | private Integer port;
63 |
64 | /** The flag proxy is used. */
65 | private Boolean proxy;
66 |
67 | /** The proxy authetication. */
68 | private Boolean proxyAuthetication;
69 |
70 | /** The flag if the password should be remembered. */
71 | private Boolean rememberPassword;
72 |
73 | /** The flag if socks is used. */
74 | private Boolean socks;
75 |
76 | /** The username. */
77 | private String username;
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/img/ImageToPdfExtensionsTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.img;
26 |
27 | import java.io.File;
28 |
29 | import org.junit.jupiter.api.Test;
30 |
31 | import io.github.astrapi69.file.delete.DeleteFileExtensions;
32 | import io.github.astrapi69.file.search.PathFinder;
33 | import net.lingala.zip4j.ZipFile;
34 | import net.lingala.zip4j.model.ZipParameters;
35 |
36 | /**
37 | * The class {@link ImageToPdfExtensionsTest}.
38 | */
39 | public class ImageToPdfExtensionsTest
40 | {
41 |
42 | /**
43 | * Test zip.
44 | *
45 | * @throws Exception
46 | * the exception
47 | */
48 | @Test
49 | public void testZip() throws Exception
50 | {
51 | final String filenameprefix = "bell";
52 | final String ext = "png";
53 | final File hImg = PathFinder.getRelativePath(PathFinder.getSrcTestResourcesDir(), "img",
54 | "xmas", filenameprefix + "." + ext);
55 |
56 | final File imgDir = PathFinder.getRelativePath(PathFinder.getSrcTestResourcesDir(), "img",
57 | "xmas");
58 |
59 | final ZipFile zipFile4j = new ZipFile(
60 | imgDir.getAbsolutePath() + File.separator + "testZip.zip");
61 | // Initiate Zip Parameters which define various properties such
62 | // as compression method, etc.
63 | final ZipParameters parameters = new ZipParameters();
64 |
65 | // Add folder to the zip file
66 | zipFile4j.addFile(hImg, parameters);
67 | DeleteFileExtensions.delete(zipFile4j.getFile());
68 |
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/panel/lottery/LotteryBox.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.lottery;
26 |
27 | import java.util.LinkedHashSet;
28 |
29 | import lombok.AccessLevel;
30 | import lombok.AllArgsConstructor;
31 | import lombok.Builder;
32 | import lombok.EqualsAndHashCode;
33 | import lombok.Getter;
34 | import lombok.NoArgsConstructor;
35 | import lombok.Setter;
36 | import lombok.ToString;
37 | import lombok.experimental.FieldDefaults;
38 |
39 | /**
40 | * The class {@link LotteryBox} represents exactly one lottery box in a lottery ticket
41 | */
42 | @Getter
43 | @Setter
44 | @EqualsAndHashCode
45 | @ToString
46 | @NoArgsConstructor
47 | @AllArgsConstructor
48 | @Builder(toBuilder = true)
49 | @FieldDefaults(level = AccessLevel.PRIVATE)
50 | public class LotteryBox
51 | {
52 |
53 | /** The columns for the layout. */
54 | @Builder.Default
55 | int columns = 7;
56 |
57 | /** The index of this box in the lottery ticket */
58 | @Builder.Default
59 | int index = 0;
60 |
61 | /** The maximum value of selected numbers. */
62 | @Builder.Default
63 | int maxNumbers = 6;
64 |
65 | /** The max volume. */
66 | @Builder.Default
67 | int maxVolume = 49;
68 |
69 | /** The min volume. */
70 | @Builder.Default
71 | int minVolume = 1;
72 |
73 | /** The rows for the layout. */
74 | @Builder.Default
75 | int rows = 7;
76 |
77 | /** The selected numbers. */
78 | LinkedHashSet selectedNumbers;
79 |
80 | /** The step count for the iteration */
81 | @Builder.Default
82 | int step = 1;
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/test/TestSwingMvvm.java:
--------------------------------------------------------------------------------
1 | package io.github.astrapi69.swing.test;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertEquals;
4 | import static org.junit.jupiter.api.Assertions.assertNotSame;
5 |
6 | import java.awt.Color;
7 | import java.awt.Font;
8 |
9 | import javax.swing.JLabel;
10 | import javax.swing.JTextField;
11 |
12 | import org.junit.jupiter.api.Test;
13 |
14 | import io.github.astrapi69.test.object.Employee;
15 | import io.github.astrapi69.test.object.Person;
16 | import net.sds.mvvm.bindings.BindingBuilder;
17 | import net.sds.mvvm.bindings.BindingException;
18 | import net.sds.mvvm.properties.Property;
19 | import net.sds.mvvm.properties.PropertyFactory;
20 | import net.sds.mvvm.triggers.DocumentTextChangedTrigger;
21 |
22 | public class TestSwingMvvm
23 | {
24 |
25 |
26 | @Test
27 | public void theSourceCanBeAComponent() throws BindingException
28 | {
29 | Property colorProperty = PropertyFactory.createProperty("Color", this, Color.class);
30 | JLabel label = new JLabel();
31 | new BindingBuilder().withSourceSupplier(() -> label.getForeground())
32 | .withSourceTrigger(
33 | (b, d) -> label.addPropertyChangeListener("foreground", e -> b.apply(d)))
34 | .withTargetConsumer(colorProperty::set).build();
35 |
36 | label.setForeground(Color.RED);
37 | assertEquals(Color.RED, label.getForeground());
38 | }
39 |
40 | @Test
41 | public void testEncapsulatedAutoBindingWithJLabel() throws BindingException
42 | {
43 | String actual;
44 | String expected;
45 | String value;
46 | String text;
47 | Employee employee;
48 | JLabel lblValue;
49 |
50 | value = "foo";
51 | employee = Employee.builder().person(Person.builder().nickname(value).build()).build();
52 | lblValue = new JLabel();
53 |
54 | new BindingBuilder().withSourceSupplier(() -> lblValue.getText())
55 | .withSourceTrigger(
56 | (b, d) -> lblValue.addPropertyChangeListener("text", e -> b.apply(d)))
57 | .withTargetConsumer(t -> employee.getPerson().setNickname(t)).build();
58 |
59 | text = "bar";
60 | lblValue.setText(text);
61 | actual = employee.getPerson().getNickname();
62 | expected = text;
63 | assertEquals(actual, expected);
64 |
65 | }
66 |
67 | @Test
68 | public void textChangesArePropagated() throws BindingException
69 | {
70 | final StringBuilder b = new StringBuilder();
71 | JTextField jTextField = new JTextField();
72 | new BindingBuilder().withSourceSupplier(() -> jTextField.getText())
73 | .withSourceTrigger(new DocumentTextChangedTrigger(jTextField.getDocument()))
74 | .withTargetConsumer(t -> b.append(t)).build();
75 |
76 | jTextField.setText("New text");
77 | assertEquals("New text", b.toString());
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/panel/lottery/LotteryPanelTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.lottery;
26 |
27 | import java.awt.Frame;
28 | import java.util.LinkedHashSet;
29 |
30 | import io.github.astrapi69.awt.window.adapter.CloseWindow;
31 | import io.github.astrapi69.model.BaseModel;
32 | import io.github.astrapi69.model.api.IModel;
33 |
34 | public class LotteryPanelTest
35 | {
36 |
37 | /**
38 | * The main method.
39 | *
40 | * @param args
41 | * the arguments
42 | */
43 | public static void main(final String[] args)
44 | {
45 |
46 | final Frame frame = new Frame();
47 | frame.addWindowListener(new CloseWindow());
48 | frame.setTitle("Lottery Panel");
49 | IModel lotteryModel;
50 |
51 | lotteryModel = BaseModel.of(
52 | LotteryBox.builder().selectedNumbers(new LinkedHashSet<>()).minVolume(1).maxVolume(49)
53 | // .step(1)
54 | .rows(7).columns(7).build());
55 |
56 | // lotteryModel = BaseModel.of(LotteryBox.builder().selectedNumbers(new LinkedHashSet<>())
57 | // .minVolume(2)
58 | // .maxVolume(98)
59 | // .step(2)
60 | // .rows(7)
61 | // .columns(7)
62 | // .build());
63 |
64 | // lotteryModel = BaseModel.of(LotteryBox.builder().selectedNumbers(new LinkedHashSet<>())
65 | // .minVolume(2)
66 | // .maxVolume(72)
67 | // .step(2)
68 | // .rows(6)
69 | // .columns(6)
70 | // .build());
71 |
72 | final LotteryPanel panel = new LotteryPanel(lotteryModel);
73 |
74 | frame.add(panel);
75 | frame.pack();
76 | frame.setSize(500, 300);
77 | frame.setVisible(true);
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/icon/ShapeIcon.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.icon;
26 |
27 | import java.awt.Color;
28 | import java.awt.Component;
29 | import java.awt.Graphics;
30 | import java.awt.Graphics2D;
31 | import java.awt.RenderingHints;
32 | import java.awt.Shape;
33 | import java.awt.geom.AffineTransform;
34 |
35 | import javax.swing.Icon;
36 |
37 | import lombok.AccessLevel;
38 | import lombok.AllArgsConstructor;
39 | import lombok.Data;
40 | import lombok.experimental.FieldDefaults;
41 | import lombok.experimental.SuperBuilder;
42 |
43 | @Data
44 | @AllArgsConstructor
45 | @SuperBuilder
46 | @FieldDefaults(level = AccessLevel.PRIVATE)
47 | public class ShapeIcon implements Icon
48 | {
49 | final Shape shape;
50 | final Color shapeColor;
51 | Color backgroundColor;
52 | int iconWidth;
53 | int iconHeight;
54 |
55 | @Override
56 | public void paintIcon(Component component, Graphics graphics, int x, int y)
57 | {
58 | Graphics2D graphics2D = (Graphics2D)graphics;
59 | graphics2D.setColor(backgroundColor);
60 | graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
61 | RenderingHints.VALUE_ANTIALIAS_ON);
62 | graphics2D.fillRect(x, y, getIconWidth(), getIconHeight());
63 | AffineTransform affineTransform = new AffineTransform();
64 | affineTransform.translate(x, y);
65 | affineTransform.scale(getIconWidth(), getIconHeight());
66 |
67 | Shape transformedShape = affineTransform.createTransformedShape(shape);
68 | graphics2D.setColor(shapeColor);
69 | graphics2D.fill(transformedShape);
70 | graphics2D.setColor(Color.BLACK);
71 | graphics2D.draw(transformedShape);
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/panel/login/NewPasswordPanelTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.login;
26 |
27 | import java.awt.Frame;
28 |
29 | import javax.swing.event.DocumentEvent;
30 |
31 | import io.github.astrapi69.awt.window.adapter.CloseWindow;
32 | import io.github.astrapi69.model.LambdaModel;
33 | import io.github.astrapi69.model.api.IModel;
34 | import io.github.astrapi69.swing.listener.document.StringBindingListener;
35 | import io.github.astrapi69.swing.panel.login.pw.ChangePasswordModelBean;
36 | import io.github.astrapi69.swing.panel.login.pw.NewPasswordPanel;
37 |
38 | public class NewPasswordPanelTest
39 | {
40 |
41 | public static void main(final String[] args)
42 | {
43 |
44 | final Frame frame = new Frame();
45 | frame.addWindowListener(new CloseWindow());
46 | frame.setTitle("Set pw Frame");
47 | final NewPasswordPanel newPasswordPanel = new NewPasswordPanel();
48 | // example of binding model with a textfield with the class StringBindingListener...
49 | ChangePasswordModelBean modelObject = newPasswordPanel.getModelObject();
50 | IModel model = LambdaModel.of(modelObject::getCurrentPassword,
51 | modelObject::setCurrentPassword);
52 | newPasswordPanel.getTxtPassword().getDocument()
53 | .addDocumentListener(new StringBindingListener(model)
54 | {
55 | @Override
56 | protected void update(DocumentEvent event)
57 | {
58 | super.update(event);
59 | System.out.println(model.getObject() + "::"
60 | + newPasswordPanel.getModelObject().getCurrentPassword());
61 | }
62 | });
63 | frame.add(newPasswordPanel);
64 | frame.pack();
65 | frame.setSize(500, 300);
66 | frame.setVisible(true);
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/panel/keypad/KeypadView.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.keypad;
26 |
27 | import io.github.astrapi69.mvc.view.AbstractGenericView;
28 |
29 | public class KeypadView extends AbstractGenericView
30 | {
31 |
32 | KeyPadPanel keyPadPanel = null;
33 |
34 | public KeypadView(final KeypadController controller)
35 | {
36 | super(controller);
37 | controller.setView(this);
38 | initialize();
39 | }
40 |
41 | public KeypadController getKeypadController()
42 | {
43 | return getController();
44 | }
45 |
46 | @Override
47 | protected void initialize()
48 | {
49 | keyPadPanel = new KeyPadPanel();
50 | setComponent(keyPadPanel);
51 | keyPadPanel.getButton0().addActionListener(getKeypadController());
52 | keyPadPanel.getButton1().addActionListener(getKeypadController());
53 | keyPadPanel.getButton2().addActionListener(getKeypadController());
54 | keyPadPanel.getButton3().addActionListener(getKeypadController());
55 | keyPadPanel.getButton4().addActionListener(getKeypadController());
56 | keyPadPanel.getButton5().addActionListener(getKeypadController());
57 | keyPadPanel.getButton6().addActionListener(getKeypadController());
58 | keyPadPanel.getButton7().addActionListener(getKeypadController());
59 | keyPadPanel.getButton8().addActionListener(getKeypadController());
60 | keyPadPanel.getButton9().addActionListener(getKeypadController());
61 | keyPadPanel.getButtonCancel().addActionListener(getKeypadController());
62 | keyPadPanel.getButtonEnter().addActionListener(getKeypadController());
63 | keyPadPanel.getButtonMinus().addActionListener(getKeypadController());
64 | keyPadPanel.getButtonPlus().addActionListener(getKeypadController());
65 | keyPadPanel.getButtonStorno().addActionListener(getKeypadController());
66 | keyPadPanel.getButtonTable().addActionListener(getKeypadController());
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/icon/ShapeIconPaintTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.icon;
26 |
27 | import java.awt.BorderLayout;
28 | import java.awt.Color;
29 | import java.awt.FlowLayout;
30 | import java.awt.Shape;
31 | import java.awt.geom.Path2D;
32 |
33 | import javax.swing.JFrame;
34 | import javax.swing.JLabel;
35 | import javax.swing.JPanel;
36 | import javax.swing.JSlider;
37 | import javax.swing.SwingUtilities;
38 |
39 | public class ShapeIconPaintTest
40 | {
41 | public static void main(String[] args)
42 | {
43 | SwingUtilities.invokeLater(() -> createAndShowGui());
44 | }
45 |
46 | private static void createAndShowGui()
47 | {
48 | JFrame frame = new JFrame();
49 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
50 | frame.getContentPane().setLayout(new BorderLayout());
51 |
52 | JPanel panel = new JPanel(new FlowLayout());
53 |
54 | ShapeIcon customIcon = ShapeIcon.builder().shape(createArrowShape()).shapeColor(Color.RED)
55 | .backgroundColor(Color.GREEN).iconHeight(16).iconWidth(16).build();
56 | panel.add(new JLabel(customIcon));
57 |
58 | frame.getContentPane().add(panel, BorderLayout.CENTER);
59 |
60 | JPanel controlPanel = new JPanel(new FlowLayout());
61 | JSlider slider = new JSlider(16, 64, 16);
62 | slider.addChangeListener(e -> {
63 | int value = slider.getValue();
64 | customIcon.setIconWidth(value);
65 | customIcon.setIconHeight(value);
66 | panel.revalidate();
67 | });
68 | controlPanel.add(slider);
69 |
70 | frame.getContentPane().add(controlPanel, BorderLayout.SOUTH);
71 |
72 | frame.setSize(500, 300);
73 | frame.setLocationRelativeTo(null);
74 | frame.setVisible(true);
75 | }
76 |
77 | private static Shape createArrowShape()
78 | {
79 | Path2D path = new Path2D.Double();
80 | path.moveTo(0.0, 0.25);
81 | path.lineTo(0.5, 0.25);
82 | path.lineTo(0.5, 0.0);
83 | path.lineTo(1.0, 0.5);
84 | path.lineTo(0.5, 1.0);
85 | path.lineTo(0.5, 0.75);
86 | path.lineTo(0.0, 0.75);
87 | path.closePath();
88 | return path;
89 | }
90 |
91 | }
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
34 |
35 | @rem Find java.exe
36 | if defined JAVA_HOME goto findJavaFromJavaHome
37 |
38 | set JAVA_EXE=java.exe
39 | %JAVA_EXE% -version >NUL 2>&1
40 | if "%ERRORLEVEL%" == "0" goto init
41 |
42 | echo.
43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
44 | echo.
45 | echo Please set the JAVA_HOME variable in your environment to match the
46 | echo location of your Java installation.
47 |
48 | goto fail
49 |
50 | :findJavaFromJavaHome
51 | set JAVA_HOME=%JAVA_HOME:"=%
52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
53 |
54 | if exist "%JAVA_EXE%" goto init
55 |
56 | echo.
57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
58 | echo.
59 | echo Please set the JAVA_HOME variable in your environment to match the
60 | echo location of your Java installation.
61 |
62 | goto fail
63 |
64 | :init
65 | @rem Get command-line arguments, handling Windows variants
66 |
67 | if not "%OS%" == "Windows_NT" goto win9xME_args
68 |
69 | :win9xME_args
70 | @rem Slurp the command line arguments.
71 | set CMD_LINE_ARGS=
72 | set _SKIP=2
73 |
74 | :win9xME_args_slurp
75 | if "x%~1" == "x" goto execute
76 |
77 | set CMD_LINE_ARGS=%*
78 |
79 | :execute
80 | @rem Setup the command line
81 |
82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
83 |
84 | @rem Execute Gradle
85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
86 |
87 | :end
88 | @rem End local scope for the variables with windows NT shell
89 | if "%ERRORLEVEL%"=="0" goto mainEnd
90 |
91 | :fail
92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
93 | rem the _cmd.exe /c_ return code!
94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
95 | exit /b 1
96 |
97 | :mainEnd
98 | if "%OS%"=="Windows_NT" endlocal
99 |
100 | :omega
101 |
--------------------------------------------------------------------------------
/gradle/publishing.gradle:
--------------------------------------------------------------------------------
1 | def releaseVersion = !version.endsWith("SNAPSHOT")
2 |
3 | task sourcesJar(type: Jar) {
4 | archiveClassifier.set("sources")
5 | from(sourceSets.main.allJava)
6 | }
7 |
8 | task javadocJar(type: Jar) {
9 | from javadoc
10 | archiveClassifier.set("javadoc")
11 | javadoc {
12 | failOnError = false
13 | }
14 | }
15 |
16 | javadoc {
17 | failOnError = false
18 | if(JavaVersion.current().isJava9Compatible()) {
19 | options.addBooleanOption("html5", true)
20 | }
21 | }
22 |
23 | publishing {
24 | publications {
25 | mavenJava(MavenPublication) {
26 | artifactId = "$rootProject.name"
27 | from components.java
28 | artifact sourcesJar
29 | artifact javadocJar
30 | pom {
31 | name = "$rootProject.name"
32 | description = "$projectDescription"
33 | url = "$projectScmProviderUrl"+"$projectHolderUsername"+"$slash"+"$rootProject.name"
34 | organization {
35 | name = "$projectOrganizationName"
36 | url = "$projectOrganizationUrl"
37 | }
38 | issueManagement {
39 | system = "$projectIssueManagementSystem"
40 | url = "$projectScmProviderUrl"+"$projectHolderUsername"+"$slash"+"$rootProject.name"+"$issuesPath"
41 | }
42 | licenses {
43 | license {
44 | name = "$projectLicenseName"
45 | url = "$projectLicenseUrl"
46 | distribution = "$projectLicenseDistribution"
47 | }
48 | }
49 | developers {
50 | developer {
51 | id = "$projectHolderUsername"
52 | name = "$projectLeaderName"
53 | }
54 | }
55 | scm {
56 | connection = "$projectScmGitUrlPrefix" + "$projectScmProviderDomain" + "$colon" + "$projectHolderUsername" + "$slash" + "$rootProject.name" + "$projectScmGitUrlSuffix"
57 | developerConnection = "$projectScmGitUrlPrefix" + "$projectScmProviderDomain" + "$colon" + "$projectHolderUsername" + "$slash" + "$rootProject.name" + "$projectScmGitUrlSuffix"
58 | url = "$projectScmGitUrlPrefix" + "$projectScmProviderDomain" + "$colon" + "$projectHolderUsername" + "$slash" + "$rootProject.name" + "$projectScmGitUrlSuffix"
59 | }
60 | }
61 | }
62 | }
63 | repositories {
64 | maven {
65 | credentials {
66 | username System.getenv("$projectRepositoriesUserNameKey") ?: project.property("$projectRepositoriesUserNameKey")
67 | password System.getenv("$projectRepositoriesPasswordKey") ?: project.property("$projectRepositoriesPasswordKey")
68 | }
69 | def releasesRepoUrl = "$projectRepositoriesReleasesRepoUrl" as Object
70 | def snapshotsRepoUrl = "$projectRepositoriesSnapshotsRepoUrl" as Object
71 | url = releaseVersion ? releasesRepoUrl : snapshotsRepoUrl
72 | }
73 | }
74 | }
75 |
76 | signing {
77 | if (releaseVersion) {
78 | sign publishing.publications.mavenJava
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/layout/DrawMessageTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.layout;
26 |
27 | import java.awt.Color;
28 | import java.awt.Dimension;
29 | import java.awt.Frame;
30 | import java.awt.event.WindowListener;
31 |
32 | import org.junit.jupiter.api.AfterEach;
33 | import org.junit.jupiter.api.BeforeEach;
34 | import org.junit.jupiter.api.Disabled;
35 | import org.junit.jupiter.api.Test;
36 |
37 | import io.github.astrapi69.awt.window.adapter.CloseWindow;
38 | import io.github.astrapi69.awt.window.adapter.DisposeWindow;
39 |
40 |
41 | /**
42 | * The unit test class for the class DrawMessage.
43 | *
44 | * @version 1.0
45 | * @author Asterios Raptis
46 | */
47 | public class DrawMessageTest
48 | {
49 |
50 | /** The dispose window. */
51 | DisposeWindow disposeWindow = null;
52 |
53 | /**
54 | * Sets up method will be invoked before every unit test method in this class.
55 | *
56 | * @throws Exception
57 | * the exception
58 | */
59 | @BeforeEach
60 | protected void setUp() throws Exception
61 | {
62 | }
63 |
64 | /**
65 | * Tear down method will be invoked after every unit test method in this class.
66 | *
67 | * @throws Exception
68 | * the exception
69 | */
70 | @AfterEach
71 | protected void tearDown() throws Exception
72 | {
73 | }
74 |
75 | /**
76 | * Test method for.
77 | *
78 | * {@link io.github.astrapi69.layout.DrawMessage#paint(java.awt.Graphics)} .
79 | */
80 | @Test
81 | @Disabled
82 | public void testPaintGraphics()
83 | {
84 | final WindowListener l = new CloseWindow();
85 | final Frame f = new Frame("DrawMessage 2D Text");
86 | f.addWindowListener(l);
87 | final Color color = new Color(0, 180, 0);
88 | final DrawMessage message = new DrawMessage("Drawed Message with DrawMessage", color);
89 | f.add("Center", message);
90 | f.pack();
91 | f.setSize(new Dimension(400, 80));
92 | f.setVisible(true);
93 | try
94 | {
95 | Thread.sleep(7000);
96 | }
97 | catch (final InterruptedException e1)
98 | {
99 | e1.printStackTrace();
100 | }
101 | f.setVisible(false);
102 | f.dispose();
103 | }
104 |
105 | }
106 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/test/TestComponentFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.test;
26 |
27 | import java.awt.Dimension;
28 | import java.awt.Frame;
29 | import java.awt.Rectangle;
30 |
31 | import javax.swing.JComponent;
32 | import javax.swing.JFrame;
33 |
34 | import io.github.astrapi69.awt.screen.ScreenSizeExtensions;
35 | import io.github.astrapi69.awt.window.adapter.CloseWindow;
36 | import io.github.astrapi69.swing.component.factory.JComponentFactory;
37 |
38 | public final class TestComponentFactory
39 | {
40 |
41 | public static Frame newTestFrame(String title)
42 | {
43 | final Frame frame = JComponentFactory.newFrame(title);
44 | frame.addWindowListener(new CloseWindow());
45 | return frame;
46 | }
47 |
48 | public static JFrame newTestJFrame(String title)
49 | {
50 | final JFrame frame = JComponentFactory.newJFrame(title);
51 | frame.addWindowListener(new CloseWindow());
52 | return frame;
53 | }
54 |
55 | public static JFrame newTestJFrameWithComponent(String title, JComponent component)
56 | {
57 | final JFrame frame = newTestJFrame(title);
58 | frame.addWindowListener(new CloseWindow());
59 | frame.add(component);
60 | return frame;
61 | }
62 |
63 | public static JFrame newTestJFrameWithComponent(String title, JComponent component,
64 | Rectangle rectangle)
65 | {
66 | final JFrame frame = newTestJFrame(title);
67 | frame.addWindowListener(new CloseWindow());
68 | frame.add(component);
69 | frame.setBounds(rectangle);
70 | return frame;
71 | }
72 |
73 | public static JFrame newTestJFrameWithComponent(String title, JComponent component,
74 | Dimension dimension)
75 | {
76 | final JFrame frame = newTestJFrame(title);
77 | frame.addWindowListener(new CloseWindow());
78 | frame.add(component);
79 | frame.setSize(dimension);
80 | return frame;
81 | }
82 |
83 | public static void showFrame(Frame frame, int divideScreenWith)
84 | {
85 | showFrame(frame, divideScreenWith, divideScreenWith);
86 | }
87 |
88 | public static void showFrame(Frame frame, int divideScreenWith, int divideScreenHeight)
89 | {
90 | ScreenSizeExtensions.centralize(frame, divideScreenWith, divideScreenHeight);
91 | ScreenSizeExtensions.showFrame(frame);
92 | }
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/check/model/CheckListPanelAssertjSwingTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.check.model;
26 |
27 | import static org.junit.jupiter.api.Assertions.assertNotNull;
28 | import static org.junit.jupiter.api.Assertions.assertTrue;
29 |
30 | import java.awt.Frame;
31 |
32 | import org.assertj.swing.fixture.FrameFixture;
33 | import org.junit.jupiter.api.Test;
34 | import org.junit.jupiter.api.extension.ExtendWith;
35 |
36 | import io.github.astrapi69.awt.window.adapter.CloseWindow;
37 | import io.github.astrapi69.component.model.check.CheckableItem;
38 | import io.github.astrapi69.component.model.check.CheckableListModel;
39 | import io.github.astrapi69.component.model.check.CheckableValue;
40 | import io.github.astrapi69.junit.jupiter.callback.before.test.IgnoreHeadlessExceptionExtension;
41 | import io.github.astrapi69.model.BaseModel;
42 | import io.github.astrapi69.model.api.IModel;
43 | import io.github.astrapi69.swing.list.JListExtensions;
44 |
45 | /**
46 | * GUI unit test with assertj-swing module
47 | */
48 | public class CheckListPanelAssertjSwingTest
49 | {
50 |
51 | private FrameFixture underTest;
52 | private CheckListPanel componentToTest;
53 |
54 | @ExtendWith(IgnoreHeadlessExceptionExtension.class)
55 | @Test
56 | // @Disabled
57 | public void test()
58 | {
59 | final Frame frame = new Frame("TestFrame");
60 | String[] strs = { "root", "home", "kde", "mint", "ubuntu" };
61 | CheckableItem[] checkableItems = JListExtensions.newCheckableItems(strs);
62 | IModel model = BaseModel
63 | .of(CheckableListModel.builder().values(checkableItems).build());
64 | componentToTest = new CheckListPanel(model);
65 | frame.add(componentToTest);
66 | frame.addWindowListener(new CloseWindow());
67 | frame.setSize(300, 200);
68 | frame.setVisible(true);
69 | underTest = new FrameFixture(frame);
70 | underTest.list("list").clickItem(0);
71 | underTest.button("printButton").click();
72 | underTest.textBox("textArea").requireText("root" + System.lineSeparator());
73 | // check model value is set
74 | CheckableItem[] values = componentToTest.getModelObject().getValues();
75 | assertNotNull(values);
76 | assertNotNull(values[0]);
77 | assertTrue(values[0].isSelected());
78 | frame.setVisible(false);
79 | frame.dispose();
80 | underTest = null;
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/list/JListExtensions.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.list;
26 |
27 | import java.awt.Rectangle;
28 | import java.awt.event.MouseAdapter;
29 | import java.awt.event.MouseEvent;
30 | import java.util.List;
31 |
32 | import javax.swing.Icon;
33 | import javax.swing.JList;
34 | import javax.swing.ListSelectionModel;
35 | import javax.swing.border.EmptyBorder;
36 | import javax.swing.plaf.metal.MetalIconFactory;
37 |
38 | import io.github.astrapi69.collection.list.ListExtensions;
39 | import io.github.astrapi69.collection.list.ListFactory;
40 | import io.github.astrapi69.component.model.check.CheckableItem;
41 | import io.github.astrapi69.component.model.check.CheckableValue;
42 | import io.github.astrapi69.swing.renderer.tree.renderer.list.CheckBoxListRenderer;
43 |
44 | public class JListExtensions
45 | {
46 |
47 | public static CheckableItem[] newCheckableItems(String[] strs)
48 | {
49 | int n = strs.length;
50 | List> itemList = ListFactory.newArrayList();
51 | for (int i = 0; i < n; i++)
52 | {
53 | itemList.add(CheckableItem. builder()
54 | .checkableValue(CheckableValue.builder().itemText(strs[i]).build()).build());
55 | }
56 | return ListExtensions.toArray(itemList);
57 | }
58 |
59 | public static JList> newJList(String[] strs)
60 | {
61 | CheckableItem[] checkableItems = newCheckableItems(strs);
62 | return newJList(checkableItems);
63 | }
64 |
65 | public static JList> newJList(
66 | CheckableItem[] checkableItems)
67 | {
68 | final JList> list = new JList<>(checkableItems);
69 |
70 | Icon icon = MetalIconFactory.getFileChooserHomeFolderIcon();
71 | list.getModel().getElementAt(1).getCheckableValue().setIcon(icon);
72 |
73 | list.setCellRenderer(new CheckBoxListRenderer());
74 | list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
75 | list.setBorder(new EmptyBorder(0, 4, 0, 0));
76 | list.addMouseListener(new MouseAdapter()
77 | {
78 | @Override
79 | public void mouseClicked(MouseEvent e)
80 | {
81 | int index = list.locationToIndex(e.getPoint());
82 | CheckableItem item = list.getModel().getElementAt(index);
83 | item.setSelected(!item.isSelected());
84 | Rectangle rect = list.getCellBounds(index, index);
85 | list.repaint(rect);
86 | }
87 | });
88 | return list;
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/base/PanelDialogExample.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.base;
26 |
27 | import java.awt.BorderLayout;
28 | import java.awt.Frame;
29 | import java.awt.event.ActionEvent;
30 |
31 | import javax.swing.JButton;
32 | import javax.swing.JPanel;
33 |
34 | import io.github.astrapi69.awt.screen.ScreenSizeExtensions;
35 | import io.github.astrapi69.awt.window.adapter.CloseWindow;
36 | import io.github.astrapi69.model.BaseModel;
37 | import io.github.astrapi69.model.api.IModel;
38 | import io.github.astrapi69.swing.button.ButtonFactory;
39 | import io.github.astrapi69.swing.panel.login.pw.ChangePasswordModelBean;
40 | import io.github.astrapi69.swing.panel.login.pw.NewPasswordPanel;
41 |
42 | public class PanelDialogExample extends PanelDialog
43 | {
44 |
45 | private static final long serialVersionUID = 1L;
46 | /** The button close. */
47 | private JButton buttonClose;
48 |
49 | public PanelDialogExample(final Frame owner, final String title, final boolean modal,
50 | final IModel model)
51 | {
52 | super(owner, title, modal, model);
53 | }
54 |
55 | public static void main(final String[] a)
56 | {
57 | final PanelDialogExample dialog = new PanelDialogExample(null, "Password title", true,
58 | BaseModel.of());
59 | dialog.addWindowListener(new CloseWindow());
60 | ScreenSizeExtensions.centralize(dialog, 3, 3);
61 | dialog.setSize(500, 250);
62 |
63 | dialog.setVisible(true);
64 | }
65 |
66 | protected JButton newButtonClose()
67 | {
68 | JButton button = ButtonFactory.newJButton("Close");
69 | button.addActionListener(e -> onClose(e));
70 | return button;
71 | }
72 |
73 | @Override
74 | protected JPanel newButtons(IModel model)
75 | {
76 | JPanel buttons = super.newButtons(model);
77 | return buttons;
78 | }
79 |
80 | @Override
81 | protected JPanel newContent(IModel model)
82 | {
83 | return new NewPasswordPanel(BaseModel.of());
84 | }
85 |
86 | private void onClose(final ActionEvent e)
87 | {
88 | this.dispose();
89 | }
90 |
91 | @Override
92 | protected void onInitializeComponents()
93 | {
94 | super.onInitializeComponents();
95 | buttonClose = newButtonClose();
96 | }
97 |
98 | @Override
99 | protected void onInitializeLayout()
100 | {
101 | super.onInitializeLayout();
102 | getButtons().add(buttonClose, BorderLayout.EAST);
103 | }
104 |
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/panel/login/PasswordFormPanel.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
72 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/panel/lottery/LotteryPanel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.lottery;
26 |
27 | import java.awt.GridLayout;
28 | import java.awt.event.ActionEvent;
29 | import java.awt.event.ActionListener;
30 | import java.util.LinkedHashMap;
31 | import java.util.LinkedHashSet;
32 | import java.util.Map;
33 |
34 | import javax.swing.JCheckBox;
35 |
36 | import io.github.astrapi69.icon.StringIcon;
37 | import io.github.astrapi69.model.BaseModel;
38 | import io.github.astrapi69.model.api.IModel;
39 | import io.github.astrapi69.swing.base.BasePanel;
40 |
41 | public class LotteryPanel extends BasePanel implements ActionListener
42 | {
43 |
44 | LinkedHashMap lotteryBoxes;
45 |
46 | public LotteryPanel()
47 | {
48 | this(BaseModel.of(LotteryBox.builder().selectedNumbers(new LinkedHashSet<>()).build()));
49 | }
50 |
51 | public LotteryPanel(final IModel model)
52 | {
53 | super(model);
54 | }
55 |
56 | @Override
57 | public void actionPerformed(ActionEvent e)
58 | {
59 | LinkedHashSet selectedNumbers = getModelObject().getSelectedNumbers();
60 |
61 | JCheckBox source = (JCheckBox)e.getSource();
62 | boolean selected = source.isSelected();
63 | StringIcon icon = (StringIcon)source.getIcon();
64 | Integer selectedNumber = Integer.valueOf(icon.getText().trim());
65 | if (selected)
66 | {
67 | selectedNumbers.add(selectedNumber);
68 | }
69 | else
70 | {
71 | selectedNumbers.remove(selectedNumber);
72 | }
73 |
74 | if (selectedNumbers.size() == getModelObject().getMaxNumbers())
75 | {
76 | lotteryBoxes.entrySet().stream()
77 | .filter(entry -> !selectedNumbers.contains(entry.getKey())).map(Map.Entry::getValue)
78 | .forEach(cb -> cb.setEnabled(false));
79 | revalidate();
80 | }
81 | else
82 | {
83 | lotteryBoxes.values().forEach(cb -> {
84 | if (!cb.isEnabled())
85 | {
86 | cb.setEnabled(true);
87 | }
88 | });
89 | }
90 |
91 | }
92 |
93 |
94 | @Override
95 | protected void onInitializeComponents()
96 | {
97 | lotteryBoxes = new LinkedHashMap<>();
98 | for (int i = getModelObject().getMinVolume(); i <= getModelObject()
99 | .getMaxVolume(); i += getModelObject().getStep())
100 | {
101 | StringIcon icon = new StringIcon(this, Integer.valueOf(i).toString());
102 | JCheckBox checkBox = new JCheckBox(icon);
103 | checkBox.addActionListener(this);
104 | checkBox.setBorderPainted(true);
105 | lotteryBoxes.put(i, checkBox);
106 | add(checkBox);
107 | }
108 | }
109 |
110 | @Override
111 | protected void onInitializeLayout()
112 | {
113 | setLayout(new GridLayout(getModelObject().getRows(), getModelObject().getColumns()));
114 | }
115 | }
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/img/ImageToPdfExtensions.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.img;
26 |
27 | import java.awt.image.BufferedImage;
28 | import java.io.ByteArrayOutputStream;
29 | import java.io.IOException;
30 | import java.io.OutputStream;
31 | import java.util.List;
32 |
33 | import javax.imageio.ImageIO;
34 |
35 | import com.itextpdf.text.BaseColor;
36 | import com.itextpdf.text.Document;
37 | import com.itextpdf.text.DocumentException;
38 | import com.itextpdf.text.Image;
39 | import com.itextpdf.text.Phrase;
40 | import com.itextpdf.text.pdf.PdfPCell;
41 | import com.itextpdf.text.pdf.PdfPTable;
42 | import com.itextpdf.text.pdf.PdfWriter;
43 |
44 | import lombok.extern.java.Log;
45 |
46 | /**
47 | * The class {@link ImageToPdfExtensions}
48 | */
49 | @Log
50 | public class ImageToPdfExtensions
51 | {
52 |
53 | /**
54 | * Creates from the given Collection of images an pdf file.
55 | *
56 | * @param result
57 | * the output stream from the pdf file where the images shell be written.
58 | * @param images
59 | * the BufferedImage collection to be written in the pdf file.
60 | * @throws DocumentException
61 | * is thrown if an error occurs when trying to get an instance of {@link PdfWriter}.
62 | * @throws IOException
63 | * Signals that an I/O exception has occurred.
64 | */
65 | public static void createPdf(final OutputStream result, final List images)
66 | throws DocumentException, IOException
67 | {
68 | final Document document = new Document();
69 | PdfWriter.getInstance(document, result);
70 | for (final BufferedImage image : images)
71 | {
72 | final ByteArrayOutputStream baos = new ByteArrayOutputStream();
73 | ImageIO.write(image, "png", baos);
74 | final Image img = Image.getInstance(baos.toByteArray());
75 | document.setPageSize(img);
76 | document.newPage();
77 | img.setAbsolutePosition(0, 0);
78 | document.add(img);
79 | }
80 | document.close();
81 | }
82 |
83 | /**
84 | * Factory method for create a new {@link PdfPTable} with the given count of columns and the
85 | * column header names
86 | *
87 | * @param numColumns
88 | * the count of columns of the table
89 | * @param headerNames
90 | * the column header names
91 | * @return the new {@link PdfPTable}
92 | */
93 | public static PdfPTable newPdfPTable(int numColumns, List headerNames)
94 | {
95 | PdfPTable table = new PdfPTable(numColumns);
96 | headerNames.stream().forEach(columnHeaderName -> {
97 | PdfPCell header = new PdfPCell();
98 | header.setBackgroundColor(BaseColor.LIGHT_GRAY);
99 | header.setBorderWidth(2);
100 | header.setPhrase(new Phrase(columnHeaderName));
101 | table.addCell(header);
102 | });
103 | return table;
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/base/BaseDialogExample.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.base;
26 |
27 | import java.awt.BorderLayout;
28 | import java.awt.Container;
29 | import java.awt.Frame;
30 | import java.awt.event.ActionEvent;
31 |
32 | import javax.swing.JButton;
33 | import javax.swing.JPanel;
34 |
35 | import io.github.astrapi69.awt.screen.ScreenSizeExtensions;
36 | import io.github.astrapi69.awt.window.adapter.CloseWindow;
37 | import io.github.astrapi69.model.BaseModel;
38 | import io.github.astrapi69.model.api.IModel;
39 | import io.github.astrapi69.swing.button.ButtonFactory;
40 | import io.github.astrapi69.swing.panel.login.pw.ChangePasswordModelBean;
41 | import io.github.astrapi69.swing.panel.login.pw.NewPasswordPanel;
42 |
43 | public class BaseDialogExample extends BaseDialog
44 | {
45 |
46 | private static final long serialVersionUID = 1L;
47 | JPanel buttons;
48 | Container container;
49 | NewPasswordPanel newPasswordPanel;
50 | /** The button close. */
51 | private JButton buttonClose;
52 |
53 | public BaseDialogExample(final Frame owner, final String title, final boolean modal,
54 | final IModel model)
55 | {
56 | super(owner, title, modal, model);
57 | }
58 |
59 | public static void main(final String[] a)
60 | {
61 | final BaseDialogExample dialog = new BaseDialogExample(null, "Password title", true,
62 | BaseModel.of());
63 | dialog.addWindowListener(new CloseWindow());
64 | ScreenSizeExtensions.centralize(dialog, 3, 3);
65 | dialog.setSize(500, 250);
66 |
67 | dialog.setVisible(true);
68 | }
69 |
70 | protected JButton newButtonClose()
71 | {
72 | JButton button = ButtonFactory.newJButton("Close");
73 | button.addActionListener(e -> onClose(e));
74 | return button;
75 | }
76 |
77 | protected JPanel newButtons(IModel model)
78 | {
79 | JPanel buttons = new JPanel();
80 | return buttons;
81 | }
82 |
83 |
84 | protected NewPasswordPanel newNewPasswordPanel(IModel model)
85 | {
86 | return new NewPasswordPanel(model);
87 | }
88 |
89 | private void onClose(final ActionEvent e)
90 | {
91 | this.setVisible(false);
92 | System.exit(0);
93 | }
94 |
95 | @Override
96 | protected void onInitializeComponents()
97 | {
98 | super.onInitializeComponents();
99 | setModal(isModal());
100 |
101 | newPasswordPanel = newNewPasswordPanel(getModel());
102 | buttonClose = newButtonClose();
103 | buttons = newButtons(getModel());
104 | }
105 |
106 | @Override
107 | protected void onInitializeLayout()
108 | {
109 | super.onInitializeLayout();
110 | buttons.add(buttonClose, BorderLayout.EAST);
111 |
112 | container = getContentPane();
113 | container.add(newPasswordPanel, BorderLayout.CENTER);
114 | container.add(buttons, BorderLayout.SOUTH);
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/mvc/view/AbstractGenericView.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.mvc.view;
26 |
27 | import java.awt.Component;
28 |
29 |
30 | /**
31 | * The class AbstractGenericView.
32 | *
33 | * @param
34 | * the generic type of the controller
35 | * @param
36 | * the generic type of the component
37 | */
38 | public abstract class AbstractGenericView implements View
39 | {
40 |
41 | /** The component. */
42 | private COMP component;
43 |
44 | /** The controller. */
45 | private C controller;
46 |
47 | /** The parent. */
48 | private View parent;
49 |
50 | /**
51 | * Instantiates a new abstract generic view.
52 | *
53 | * @param controller
54 | * the controller
55 | */
56 | public AbstractGenericView(final C controller)
57 | {
58 | this.controller = controller;
59 | initialize();
60 | }
61 |
62 | /**
63 | * Returns the field component.
64 | *
65 | * @return The field .
66 | */
67 | @Override
68 | public COMP getComponent()
69 | {
70 | return component;
71 | }
72 |
73 | /**
74 | * Sets the field component.
75 | *
76 | * @param component
77 | * The component to set.
78 | */
79 | @Override
80 | public void setComponent(final COMP component)
81 | {
82 | this.component = component;
83 | }
84 |
85 | /**
86 | * Returns the field controller.
87 | *
88 | * @return The field .
89 | */
90 | @Override
91 | public C getController()
92 | {
93 | return controller;
94 | }
95 |
96 | /**
97 | * Sets the field controller.
98 | *
99 | * @param controller
100 | * The controller to set.
101 | */
102 | @Override
103 | public void setController(final C controller)
104 | {
105 | this.controller = controller;
106 | }
107 |
108 | /**
109 | * Gets the parent.
110 | *
111 | * @return the parent
112 | */
113 | @Override
114 | public View getParent()
115 | {
116 | return parent;
117 | }
118 |
119 | /**
120 | * Sets the parent.
121 | *
122 | * @param parent
123 | * the parent
124 | */
125 | public void setParent(final View parent)
126 | {
127 | this.parent = parent;
128 | }
129 |
130 | /**
131 | * Gets the root parent view.
132 | *
133 | * @return the root parent view
134 | */
135 | public View, ?> getRootParentView()
136 | {
137 | View, ?> currentView = this;
138 | while (currentView.hasParent())
139 | {
140 | currentView = currentView.getParent();
141 | }
142 | return currentView;
143 | }
144 |
145 | /**
146 | * Checks for parent.
147 | *
148 | * @return true, if successful
149 | */
150 | @Override
151 | public boolean hasParent()
152 | {
153 | return null != this.parent;
154 | }
155 |
156 | /**
157 | * Initialize.
158 | */
159 | protected abstract void initialize();
160 |
161 | }
162 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/panel/login/LoginController.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.login;
26 |
27 | import java.awt.event.ActionEvent;
28 | import java.awt.event.WindowEvent;
29 | import java.awt.event.WindowListener;
30 |
31 | import io.github.astrapi69.mvc.controller.AbstractGenericController;
32 |
33 | public class LoginController extends AbstractGenericController
34 | implements
35 | WindowListener
36 | {
37 |
38 | private final LoginDialog dialog;
39 |
40 | private LoginPanel loginPanel;
41 |
42 | public LoginController(final LoginDialog dialog)
43 | {
44 | super();
45 | this.dialog = dialog;
46 | this.dialog.addWindowListener(this);
47 | }
48 |
49 | protected LoginModel getLoginModel()
50 | {
51 | return getModel();
52 | }
53 |
54 | protected LoginPanel getLoginPanel()
55 | {
56 | return getView().getComponent();
57 | }
58 |
59 | protected LoginView getLoginView()
60 | {
61 | return getView();
62 |
63 | }
64 |
65 | @Override
66 | protected void preinitialize()
67 | {
68 | setModel(new LoginModel());
69 | super.preinitialize();
70 | }
71 |
72 | @Override
73 | public void process(final ActionEvent actionEvent)
74 | {
75 | if (null == loginPanel)
76 | {
77 | loginPanel = getView().getComponent();
78 | }
79 | if (actionEvent.getSource() == getView().getComponent().getBtnLogin())
80 | {
81 |
82 | final LoginModel model = getModel();
83 | model.getObject().setUsername(getView().getComponent().getTxtUsername().getText());
84 | final String pw = new String(getView().getComponent().getTxtPassword().getPassword());
85 | model.getObject().setPassword(pw);
86 | // AuthorisationService authorisationService = new AuthorisationServiceImpl();
87 | // Users user = authorisationService.authenticateUser( getModel() );
88 | // if(null != user){
89 | // this.dialog.dispose();
90 | // MainFrame.getInstance().setVisible( true );
91 | // } else {
92 | // getView().getComponent().getTxtInfo().setForeground( Color.RED );
93 | // loginPanel.getTxtInfo().setText( "Access denied!" );
94 | // loginPanel.getTxtUsername().setText( "" );
95 | // loginPanel.getTxtPassword().setText( "" );
96 | // }
97 |
98 | }
99 | else if (actionEvent.getSource() == loginPanel.getBtnCancel())
100 | {
101 | System.exit(0);
102 | }
103 |
104 | }
105 |
106 |
107 | @Override
108 | public void windowActivated(final WindowEvent e)
109 | {
110 | }
111 |
112 | @Override
113 | public void windowClosed(final WindowEvent e)
114 | {
115 | }
116 |
117 | @Override
118 | public void windowClosing(final WindowEvent e)
119 | {
120 | }
121 |
122 | @Override
123 | public void windowDeactivated(final WindowEvent e)
124 | {
125 | }
126 |
127 | @Override
128 | public void windowDeiconified(final WindowEvent e)
129 | {
130 | }
131 |
132 | @Override
133 | public void windowIconified(final WindowEvent e)
134 | {
135 | }
136 |
137 | @Override
138 | public void windowOpened(final WindowEvent e)
139 | {
140 | }
141 |
142 | }
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/paint/PainterExtensions.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.paint;
26 |
27 | import java.awt.Color;
28 | import java.awt.LinearGradientPaint;
29 |
30 | import org.jdesktop.swingx.painter.CompoundPainter;
31 | import org.jdesktop.swingx.painter.GlossPainter;
32 | import org.jdesktop.swingx.painter.MattePainter;
33 | import org.jdesktop.swingx.painter.PinstripePainter;
34 |
35 | /**
36 | * The class {@link PainterExtensions}.
37 | *
38 | * @deprecated will be removed because of swingx remove in future versions
39 | */
40 | @Deprecated
41 | public class PainterExtensions
42 | {
43 |
44 | /**
45 | * Gets a CompoundPainter object.
46 | *
47 | * @param matte
48 | * the matte color
49 | * @param gloss
50 | * the gloss color
51 | * @param position
52 | * the position
53 | * @param angle
54 | * the angle
55 | * @param pinstripe
56 | * the pinstripe painter
57 | * @return the CompoundPainter object.
58 | */
59 | @SuppressWarnings("rawtypes")
60 | public static CompoundPainter getCompoundPainter(final Color matte, final Color gloss,
61 | final GlossPainter.GlossPosition position, final double angle, final Color pinstripe)
62 | {
63 | final MattePainter mp = new MattePainter(matte);
64 | final GlossPainter gp = new GlossPainter(gloss, position);
65 | final PinstripePainter pp = new PinstripePainter(pinstripe, angle);
66 | final CompoundPainter compoundPainter = new CompoundPainter(mp, pp, gp);
67 | return compoundPainter;
68 |
69 | }
70 |
71 | /**
72 | * Gets the compound painter.
73 | *
74 | * @param color
75 | * the color
76 | * @param position
77 | * the position
78 | * @param angle
79 | * the angle
80 | * @return the compound painter
81 | */
82 | @SuppressWarnings("rawtypes")
83 | public static CompoundPainter getCompoundPainter(final Color color,
84 | final GlossPainter.GlossPosition position, final double angle)
85 | {
86 | final MattePainter mp = new MattePainter(color);
87 | final GlossPainter gp = new GlossPainter(color, position);
88 | final PinstripePainter pp = new PinstripePainter(color, angle);
89 | final CompoundPainter compoundPainter = new CompoundPainter(mp, pp, gp);
90 | return compoundPainter;
91 |
92 | }
93 |
94 | /**
95 | * Gets a MattePainter object.
96 | *
97 | * @param width
98 | * the width
99 | * @param height
100 | * the height
101 | * @param fractions
102 | * the fractions
103 | * @param colors
104 | * the colors
105 | * @return the MattePainter object
106 | */
107 | public static MattePainter getMattePainter(final int width, final int height,
108 | final float[] fractions, final Color... colors)
109 | {
110 | final LinearGradientPaint gradientPaint = new LinearGradientPaint(0.0f, 0.0f, width, height,
111 | fractions, colors);
112 | final MattePainter mattePainter = new MattePainter(gradientPaint);
113 | return mattePainter;
114 |
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/mvc/controller/Controller.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.mvc.controller;
26 |
27 | import java.awt.event.ActionEvent;
28 | import java.util.Map;
29 |
30 | /**
31 | * The Interface Controller.
32 | *
33 | * @param
34 | * the generic type of the model
35 | * @param
36 | * the generic type of the view
37 | */
38 | public interface Controller
39 | {
40 |
41 | /**
42 | * Gets the child from this controller.
43 | *
44 | * @param key
45 | * the key
46 | *
47 | * @return the child or null.
48 | */
49 | Controller getChild(final String key);
50 |
51 | /**
52 | * Gets the children from this controller.
53 | *
54 | * @return the children
55 | */
56 | Map> getChildren();
57 |
58 | /**
59 | * Gets the model.
60 | *
61 | * @return the model
62 | */
63 | M getModel();
64 |
65 | /**
66 | * Sets the model.
67 | *
68 | * @param model
69 | * the new model
70 | */
71 | void setModel(final M model);
72 |
73 | /**
74 | * Gets the name from the Controller.
75 | *
76 | * @return the name from the Controller.
77 | */
78 | String getName();
79 |
80 | /**
81 | * Gets the parent from this controller.
82 | *
83 | * @return the parent or null.
84 | */
85 | Controller getParent();
86 |
87 | /**
88 | * Sets the parent.
89 | *
90 | * @param controller
91 | * the new parent
92 | */
93 | void setParent(final Controller controller);
94 |
95 | /**
96 | * Gets the view.
97 | *
98 | * @return the view
99 | */
100 | V getView();
101 |
102 | /**
103 | * Sets the view.
104 | *
105 | * @param view
106 | * the new view
107 | */
108 | void setView(final V view);
109 |
110 | /**
111 | * Checks for child.
112 | *
113 | * @param controller
114 | * the controller
115 | *
116 | * @return true, if successful
117 | */
118 | boolean hasChild(final Controller controller);
119 |
120 | /**
121 | * Checks for child.
122 | *
123 | * @param key
124 | * the key
125 | *
126 | * @return true, if successful
127 | */
128 | boolean hasChild(final String key);
129 |
130 | /**
131 | * Process.
132 | *
133 | * @param event
134 | * the event
135 | */
136 | void process(final ActionEvent event);
137 |
138 | /**
139 | * Removes the child.
140 | *
141 | * @param controller
142 | * the controller
143 | *
144 | * @return the controller
145 | */
146 | Controller removeChild(final Controller controller);
147 |
148 | /**
149 | * Removes the child.
150 | *
151 | * @param key
152 | * the key from the controller
153 | *
154 | * @return the controller
155 | */
156 | Controller removeChild(final String key);
157 |
158 | /**
159 | * Sets a child from this controller.
160 | *
161 | * @param key
162 | * the key
163 | * @param controller
164 | * the controller
165 | *
166 | * @return the object
167 | */
168 | Object setChild(final String key, final Controller controller);
169 |
170 | }
171 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/panel/field/FieldPanel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.field;
26 |
27 | import javax.swing.DefaultComboBoxModel;
28 | import javax.swing.GroupLayout;
29 | import javax.swing.JComboBox;
30 | import javax.swing.JLabel;
31 | import javax.swing.JTextField;
32 | import javax.swing.LayoutStyle;
33 |
34 | import io.github.astrapi69.swing.base.BasePanel;
35 | import lombok.Getter;
36 |
37 | /**
38 | * The class {@link FieldPanel} for create a new field.
39 | */
40 | public abstract class FieldPanel extends BasePanel
41 | {
42 |
43 | /** The Constant serialVersionUID. */
44 | private static final long serialVersionUID = 1L;
45 |
46 |
47 | /** The {@link JComboBox} type. */
48 | @Getter
49 | private JComboBox dropDownType;
50 |
51 | /** The {@link JLabel} field name. */
52 | @Getter
53 | private JLabel lblFieldName;
54 |
55 | /** The {@link JLabel} type. */
56 | @Getter
57 | private JLabel lblType;
58 |
59 | /** The {@link JTextField} field name. */
60 | @Getter
61 | private JTextField txtFieldName;
62 |
63 |
64 | /**
65 | * Instantiates a new {@link FieldPanel}.
66 | */
67 | public FieldPanel()
68 | {
69 | }
70 |
71 | protected abstract DefaultComboBoxModel newTypeModel();
72 |
73 | @Override
74 | protected void onInitializeComponents()
75 | {
76 | txtFieldName = new JTextField();
77 | lblFieldName = new JLabel();
78 | lblType = new JLabel();
79 | dropDownType = new JComboBox<>();
80 |
81 | txtFieldName.setToolTipText("Enter a name");
82 |
83 | lblFieldName.setText("Field Name");
84 |
85 | lblType.setText("Type");
86 |
87 | dropDownType.setModel(newTypeModel());
88 | }
89 |
90 | @Override
91 | protected void onInitializeLayout()
92 | {
93 | final GroupLayout layout = new GroupLayout(this);
94 | this.setLayout(layout);
95 | layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
96 | .addGroup(layout.createSequentialGroup().addGap(18, 18, 18)
97 | .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
98 | .addComponent(txtFieldName)
99 | .addComponent(lblFieldName, GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE))
100 | .addGap(18, 18, 18)
101 | .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
102 | .addComponent(dropDownType, 0, 168, Short.MAX_VALUE).addComponent(lblType,
103 | GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
104 | .addContainerGap(19, Short.MAX_VALUE)));
105 | layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
106 | .addGroup(layout.createSequentialGroup().addGap(17, 17, 17)
107 | .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
108 | .addComponent(lblFieldName).addComponent(lblType))
109 | .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
110 | .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
111 | .addComponent(txtFieldName, GroupLayout.PREFERRED_SIZE,
112 | GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
113 | .addComponent(dropDownType, GroupLayout.PREFERRED_SIZE,
114 | GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
115 | .addContainerGap(23, Short.MAX_VALUE)));
116 | }
117 |
118 | }
119 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/panel/keypad/KeypadController.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.keypad;
26 |
27 | import java.awt.event.ActionEvent;
28 |
29 | import io.github.astrapi69.mvc.controller.AbstractGenericController;
30 |
31 | public class KeypadController extends AbstractGenericController, KeypadView>
32 | {
33 |
34 | KeyPadPanel keyPadPanel = null;
35 |
36 | public KeypadController()
37 | {
38 | super();
39 | }
40 |
41 | public KeyPadPanel getKeyPadPanel()
42 | {
43 | return getKeypadView().getComponent();
44 | }
45 |
46 | public KeypadView getKeypadView()
47 | {
48 | return getView();
49 | }
50 |
51 | @Override
52 | public void process(final ActionEvent actionEvent)
53 | {
54 | if (null == keyPadPanel)
55 | {
56 | keyPadPanel = getKeyPadPanel();
57 | }
58 | if (actionEvent.getSource() == keyPadPanel.getButton1())
59 | {
60 | keyPadPanel.getTextAreaDisplay().append("1");
61 | System.out.println("1");
62 | }
63 | else if (actionEvent.getSource() == keyPadPanel.getButton2())
64 | {
65 | keyPadPanel.getTextAreaDisplay().append("2");
66 | System.out.println("2");
67 | }
68 | else if (actionEvent.getSource() == keyPadPanel.getButton3())
69 | {
70 | keyPadPanel.getTextAreaDisplay().append("3");
71 | System.out.println("3");
72 | }
73 | else if (actionEvent.getSource() == keyPadPanel.getButton4())
74 | {
75 | keyPadPanel.getTextAreaDisplay().append("4");
76 | System.out.println("4");
77 | }
78 | else if (actionEvent.getSource() == keyPadPanel.getButton5())
79 | {
80 | keyPadPanel.getTextAreaDisplay().append("5");
81 | System.out.println("5");
82 | }
83 | else if (actionEvent.getSource() == keyPadPanel.getButton6())
84 | {
85 | keyPadPanel.getTextAreaDisplay().append("6");
86 | System.out.println("6");
87 | }
88 | else if (actionEvent.getSource() == keyPadPanel.getButton7())
89 | {
90 | keyPadPanel.getTextAreaDisplay().append("7");
91 | System.out.println("7");
92 | }
93 | else if (actionEvent.getSource() == keyPadPanel.getButton8())
94 | {
95 | keyPadPanel.getTextAreaDisplay().append("8");
96 | System.out.println("8");
97 | }
98 | else if (actionEvent.getSource() == keyPadPanel.getButton9())
99 | {
100 | keyPadPanel.getTextAreaDisplay().append("9");
101 | System.out.println("9");
102 | }
103 | else if (actionEvent.getSource() == keyPadPanel.getButton0())
104 | {
105 | keyPadPanel.getTextAreaDisplay().append("0");
106 | System.out.println("0");
107 | }
108 | else if (actionEvent.getSource() == keyPadPanel.getButtonTable())
109 | {
110 | System.out.println("Table");
111 | }
112 | else if (actionEvent.getSource() == keyPadPanel.getButtonCancel())
113 | {
114 | System.out.println("Cancel");
115 | }
116 | else if (actionEvent.getSource() == keyPadPanel.getButtonStorno())
117 | {
118 | System.out.println("Storno");
119 | }
120 | else if (actionEvent.getSource() == keyPadPanel.getButtonEnter())
121 | {
122 | System.out.println("Enter");
123 | }
124 | else if (actionEvent.getSource() == keyPadPanel.getButtonPlus())
125 | {
126 | System.out.println("plus");
127 | }
128 | else if (actionEvent.getSource() == keyPadPanel.getButtonMinus())
129 | {
130 | System.out.println("minus");
131 | }
132 | }
133 |
134 | }
135 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/check/model/CheckListPanel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.check.model;
26 |
27 | import java.awt.BorderLayout;
28 | import java.awt.GridLayout;
29 |
30 | import javax.swing.JButton;
31 | import javax.swing.JList;
32 | import javax.swing.JPanel;
33 | import javax.swing.JScrollPane;
34 | import javax.swing.JTextArea;
35 | import javax.swing.ListModel;
36 |
37 | import io.github.astrapi69.component.model.check.CheckableItem;
38 | import io.github.astrapi69.component.model.check.CheckableListModel;
39 | import io.github.astrapi69.component.model.check.CheckableValue;
40 | import io.github.astrapi69.model.BaseModel;
41 | import io.github.astrapi69.model.api.IModel;
42 | import io.github.astrapi69.swing.base.BasePanel;
43 | import io.github.astrapi69.swing.list.JListExtensions;
44 |
45 | public class CheckListPanel extends BasePanel
46 | {
47 | JList> list;
48 | JScrollPane checklistPane;
49 | JTextArea textArea;
50 | JButton printButton;
51 | JScrollPane textPane;
52 | JButton uncheckButton;
53 | JButton clearTextButton;
54 | JPanel buttonPanel;
55 |
56 | public CheckListPanel()
57 | {
58 | this(BaseModel.of(CheckableListModel.builder().build()));
59 | }
60 |
61 | public CheckListPanel(IModel model)
62 | {
63 | super(model);
64 | }
65 |
66 | /**
67 | * Initialize components.
68 | */
69 | @Override
70 | protected void onInitializeComponents()
71 | {
72 | list = JListExtensions.newJList(getModelObject().getValues());
73 | list.setName("list");
74 |
75 | checklistPane = new JScrollPane(list);
76 |
77 | textArea = new JTextArea(3, 10);
78 | textArea.setName("textArea");
79 | textPane = new JScrollPane(textArea);
80 | printButton = new JButton("Print entries");
81 | printButton.setName("printButton");
82 | uncheckButton = new JButton("Uncheck entries");
83 | clearTextButton = new JButton("Clear Text");
84 | buttonPanel = new JPanel(new GridLayout(3, 1));
85 | buttonPanel.add(printButton);
86 | buttonPanel.add(uncheckButton);
87 | buttonPanel.add(clearTextButton);
88 | // add action listeners
89 | printButton.addActionListener(e -> {
90 | ListModel> model = list.getModel();
91 | int n = model.getSize();
92 | for (int i = 0; i < n; i++)
93 | {
94 | CheckableItem item = model.getElementAt(i);
95 | if (item.isSelected())
96 | {
97 | textArea.append(item.getCheckableValue().getItemText());
98 | textArea.append(System.getProperty("line.separator"));
99 | }
100 | }
101 | });
102 |
103 | uncheckButton.addActionListener(e -> {
104 | ListModel> model = list.getModel();
105 | int n = model.getSize();
106 | for (int i = 0; i < n; i++)
107 | {
108 | CheckableItem item = model.getElementAt(i);
109 | item.setSelected(false);
110 | }
111 | list.repaint();
112 | });
113 |
114 | clearTextButton.addActionListener(e -> textArea.setText(""));
115 | }
116 |
117 |
118 | /**
119 | * Initialize layout.
120 | */
121 | @Override
122 | protected void onInitializeLayout()
123 | {
124 | setLayout(new BorderLayout());
125 |
126 | add(checklistPane, BorderLayout.CENTER);
127 | add(buttonPanel, BorderLayout.WEST);
128 | add(textPane, BorderLayout.SOUTH);
129 | }
130 |
131 | }
132 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/img/ImageIconFactoryTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.img;
26 |
27 | import static org.junit.jupiter.api.Assertions.assertNotNull;
28 |
29 | import java.io.InputStream;
30 |
31 | import javax.swing.ImageIcon;
32 |
33 | import org.apache.batik.transcoder.TranscoderException;
34 | import org.junit.jupiter.api.Disabled;
35 | import org.junit.jupiter.api.Test;
36 | import org.meanbean.test.BeanTester;
37 |
38 | import io.github.astrapi69.icon.ImageIconFactory;
39 | import io.github.astrapi69.lang.ClassExtensions;
40 |
41 | /**
42 | * The unit test class for the class {@link ImageIconFactory}
43 | *
44 | * @author Asterios Raptis
45 | */
46 | class ImageIconFactoryTest
47 | {
48 |
49 | /**
50 | * Test for method
51 | * {{@link BatikImageIconFactory#newImageIconFromSVG(String, float, float, String)}
52 | *
53 | * @throws TranscoderException
54 | * is thrown when a transcoder is not able to transcode its input
55 | */
56 | @Test
57 | @Disabled
58 | public void testNnewImageIconFromSVG() throws TranscoderException
59 | {
60 | ImageIcon actual;
61 | String relativeImagePath;
62 | float targetWidth;
63 | float targetHeight;
64 | String description;
65 |
66 | relativeImagePath = "img/xmas/greendices.svg";
67 | targetWidth = 10f;
68 | targetHeight = 10f;
69 | description = "A description";
70 | actual = BatikImageIconFactory.newImageIconFromSVG(relativeImagePath, targetWidth,
71 | targetHeight, description);
72 | assertNotNull(actual);
73 | }
74 |
75 | /**
76 | * Test for method
77 | * {{@link BatikImageIconFactory#newImageIconFromSVG(InputStream, float, float, String)}
78 | *
79 | * @throws TranscoderException
80 | * is thrown when a transcoder is not able to transcode its input
81 | */
82 | @Test
83 | @Disabled
84 | public void testNnewImageIconFromSVGWithInputStream() throws TranscoderException
85 | {
86 | ImageIcon actual;
87 | String relativeImagePath;
88 | float targetWidth;
89 | float targetHeight;
90 | String description;
91 | InputStream svgImageAsStream;
92 |
93 | relativeImagePath = "img/xmas/greendices.svg";
94 |
95 | svgImageAsStream = ClassExtensions.getResourceAsStream(relativeImagePath);
96 | targetWidth = 10f;
97 | targetHeight = 10f;
98 | description = "A description";
99 | actual = BatikImageIconFactory.newImageIconFromSVG(svgImageAsStream, targetWidth,
100 | targetHeight, description);
101 | assertNotNull(actual);
102 | }
103 |
104 | /**
105 | * Test for method {{@link BatikImageIconFactory#newImageIconFromSVG(String, float, float)}
106 | *
107 | * @throws TranscoderException
108 | * is thrown when a transcoder is not able to transcode its input
109 | */
110 | @Test
111 | @Disabled
112 | public void testNewImageIconFromSVGWithRelativePathWidthAndHeight() throws TranscoderException
113 | {
114 | ImageIcon actual;
115 | String relativeImagePath;
116 | float targetWidth;
117 | float targetHeight;
118 |
119 | relativeImagePath = "img/xmas/greendices.svg";
120 | targetWidth = 10f;
121 | targetHeight = 10f;
122 | actual = BatikImageIconFactory.newImageIconFromSVG(relativeImagePath, targetWidth,
123 | targetHeight);
124 | assertNotNull(actual);
125 | }
126 |
127 | /**
128 | * Test method for {@link ImageIconFactory} with {@link BeanTester}
129 | */
130 | @Test
131 | public void testWithBeanTester()
132 | {
133 | final BeanTester beanTester = new BeanTester();
134 | beanTester.testBean(ImageIconFactory.class);
135 | }
136 |
137 | }
138 |
--------------------------------------------------------------------------------
/src/main/java/io/github/astrapi69/swing/panel/login/pw/PasswordPanel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.login.pw;
26 |
27 | import io.github.astrapi69.model.BaseModel;
28 | import io.github.astrapi69.model.api.IModel;
29 | import io.github.astrapi69.swing.base.BasePanel;
30 | import lombok.Getter;
31 |
32 | @Getter
33 | public class PasswordPanel extends BasePanel
34 | {
35 |
36 | private static final long serialVersionUID = 1L;
37 | private javax.swing.JLabel lblPassword;
38 | private javax.swing.JLabel lblRepeatPassword;
39 | private javax.swing.JPasswordField txtPassword;
40 | private javax.swing.JPasswordField txtRepeatPassword;
41 |
42 | public PasswordPanel()
43 | {
44 | this(BaseModel.of(PasswordBean.builder().build()));
45 | }
46 |
47 | public PasswordPanel(final IModel model)
48 | {
49 | super(model);
50 | }
51 |
52 | @Override
53 | protected void onInitializeComponents()
54 | {
55 | super.onInitializeComponents();
56 | lblPassword = new javax.swing.JLabel();
57 | txtPassword = new javax.swing.JPasswordField();
58 | lblRepeatPassword = new javax.swing.JLabel();
59 | txtRepeatPassword = new javax.swing.JPasswordField();
60 |
61 | lblPassword.setText("Password");
62 |
63 | lblRepeatPassword.setText("Repeat password");
64 | }
65 |
66 | @Override
67 | protected void onInitializeLayout()
68 | {
69 | super.onInitializeLayout();
70 |
71 | final javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
72 | this.setLayout(layout);
73 | layout.setHorizontalGroup(
74 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
75 | .addGroup(layout.createSequentialGroup().addContainerGap()
76 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
77 | .addGroup(layout.createSequentialGroup()
78 | .addComponent(lblPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 200,
79 | javax.swing.GroupLayout.PREFERRED_SIZE)
80 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
81 | .addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 260,
82 | javax.swing.GroupLayout.PREFERRED_SIZE))
83 | .addGroup(layout.createSequentialGroup()
84 | .addComponent(lblRepeatPassword, javax.swing.GroupLayout.PREFERRED_SIZE,
85 | 200, javax.swing.GroupLayout.PREFERRED_SIZE)
86 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
87 | .addComponent(txtRepeatPassword, javax.swing.GroupLayout.PREFERRED_SIZE,
88 | 260, javax.swing.GroupLayout.PREFERRED_SIZE)))
89 | .addContainerGap(18, Short.MAX_VALUE)));
90 | layout
91 | .setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
92 | .addGroup(layout.createSequentialGroup().addContainerGap()
93 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
94 | .addComponent(lblPassword).addComponent(txtPassword,
95 | javax.swing.GroupLayout.PREFERRED_SIZE,
96 | javax.swing.GroupLayout.DEFAULT_SIZE,
97 | javax.swing.GroupLayout.PREFERRED_SIZE))
98 | .addGap(18, 18, 18)
99 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
100 | .addComponent(lblRepeatPassword).addComponent(txtRepeatPassword,
101 | javax.swing.GroupLayout.PREFERRED_SIZE,
102 | javax.swing.GroupLayout.DEFAULT_SIZE,
103 | javax.swing.GroupLayout.PREFERRED_SIZE))
104 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
105 | }
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/layout/DrawMessage.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.layout;
26 |
27 | import java.awt.Color;
28 | import java.awt.Dimension;
29 | import java.awt.Font;
30 | import java.awt.Graphics;
31 | import java.awt.Graphics2D;
32 | import java.awt.RenderingHints;
33 | import java.awt.font.FontRenderContext;
34 | import java.awt.font.TextLayout;
35 |
36 | import javax.swing.JComponent;
37 |
38 | import lombok.Data;
39 | import lombok.EqualsAndHashCode;
40 |
41 | /**
42 | * The class DrawMessage draws a message to a JComponent to the given Color. You can use it for
43 | * JList to put different list items in different colors.
44 | *
45 | * @version 1.0
46 | * @author Asterios Raptis
47 | */
48 | @Data
49 | @EqualsAndHashCode(callSuper = true)
50 | public class DrawMessage extends JComponent
51 | {
52 |
53 | /**
54 | * The generated serialVersionUID.
55 | */
56 | private static final long serialVersionUID = 1482171136672852023L;
57 |
58 | /**
59 | * The color.
60 | */
61 | private Color color;
62 |
63 | /**
64 | * The message.
65 | */
66 | private String message;
67 |
68 | /**
69 | * The font of the message.
70 | */
71 | Font messageFont;
72 |
73 | /**
74 | * Instantiates a new draw message.
75 | *
76 | * @param message
77 | * the message
78 | * @param color
79 | * the color
80 | */
81 | public DrawMessage(final String message, final Color color)
82 | {
83 | this(message, color, new Font("Arial", Font.BOLD, 16));
84 | }
85 |
86 | /**
87 | * Instantiates a new draw message.
88 | *
89 | * @param message
90 | * the message
91 | * @param color
92 | * the color
93 | * @param messageFont
94 | * the message font
95 | */
96 | public DrawMessage(final String message, final Color color, final Font messageFont)
97 | {
98 | this.message = message;
99 | this.color = color;
100 | this.messageFont = messageFont;
101 | }
102 |
103 | /**
104 | * Gets the minimum size.
105 | *
106 | * @return the minimum size {@inheritDoc}
107 | * @see javax.swing.JComponent#getMinimumSize()
108 | */
109 | @Override
110 | public Dimension getMinimumSize()
111 | {
112 | return new Dimension(150, 5);
113 | }
114 |
115 | /**
116 | * Gets the preferred size.
117 | *
118 | * @return the preferred size {@inheritDoc}
119 | * @see javax.swing.JComponent#getPreferredSize()
120 | */
121 | @Override
122 | public Dimension getPreferredSize()
123 | {
124 | return new Dimension(200, 16);
125 | }
126 |
127 | /**
128 | * Inits the graphics2D object.
129 | *
130 | * @param g
131 | * the Graphics object.
132 | * @return the graphics2 d
133 | */
134 | protected Graphics2D initGraphics2D(final Graphics g)
135 | {
136 | Graphics2D g2;
137 | g2 = (Graphics2D)g;
138 | g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
139 | g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
140 | g2.setColor(this.color);
141 | return g2;
142 | }
143 |
144 | /**
145 | * Paint.
146 | *
147 | * @param g
148 | * the g {@inheritDoc}
149 | * @see javax.swing.JComponent#paint(java.awt.Graphics)
150 | */
151 | @Override
152 | public void paint(final Graphics g)
153 | {
154 | Graphics2D g2 = this.initGraphics2D(g);
155 | final FontRenderContext frc = g2.getFontRenderContext();
156 | final String display = new String(this.message.getBytes());
157 | final TextLayout textLayout = new TextLayout(display, messageFont, frc);
158 | final Dimension dimension = this.getSize();
159 | textLayout.draw(g2, 0, dimension.height);
160 | }
161 | }
162 |
--------------------------------------------------------------------------------
/src/test/java/io/github/astrapi69/swing/panel/login/PasswordFormPanel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The MIT License
3 | *
4 | * Copyright (C) 2015 Asterios Raptis
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining
7 | * a copy of this software and associated documentation files (the
8 | * "Software"), to deal in the Software without restriction, including
9 | * without limitation the rights to use, copy, modify, merge, publish,
10 | * distribute, sublicense, and/or sell copies of the Software, and to
11 | * permit persons to whom the Software is furnished to do so, subject to
12 | * the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be
15 | * included in all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 | */
25 | package io.github.astrapi69.swing.panel.login;
26 |
27 | import lombok.Getter;
28 |
29 | /**
30 | *
31 | * @author astrapi69
32 | */
33 | @Getter
34 | public class PasswordFormPanel extends javax.swing.JPanel
35 | {
36 |
37 | // Variables declaration - do not modify//GEN-BEGIN:variables
38 | private javax.swing.JLabel lblPassword;
39 | private javax.swing.JLabel lblRepeatPassword;
40 | private javax.swing.JPasswordField txtPassword;
41 | private javax.swing.JPasswordField txtRepeatPassword;
42 |
43 | // End of variables declaration//GEN-END:variables
44 | /**
45 | * Creates new form NewPasswordFormPanel
46 | */
47 | public PasswordFormPanel()
48 | {
49 | initComponents();
50 | }
51 |
52 | /**
53 | * This method is called from within the constructor to initialize the form. WARNING: Do NOT
54 | * modify this code. The content of this method is always regenerated by the Form Editor.
55 | */
56 | // @SuppressWarnings("unchecked")
57 | // //GEN-BEGIN:initComponents
58 | private void initComponents()
59 | {
60 |
61 | lblPassword = new javax.swing.JLabel();
62 | txtPassword = new javax.swing.JPasswordField();
63 | lblRepeatPassword = new javax.swing.JLabel();
64 | txtRepeatPassword = new javax.swing.JPasswordField();
65 |
66 | lblPassword.setText("Password");
67 |
68 | lblRepeatPassword.setText("Repeat password");
69 |
70 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
71 | this.setLayout(layout);
72 | layout.setHorizontalGroup(
73 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
74 | .addGroup(layout.createSequentialGroup().addContainerGap()
75 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
76 | .addGroup(layout.createSequentialGroup()
77 | .addComponent(lblPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 200,
78 | javax.swing.GroupLayout.PREFERRED_SIZE)
79 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
80 | .addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 260,
81 | javax.swing.GroupLayout.PREFERRED_SIZE))
82 | .addGroup(layout.createSequentialGroup()
83 | .addComponent(lblRepeatPassword, javax.swing.GroupLayout.PREFERRED_SIZE,
84 | 200, javax.swing.GroupLayout.PREFERRED_SIZE)
85 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
86 | .addComponent(txtRepeatPassword, javax.swing.GroupLayout.PREFERRED_SIZE,
87 | 260, javax.swing.GroupLayout.PREFERRED_SIZE)))
88 | .addContainerGap(18, Short.MAX_VALUE)));
89 | layout
90 | .setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
91 | .addGroup(layout.createSequentialGroup().addContainerGap()
92 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
93 | .addComponent(lblPassword).addComponent(txtPassword,
94 | javax.swing.GroupLayout.PREFERRED_SIZE,
95 | javax.swing.GroupLayout.DEFAULT_SIZE,
96 | javax.swing.GroupLayout.PREFERRED_SIZE))
97 | .addGap(18, 18, 18)
98 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
99 | .addComponent(lblRepeatPassword).addComponent(txtRepeatPassword,
100 | javax.swing.GroupLayout.PREFERRED_SIZE,
101 | javax.swing.GroupLayout.DEFAULT_SIZE,
102 | javax.swing.GroupLayout.PREFERRED_SIZE))
103 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
104 | }// //GEN-END:initComponents
105 |
106 | }
107 |
--------------------------------------------------------------------------------