Wordcount (including UI), date of creation
[fanfix.git] / src / be / nikiroo / fanfix / reader / LocalReaderBook.java
index d19b6034d67eeb60b435e002f853d5b973122ebc..8c470785dbf72f99d742125a5195492ace180dc7 100644 (file)
@@ -85,7 +85,7 @@ class LocalReaderBook extends JPanel {
        private Date lastClick;
 
        private List<BookActionListener> listeners;
-       private String luid;
+       private MetaData meta;
        private boolean cached;
 
        /**
@@ -95,14 +95,26 @@ class LocalReaderBook extends JPanel {
         *            the story {@code}link MetaData}
         * @param cached
         *            TRUE if it is locally cached
+        * @param seeWordcount
+        *            TRUE to see word counts, FALSE to see authors
         */
-       public LocalReaderBook(MetaData meta, boolean cached) {
+       public LocalReaderBook(MetaData meta, boolean cached, boolean seeWordCount) {
                this.cached = cached;
-               luid = meta.getLuid();
+               this.meta = meta;
+
+               String optSecondary = meta.getAuthor();
+               if (seeWordCount) {
+                       if (meta.getWords() >= 4000) {
+                               optSecondary = (meta.getWords() / 1000) + "k words";
+                       } else if (meta.getWords() > 0) {
+                               optSecondary = meta.getWords() + " words";
+                       } else {
+                               optSecondary = "empty";
+                       }
+               }
 
-               String optAuthor = meta.getAuthor();
-               if (optAuthor != null && !optAuthor.isEmpty()) {
-                       optAuthor = "(" + optAuthor + ")";
+               if (optSecondary != null && !optSecondary.isEmpty()) {
+                       optSecondary = "(" + optSecondary + ")";
                }
 
                icon = new JLabel(generateCoverIcon(meta.getCover()));
@@ -114,7 +126,7 @@ class LocalReaderBook extends JPanel {
                                                                + "%s" + "<br>" + "<span style='color: %s;'>"
                                                                + "%s" + "</span>" + "</body>" + "</html>",
                                                TEXT_WIDTH, TEXT_HEIGHT, meta.getTitle(), AUTHOR_COLOR,
-                                               optAuthor));
+                                               optSecondary));
 
                setLayout(new BorderLayout(10, 10));
                add(icon, BorderLayout.CENTER);
@@ -229,12 +241,12 @@ class LocalReaderBook extends JPanel {
        }
 
        /**
-        * The Library UID of the book represented by this item.
+        * The Library {@code}link MetaData} of the book represented by this item.
         * 
-        * @return the LUID
+        * @return the meta
         */
-       public String getLuid() {
-               return luid;
+       public MetaData getMeta() {
+               return meta;
        }
 
        /**