search: cleanup
[nikiroo-utils.git] / src / be / nikiroo / fanfix / reader / ui / GuiReaderPropertiesPane.java
CommitLineData
5beb7cdc
NR
1package be.nikiroo.fanfix.reader.ui;
2
3import java.awt.BorderLayout;
4import java.awt.Color;
5import java.awt.Font;
6import java.util.Map;
7
8import javax.swing.BorderFactory;
9import javax.swing.BoxLayout;
10import javax.swing.ImageIcon;
11import javax.swing.JLabel;
12import javax.swing.JPanel;
13import javax.swing.JTextArea;
14
15import be.nikiroo.fanfix.data.MetaData;
16import be.nikiroo.fanfix.data.Story;
17import be.nikiroo.fanfix.library.BasicLibrary;
18import be.nikiroo.fanfix.reader.BasicReader;
19
20/**
21 * A panel displaying properties and other information of a {@link Story}.
22 *
23 * @author niki
24 */
25public class GuiReaderPropertiesPane extends JPanel {
26 private static final long serialVersionUID = 1L;
27 private final int space = 10;
28
29 /**
30 * Create a new {@link GuiReaderPropertiesPane}.
31 *
32 * @param lib
33 * the library to use for the cover image
34 * @param meta
35 * the meta to describe
36 */
37 public GuiReaderPropertiesPane(BasicLibrary lib, MetaData meta) {
38 // Image
39 ImageIcon img = GuiReaderCoverImager.generateCoverIcon(lib, meta);
40
41 setLayout(new BorderLayout());
42
43 // Main panel
44 JPanel mainPanel = new JPanel(new BorderLayout());
45 JPanel mainPanelKeys = new JPanel();
46 mainPanelKeys.setLayout(new BoxLayout(mainPanelKeys, BoxLayout.Y_AXIS));
47 JPanel mainPanelValues = new JPanel();
48 mainPanelValues.setLayout(new BoxLayout(mainPanelValues,
49 BoxLayout.Y_AXIS));
50
51 mainPanel.add(mainPanelKeys, BorderLayout.WEST);
52 mainPanel.add(mainPanelValues, BorderLayout.CENTER);
53
54 Map<String, String> desc = BasicReader.getMetaDesc(meta);
55
56 Color trans = new Color(0, 0, 0, 1);
57 Color base = mainPanelValues.getBackground();
58 for (String key : desc.keySet()) {
59 JTextArea jKey = new JTextArea(key);
60 jKey.setFont(new Font(jKey.getFont().getFontName(), Font.BOLD, jKey
61 .getFont().getSize()));
62 jKey.setEditable(false);
63 jKey.setLineWrap(false);
64 jKey.setBackground(trans);
65 mainPanelKeys.add(jKey);
66
67 final JTextArea jValue = new JTextArea(desc.get(key));
68 jValue.setEditable(false);
69 jValue.setLineWrap(false);
70 jValue.setBackground(base);
71 mainPanelValues.add(jValue);
72 }
73
74 // Image
75 JLabel imgLabel = new JLabel(img);
76 imgLabel.setVerticalAlignment(JLabel.TOP);
77
78 // Borders
79 mainPanelKeys.setBorder(BorderFactory.createEmptyBorder(space, space,
80 space, space));
81 mainPanelValues.setBorder(BorderFactory.createEmptyBorder(space, space,
82 space, space));
83 imgLabel.setBorder(BorderFactory.createEmptyBorder(0, space, space, 0));
84
85 // Add all
86 add(imgLabel, BorderLayout.WEST);
87 add(mainPanel, BorderLayout.CENTER);
88 }
89
90 /**
91 * The invisible border size (multiply by 2 if you need the total width or
92 * the total height).
93 *
94 * @return the invisible border thickness
95 */
96 public int getBorderThickness() {
97 return space;
98 }
99}