diff --git a/README.md b/README.md index 511d605..5ae916b 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ Maven Info com.dorkbox Notify - 3.5 + 3.6 ``` diff --git a/src/dorkbox/notify/Notify.java b/src/dorkbox/notify/Notify.java index ab539f4..67ef93e 100644 --- a/src/dorkbox/notify/Notify.java +++ b/src/dorkbox/notify/Notify.java @@ -93,7 +93,7 @@ class Notify { */ public static String getVersion() { - return "3.5"; + return "3.6"; } /** @@ -245,6 +245,12 @@ class Notify { bufferedImage = ImageUtil.resizeImage(bufferedImage, -1, 48); } + // we have to now clamp to a max dimension of 48 + bufferedImage = ImageUtil.clampMaxImageSize(bufferedImage, 48); + + // now we want to center the image + bufferedImage = ImageUtil.getSquareBufferedImage(bufferedImage); + this.icon = new ImageIcon(bufferedImage); return this; } diff --git a/test/NotifyTest.java b/test/NotifyTest.java index 7371645..ad0a8e7 100644 --- a/test/NotifyTest.java +++ b/test/NotifyTest.java @@ -14,7 +14,11 @@ * limitations under the License. */ import java.awt.FlowLayout; +import java.awt.Image; +import java.io.IOException; +import java.io.InputStream; +import javax.imageio.ImageIO; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; @@ -23,6 +27,8 @@ 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; public @@ -142,7 +148,7 @@ class NotifyTest { System.err.println("Notification " + finalI + " clicked on!"); } }); - notify.showConfirm(); + notify.show(); try { Thread.sleep(1000); @@ -151,6 +157,17 @@ class NotifyTest { } } + InputStream resourceAsStream = LocationResolver.getResourceAsStream("notify-dark.png"); + Image image = null; + try { + image = ImageUtil.getImageImmediate(ImageIO.read(resourceAsStream)); + // image = image.getScaledInstance(144, 104, Image.SCALE_SMOOTH); + image = image.getScaledInstance(104, 144, Image.SCALE_SMOOTH); + } catch (IOException e) { + e.printStackTrace(); + } + + for (int i = 0; i < count; i++) { final int finalI = i; notify = Notify.create() @@ -171,7 +188,14 @@ class NotifyTest { System.err.println("Notification " + finalI + " clicked on!"); } }); - notify.show(); + + if (i == 0) { + notify.image(image); + notify.show(); + } + else { + notify.showConfirm(); + } try { Thread.sleep(1000);