X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2Fui%2FGuiReaderBook.java;h=15d2ad4407ed487554a5586e6c2012986e5b2fb3;hp=af2a5a783f370a7b0cd52d0c83f134545a6c5bc5;hb=c349fd480d7ab36ad423e965434a6f1f418d60a5;hpb=3828c808ecfff13b78c1b2c077f74d6e81799ec0 diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReaderBook.java b/src/be/nikiroo/fanfix/reader/ui/GuiReaderBook.java index af2a5a7..15d2ad4 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReaderBook.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReaderBook.java @@ -68,6 +68,7 @@ class GuiReaderBook extends JPanel { private List listeners; private GuiReaderBookInfo info; private boolean cached; + private boolean seeWordCount; /** * Create a new {@link GuiReaderBook} item for the given {@link Story}. @@ -83,22 +84,15 @@ class GuiReaderBook extends JPanel { */ public GuiReaderBook(Reader reader, GuiReaderBookInfo info, boolean cached, boolean seeWordCount) { - this.cached = cached; this.info = info; - - String optSecondary = info.getSecondaryInfo(seeWordCount); + this.cached = cached; + this.seeWordCount = seeWordCount; icon = new JLabel(GuiReaderCoverImager.generateCoverIcon( reader.getLibrary(), info)); - title = new JLabel( - String.format( - "" - + "" - + "%s" + "
" + "" - + "%s" + "" + "" + "", - GuiReaderCoverImager.TEXT_WIDTH, - GuiReaderCoverImager.TEXT_HEIGHT, info.getMainInfo(), - AUTHOR_COLOR, optSecondary)); + + title = new JLabel(); + updateTitle(); setLayout(new BorderLayout(10, 10)); add(icon, BorderLayout.CENTER); @@ -258,12 +252,30 @@ class GuiReaderBook extends JPanel { } /** - * Paint the item, then call {@link GuiReaderBook#paintOverlay(Graphics)}. + * Update the title, paint the item, then call + * {@link GuiReaderCoverImager#paintOverlay(Graphics, boolean, boolean, boolean, boolean)} + * . */ @Override public void paint(Graphics g) { + updateTitle(); super.paint(g); GuiReaderCoverImager.paintOverlay(g, isEnabled(), isSelected(), isHovered(), isCached()); } + + /** + * Update the title with the currently registered information. + */ + private void updateTitle() { + String optSecondary = info.getSecondaryInfo(seeWordCount); + title.setText(String + .format("" + + "" + + "%s" + "
" + "" + "%s" + + "" + "" + "", + GuiReaderCoverImager.TEXT_WIDTH, + GuiReaderCoverImager.TEXT_HEIGHT, info.getMainInfo(), + AUTHOR_COLOR, optSecondary)); + } }