Instance: use getInstance()
[nikiroo-utils.git] / src / be / nikiroo / fanfix / reader / ui / GuiReaderCoverImager.java
index 0bbf82eb47c29dcaab4a4a3fdee38cf9a995e7c3..8d5aaebcc73674c27f32d4e931c9d1ebae871445 100644 (file)
@@ -129,6 +129,24 @@ class GuiReaderCoverImager {
                return generateCoverIcon(lib, GuiReaderBookInfo.fromMeta(meta));
        }
 
+       /**
+        * The width of a cover image.
+        * 
+        * @return the width
+        */
+       static public int getCoverWidth() {
+               return SPINE_WIDTH + COVER_WIDTH;
+       }
+
+       /**
+        * The height of a cover image.
+        * 
+        * @return the height
+        */
+       static public int getCoverHeight() {
+               return COVER_HEIGHT + HOFFSET;
+       }
+
        /**
         * Generate a cover icon based upon the given {@link GuiReaderBookInfo}.
         * 
@@ -144,23 +162,22 @@ class GuiReaderCoverImager {
                BufferedImage resizedImage = null;
                String id = getIconId(info);
 
-               InputStream in = Instance.getCache().getFromCache(id);
+               InputStream in = Instance.getInstance().getCache().getFromCache(id);
                if (in != null) {
                        try {
                                resizedImage = ImageUtilsAwt.fromImage(new Image(in));
                                in.close();
                                in = null;
                        } catch (IOException e) {
-                               Instance.getTraceHandler().error(e);
+                               Instance.getInstance().getTraceHandler().error(e);
                        }
                }
 
                if (resizedImage == null) {
                        try {
                                Image cover = info.getBaseImage(lib);
-                               resizedImage = new BufferedImage(SPINE_WIDTH + COVER_WIDTH,
-                                               SPINE_HEIGHT + COVER_HEIGHT + HOFFSET,
-                                               BufferedImage.TYPE_4BYTE_ABGR);
+                               resizedImage = new BufferedImage(getCoverWidth(),
+                                               getCoverHeight(), BufferedImage.TYPE_4BYTE_ABGR);
 
                                Graphics2D g = resizedImage.createGraphics();
                                try {
@@ -187,14 +204,14 @@ class GuiReaderCoverImager {
                                        ImageIO.write(resizedImage, "png", out);
                                        byte[] imageBytes = out.toByteArray();
                                        in = new ByteArrayInputStream(imageBytes);
-                                       Instance.getCache().addToCache(in, id);
+                                       Instance.getInstance().getCache().addToCache(in, id);
                                        in.close();
                                        in = null;
                                }
                        } catch (MalformedURLException e) {
-                               Instance.getTraceHandler().error(e);
+                               Instance.getInstance().getTraceHandler().error(e);
                        } catch (IOException e) {
-                               Instance.getTraceHandler().error(e);
+                               Instance.getInstance().getTraceHandler().error(e);
                        }
                }
 
@@ -209,7 +226,7 @@ class GuiReaderCoverImager {
         */
        static public void clearIcon(GuiReaderBookInfo info) {
                String id = getIconId(info);
-               Instance.getCache().removeFromCache(id);
+               Instance.getInstance().getCache().removeFromCache(id);
        }
 
        /**