X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2FGuiReaderBook.java;h=2ae04b461d13bdd43cac911e0702190439d12cca;hb=e604986c4208da0091d26bc0e1c4feb4ff3c588f;hp=29f4c49783a0a727d7c9f08011ee5c8408617c9c;hpb=14b574483b51d3859acef6a269f8841b5a4eb5f8;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/reader/GuiReaderBook.java b/src/be/nikiroo/fanfix/reader/GuiReaderBook.java index 29f4c49..2ae04b4 100644 --- a/src/be/nikiroo/fanfix/reader/GuiReaderBook.java +++ b/src/be/nikiroo/fanfix/reader/GuiReaderBook.java @@ -118,12 +118,20 @@ class GuiReaderBook extends JPanel { String optSecondary = meta.getAuthor(); if (seeWordCount) { if (meta.getWords() >= 4000) { - optSecondary = (meta.getWords() / 1000) + "k words"; + optSecondary = "" + (meta.getWords() / 1000) + "k"; } else if (meta.getWords() > 0) { - optSecondary = meta.getWords() + " words"; + optSecondary = "" + meta.getWords(); } else { optSecondary = ""; } + + if (!optSecondary.isEmpty()) { + if (meta.isImageDocument()) { + optSecondary += " images"; + } else { + optSecondary += " words"; + } + } } if (optSecondary != null && !optSecondary.isEmpty()) { @@ -373,18 +381,22 @@ class GuiReaderBook extends JPanel { BufferedImage resizedImage = null; String id = null; - if (meta.getLuid() != null) { - id = meta.getUuid() + ".thumb_" + SPINE_WIDTH + "x" + COVER_WIDTH - + "+" + SPINE_HEIGHT + "+" + COVER_HEIGHT + "@" + HOFFSET; - InputStream in = Instance.getCache().getFromCache(id); - if (in != null) { - try { - resizedImage = ImageUtils.fromStream(in); - in.close(); - in = null; - } catch (IOException e) { - Instance.syserr(e); - } + String key = meta.getUuid(); + if (key == null) { + // a fake meta (a source) + key = "source_" + meta.getSource(); + } + + id = key + ".thumb_" + SPINE_WIDTH + "x" + COVER_WIDTH + "+" + + SPINE_HEIGHT + "+" + COVER_HEIGHT + "@" + HOFFSET; + InputStream in = Instance.getCache().getFromCache(id); + if (in != null) { + try { + resizedImage = ImageUtils.fromStream(in); + in.close(); + in = null; + } catch (IOException e) { + Instance.syserr(e); } } @@ -418,7 +430,7 @@ class GuiReaderBook extends JPanel { ByteArrayOutputStream out = new ByteArrayOutputStream(); ImageIO.write(resizedImage, "png", out); byte[] imageBytes = out.toByteArray(); - InputStream in = new ByteArrayInputStream(imageBytes); + in = new ByteArrayInputStream(imageBytes); Instance.getCache().addToCache(in, id); in.close(); in = null;