X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2Fui%2FGuiReaderTextViewer.java;fp=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2Fui%2FGuiReaderTextViewer.java;h=0000000000000000000000000000000000000000;hb=32ba91e9d2443ac9d17d3db66eef4c570d02cdf1;hp=281f082a0b82aa3842d59d12abedaa948ca4e0f6;hpb=1ee6709558f5e1a6200dd6ec20c0f206c22797cc;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReaderTextViewer.java b/src/be/nikiroo/fanfix/reader/ui/GuiReaderTextViewer.java deleted file mode 100644 index 281f082..0000000 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReaderTextViewer.java +++ /dev/null @@ -1,145 +0,0 @@ -package be.nikiroo.fanfix.reader.ui; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Font; -import java.awt.LayoutManager; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.BorderFactory; -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.SwingConstants; - -import be.nikiroo.fanfix.data.Chapter; -import be.nikiroo.fanfix.data.MetaData; -import be.nikiroo.fanfix.data.Story; -import be.nikiroo.fanfix.library.BasicLibrary; - -public class GuiReaderTextViewer extends JFrame { - private static final long serialVersionUID = 1L; - - private Story story; - private MetaData meta; - private JLabel title; - private JLabel text; - private JLabel chapterLabel; - private GuiReaderPropertiesPane descPane; - private int currentChapter = -42; // cover = -1 - private GuiReaderTextViewerOutput htmlOutput = new GuiReaderTextViewerOutput(); - - public GuiReaderTextViewer(BasicLibrary lib, Story story) { - super(story.getMeta().getLuid() + ": " + story.getMeta().getTitle()); - - setSize(800, 600); - - this.story = story; - this.meta = story.getMeta(); - - initGuiBase(lib); - initGuiNavButtons(); - - setChapter(-1); - } - - private void initGuiBase(BasicLibrary lib) { - setLayout(new BorderLayout()); - - title = new JLabel(); - title.setFont(new Font(Font.SERIF, Font.BOLD, - title.getFont().getSize() * 3)); - title.setText(meta.getTitle()); - title.setHorizontalAlignment(SwingConstants.CENTER); - title.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - add(title, BorderLayout.NORTH); - - JPanel contentPane = new JPanel(new BorderLayout()); - add(contentPane, BorderLayout.CENTER); - - descPane = new GuiReaderPropertiesPane(lib, meta); - contentPane.add(descPane, BorderLayout.NORTH); - - text = new JLabel(); - text.setAlignmentY(TOP_ALIGNMENT); - - // TODO: why is it broken? - // text.setPreferredSize(new Dimension(500, 500)); - - JScrollPane scroll = new JScrollPane(text); - scroll.getVerticalScrollBar().setUnitIncrement(16); - contentPane.add(scroll, BorderLayout.CENTER); - } - - private void initGuiNavButtons() { - JPanel navButtons = new JPanel(); - LayoutManager layout = new BoxLayout(navButtons, BoxLayout.X_AXIS); - navButtons.setLayout(layout); - - navButtons.add(createNavButton("<<", new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - setChapter(-1); - } - })); - navButtons.add(createNavButton(" < ", new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - setChapter(currentChapter - 1); - } - })); - navButtons.add(createNavButton(" > ", new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - setChapter(currentChapter + 1); - } - })); - navButtons.add(createNavButton(">>", new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - setChapter(story.getChapters().size() - 1); - } - })); - - add(navButtons, BorderLayout.SOUTH); - - chapterLabel = new JLabel(""); - navButtons.add(chapterLabel); - } - - private JButton createNavButton(String text, ActionListener action) { - JButton navButton = new JButton(text); - navButton.addActionListener(action); - navButton.setForeground(Color.BLUE); - return navButton; - } - - private void setChapter(int chapter) { - if (chapter >= -1 && chapter < story.getChapters().size() - && chapter != currentChapter) { - currentChapter = chapter; - - Chapter chap; - if (chapter == -1) { - chap = meta.getResume(); - setCoverPage(); - } else { - chap = story.getChapters().get(chapter); - descPane.setVisible(false); - } - - chapterLabel.setText("  Chapter " - + chap.getNumber() + ": " + chap.getName() + ""); - - text.setText(htmlOutput.convert(chap)); - } - } - - private void setCoverPage() { - descPane.setVisible(true); - } -}