1 package be
.nikiroo
.fanfix
.reader
.ui
;
3 import java
.awt
.BorderLayout
;
7 import java
.util
.Map
.Entry
;
9 import javax
.swing
.BorderFactory
;
10 import javax
.swing
.BoxLayout
;
11 import javax
.swing
.ImageIcon
;
12 import javax
.swing
.JFrame
;
13 import javax
.swing
.JLabel
;
14 import javax
.swing
.JPanel
;
15 import javax
.swing
.JTextArea
;
17 import be
.nikiroo
.fanfix
.data
.MetaData
;
18 import be
.nikiroo
.fanfix
.data
.Story
;
19 import be
.nikiroo
.fanfix
.reader
.BasicReader
;
20 import be
.nikiroo
.fanfix
.reader
.Reader
;
23 * A frame displaying properties and other information of a {@link Story}.
27 public class GuiReaderPropertiesFrame
extends JFrame
{
28 private static final long serialVersionUID
= 1L;
31 * Create a new {@link GuiReaderPropertiesFrame}.
36 * the meta to describe
38 public GuiReaderPropertiesFrame(Reader reader
, MetaData meta
) {
44 ImageIcon img
= GuiReaderCoverImager
.generateCoverIcon(
45 reader
.getLibrary(), meta
);
48 setTitle(meta
.getLuid() + ": " + meta
.getTitle());
50 setSize(800, img
.getIconHeight() + 2 * top
);
51 setLayout(new BorderLayout());
54 JPanel mainPanel
= new JPanel(new BorderLayout());
55 JPanel mainPanelKeys
= new JPanel();
56 mainPanelKeys
.setLayout(new BoxLayout(mainPanelKeys
, BoxLayout
.Y_AXIS
));
57 JPanel mainPanelValues
= new JPanel();
58 mainPanelValues
.setLayout(new BoxLayout(mainPanelValues
,
61 mainPanel
.add(mainPanelKeys
, BorderLayout
.WEST
);
62 mainPanel
.add(mainPanelValues
, BorderLayout
.CENTER
);
64 List
<Entry
<String
, String
>> infos
= BasicReader
.getMetaDesc(meta
);
66 Color trans
= new Color(0, 0, 0, 1);
67 for (Entry
<String
, String
> info
: infos
) {
68 JTextArea key
= new JTextArea(info
.getKey());
69 key
.setFont(new Font(key
.getFont().getFontName(), Font
.BOLD
, key
70 .getFont().getSize()));
71 key
.setEditable(false);
72 key
.setLineWrap(false);
73 key
.setBackground(trans
);
74 mainPanelKeys
.add(key
);
76 JTextArea value
= new JTextArea(info
.getValue());
77 value
.setEditable(false);
78 value
.setLineWrap(false);
79 value
.setBackground(trans
);
80 mainPanelValues
.add(value
);
84 JLabel imgLabel
= new JLabel(img
);
85 imgLabel
.setVerticalAlignment(JLabel
.TOP
);
88 mainPanelKeys
.setBorder(BorderFactory
.createEmptyBorder(top
, space
, 0,
90 mainPanelValues
.setBorder(BorderFactory
.createEmptyBorder(top
, space
,
92 imgLabel
.setBorder(BorderFactory
.createEmptyBorder(0, space
, 0, 0));
95 add(imgLabel
, BorderLayout
.WEST
);
96 add(mainPanel
, BorderLayout
.CENTER
);