Interface.java
1.91 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
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Interface extends JFrame{
private static final long serialVersionUID = 1L;
private static final Font titleFont = new Font(new JLabel().getFont().getName(), Font.BOLD, 14);
private static final Font defaultFont = new Font(new JLabel().getFont().getName(), Font.PLAIN, new JLabel().getFont().getSize());
private MusicList musicList;
private AnimationPlayer animPlayer;
public Interface(MusicList musicList, final Runnable executeOnClose) {
super("VRGNYMusicLights");
this.musicList = musicList;
setResizable(false);
populateWindow();
pack();
setLocationRelativeTo(null); // center window
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
if(animPlayer != null)
animPlayer.stopTickClock();
if(executeOnClose != null)
executeOnClose.run();
dispose();
}
});
}
private void populateWindow() {
JPanel mainPanel = new JPanel(new BorderLayout());
addPlayPanel(mainPanel);
addTimeLine(mainPanel);
add(mainPanel);
}
private void addPlayPanel(JPanel parent) {
JPanel playPanel = new JPanel(new BorderLayout());
// title
JLabel title = new JLabel("Visualizer :");
title.setFont(titleFont);
playPanel.add(title, BorderLayout.NORTH);
// lights
LightCanvasJPanel lightCanvas = new LightCanvasJPanel();
playPanel.add(lightCanvas, BorderLayout.CENTER);
// controls
animPlayer = new AnimationPlayer(lightCanvas, musicList);
animPlayer.setAlignmentX(CENTER_ALIGNMENT);
playPanel.add(animPlayer, BorderLayout.SOUTH);
parent.add(playPanel, BorderLayout.SOUTH);
}
private void addTimeLine(JPanel parent) {
JPanel timeLine = new JPanel();
}
}