From 7e468c87aaf9a9a60baca04c0eb232fdffc0b696 Mon Sep 17 00:00:00 2001 From: Robinson Date: Tue, 9 Feb 2021 23:22:51 +0100 Subject: [PATCH] Updated to newer version of utilties project. fixed several issues with the gradle build --- LICENSE | 353 +++++++++++++++++++++++--- build.gradle.kts | 224 ++++------------ src/dorkbox/notify/ActionHandler.java | 21 ++ src/dorkbox/notify/LookAndFeel.java | 5 +- src/dorkbox/notify/Notify.java | 15 +- test/NotifyTest.java | 274 +++++++++++--------- test/notify-dark.png | Bin 0 -> 6277 bytes 7 files changed, 538 insertions(+), 354 deletions(-) create mode 100644 src/dorkbox/notify/ActionHandler.java create mode 100644 test/notify-dark.png diff --git a/LICENSE b/LICENSE index 33bfec9..14b0cfb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,39 +1,318 @@ - - Dorkbox Notify - Apache 2.0 License - https://github.com/dorkbox - Copyright 2015, dorkbox, llc - Linux, MacOS, or Windows (notification/growl/toast/) popups for the desktop for Java 6+ + - Notify - + [The Apache Software License, Version 2.0] + https://git.dorkbox.com/dorkbox/Notify + Copyright 2021 + Dorkbox LLC + Linux, MacOS, or Windows (notification/growl/toast/) popups for the desktop for Java 8+ + + Extra license information + - SwingActiveRender - Active Renderer for Swing + [The Apache Software License, Version 2.0] + https://git.dorkbox.com/dorkbox/SwingActiveRender + Copyright 2021 + Dorkbox LLC + + Extra license information + - PropertyLoader - Property annotation and loader for fields + [The Apache Software License, Version 2.0] + https://git.dorkbox.com/dorkbox/PropertyLoader + Copyright 2021 + Dorkbox LLC + + - Utilities - Utilities for use within Java projects + [The Apache Software License, Version 2.0] + https://git.dorkbox.com/dorkbox/Utilities + Copyright 2021 + Dorkbox LLC + + Extra license information + - MersenneTwisterFast - + [BSD 3-Clause License] + https://git.dorkbox.com/dorkbox/Utilities + Copyright 2003 + Sean Luke + Michael Lecuyer (portions Copyright 1993 + + - FileUtil (code from FilenameUtils.java for normalize + dependencies) - + [The Apache Software License, Version 2.0] + https://git.dorkbox.com/dorkbox/Utilities + http://commons.apache.org/proper/commons-io/ + Copyright 2013 + The Apache Software Foundation + Kevin A. Burton + Scott Sanders + Daniel Rall + Christoph.Reck + Peter Donald + Jeff Turner + Matthew Hawthorne + Martin Cooper + Jeremias Maerki + Stephen Colebourne + + - FastThreadLocal - + [BSD 3-Clause License] + https://git.dorkbox.com/dorkbox/Utilities + https://github.com/LWJGL/lwjgl3/blob/5819c9123222f6ce51f208e022cb907091dd8023/modules/core/src/main/java/org/lwjgl/system/FastThreadLocal.java + https://github.com/riven8192/LibStruct/blob/master/src/net/indiespot/struct/runtime/FastThreadLocal.java + Copyright 2014 + Lightweight Java Game Library Project + Riven + + - Base64Fast - + [BSD 3-Clause License] + https://git.dorkbox.com/dorkbox/Utilities + http://migbase64.sourceforge.net/ + Copyright 2004 + Mikael Grev, MiG InfoCom AB. (base64@miginfocom.com) + + - BCrypt - + [BSD 2-Clause "Simplified" or "FreeBSD" license] + https://git.dorkbox.com/dorkbox/Utilities + http://www.mindrot.org/projects/jBCrypt + Copyright 2006 + Damien Miller (djm@mindrot.org) + GWT modified version + + - Bias, BinarySearch - + [MIT License] + https://git.dorkbox.com/dorkbox/Utilities + https://github.com/timboudreau/util + Copyright 2013 + Tim Boudreau + + - ConcurrentEntry - + [The Apache Software License, Version 2.0] + https://git.dorkbox.com/dorkbox/Utilities + Copyright 2016 + bennidi + dorkbox + + - Collection Utilities (Array, ArrayMap, BooleanArray, ByteArray, CharArray, FloatArray, IdentityMap, IntArray, IntFloatMap, IntIntMap, IntMap, IntSet, LongArray, LongMap, ObjectFloatMap, ObjectIntMap, ObjectMap, ObjectSet, OrderedMap, OrderedSet) - + [The Apache Software License, Version 2.0] + https://git.dorkbox.com/dorkbox/Utilities + https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/utils + Copyright 2011 + LibGDX + Mario Zechner (badlogicgames@gmail.com) + Nathan Sweet (nathan.sweet@gmail.com) + + - Predicate - + [The Apache Software License, Version 2.0] + https://git.dorkbox.com/dorkbox/Utilities + https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/utils + Copyright 2011 + LibGDX + Mario Zechner (badlogicgames@gmail.com) + Nathan Sweet (nathan.sweet@gmail.com) + xoppa + + - Select, QuickSelect - + [The Apache Software License, Version 2.0] + https://git.dorkbox.com/dorkbox/Utilities + https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/utils + Copyright 2011 + LibGDX + Mario Zechner (badlogicgames@gmail.com) + Nathan Sweet (nathan.sweet@gmail.com) + Jon Renner + + - TimSort, ComparableTimSort - + [The Apache Software License, Version 2.0] + https://git.dorkbox.com/dorkbox/Utilities + https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/utils + Copyright 2008 + The Android Open Source Project + + - Modified hex conversion utility methods - + [The Apache Software License, Version 2.0] + https://git.dorkbox.com/dorkbox/Utilities + https://netty.io + Copyright 2014 + The Netty Project + + - Retrofit - A type-safe HTTP client for Android and Java + [The Apache Software License, Version 2.0] + https://github.com/square/retrofit + Copyright 2020 + Square, Inc + + - JNA - Simplified native library access for Java. + [The Apache Software License, Version 2.0] + https://github.com/twall/jna + Copyright 2021 + Timothy Wall + + - JNA-Platform - Mappings for a number of commonly used platform functions + [The Apache Software License, Version 2.0] + https://github.com/twall/jna + Copyright 2021 + Timothy Wall + + - Java Uuid Generator - A set of Java classes for working with UUIDs + [The Apache Software License, Version 2.0] + https://github.com/cowtowncoder/java-uuid-generator + Copyright 2021 + Tatu Saloranta (tatu.saloranta@iki.fi) + Contributors. See source release-notes/CREDITS + + - Netty - An event-driven asynchronous network application framework + [The Apache Software License, Version 2.0] + https://netty.io + Copyright 2021 + The Netty Project + Contributors. See source NOTICE + + - Bouncy Castle Crypto - Lightweight cryptography API and JCE Extension + [The Apache Software License, Version 2.0] + http://www.bouncycastle.org + Copyright 2021 + The Legion of the Bouncy Castle Inc + + - Lightweight Java Game Library - Java library that enables cross-platform access to popular native APIs + [BSD 3-Clause License] + https://github.com/LWJGL/lwjgl3 + Copyright 2021 + Lightweight Java Game Library + + - TypeTools - A simple, zero-dependency library for working with types. Supports Java 1.6+ and Android. + [The Apache Software License, Version 2.0] + https://github.com/jhalterman/typetools + Copyright 2021 + Jonathan Halterman and friends + + - SLF4J - Simple facade or abstraction for various logging frameworks + [MIT License] + http://www.slf4j.org + Copyright 2021 + QOS.ch + + - XZ for Java - Complete implementation of XZ data compression in pure Java + [Public Domain, per Creative Commons CC0] + https://tukaani.org/xz/java.html + Copyright 2021 + Lasse Collin + Igor Pavlov + + - Executor - Shell, JVM, and SSH command execution on Linux, MacOS, or Windows for Java 8+ + [The Apache Software License, Version 2.0] + https://git.dorkbox.com/dorkbox/Executor + Copyright 2021 + Dorkbox LLC + + Extra license information + - ZT Process Executor - + [The Apache Software License, Version 2.0] + https://github.com/zeroturnaround/zt-exec + Copyright 2014 + ZeroTurnaround LLC + + - Apache Commons Exec - + [The Apache Software License, Version 2.0] + https://commons.apache.org/proper/commons-exec/ + Copyright 2014 + The Apache Software Foundation + + - Kotlin - + [The Apache Software License, Version 2.0] + https://github.com/JetBrains/kotlin + Copyright 2020 + JetBrains s.r.o. and Kotlin Programming Language contributors + Kotlin Compiler, Test Data+Libraries, and Tools repository contain third-party code, to which different licenses may apply + See: https://github.com/JetBrains/kotlin/blob/master/license/README.md + + - kotlinx.coroutines - Library support for Kotlin coroutines with multiplatform support + [The Apache Software License, Version 2.0] + https://github.com/Kotlin/kotlinx.coroutines + Copyright 2021 + JetBrains s.r.o. + + - kotlin-logging - Lightweight logging framework for Kotlin + [The Apache Software License, Version 2.0] + https://github.com/MicroUtils/kotlin-logging + Copyright 2021 + Ohad Shai + + - SLF4J - Simple facade or abstraction for various logging frameworks + [MIT License] + http://www.slf4j.org + Copyright 2021 + QOS.ch + + - SSHJ - SSHv2 library for Java + [The Apache Software License, Version 2.0] + https://github.com/hierynomus/sshj + Copyright 2021 + Jeroen van Erp + SSHJ Contributors + + Extra license information + - Apache MINA - + [The Apache Software License, Version 2.0] + https://mina.apache.org/sshd-project/ + The Apache Software Foundation + + - Apache Commons-Net - + [The Apache Software License, Version 2.0] + https://commons.apache.org/proper/commons-net/ + The Apache Software Foundation + + - JZlib - + [The Apache Software License, Version 2.0] + http://www.jcraft.com/jzlib + Atsuhiko Yamanaka + JCraft, Inc. + + - Bouncy Castle Crypto - + [The Apache Software License, Version 2.0] + http://www.bouncycastle.org + The Legion of the Bouncy Castle Inc + + - ed25519-java - + [Public Domain, per Creative Commons CC0] + https://github.com/str4d/ed25519-java + https://github.com/str4d + + - SwtJavaFx - Swt and JavaFx Utilities + [The Apache Software License, Version 2.0] + https://git.dorkbox.com/dorkbox/SwtJavaFx + Copyright 2021 + Dorkbox LLC + + Extra license information + - Eclipse Platform - Frameworks and common services to support the use of Eclipse and it's tools (SWT) + [Eclipse Public License (EPL)] + https://projects.eclipse.org/projects/eclipse.platform + Copyright 2021 + The Eclipse Foundation, Inc. + + - OpenJFX - OpenJFX client application platform for desktop, mobile and embedded systems + [GNU General Public License, version 2, with the Classpath Exception] + https://github.com/openjdk/jfx + Copyright 2021 + Oracle and/or its affiliates + + - SLF4J - Simple facade or abstraction for various logging frameworks + [MIT License] + http://www.slf4j.org + Copyright 2021 + QOS.ch + + - PropertyLoader - Property annotation and loader for fields + [The Apache Software License, Version 2.0] + https://git.dorkbox.com/dorkbox/PropertyLoader + Copyright 2021 + Dorkbox LLC + + - PropertyLoader - Property annotation and loader for fields + [The Apache Software License, Version 2.0] + https://git.dorkbox.com/dorkbox/PropertyLoader + Copyright 2021 + Dorkbox LLC - - ControlsFX - BSD 3-clause License - https://bitbucket.org/controlsfx/controlsfx/ - Copyright 2013, 2014, ControlsFX - Dialog icons by the ControlsFX project - - - - Dorkbox ObjectPool - Apache 2.0 License - https://github.com/dorkbox - Copyright 2014, dorkbox, llc - Fast, lightweight, and compatible blocking/non-blocking/soft-reference object pool for Java 6+ - - - - Dorkbox TweenEngine - Apache 2.0 License - https://github.com/dorkbox - Copyright 2015, dorkbox, llc - High performance and lightweight Animation/Tween framework for Java 6+ - - - - Java Universal Tween Engine - Apache 2.0 License - https://code.google.com/p/java-universal-tween-engine/ - Copyright 2012, Aurelien Ribon - Abandoned project, origin of TweenEngine code fork. - - - - Robert Penner's Easing Functions - BSD 3-clause License - http://robertpenner.com/easing/ - Copyright 2001, Robert Penner - Tween easing algorithms - - - - SLF4J - MIT License - http://www.slf4j.org - Copyright 2004-2008, QOS.ch + - Dorkbox TweenEngine - + [The Apache Software License, Version 2.0] + https://git.dorkbox.com/dorkbox/TweenEngine + Copyright 2021 + Dorkbox LLC diff --git a/build.gradle.kts b/build.gradle.kts index 77c02e2..da0fded 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,45 +14,29 @@ * limitations under the License. */ -import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask import java.time.Instant -import java.util.Properties -import kotlin.collections.ArrayList -import kotlin.collections.component1 -import kotlin.collections.component2 -import kotlin.collections.set -import kotlin.reflect.KMutableProperty -import kotlin.reflect.full.declaredMemberProperties /////////////////////////////// ////// PUBLISH TO SONATYPE / MAVEN CENTRAL -////// -////// TESTING : local maven repo -////// -////// RELEASE : sonatype / maven central, then +////// TESTING : (to local maven repo) <'publish and release' - 'publishToMavenLocal'> +////// RELEASE : (to sonatype/maven central), <'publish and release' - 'publishToSonatypeAndRelease'> /////////////////////////////// -println("\tGradle ${project.gradle.gradleVersion} on Java ${JavaVersion.current()}") +gradle.startParameter.showStacktrace = ShowStacktrace.ALWAYS_FULL // always show the stacktrace! +gradle.startParameter.warningMode = WarningMode.All plugins { - java - signing - `maven-publish` + id("com.dorkbox.GradleUtils") version "1.12" + id("com.dorkbox.Licensing") version "2.5.4" + id("com.dorkbox.VersionUpdate") version "2.1" + id("com.dorkbox.GradlePublish") version "1.10" - // close and release on sonatype - id("io.codearte.nexus-staging") version "0.20.0" - - id("com.dorkbox.CrossCompile") version "1.0.1" - id("com.dorkbox.Licensing") version "1.4" - id("com.dorkbox.VersionUpdate") version "1.4.1" - id("com.dorkbox.GradleUtils") version "1.0" - - kotlin("jvm") version "1.3.11" + kotlin("jvm") version "1.4.21-2" } object Extras { // set for the project - const val description = "Linux, MacOS, or Windows (notification/growl/toast/) popups for the desktop for Java 6+" + const val description = "Linux, MacOS, or Windows (notification/growl/toast/) popups for the desktop for Java 8+" const val group = "com.dorkbox" const val version = "3.7" @@ -60,45 +44,18 @@ object Extras { const val name = "Notify" const val id = "Notify" const val vendor = "Dorkbox LLC" + const val vendorUrl = "https://dorkbox.com" const val url = "https://git.dorkbox.com/dorkbox/Notify" val buildDate = Instant.now().toString() - - val JAVA_VERSION = JavaVersion.VERSION_1_6.toString() - - var sonatypeUserName = "" - var sonatypePassword = "" } /////////////////////////////// ///// assign 'Extras' -///////////////////////////////z -description = Extras.description -group = Extras.group -version = Extras.version - -val propsFile = File("$projectDir/../../gradle.properties").normalize() -if (propsFile.canRead()) { - println("\tLoading custom property data from: [$propsFile]") - - val props = Properties() - propsFile.inputStream().use { - props.load(it) - } - - val extraProperties = Extras::class.declaredMemberProperties.filterIsInstance>() - props.forEach { (k, v) -> run { - val key = k as String - val value = v as String - - val member = extraProperties.find { it.name == key } - if (member != null) { - member.setter.call(Extras::class.objectInstance, value) - } - else { - project.extra.set(k, v) - } - }} -} +/////////////////////////////// +GradleUtils.load("$projectDir/../../gradle.properties", Extras) +GradleUtils.fixIntellijPaths() +GradleUtils.defaultResolutionStrategy() +GradleUtils.compileConfiguration(JavaVersion.VERSION_1_8) licensing { license(License.APACHE_2) { @@ -107,11 +64,6 @@ licensing { note(Extras.description) } - license("Dorkbox Utils", License.APACHE_2) { - author(Extras.vendor) - url("https://git.dorkbox.com/dorkbox/Utilities") - } - license("Dorkbox TweenEngine", License.APACHE_2) { author(Extras.vendor) url("https://git.dorkbox.com/dorkbox/TweenEngine") @@ -126,6 +78,11 @@ sourceSets { // want to include java files for the source. 'setSrcDirs' resets includes... include("**/*.java") } + + resources { + setSrcDirs(listOf("resources")) + include("*.png") + } } test { @@ -135,6 +92,11 @@ sourceSets { // want to include java files for the source. 'setSrcDirs' resets includes... include("**/*.java") } + + resources { + setSrcDirs(listOf("test")) + include("*.png") + } } } @@ -146,17 +108,6 @@ repositories { /////////////////////////////// ////// Task defaults /////////////////////////////// -tasks.withType { - options.encoding = "UTF-8" - - sourceCompatibility = Extras.JAVA_VERSION - targetCompatibility = Extras.JAVA_VERSION -} - -tasks.withType { - duplicatesStrategy = DuplicatesStrategy.FAIL -} - tasks.jar.get().apply { manifest { // https://docs.oracle.com/javase/tutorial/deployment/jar/packageman.html @@ -174,118 +125,33 @@ tasks.jar.get().apply { } } -tasks.compileJava.get().apply { - println("\tCompiling classes to Java $sourceCompatibility") -} - - dependencies { implementation("com.dorkbox:TweenEngine:8.3") - implementation("com.dorkbox:Utilities:1.1") + implementation("com.dorkbox:SwingActiveRender:1.1") + implementation("com.dorkbox:Utilities:1.9") + implementation("com.dorkbox:PropertyLoader:1.0") } -/////////////////////////////// -////// PUBLISH TO SONATYPE / MAVEN CENTRAL -////// -////// TESTING : local maven repo -////// -////// RELEASE : sonatype / maven central, then -/////////////////////////////// -val sourceJar = task("sourceJar") { - description = "Creates a JAR that contains the source code." +publishToSonatype { + groupId = Extras.group + artifactId = Extras.id + version = Extras.version - from(sourceSets["main"].java) + name = Extras.name + description = Extras.description + url = Extras.url - archiveClassifier.set("sources") -} + vendor = Extras.vendor + vendorUrl = Extras.vendorUrl -val javaDocJar = task("javaDocJar") { - description = "Creates a JAR that contains the javadocs." - - archiveClassifier.set("javadoc") -} - -publishing { - publications { - create("maven") { - groupId = Extras.group - artifactId = Extras.id - version = Extras.version - - from(components["java"]) - - artifact(sourceJar) - artifact(javaDocJar) - - pom { - name.set(Extras.name) - description.set(Extras.description) - url.set(Extras.url) - - issueManagement { - url.set("${Extras.url}/issues") - system.set("Gitea Issues") - } - organization { - name.set(Extras.vendor) - url.set("https://dorkbox.com") - } - developers { - developer { - id.set("dorkbox") - name.set(Extras.vendor) - email.set("email@dorkbox.com") - } - } - scm { - url.set(Extras.url) - connection.set("scm:${Extras.url}.git") - } - } - - } + issueManagement { + url = "${Extras.url}/issues" + nickname = "Gitea Issues" } - - repositories { - maven { - setUrl("https://oss.sonatype.org/service/local/staging/deploy/maven2") - credentials { - username = Extras.sonatypeUserName - password = Extras.sonatypePassword - } - } - } - - - tasks.withType { - onlyIf { - publication == publishing.publications["maven"] && repository == publishing.repositories["maven"] - } - } - - tasks.withType { - onlyIf { - publication == publishing.publications["maven"] - } - } - - // output the release URL in the console - tasks["releaseRepository"].doLast { - val url = "https://oss.sonatype.org/content/repositories/releases/" - val projectName = Extras.group.replace('.', '/') - val name = Extras.name - val version = Extras.version - - println("Maven URL: $url$projectName/$name/$version/") + developer { + id = "dorkbox" + name = Extras.vendor + email = "email@dorkbox.com" } } - -nexusStaging { - username = Extras.sonatypeUserName - password = Extras.sonatypePassword -} - -signing { - sign(publishing.publications["maven"]) -} diff --git a/src/dorkbox/notify/ActionHandler.java b/src/dorkbox/notify/ActionHandler.java new file mode 100644 index 0000000..c83c62f --- /dev/null +++ b/src/dorkbox/notify/ActionHandler.java @@ -0,0 +1,21 @@ +/* + * Copyright 2021 dorkbox, llc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package dorkbox.notify; + +public +interface ActionHandler { + void handle(T value); +} diff --git a/src/dorkbox/notify/LookAndFeel.java b/src/dorkbox/notify/LookAndFeel.java index daf0154..03651c6 100644 --- a/src/dorkbox/notify/LookAndFeel.java +++ b/src/dorkbox/notify/LookAndFeel.java @@ -24,15 +24,14 @@ import java.util.Iterator; import java.util.Map; import java.util.Random; +import dorkbox.swingActiveRender.ActionHandlerLong; +import dorkbox.swingActiveRender.SwingActiveRender; import dorkbox.tweenEngine.BaseTween; import dorkbox.tweenEngine.Tween; import dorkbox.tweenEngine.TweenCallback; import dorkbox.tweenEngine.TweenEngine; import dorkbox.tweenEngine.TweenEquations; -import dorkbox.util.ActionHandler; -import dorkbox.util.ActionHandlerLong; import dorkbox.util.ScreenUtil; -import dorkbox.util.swing.SwingActiveRender; @SuppressWarnings({"FieldCanBeLocal"}) class LookAndFeel { diff --git a/src/dorkbox/notify/Notify.java b/src/dorkbox/notify/Notify.java index cff4305..0fd8c9d 100644 --- a/src/dorkbox/notify/Notify.java +++ b/src/dorkbox/notify/Notify.java @@ -17,7 +17,6 @@ package dorkbox.notify; import java.awt.Image; import java.awt.image.BufferedImage; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.lang.ref.SoftReference; @@ -28,10 +27,9 @@ import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JFrame; -import dorkbox.util.ActionHandler; +import dorkbox.propertyLoader.Property; import dorkbox.util.ImageUtil; import dorkbox.util.LocationResolver; -import dorkbox.util.Property; import dorkbox.util.SwingUtil; /** @@ -129,11 +127,11 @@ class Notify { throw new RuntimeException("Unable to set an image that already has been set. This action must be done as soon as possible."); } - Image imageImmediate = ImageUtil.getImageImmediate(image); + ImageUtil.waitForImageLoad(image); // we only use 48x48 pixel images. Resize as necessary - int width = imageImmediate.getWidth(null); - int height = imageImmediate.getHeight(null); + int width = image.getWidth(null); + int height = image.getHeight(null); BufferedImage bufferedImage; @@ -161,11 +159,12 @@ class Notify { } if (image == null) { - String name = IMAGE_PATH + File.separatorChar + imageName; + // String name = IMAGE_PATH + File.separatorChar + imageName; + String name = imageName; resourceAsStream = LocationResolver.getResourceAsStream(name); - image = new ImageIcon(ImageUtil.getImageImmediate(ImageIO.read(resourceAsStream))); + image = new ImageIcon(ImageIO.read(resourceAsStream)); imageCache.put(imageName, new SoftReference(image)); } } catch (IOException e) { diff --git a/test/NotifyTest.java b/test/NotifyTest.java index a4ec722..6483443 100644 --- a/test/NotifyTest.java +++ b/test/NotifyTest.java @@ -26,7 +26,6 @@ import javax.swing.JPanel; import dorkbox.notify.Notify; import dorkbox.notify.Pos; -import dorkbox.util.ActionHandler; import dorkbox.util.ImageUtil; import dorkbox.util.LocationResolver; import dorkbox.util.ScreenUtil; @@ -63,104 +62,107 @@ class NotifyTest { int count = 2; - for (int i = 0; i < count; i++) { - final int finalI = i; - notify = Notify.create() - .title("Notify title " + i) - .text("This is a notification " + i + " popup message This is a notification popup message This is a " + - "notification popup message") - .hideAfter(13000) - .position(Pos.BOTTOM_RIGHT) - // .position(Pos.CENTER) - // .setScreen(0) - .darkStyle() - // .shake(1300, 4) - .shake(1300, 10) - .attach(frame) - .hideCloseButton() - .onAction(new ActionHandler() { - @Override - public - void handle(final Notify arg0) { - System.err.println("Notification " + finalI + " clicked on!"); - } - }); - notify.showWarning(); - - // try { - // Thread.sleep(1000); - // } catch (InterruptedException e) { - // e.printStackTrace(); - // } - } - - for (int i = 0; i < count; i++) { - final int finalI = i; - notify = Notify.create() - .title("Notify title " + i) - .text("This is a notification " + i + " popup message This is a notification popup message This is a " + - "notification popup message") - .hideAfter(13000) - .position(Pos.TOP_LEFT) - // .position(Pos.CENTER) - // .setScreen(0) - // .darkStyle() - // .shake(1300, 4) - // .shake(1300, 10) - .attach(frame) - // .hideCloseButton() - .onAction(new ActionHandler() { - @Override - public - void handle(final Notify arg0) { - System.err.println("Notification " + finalI + " clicked on!"); - } - }); - notify.showWarning(); - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - - - - for (int i = 0; i < count; i++) { - final int finalI = i; - notify = Notify.create() - .title("Notify title " + i) - .text("This is a notification " + i + " popup message This is a notification popup message This is a " + - "notification popup message") - .hideAfter(3000) - .position(Pos.TOP_RIGHT) -// .setScreen(0) - .darkStyle() - // .shake(1300, 4) - .shake(1300, 10) - .hideCloseButton() - .onAction(new ActionHandler() { - @Override - public - void handle(final Notify arg0) { - System.err.println("Notification " + finalI + " clicked on!"); - } - }); - notify.show(); - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } +// for (int i = 0; i < count; i++) { +// final int finalI = i; +// notify = Notify.create() +// .title("Notify title " + i) +// .text("This is a notification " + i + " popup message This is a notification popup message This is a " + +// "notification popup message") +// .hideAfter(13000) +// .position(Pos.BOTTOM_RIGHT) +// // .position(Pos.CENTER) +// // .setScreen(0) +// .darkStyle() +// // .shake(1300, 4) +// .shake(1300, 10) +// .attach(frame) +// .hideCloseButton() +// .onAction(new ActionHandler() { +// @Override +// public +// void handle(final Notify arg0) { +// System.err.println("Notification " + finalI + " clicked on!"); +// } +// }); +// notify.showWarning(); +// +// // try { +// // Thread.sleep(1000); +// // } catch (InterruptedException e) { +// // e.printStackTrace(); +// // } +// } +// +// for (int i = 0; i < count; i++) { +// final int finalI = i; +// notify = Notify.create() +// .title("Notify title " + i) +// .text("This is a notification " + i + " popup message This is a notification popup message This is a " + +// "notification popup message") +// .hideAfter(13000) +// .position(Pos.TOP_LEFT) +// // .position(Pos.CENTER) +// // .setScreen(0) +// // .darkStyle() +// // .shake(1300, 4) +// // .shake(1300, 10) +// .attach(frame) +// // .hideCloseButton() +// .onAction(new ActionHandler() { +// @Override +// public +// void handle(final Notify arg0) { +// System.err.println("Notification " + finalI + " clicked on!"); +// } +// }); +// notify.showWarning(); +// +// try { +// Thread.sleep(1000); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// } +// +// +// +// +// for (int i = 0; i < count; i++) { +// final int finalI = i; +// notify = Notify.create() +// .title("Notify title " + i) +// .text("This is a notification " + i + " popup message This is a notification popup message This is a " + +// "notification popup message") +// .hideAfter(3000) +// .position(Pos.TOP_RIGHT) +// // .setScreen(0) +// .darkStyle() +// // .shake(1300, 4) +// .shake(1300, 10) +// .hideCloseButton() +// .onAction(new ActionHandler() { +// @Override +// public +// void handle(final Notify arg0) { +// System.err.println("Notification " + finalI + " clicked on!"); +// } +// }); +// notify.show(); +// +// try { +// Thread.sleep(1000); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// } + // The purpose of this, is to display this image AS A SQUARE! InputStream resourceAsStream = LocationResolver.getResourceAsStream("notify-dark.png"); Image image = null; try { - image = ImageUtil.getImageImmediate(ImageIO.read(resourceAsStream)); + image = ImageIO.read(resourceAsStream); + ImageUtil.waitForImageLoad(image); + // image = image.getScaledInstance(144, 104, Image.SCALE_SMOOTH); // image = image.getScaledInstance(104, 144, Image.SCALE_SMOOTH); image = image.getScaledInstance(144, 144, Image.SCALE_SMOOTH); @@ -168,41 +170,59 @@ class NotifyTest { e.printStackTrace(); } - - for (int i = 0; i < count; i++) { - final int finalI = i; - notify = Notify.create() - .title("Notify title " + i) - .text("This is a notification " + i + " popup message This is a notification popup message This is a " + - "notification popup message") - // .hideAfter(13000) - .position(Pos.BOTTOM_LEFT) + notify = Notify.create() + .title("Notify scaled") + .text("This is a notification popup message scaled This is a notification popup message This is a " + + "notification popup message scaled ") + // .hideAfter(13000) + .position(Pos.BOTTOM_LEFT) // .setScreen(0) // .darkStyle() - // .shake(1300, 4) - // .shake(1300, 10) - // .hideCloseButton() - .onAction(new ActionHandler() { - @Override - public - void handle(final Notify arg0) { - System.err.println("Notification " + finalI + " clicked on!"); - } - }); + // .shake(1300, 4) + // .shake(1300, 10) + // .hideCloseButton() + .onAction(arg0->System.err.println("Notification scaled clicked on!")); - if (i == 0) { - notify.image(image); - notify.show(); - } - else { - notify.showConfirm(); - } + notify.image(image); + notify.show(); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } + + +// +// for (int i = 0; i < count; i++) { +// final int finalI = i; +// notify = Notify.create() +// .title("Notify title " + i) +// .text("This is a notification " + i + " popup message This is a notification popup message This is a " + +// "notification popup message") +// // .hideAfter(13000) +// .position(Pos.BOTTOM_LEFT) +// // .setScreen(0) +// // .darkStyle() +// // .shake(1300, 4) +// // .shake(1300, 10) +// // .hideCloseButton() +// .onAction(new ActionHandler() { +// @Override +// public +// void handle(final Notify arg0) { +// System.err.println("Notification " + finalI + " clicked on!"); +// } +// }); +// +// if (i == 0) { +// notify.image(image); +// notify.show(); +// } +// else { +// notify.showConfirm(); +// } +// +// try { +// Thread.sleep(1000); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// } } } diff --git a/test/notify-dark.png b/test/notify-dark.png new file mode 100644 index 0000000000000000000000000000000000000000..c9478cae516778324a490bd9966881dd7242ec98 GIT binary patch literal 6277 zcmV;07<%W4P) zU5p#ob;l2f%awMPD{1W=0u6+Ot}WQ&Xtjteul(Q!Qy>rRLs0mEZVIEaVZ{(&x)2bc z4%~-=@=Fk>2wFHB%SjUiNeUF95xXyOfTG5@F)DlQAVwR~32argBv%$kTJ2K&7?Lw{ z`*4S|!>{3d+!=Cr&+kDZXNULPA?JVZIrrmCESXF~Xb?ieD;z;~6R}tLC~pLT(L!L-9C%Xx zNZAL`D(W0T+|#EQ->raqhNJ8IuixYJS zGKIJoX5VSJ0}nxVHtv;gojFGKsCfjLe!S|G{ll=_kjhAz6hNgUmnsvf0D|mLyza3b z`tc|>-VTsjO40w*>2jsqaP<+|P?%tQf$U+1D&Ku`KnP*E@s>}ouBQ26e`%E0*KP8y z+^l3$DS%3OK=ZVWzVk!Gb)5rR@Ku_GYc^DwMw zB$bhRniO_!fkVlbf>Y@<4}ALAw&nv{T}lB!qgRQJkMZf%)wG8JL;oc=%D*e8R?~d?m^cqS z*vBh^ToKPF0RU=^WJX#|L8H80t^x2op9DZRf7ekdm6lSOOa`D*@}ha)9sXoud&cmo z6c1qcr0L<{B5_f2SNMVeUVkQ9^fz5R43d|W@Bjaaax0T<^W$U_!S{j2HzdVD_1HNKDC<8NJ(B^ zF9#`etVb|qPJUNrsf?7$0F0XP@A}+bF*eHON;;F;{@9R@`mE5HlFin+QZANi>DARV zpI*&0>|-+Hu4ojMaygw!^LD$|03Wi8*q%%3eeFPSKY!Y`;xx+ZJ<)MDxb9LZ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