private void listTraveledArtists() { ArrayList<ArtistNode> nodes = (ArrayList<ArtistNode>) ui.getTraveledArtists(); if (nodes.size() == 0) { System.out.println("You have yet to discover artists!"); return; } System.out.println("Your visited artists:"); System.out.println(separator); for (int j = 1; j <= nodes.size(); j++) { ArtistNode a = nodes.get(j - 1); System.out.println(j + " : " + a.getName()); } }
private void displayArtistInformation(ArtistNode a) { System.out.println(separator); System.out.println(a.getName().toUpperCase()); System.out.println("(Image path: " + a.getImageURL() + ")"); System.out.println("Tags: " + a.getTags()); System.out.println("Most popular albums: " + a.getTopAlbums()); System.out.println("Most popular tracks: " + a.getTopTracks()); // hypem BlogPost[] posts = a.getRelatedHypemPosts(); if (posts != null && posts.length > 1) { posts = Utils.sortBlogPostArray(posts, Settings.Sort.BYLIKES); System.out.println("Blog posts about this artist:"); for (BlogPost j : posts) { if (j != null) { System.out.println(j.info()); System.out.println(); } } } }
/** Create the panel. */ public ArtistInfoPanel(final ArtistNode a) { super(); NumberFormat nf1 = NumberFormat.getInstance(); // Own settings setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); setBackground(Color.DARK_GRAY); setLayout(new BorderLayout(0, 0)); Utils.fixSize(this, size); // COMPONENTS // listener MouseListener ML_CLOSE = new MouseAdapter() { public void mouseClicked(MouseEvent e) { GroovesharkConnector.getInstance().stop(); NavigationPanel.getInstance().hideArtistInfoBox(); } }; MouseListener ML_CONFIRM = new MouseAdapter() { public void mouseClicked(MouseEvent e) { GroovesharkConnector.getInstance().stop(); GUI.getInstance().search(a); NavigationPanel.getInstance().hideArtistInfoBox(); } }; // Name panel // ========================================================================================= JPanel namePanel = new JPanel(); namePanel.setBackground(Color.DARK_GRAY); // Name panel / Scrobble label this.add(namePanel, BorderLayout.NORTH); namePanel.setLayout(new GridLayout(0, 2, 0, 0)); JPanel upperleftPanel = new JPanel(); upperleftPanel.setBackground(Color.DARK_GRAY); namePanel.add(upperleftPanel); upperleftPanel.setLayout(new BorderLayout(0, 0)); // Name panel / Name label JLabel nameTxt = new JLabel(a.getName()); upperleftPanel.add(nameTxt, BorderLayout.NORTH); nameTxt.setForeground(Color.WHITE); nameTxt.setHorizontalAlignment(SwingConstants.LEFT); nameTxt.setFont(new Font("Tahoma", Font.BOLD, 16)); JLabel playTxt = new JLabel( "(" + nf1.format(a.getScrobbles()) + " scrobbled tracks, " + nf1.format(a.getListener()) + " listeners)"); upperleftPanel.add(playTxt, BorderLayout.SOUTH); playTxt.setForeground(Color.WHITE); playTxt.setHorizontalAlignment(SwingConstants.LEFT); playTxt.setFont(new Font("Tahoma", Font.ITALIC, 13)); JPanel closePanel = new JPanel(); closePanel.setBackground(Color.DARK_GRAY); namePanel.add(closePanel); closePanel.setLayout(null); CloseButton btnX = new CloseButton("x"); btnX.resizeButton(20, 20); btnX.setBounds(429, 0, 20, 20); btnX.addMouseListener(ML_CLOSE); closePanel.add(btnX); // ========================================================================================= // content panel // ========================================================================================= JTabbedPane contentPanel = new JTabbedPane(JTabbedPane.LEFT); contentPanel.setLayout(new BorderLayout(0, 0)); contentPanel.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); contentPanel.setOpaque(true); contentPanel.setBackground(Color.DARK_GRAY); contentPanel.setForeground(Color.BLACK); // content panel / biography panel JScrollPane bioPanel = new JScrollPane(); bioPanel.setLayout(new ScrollPaneLayout()); // content panel / biography panel / biography TextArea JTextArea bioArea = new SanTextbox(Utils.deleteHTMLfromText(a.getWikiFull())); bioArea.setBorder(new LineBorder(new Color(0, 0, 0))); bioArea.setBounds(new Rectangle(500, 300)); bioArea.setBackground(Color.DARK_GRAY); bioArea.setForeground(Color.WHITE); bioArea.setEditable(false); bioArea.setWrapStyleWord(true); bioArea.setLineWrap(true); bioArea.setSelectionColor(bioArea.getBackground()); Font f = new Font(Font.SANS_SERIF, Font.PLAIN, 12); GridBagConstraints gbc_bioArea = new GridBagConstraints(); gbc_bioArea.insets = new Insets(0, 0, 5, 0); gbc_bioArea.fill = GridBagConstraints.BOTH; gbc_bioArea.gridx = 0; gbc_bioArea.gridy = 0; FontMetrics fm = bioArea.getFontMetrics(f); bioArea.setSize(width, fm.getHeight() * bioArea.getLineCount()); bioPanel.getViewport().setView(bioArea); VTextIcon contentIcon = new VTextIcon(contentPanel, "biography", VTextIcon.ROTATE_LEFT); // content panel / popular content panel JPanel popularPanel = new JPanel(); popularPanel.setLayout(new GridLayout(1, 0)); // content panel / popular content panel / container panel JPanel container = new JPanel(); container.setLayout(new BorderLayout()); // content panel / popular content panel / tracks panel JPanel tracksPanel = new JPanel(); tracksPanel.setLayout(new GridLayout(Settings.TRACKFETCH, 0)); tracksPanel.setBorder( new TitledBorder( new BevelBorder(BevelBorder.LOWERED, null, null, null, null), "top tracks:", TitledBorder.LEADING, TitledBorder.TOP, null, null)); ContentTrackField.resetList(); Iterator<Track> t = a.getTopTracks().iterator(); // content panel / popular content panel / tracks panel / tracks for (int z = 0; t.hasNext(); z++) { Track track = t.next(); JLabel feld = new ContentTrackField(track.getListeners()); Dimension feldd = new Dimension(500, (20 - 3 * z)); feld.setSize(feldd); Font fontor = new Font("Tahoma", z < 2 ? Font.BOLD : Font.PLAIN, 19 - z); feld.setFont(fontor); feld.setText(track.getName() + " (" + nf1.format(track.getListeners()) + " listeners)"); tracksPanel.add(feld); } ContentTrackField.recalc(); container.add(tracksPanel, BorderLayout.CENTER); // content panel / popular content panel / albums panel JPanel albumsPanel = new JPanel(); albumsPanel.setSize(500, 100); albumsPanel.setLayout(new GridLayout(Settings.ALBUMFETCH, 0)); albumsPanel.setBorder( new TitledBorder( new BevelBorder(BevelBorder.LOWERED, null, null, null, null), "top albums:", TitledBorder.LEADING, TitledBorder.TOP, null, null)); ContentAlbumField.resetList(); Iterator<Album> albI = a.getTopAlbums().iterator(); // content panel / popular content panel / albums panel / albums for (int z = 0; albI.hasNext(); z++) { Album album = albI.next(); JLabel feld = new ContentAlbumField(album.getListeners()); Dimension feldd = new Dimension(500, (20 - 3 * z)); feld.setSize(feldd); Font fontor = new Font("Tahoma", z < 2 ? Font.BOLD : Font.PLAIN, 19 - 2 * z); feld.setFont(fontor); feld.setText(album.getName()); albumsPanel.add(feld); } ContentAlbumField.recalc(); container.add(albumsPanel, BorderLayout.SOUTH); popularPanel.add(container); VTextIcon popularIcon = new VTextIcon(contentPanel, "popular content", VTextIcon.ROTATE_LEFT); // content panel / blogpost panel JScrollPane postPanel = new JScrollPane(); postPanel.setLayout(new ScrollPaneLayout()); postPanel.getVerticalScrollBar().setBlockIncrement(1); postPanel.setSize(500, 300); VTextIcon blogIcon = new VTextIcon(contentPanel, "blog posts", VTextIcon.ROTATE_LEFT); // content panel / blogpost panel / posts list JList<BlogPost> list = new JList<BlogPost>(); DefaultListModel<BlogPost> model = new DefaultListModel<BlogPost>(); BlogPost[] posts = Utils.sortBlogPostArray(a.getRelatedHypemPosts(), Settings.Sort.BYLIKES); if (posts != null) { for (BlogPost b : posts) { model.addElement(b); } list.setCellRenderer(new BlogPostListCellRenderer()); } else { list.setSelectionBackground(Color.WHITE); list.setBorder(null); } list.setFixedCellHeight(150); list.setModel(model); postPanel.getViewport().setView(list); // composing the tab order for the content panel // 1. popular content, 2. biography, 3. blog posts contentPanel.addTab(TABLENGTH, popularIcon, popularPanel); contentPanel.addTab(TABLENGTH, contentIcon, bioPanel); contentPanel.addTab(TABLENGTH, blogIcon, postPanel); // adding the content panel to the main panel this.add(contentPanel, BorderLayout.CENTER); // ========================================================================================= // west panel // ========================================================================================= JPanel panel = new JPanel(); panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); panel.setBackground(Color.DARK_GRAY); panel.setLayout(new BorderLayout(0, 0)); // west panel / image panel JPanel imagePanel = new ImagePanel(a.getLargeImage()); imagePanel.setBackground(Color.DARK_GRAY); panel.add(imagePanel, BorderLayout.CENTER); // west panel / tags panel JPanel tagsPanel = new JPanel(); tagsPanel.setLayout(new BorderLayout(0, 0)); tagsPanel.setBorder( new TitledBorder( new BevelBorder(BevelBorder.LOWERED, null, null, null, null), "tags:", TitledBorder.LEADING, TitledBorder.TOP, null, null)); tagsPanel.setForeground(Color.WHITE); tagsPanel.setBackground(Color.DARK_GRAY); // west panel / image panel / textfield JTextArea tagField = new SanTextbox(); tagField.setWrapStyleWord(true); tagField.setEnabled(false); tagField.setEditable(false); tagField.setLineWrap(true); tagField.setBorder(null); tagField.setBackground(null); tagField.setForeground(Color.WHITE); StringBuilder sb = new StringBuilder(); for (Iterator<String> i = a.getTags().iterator(); i.hasNext(); ) { sb.append(i.next()); if (i.hasNext()) sb.append(", "); } tagField.setText(sb.toString()); tagField.setColumns(10); tagsPanel.add(tagField); panel.add(tagsPanel, BorderLayout.SOUTH); this.add(panel, BorderLayout.WEST); // ========================================================================================= // south panel // ========================================================================================= JPanel musicPanel = new JPanel(); musicPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); // get tracks for element creation ArrayList<Track> tracks = (ArrayList<Track>) a.getTopTracks(); musicPanel.setLayout(new GridLayout(0, 2)); musicPanel.setBackground(Color.DARK_GRAY); // south panel / track play elements (according to artist node information) JPanel musicElementsPanel = new JPanel(); musicElementsPanel.setSize(500, 300); musicElementsPanel.setBackground(Color.DARK_GRAY); musicPanel.add(musicElementsPanel); musicElementsPanel.setLayout(new GridLayout(0, 1)); if (tracks != null && tracks.size() > 0) { for (int i = 0; i < 5; i++) { TrackPlayElement element = new TrackPlayElement(a.getName(), tracks.get(i).getName()); if (element != null) { element.setForeground(Color.WHITE); musicElementsPanel.add(element); } } } JPanel buttonsPanel = new JPanel(); buttonsPanel.setLayout(null); JButton confirmButton = new JButton("<html>Save this artist & do another search</html>"); confirmButton.setBounds(337, 9, 100, 100); confirmButton.addMouseListener(ML_CONFIRM); buttonsPanel.add(confirmButton); JButton abortButton = new JButton("Go back"); abortButton.setBounds(337, 120, 99, 23); abortButton.addMouseListener(ML_CLOSE); buttonsPanel.add(abortButton); buttonsPanel.setBackground(Color.DARK_GRAY); musicPanel.add(buttonsPanel); this.add(musicPanel, BorderLayout.SOUTH); Dimension d = new Dimension(500, 150); Utils.fixSize(musicPanel, d); // ========================================================================================= }