-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWillCall.java
More file actions
968 lines (798 loc) · 45.5 KB
/
Copy pathWillCall.java
File metadata and controls
968 lines (798 loc) · 45.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Week9;
/**
*
* @author David Hodge
* willCall is a music/concert discovery application that utilizes the last.fm Java bindings to pull
* the top 5 artists for a specified user, associated playback statistics, upcoming concerts
* and top tracks for each artist.
*
*/
import de.umass.lastfm.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Collection;
import java.util.Iterator;
public class WillCall extends javax.swing.JFrame {
/**
* Creates new form WillCall
*/
//last.fm API key for my application
String key = "7cc01cf3a6d18242a5d58ca02677b5ae";
String user;
//this particular API binding tended to store data in object collections rather than arrays or something similar because
//of the potentially large amount of data that the site might return. each collection requires an iterator.
Collection<Artist> topArtists;
Iterator<Artist> artists;
String[] arName = new String[5];
String[] plc = new String[5];
//PaginatedResult is a custom class that serves a similar purpose as collections but is returned by methods
//for which the result set might be so large that it need to be paginated. Each PaginatedResult<> contains the
//total number of result pages, the current page and a collection of entries for the current page.
PaginatedResult<de.umass.lastfm.Event> eventForArtist;
Collection<de.umass.lastfm.Event> collEvent;
Iterator<de.umass.lastfm.Event> events;
Collection<Track> topTracks;
Iterator<Track> tracks;
private final static String newline = "\n";
public WillCall() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
usernameLabel = new javax.swing.JLabel();
enterButton = new javax.swing.JButton();
quitStartButton = new javax.swing.JButton();
usernameTextField = new javax.swing.JTextField();
jPanel2 = new javax.swing.JPanel();
nameLabel = new javax.swing.JLabel();
pcLabel = new javax.swing.JLabel();
eventLabel = new javax.swing.JLabel();
trackLabel = new javax.swing.JLabel();
band1Label = new javax.swing.JLabel();
band2Label = new javax.swing.JLabel();
band3Label = new javax.swing.JLabel();
band4Label = new javax.swing.JLabel();
band5Label = new javax.swing.JLabel();
pc1Label = new javax.swing.JLabel();
pc2Label = new javax.swing.JLabel();
pc3Label = new javax.swing.JLabel();
pc4Label = new javax.swing.JLabel();
pc5Label = new javax.swing.JLabel();
event1Button = new javax.swing.JButton();
event2Button = new javax.swing.JButton();
event3Button = new javax.swing.JButton();
event4Button = new javax.swing.JButton();
event5Button = new javax.swing.JButton();
track1Button = new javax.swing.JButton();
track2Button = new javax.swing.JButton();
track3Button = new javax.swing.JButton();
track4Button = new javax.swing.JButton();
track5Button = new javax.swing.JButton();
jPanel3 = new javax.swing.JPanel();
concertQuitButton = new javax.swing.JButton();
jScrollPane3 = new javax.swing.JScrollPane();
concertTextArea = new javax.swing.JTextArea();
jPanel4 = new javax.swing.JPanel();
tracksQuitButton = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
tracksTextArea = new javax.swing.JTextArea();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("willCall");
jTabbedPane1.setPreferredSize(new java.awt.Dimension(400, 300));
jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jPanel1.setPreferredSize(new java.awt.Dimension(400, 300));
usernameLabel.setText("enter username: ");
enterButton.setText("enter");
enterButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
enterButtonActionPerformed(evt);
}
});
quitStartButton.setText("quit");
quitStartButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
quitStartButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(enterButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(quitStartButton, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(149, 149, 149))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(32, 32, 32)
.addComponent(usernameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(151, 151, 151)
.addComponent(usernameLabel)))
.addContainerGap(45, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap(112, Short.MAX_VALUE)
.addComponent(usernameLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(usernameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(quitStartButton)
.addComponent(enterButton))
.addGap(115, 115, 115))
);
jTabbedPane1.addTab("username", jPanel1);
jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jPanel2.setPreferredSize(new java.awt.Dimension(400, 300));
nameLabel.setText("name");
pcLabel.setText("playCount");
eventLabel.setText("events");
trackLabel.setText("tracks");
band1Label.setText("band1");
band2Label.setText("band2");
band3Label.setText("band3");
band4Label.setText("band4");
band5Label.setText("band5");
pc1Label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
pc1Label.setText("pc1");
pc2Label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
pc2Label.setText("pc2");
pc3Label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
pc3Label.setText("pc3");
pc4Label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
pc4Label.setText("pc4");
pc5Label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
pc5Label.setText("pc5");
event1Button.setText("getConcerts");
event1Button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
event1ButtonActionPerformed(evt);
}
});
event2Button.setText("getConcerts");
event2Button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
event2ButtonActionPerformed(evt);
}
});
event3Button.setText("getConcerts");
event3Button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
event3ButtonActionPerformed(evt);
}
});
event4Button.setText("getConcerts");
event4Button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
event4ButtonActionPerformed(evt);
}
});
event5Button.setText("getConcerts");
event5Button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
event5ButtonActionPerformed(evt);
}
});
track1Button.setText("tracks");
track1Button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
track1ButtonActionPerformed(evt);
}
});
track2Button.setText("tracks");
track2Button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
track2ButtonActionPerformed(evt);
}
});
track3Button.setText("tracks");
track3Button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
track3ButtonActionPerformed(evt);
}
});
track4Button.setText("tracks");
track4Button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
track4ButtonActionPerformed(evt);
}
});
track5Button.setText("tracks");
track5Button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
track5ButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(band5Label, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pc5Label, javax.swing.GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addComponent(band4Label, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pc4Label, javax.swing.GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addComponent(band3Label, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pc3Label, javax.swing.GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addComponent(band2Label, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pc2Label, javax.swing.GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE)))
.addGap(240, 240, 240))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(band1Label, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pc1Label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(nameLabel)
.addGap(66, 66, 66)
.addComponent(pcLabel)))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(30, 30, 30)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(event1Button)
.addComponent(event2Button)
.addComponent(event3Button)
.addComponent(event4Button)
.addComponent(event5Button))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(track5Button, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE)
.addComponent(track4Button, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE)
.addComponent(track3Button, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE)
.addComponent(track2Button, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE)
.addComponent(track1Button, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE))
.addContainerGap())
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(61, 61, 61)
.addComponent(eventLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 88, Short.MAX_VALUE)
.addComponent(trackLabel)
.addGap(39, 39, 39))))))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(nameLabel)
.addComponent(pcLabel)
.addComponent(eventLabel)
.addComponent(trackLabel))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(pc1Label, javax.swing.GroupLayout.DEFAULT_SIZE, 38, Short.MAX_VALUE)
.addComponent(event1Button)
.addComponent(track1Button))
.addComponent(band1Label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(band2Label, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(pc2Label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(event2Button)
.addComponent(track2Button))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(band3Label, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(pc3Label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(event3Button)
.addComponent(track3Button))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(band4Label, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(pc4Label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(event4Button)
.addComponent(track4Button))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(band5Label, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(pc5Label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(event5Button)
.addComponent(track5Button))
.addContainerGap(26, Short.MAX_VALUE))
);
jTabbedPane1.addTab("topArtists", jPanel2);
jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jPanel3.setPreferredSize(new java.awt.Dimension(400, 300));
jPanel3.setRequestFocusEnabled(false);
concertQuitButton.setText("quit");
concertQuitButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
concertQuitButtonActionPerformed(evt);
}
});
concertTextArea.setEditable(false);
concertTextArea.setColumns(20);
concertTextArea.setRows(5);
jScrollPane3.setViewportView(concertTextArea);
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(0, 330, Short.MAX_VALUE)
.addComponent(concertQuitButton))
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE))
.addContainerGap())
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(concertQuitButton)
.addContainerGap(21, Short.MAX_VALUE))
);
jTabbedPane1.addTab("concerts", jPanel3);
jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jPanel4.setPreferredSize(new java.awt.Dimension(400, 300));
tracksQuitButton.setText("quit");
tracksQuitButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tracksQuitButtonActionPerformed(evt);
}
});
tracksTextArea.setEditable(false);
tracksTextArea.setColumns(20);
tracksTextArea.setRows(5);
jScrollPane1.setViewportView(tracksTextArea);
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGap(0, 330, Short.MAX_VALUE)
.addComponent(tracksQuitButton))
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE))
.addContainerGap())
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(tracksQuitButton)
.addContainerGap())
);
jTabbedPane1.addTab("topTracks", jPanel4);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 410, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 328, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void enterButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//pull the username from the text field
user = usernameTextField.getText();
//initializes a collection of the users top artists and creates an iterator for said collection
topArtists = User.getTopArtists(user, key);
artists = topArtists.iterator();
//in order to retrieve the data in the top artist collection I needed to dump the collection
//into an Artist array and the dump that into a String array so that I could parse the text and
//use it to populate the text labels/playcounts
Artist[] lol3 = new Artist[topArtists.size()];
lol3 = topArtists.toArray(lol3);
String[] derp = new String[lol3.length];
//for loop to copy the Artist array elements into the string array
for(int q = 0; q<lol3.length; q++){
derp[q] = lol3[q].toString();
}
//String[] arName = new String[5];
//the next two for loops are basically used to parse the data originally contained in the Artist collection.
//initially the data was all jumbled up with a bunch of extra garbage
//i.e. Artist[name='Andrew Bird', id='null', url='http://www.last.fm/music/Andrew+Bird', mbid='081b133e-ce74-42ba-92c1-c18234acb532', playcount=6, listeners=-1, streamable=true]
//so I needed to slice and dice the parts of interest for my application (the artist name and playcount) which I did first by splitting via commas
//and then splitting by "'" for the artist name and "=" for the playcount. Then dumped the results into to separate string arrays which I could use to
//source the text for the topArtist textLabels for a specific user.
for(int b = 0; b < 5; b++){
//System.out.println(derp[b]);
String[] test = derp[b].split(", ");
//System.out.println(test[0].trim());
String[] test2 = test[0].split("'");
//System.out.println(test2[1].trim());
arName[b] = test2[1].trim();
}
//String[] plc = new String[5];
for(int d = 0; d < 5; d++){
//System.out.println(derp[d]);
String[] jest = derp[d].split(", ");
//System.out.println(jest[0].trim());
String[] jest3 = jest[4].split("=");
//System.out.println(jest3[1].trim());
plc[d] = jest3[1].trim();
}
//setting the text for the labels using all that junk parsed out above
band1Label.setText(arName[0]);
pc1Label.setText(plc[0]);
band2Label.setText(arName[1]);
pc2Label.setText(plc[1]);
band3Label.setText(arName[2]);
pc3Label.setText(plc[2]);
band4Label.setText(arName[3]);
pc4Label.setText(plc[3]);
band5Label.setText(arName[4]);
pc5Label.setText(plc[4]);
}
private void quitStartButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
private void event1ButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//this basic code is repeated for each event button per artist, need to go back and make one unified method to do this so that I don't have to
//repeat a lot of the same code.
//clear out any existing text in the textArea
concertTextArea.setText("");
//started with that lovely PaginatedResult<> that is returned by Artist.getEvents() using the artist label for that row as a parameter.
//in order to make the data in a PaginatedResult<> accessible I used the method getPageResults() to dump it into an Event collection
eventForArtist = Artist.getEvents(arName[0], key);
collEvent = eventForArtist.getPageResults();
events = collEvent.iterator();
//then to use the data from the event collection I had to put that into an Event array and then a string array
de.umass.lastfm.Event[] lol4 = new de.umass.lastfm.Event[collEvent.size()];
lol4 = collEvent.toArray(lol4);
String[] arCons = new String[lol4.length];
//for each element in the Event array, create a new venue and pull pertinent info about the venue then eventually dump all of that into a
//concatenated string and set each of these big boy strings as a separate element in a string array
for(int l = 0; l<lol4.length; l++) {
Venue ven = lol4[l].getVenue();
String vName = ven.getName();
String vAddr = ven.getStreet();
String vCity = ven.getCity();
String vCountry = ven.getCountry();
String vPost = ven.getPostal();
String vPhone = ven.getPhonenumber();
String vInfo = vName + ", " + vAddr + ", " + vCity + ", " + vCountry + ", " + vPost + ", " + vPhone;
arCons[l] = vInfo;
}
//append each element from the aforementioned string array as a separate row in the concertTextArea
for(int x = 0; x < arCons.length; x++) {
concertTextArea.append(arCons[x] + newline);
}
}
private void concertQuitButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
private void tracksQuitButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
private void event2ButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
concertTextArea.setText("");
eventForArtist = Artist.getEvents(arName[1], key);
collEvent = eventForArtist.getPageResults();
events = collEvent.iterator();
de.umass.lastfm.Event[] lol4 = new de.umass.lastfm.Event[collEvent.size()];
lol4 = collEvent.toArray(lol4);
String[] arCons = new String[lol4.length];
for(int l = 0; l<lol4.length; l++) {
Venue ven = lol4[l].getVenue();
String vName = ven.getName();
String vAddr = ven.getStreet();
String vCity = ven.getCity();
String vCountry = ven.getCountry();
String vPost = ven.getPostal();
String vPhone = ven.getPhonenumber();
String vInfo = vName + ", " + vAddr + ", " + vCity + ", " + vCountry + ", " + vPost + ", " + vPhone;
arCons[l] = vInfo;
}
for(int x = 0; x < arCons.length; x++) {
concertTextArea.append(arCons[x] + newline);
}
}
private void event3ButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
concertTextArea.setText("");
eventForArtist = Artist.getEvents(arName[2], key);
collEvent = eventForArtist.getPageResults();
events = collEvent.iterator();
de.umass.lastfm.Event[] lol4 = new de.umass.lastfm.Event[collEvent.size()];
lol4 = collEvent.toArray(lol4);
String[] arCons = new String[lol4.length];
for(int l = 0; l<lol4.length; l++) {
Venue ven = lol4[l].getVenue();
String vName = ven.getName();
String vAddr = ven.getStreet();
String vCity = ven.getCity();
String vCountry = ven.getCountry();
String vPost = ven.getPostal();
String vPhone = ven.getPhonenumber();
String vInfo = vName + ", " + vAddr + ", " + vCity + ", " + vCountry + ", " + vPost + ", " + vPhone;
arCons[l] = vInfo;
}
for(int x = 0; x < arCons.length; x++) {
concertTextArea.append(arCons[x] + newline);
}
}
private void event4ButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
concertTextArea.setText("");
eventForArtist = Artist.getEvents(arName[3], key);
collEvent = eventForArtist.getPageResults();
events = collEvent.iterator();
de.umass.lastfm.Event[] lol4 = new de.umass.lastfm.Event[collEvent.size()];
lol4 = collEvent.toArray(lol4);
String[] arCons = new String[lol4.length];
for(int l = 0; l<lol4.length; l++) {
Venue ven = lol4[l].getVenue();
String vName = ven.getName();
String vAddr = ven.getStreet();
String vCity = ven.getCity();
String vCountry = ven.getCountry();
String vPost = ven.getPostal();
String vPhone = ven.getPhonenumber();
String vInfo = vName + ", " + vAddr + ", " + vCity + ", " + vCountry + ", " + vPost + ", " + vPhone;
arCons[l] = vInfo;
}
for(int x = 0; x < arCons.length; x++) {
concertTextArea.append(arCons[x] + newline);
}
}
private void event5ButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
concertTextArea.setText("");
eventForArtist = Artist.getEvents(arName[4], key);
collEvent = eventForArtist.getPageResults();
events = collEvent.iterator();
de.umass.lastfm.Event[] lol4 = new de.umass.lastfm.Event[collEvent.size()];
lol4 = collEvent.toArray(lol4);
String[] arCons = new String[lol4.length];
for(int l = 0; l<lol4.length; l++) {
Venue ven = lol4[l].getVenue();
String vName = ven.getName();
String vAddr = ven.getStreet();
String vCity = ven.getCity();
String vCountry = ven.getCountry();
String vPost = ven.getPostal();
String vPhone = ven.getPhonenumber();
String vInfo = vName + ", " + vAddr + ", " + vCity + ", " + vCountry + ", " + vPost + ", " + vPhone;
arCons[l] = vInfo;
}
for(int x = 0; x < arCons.length; x++) {
concertTextArea.append(arCons[x] + newline);
}
}
private void track1ButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//just like with the event buttons, I need to make a method to handle this process for the track buttons so that I don't have so much repeated code
//clear the contents of the trackTextArea
tracksTextArea.setText("");
//similar process but for the top tracks - take a collection then dump into an object array then into a series of string arrays
//and parse as necessary to filter out garbage text
topTracks = Artist.getTopTracks(arName[0], key);
tracks = topTracks.iterator();
Track[] lol2 = new Track[topTracks.size()];
lol2 = topTracks.toArray(lol2);
String[] trax = new String[lol2.length];
for(int z = 0; z < lol2.length; z++){
trax[z] = lol2[z].toString();
}
String[] yarg = new String[trax.length];
for(int u = 0; u<trax.length; u++){
String[] nest = trax[u].split(",");
String[] nest2 = nest[0].split("=");
yarg[u] = nest2[1].trim();
}
//once I've filtered out the garbage with the above I can append each element of the cleaned up string array as a new row in the textArea
for(int o = 0; o < yarg.length; o++) {
tracksTextArea.append(yarg[o] + newline);
}
}
private void track2ButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
tracksTextArea.setText("");
topTracks = Artist.getTopTracks(arName[1], key);
tracks = topTracks.iterator();
Track[] lol2 = new Track[topTracks.size()];
lol2 = topTracks.toArray(lol2);
String[] trax = new String[lol2.length];
for(int z = 0; z < lol2.length; z++){
trax[z] = lol2[z].toString();
}
String[] yarg = new String[trax.length];
for(int u = 0; u<trax.length; u++){
String[] nest = trax[u].split(",");
String[] nest2 = nest[0].split("=");
yarg[u] = nest2[1].trim();
}
for(int o = 0; o < yarg.length; o++) {
tracksTextArea.append(yarg[o] + newline);
}
}
private void track3ButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
tracksTextArea.setText("");
topTracks = Artist.getTopTracks(arName[2], key);
tracks = topTracks.iterator();
Track[] lol2 = new Track[topTracks.size()];
lol2 = topTracks.toArray(lol2);
String[] trax = new String[lol2.length];
for(int z = 0; z < lol2.length; z++){
trax[z] = lol2[z].toString();
}
String[] yarg = new String[trax.length];
for(int u = 0; u<trax.length; u++){
String[] nest = trax[u].split(",");
String[] nest2 = nest[0].split("=");
yarg[u] = nest2[1].trim();
}
for(int o = 0; o < yarg.length; o++) {
tracksTextArea.append(yarg[o] + newline);
}
}
private void track4ButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
tracksTextArea.setText("");
topTracks = Artist.getTopTracks(arName[3], key);
tracks = topTracks.iterator();
Track[] lol2 = new Track[topTracks.size()];
lol2 = topTracks.toArray(lol2);
String[] trax = new String[lol2.length];
for(int z = 0; z < lol2.length; z++){
trax[z] = lol2[z].toString();
}
String[] yarg = new String[trax.length];
for(int u = 0; u<trax.length; u++){
String[] nest = trax[u].split(",");
String[] nest2 = nest[0].split("=");
yarg[u] = nest2[1].trim();
}
for(int o = 0; o < yarg.length; o++) {
tracksTextArea.append(yarg[o] + newline);
}
}
private void track5ButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
tracksTextArea.setText("");
topTracks = Artist.getTopTracks(arName[4], key);
tracks = topTracks.iterator();
Track[] lol2 = new Track[topTracks.size()];
lol2 = topTracks.toArray(lol2);
String[] trax = new String[lol2.length];
for(int z = 0; z < lol2.length; z++){
trax[z] = lol2[z].toString();
}
String[] yarg = new String[trax.length];
for(int u = 0; u<trax.length; u++){
String[] nest = trax[u].split(",");
String[] nest2 = nest[0].split("=");
yarg[u] = nest2[1].trim();
}
for(int o = 0; o < yarg.length; o++) {
tracksTextArea.append(yarg[o] + newline);
}
}
public void close() {
WindowEvent winClosingEvent = new WindowEvent(this, WindowEvent.WINDOW_CLOSING);
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(winClosingEvent);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(WillCall.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(WillCall.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(WillCall.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(WillCall.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new WillCall().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel band1Label;
private javax.swing.JLabel band2Label;
private javax.swing.JLabel band3Label;
private javax.swing.JLabel band4Label;
private javax.swing.JLabel band5Label;
private javax.swing.JButton concertQuitButton;
private javax.swing.JTextArea concertTextArea;
private javax.swing.JButton enterButton;
private javax.swing.JButton event1Button;
private javax.swing.JButton event2Button;
private javax.swing.JButton event3Button;
private javax.swing.JButton event4Button;
private javax.swing.JButton event5Button;
private javax.swing.JLabel eventLabel;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JLabel nameLabel;
private javax.swing.JLabel pc1Label;
private javax.swing.JLabel pc2Label;
private javax.swing.JLabel pc3Label;
private javax.swing.JLabel pc4Label;
private javax.swing.JLabel pc5Label;
private javax.swing.JLabel pcLabel;
private javax.swing.JButton quitStartButton;
private javax.swing.JButton track1Button;
private javax.swing.JButton track2Button;
private javax.swing.JButton track3Button;
private javax.swing.JButton track4Button;
private javax.swing.JButton track5Button;
private javax.swing.JLabel trackLabel;
private javax.swing.JButton tracksQuitButton;
private javax.swing.JTextArea tracksTextArea;
private javax.swing.JLabel usernameLabel;
private javax.swing.JTextField usernameTextField;
// End of variables declaration
}