reformat
[fanfix.git] / src / be / nikiroo / fanfix_swing / gui / book / BookLine.java
index 6437f613459ad895cf37e648630cded4d99fde87..f7926a0212d3dd36db60bf13c9c61b6e0c6308b3 100644 (file)
@@ -6,6 +6,7 @@ import java.awt.Graphics;
 
 import javax.swing.JLabel;
 import javax.swing.JPanel;
+import javax.swing.SwingConstants;
 
 import be.nikiroo.fanfix.data.Story;
 import be.nikiroo.fanfix_swing.gui.BooksPanel;
@@ -37,8 +38,10 @@ public class BookLine extends JPanel {
        /**
         * Create a new {@link BookLine} item for the given {@link Story}.
         * 
-        * @param info         the information about the story to represent
-        * @param seeWordCount TRUE to see word counts, FALSE to see authors
+        * @param info
+        *            the information about the story to represent
+        * @param seeWordCount
+        *            TRUE to see word counts, FALSE to see authors
         */
        public BookLine(BookInfo info, boolean seeWordCount) {
                this.info = info;
@@ -51,16 +54,29 @@ public class BookLine extends JPanel {
         * Initialise this {@link BookLine}.
         */
        protected void init() {
-               // TODO: image
-               iconCached = new JLabel("   ");
-               iconNotCached = new JLabel(" * ");
+               iconCached = new JLabel(" ◉ ");
+               iconNotCached = new JLabel(" ○ ");
+
+               iconNotCached.setForeground(BookCoverImager.UNCACHED_ICON_COLOR);
+               iconCached.setForeground(BookCoverImager.UNCACHED_ICON_COLOR);
+               iconCached.setPreferredSize(iconNotCached.getPreferredSize());
 
                title = new JLabel();
                secondary = new JLabel();
                secondary.setForeground(AUTHOR_COLOR);
 
+               JLabel id = new JLabel(info.getMeta().getLuid());
+               id.setPreferredSize(new JLabel(" 999 ").getPreferredSize());
+               id.setForeground(Color.gray);
+               id.setHorizontalAlignment(SwingConstants.CENTER);
+
+               JPanel idTitle = new JPanel(new BorderLayout());
+               idTitle.setOpaque(false);
+               idTitle.add(id, BorderLayout.WEST);
+               idTitle.add(title, BorderLayout.CENTER);
+
                setLayout(new BorderLayout());
-               add(title, BorderLayout.CENTER);
+               add(idTitle, BorderLayout.CENTER);
                add(secondary, BorderLayout.EAST);
 
                updateMeta();
@@ -78,7 +94,8 @@ public class BookLine extends JPanel {
        /**
         * The book current selection state,
         * 
-        * @param selected TRUE if it is selected
+        * @param selected
+        *            TRUE if it is selected
         */
        public void setSelected(boolean selected) {
                if (this.selected != selected) {
@@ -99,7 +116,8 @@ public class BookLine extends JPanel {
        /**
         * The item mouse-hover state.
         * 
-        * @param hovered TRUE if it is mouse-hovered
+        * @param hovered
+        *            TRUE if it is mouse-hovered
         */
        public void setHovered(boolean hovered) {
                if (this.hovered != hovered) {
@@ -120,7 +138,8 @@ public class BookLine extends JPanel {
        /**
         * The secondary value content: word count or author.
         * 
-        * @param seeWordCount TRUE to see word counts, FALSE to see authors
+        * @param seeWordCount
+        *            TRUE to see word counts, FALSE to see authors
         */
        public void setSeeWordCount(boolean seeWordCount) {
                if (this.seeWordCount != seeWordCount) {
@@ -154,15 +173,17 @@ public class BookLine extends JPanel {
                String main = info.getMainInfo();
                String optSecondary = info.getSecondaryInfo(seeWordCount);
 
-               //TODO: max size limit?
+               // TODO: max size limit?
                title.setText(main);
                secondary.setText(optSecondary + " ");
 
-               setBackground(BookCoverImager.getBackground(isEnabled(), isSelected(), isHovered()));
+               setBackground(BookCoverImager.getBackground(isEnabled(), isSelected(),
+                               isHovered()));
 
                remove(iconCached);
                remove(iconNotCached);
-               add(getInfo().isCached() ? iconCached : iconNotCached, BorderLayout.WEST);
+               add(getInfo().isCached() ? iconCached : iconNotCached,
+                               BorderLayout.WEST);
                validate();
        }
 }