From 771db2a2816b83efc6f830e10015ec665f2df0e3 Mon Sep 17 00:00:00 2001 From: aj Date: Tue, 3 Apr 2018 00:28:01 -0700 Subject: [PATCH] added percentages to more views --- .../src/sarsoo/fmframework/gui/AlbumView.java | 4 +++- .../src/sarsoo/fmframework/gui/FMObjListView.java | 14 +++++++------- .../src/sarsoo/fmframework/gui/FMObjView.java | 12 ++++++++++-- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/fmframework/src/sarsoo/fmframework/gui/AlbumView.java b/fmframework/src/sarsoo/fmframework/gui/AlbumView.java index 389ff5b..c4f9615 100644 --- a/fmframework/src/sarsoo/fmframework/gui/AlbumView.java +++ b/fmframework/src/sarsoo/fmframework/gui/AlbumView.java @@ -16,6 +16,8 @@ import javax.swing.SwingConstants; import sarsoo.fmframework.music.Album; import sarsoo.fmframework.net.Network; +import sarsoo.fmframework.util.Maths; +import sarsoo.fmframework.util.Reference; public class AlbumView extends JFrame { JPanel buttons = new JPanel(); @@ -73,7 +75,7 @@ public class AlbumView extends JFrame { playCount.setText(numberFormat.format(album.getPlayCount()) + " Scrobbles"); playCount.setHorizontalAlignment(SwingConstants.CENTER); - userPlayCount.setText(numberFormat.format(album.getUserPlayCount()) + " Your Scrobbles"); + userPlayCount.setText(numberFormat.format(album.getUserPlayCount()) + String.format(" Your Scrobbles (%.2f%%)", Maths.getPercentListening(album, Reference.getUserName()))); userPlayCount.setHorizontalAlignment(SwingConstants.CENTER); userPlayCount.setFont(sub); diff --git a/fmframework/src/sarsoo/fmframework/gui/FMObjListView.java b/fmframework/src/sarsoo/fmframework/gui/FMObjListView.java index aac6fe9..c603630 100644 --- a/fmframework/src/sarsoo/fmframework/gui/FMObjListView.java +++ b/fmframework/src/sarsoo/fmframework/gui/FMObjListView.java @@ -92,14 +92,14 @@ public class FMObjListView extends JFrame { info.add(totalScrobbles); double percent = Maths.getPercentListening(objects, Reference.getUserName()); - if (percent > 1) { - JLabel percentLabel = new JLabel(); - percentLabel.setHorizontalAlignment(SwingConstants.CENTER); - percentLabel.setText(String.format("%.2f%%", percent)); - percentLabel.setFont(font); - info.add(percentLabel); + // if (percent > 1) { + JLabel percentLabel = new JLabel(); + percentLabel.setHorizontalAlignment(SwingConstants.CENTER); + percentLabel.setText(String.format("%.2f%%", percent)); + percentLabel.setFont(font); + info.add(percentLabel); - } + // } add(info); pack(); diff --git a/fmframework/src/sarsoo/fmframework/gui/FMObjView.java b/fmframework/src/sarsoo/fmframework/gui/FMObjView.java index e403a12..0f96bde 100644 --- a/fmframework/src/sarsoo/fmframework/gui/FMObjView.java +++ b/fmframework/src/sarsoo/fmframework/gui/FMObjView.java @@ -1,6 +1,7 @@ package sarsoo.fmframework.gui; import java.awt.FlowLayout; +import java.awt.Font; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -15,6 +16,8 @@ import javax.swing.SwingConstants; import sarsoo.fmframework.music.FMObj; import sarsoo.fmframework.net.Network; +import sarsoo.fmframework.util.Maths; +import sarsoo.fmframework.util.Reference; public class FMObjView extends JFrame{ JPanel buttons = new JPanel(); @@ -44,15 +47,20 @@ public class FMObjView extends JFrame{ buttons.add(musicBrainz); NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US); + Font title = new Font("Arial", Font.BOLD, 24); + Font sub = new Font("Arial", Font.PLAIN, 20); name.setText(obj.getName()); name.setHorizontalAlignment(SwingConstants.CENTER); + name.setFont(title); + listeners.setText(numberFormat.format(obj.getListeners()) + " Listeners"); listeners.setHorizontalAlignment(SwingConstants.CENTER); playCount.setText(numberFormat.format(obj.getPlayCount()) + " Scrobbles"); playCount.setHorizontalAlignment(SwingConstants.CENTER); - userPlayCount.setText(numberFormat.format(obj.getUserPlayCount()) + " Your Scrobbles"); + userPlayCount.setText(numberFormat.format(obj.getUserPlayCount()) + String.format(" Your Scrobbles (%.2f%%)", Maths.getPercentListening(obj, Reference.getUserName()))); userPlayCount.setHorizontalAlignment(SwingConstants.CENTER); + userPlayCount.setFont(sub); viewWiki.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { @@ -70,9 +78,9 @@ public class FMObjView extends JFrame{ } }); add(name); + add(userPlayCount); add(listeners); add(playCount); - add(userPlayCount); // add(info); add(buttons);