From: Niki Roo Date: Fri, 22 Mar 2019 08:42:59 +0000 (+0100) Subject: code cleanup X-Git-Tag: fanfix-swing-0.0.1~12^2~218 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=a6c830bb1ea8527a3600aa6d0e05d5b2291c4b15;p=fanfix-swing.git code cleanup --- diff --git a/src/be/nikiroo/fanfix/reader/BasicReader.java b/src/be/nikiroo/fanfix/reader/BasicReader.java index 83f2d3c2..008e4d5b 100644 --- a/src/be/nikiroo/fanfix/reader/BasicReader.java +++ b/src/be/nikiroo/fanfix/reader/BasicReader.java @@ -6,11 +6,9 @@ import java.net.MalformedURLException; import java.net.URL; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.AbstractMap.SimpleEntry; -import java.util.ArrayList; import java.util.Date; -import java.util.List; -import java.util.Map.Entry; +import java.util.Map; +import java.util.TreeMap; import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.bundles.Config; @@ -216,8 +214,8 @@ public abstract class BasicReader implements Reader { * * @return the information */ - public static List> getMetaDesc(MetaData meta) { - List> metaDesc = new ArrayList>(); + public static Map getMetaDesc(MetaData meta) { + Map metaDesc = new TreeMap(); // TODO: i18n @@ -229,19 +227,15 @@ public abstract class BasicReader implements Reader { tags.append(tag); } - metaDesc.add(new SimpleEntry("Author", meta.getAuthor())); - metaDesc.add(new SimpleEntry("Publication date", - formatDate(meta.getDate()))); - metaDesc.add(new SimpleEntry("Published on", meta - .getPublisher())); - metaDesc.add(new SimpleEntry("URL", meta.getUrl())); - metaDesc.add(new SimpleEntry("Word count", format(meta - .getWords()))); - metaDesc.add(new SimpleEntry("Source", meta.getSource())); - metaDesc.add(new SimpleEntry("Subject", meta - .getSubject())); - metaDesc.add(new SimpleEntry("Language", meta.getLang())); - metaDesc.add(new SimpleEntry("Tags", tags.toString())); + metaDesc.put("Author", meta.getAuthor()); + metaDesc.put("Publication date", formatDate(meta.getDate())); + metaDesc.put("Published on", meta.getPublisher()); + metaDesc.put("URL", meta.getUrl()); + metaDesc.put("Word count", format(meta.getWords())); + metaDesc.put("Source", meta.getSource()); + metaDesc.put("Subject", meta.getSubject()); + metaDesc.put("Language", meta.getLang()); + metaDesc.put("Tags", tags.toString()); return metaDesc; } diff --git a/src/be/nikiroo/fanfix/reader/tui/TuiReaderStoryWindow.java b/src/be/nikiroo/fanfix/reader/tui/TuiReaderStoryWindow.java index 59842ad9..4848ef82 100644 --- a/src/be/nikiroo/fanfix/reader/tui/TuiReaderStoryWindow.java +++ b/src/be/nikiroo/fanfix/reader/tui/TuiReaderStoryWindow.java @@ -171,13 +171,12 @@ class TuiReaderStoryWindow extends TWindow { setCurrentTitle(meta.getTitle()); - List> metaDesc = BasicReader - .getMetaDesc(meta); + Map metaDesc = BasicReader.getMetaDesc(meta); String[][] metaDescObj = new String[metaDesc.size()][2]; int i = 0; - for (Map.Entry entry : metaDesc) { - metaDescObj[i][0] = " " + entry.getKey(); - metaDescObj[i][1] = entry.getValue(); + for (String key : metaDesc.keySet()) { + metaDescObj[i][0] = " " + key; + metaDescObj[i][1] = metaDesc.get(key); i++; } diff --git a/src/be/nikiroo/fanfix/reader/ui/GuiReaderPropertiesFrame.java b/src/be/nikiroo/fanfix/reader/ui/GuiReaderPropertiesFrame.java index 975136fd..18417716 100644 --- a/src/be/nikiroo/fanfix/reader/ui/GuiReaderPropertiesFrame.java +++ b/src/be/nikiroo/fanfix/reader/ui/GuiReaderPropertiesFrame.java @@ -3,8 +3,7 @@ package be.nikiroo.fanfix.reader.ui; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; -import java.util.List; -import java.util.Map.Entry; +import java.util.Map; import javax.swing.BorderFactory; import javax.swing.BoxLayout; @@ -63,23 +62,23 @@ public class GuiReaderPropertiesFrame extends JFrame { mainPanel.add(mainPanelKeys, BorderLayout.WEST); mainPanel.add(mainPanelValues, BorderLayout.CENTER); - List> desc = BasicReader.getMetaDesc(meta); + Map desc = BasicReader.getMetaDesc(meta); Color trans = new Color(0, 0, 0, 1); - for (Entry descLine : desc) { - JTextArea key = new JTextArea(descLine.getKey()); - key.setFont(new Font(key.getFont().getFontName(), Font.BOLD, key + for (String key : desc.keySet()) { + JTextArea jKey = new JTextArea(key); + jKey.setFont(new Font(jKey.getFont().getFontName(), Font.BOLD, jKey .getFont().getSize())); - key.setEditable(false); - key.setLineWrap(false); - key.setBackground(trans); - mainPanelKeys.add(key); - - JTextArea value = new JTextArea(descLine.getValue()); - value.setEditable(false); - value.setLineWrap(false); - value.setBackground(trans); - mainPanelValues.add(value); + jKey.setEditable(false); + jKey.setLineWrap(false); + jKey.setBackground(trans); + mainPanelKeys.add(jKey); + + JTextArea jValue = new JTextArea(desc.get(key)); + jValue.setEditable(false); + jValue.setLineWrap(false); + jValue.setBackground(trans); + mainPanelValues.add(jValue); } // Image