From c748662760838e5bf08868b3dfde8c29b2744866 Mon Sep 17 00:00:00 2001 From: Andrew Lalis Date: Sat, 13 Mar 2021 14:25:40 +0100 Subject: [PATCH] Icons for book navigation. --- design/page_first.svg | 80 ++++++++++++++++++ design/page_last.svg | 80 ++++++++++++++++++ design/page_left.svg | 71 ++++++++++++++++ design/page_right.svg | 71 ++++++++++++++++ .../blockbookbinder/util/IconLoader.java | 24 ++++++ .../view/book/BookPreviewPanel.java | 14 +-- src/main/resources/images/page_first.png | Bin 0 -> 505 bytes src/main/resources/images/page_last.png | Bin 0 -> 494 bytes src/main/resources/images/page_left.png | Bin 0 -> 515 bytes src/main/resources/images/page_right.png | Bin 0 -> 504 bytes 10 files changed, 335 insertions(+), 5 deletions(-) create mode 100644 design/page_first.svg create mode 100644 design/page_last.svg create mode 100644 design/page_left.svg create mode 100644 design/page_right.svg create mode 100644 src/main/java/nl/andrewlalis/blockbookbinder/util/IconLoader.java create mode 100644 src/main/resources/images/page_first.png create mode 100644 src/main/resources/images/page_last.png create mode 100644 src/main/resources/images/page_left.png create mode 100644 src/main/resources/images/page_right.png diff --git a/design/page_first.svg b/design/page_first.svg new file mode 100644 index 0000000..08f9b38 --- /dev/null +++ b/design/page_first.svg @@ -0,0 +1,80 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/design/page_last.svg b/design/page_last.svg new file mode 100644 index 0000000..77f07c1 --- /dev/null +++ b/design/page_last.svg @@ -0,0 +1,80 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/design/page_left.svg b/design/page_left.svg new file mode 100644 index 0000000..1f960f2 --- /dev/null +++ b/design/page_left.svg @@ -0,0 +1,71 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/design/page_right.svg b/design/page_right.svg new file mode 100644 index 0000000..c29b18f --- /dev/null +++ b/design/page_right.svg @@ -0,0 +1,71 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/src/main/java/nl/andrewlalis/blockbookbinder/util/IconLoader.java b/src/main/java/nl/andrewlalis/blockbookbinder/util/IconLoader.java new file mode 100644 index 0000000..1d66e21 --- /dev/null +++ b/src/main/java/nl/andrewlalis/blockbookbinder/util/IconLoader.java @@ -0,0 +1,24 @@ +package nl.andrewlalis.blockbookbinder.util; + +import javax.imageio.ImageIO; +import javax.swing.*; +import java.awt.*; +import java.io.IOException; +import java.io.InputStream; + +public class IconLoader { + + public static Icon load(String resourceName, int width, int height) { + try { + InputStream is = IconLoader.class.getClassLoader().getResourceAsStream(resourceName); + if (is == null) { + throw new IOException("Could not open resource: " + resourceName); + } + Image img = ImageIO.read(is).getScaledInstance(width, height, Image.SCALE_SMOOTH); + return new ImageIcon(img); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } +} diff --git a/src/main/java/nl/andrewlalis/blockbookbinder/view/book/BookPreviewPanel.java b/src/main/java/nl/andrewlalis/blockbookbinder/view/book/BookPreviewPanel.java index f7b5299..4165afb 100644 --- a/src/main/java/nl/andrewlalis/blockbookbinder/view/book/BookPreviewPanel.java +++ b/src/main/java/nl/andrewlalis/blockbookbinder/view/book/BookPreviewPanel.java @@ -3,6 +3,7 @@ package nl.andrewlalis.blockbookbinder.view.book; import lombok.Getter; import nl.andrewlalis.blockbookbinder.model.Book; import nl.andrewlalis.blockbookbinder.model.BookPage; +import nl.andrewlalis.blockbookbinder.util.IconLoader; import javax.swing.*; import javax.swing.border.EmptyBorder; @@ -50,13 +51,15 @@ public class BookPreviewPanel extends JPanel { this.add(previewPageScrollPane, BorderLayout.CENTER); JPanel previewButtonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); - this.firstPageButton = new JButton("First"); + this.firstPageButton = new JButton(); + this.firstPageButton.setIcon(IconLoader.load("images/page_first.png", 16, 16)); this.firstPageButton.addActionListener(e -> { this.currentPage = 0; displayCurrentPage(); }); - this.previousPageButton = new JButton("Previous Page"); + this.previousPageButton = new JButton(); + this.previousPageButton.setIcon(IconLoader.load("images/page_left.png", 16, 16)); this.previousPageButton.addActionListener(e -> { if (currentPage > 0) { currentPage--; @@ -64,15 +67,16 @@ public class BookPreviewPanel extends JPanel { } }); - this.nextPageButton = new JButton("Next Page"); + this.nextPageButton = new JButton(); + this.nextPageButton.setIcon(IconLoader.load("images/page_right.png", 16, 16)); this.nextPageButton.addActionListener(e -> { if (currentPage < book.getPageCount() - 1) { currentPage++; displayCurrentPage(); } }); - - this.lastPageButton = new JButton("Last"); + this.lastPageButton = new JButton(); + this.lastPageButton.setIcon(IconLoader.load("images/page_last.png", 16, 16)); this.lastPageButton.addActionListener(e -> { this.currentPage = Math.max(this.book.getPageCount() - 1, 0); displayCurrentPage(); diff --git a/src/main/resources/images/page_first.png b/src/main/resources/images/page_first.png new file mode 100644 index 0000000000000000000000000000000000000000..ad59c504c1c5a59936d30781715cc379bced3047 GIT binary patch literal 505 zcmV!@-T=epwn= z!a7EB&R>TIz6J>wx{%M|D5#g+zUPJNMSxN4YPEBo_ymi1k#}=90S2&!n~3-ppYXa< zk;ex3h+h$L6NeZpQmAZz8T{xVKEj8B4^b+>Fuve#M0|l&yeuOx5}+?Bd>s-0NrDZQ z6&DFGkDn27+RpDDEAABFtyZ@g6CWqxdO}`+orw4fDw;vH_TF7M-)<|E1s(|KuVFpXuQe*(67efI7@94l91Y_WLX+m#(5;fW_nS|Wl$j8 vFUuXaFo_MVej>}g1yJn^6KY|Vgit4)M;D=AT~k(tu=zZI_0(n{c<{lFS&;E=*+BZS|U0R7(ZfN zq(oH2Uck7F1Cdg3y~pS$W<+?5a(#|-`;g@RC0h&_Uu({%v?f4x&}>0c!m8v>-!y0r kf9mw}FHFd}G<%!+52SSo91^BHYybcN07*qoM6N<$g31)ekN^Mx literal 0 HcmV?d00001 diff --git a/src/main/resources/images/page_left.png b/src/main/resources/images/page_left.png new file mode 100644 index 0000000000000000000000000000000000000000..ca73e663a13d763a426b9fcdd573a4f8a8d65b85 GIT binary patch literal 515 zcmV+e0{s1nP)LTla@_>iXnp*7!P6La$U6T8p<(AfY0002ovPDHLk FV1hZg)8GIA literal 0 HcmV?d00001 diff --git a/src/main/resources/images/page_right.png b/src/main/resources/images/page_right.png new file mode 100644 index 0000000000000000000000000000000000000000..7ab29fa3b39271d6064289209e0b0373779eda65 GIT binary patch literal 504 zcmVS zkU^tMLv5~!OPjRiV6+NNf`f>VLQ8^B5hyxDZ_tf<9R4>7xsTI*&QSf}STKwBMGEZ1_biwE_RC zr&-_uWokA8@OR8-fV-7bz8ioW%2%JsfM3V!09@e}E@gnvD|bHvzr}b4_#_@F``Hfs zrS<-Jr@>vy7rhI>O=U&Sb{Y&(W`i95KG)&8E0DrEA uIS=;_f!CF3S6h1U5HE38>309~_vQeC*Sz}WYM1H&0000