Blame view

VRGNYMusicLights/Sources/Interface.java 1.91 KB
742429d1   pfrison   VRGNYMusicLight b...
1
2
3
4
5
  import java.awt.BorderLayout;
  import java.awt.Font;
  import java.awt.event.WindowAdapter;
  import java.awt.event.WindowEvent;
  
742429d1   pfrison   VRGNYMusicLight b...
6
7
8
9
10
11
12
13
  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());
a89c030d   pfrison   VRGNYMusicLights ...
14
15
16
  	
  	private MusicList musicList;
  	private AnimationPlayer animPlayer;
742429d1   pfrison   VRGNYMusicLight b...
17
  
a89c030d   pfrison   VRGNYMusicLights ...
18
  	public Interface(MusicList musicList, final Runnable executeOnClose) {
742429d1   pfrison   VRGNYMusicLight b...
19
  		super("VRGNYMusicLights");
a89c030d   pfrison   VRGNYMusicLights ...
20
  		this.musicList = musicList;
742429d1   pfrison   VRGNYMusicLight b...
21
22
23
24
25
26
27
28
  		setResizable(false);
  		populateWindow();
  		pack();
  		setLocationRelativeTo(null); // center window
          
  		addWindowListener(new WindowAdapter() {
          	@Override
          	public void windowClosing(WindowEvent e) {
a89c030d   pfrison   VRGNYMusicLights ...
29
30
          		if(animPlayer != null)
          			animPlayer.stopTickClock();
742429d1   pfrison   VRGNYMusicLight b...
31
32
33
34
35
36
37
38
39
40
          		if(executeOnClose != null)
          			executeOnClose.run();
          		dispose();
          	}
  		});
  	}
  	
  	private void populateWindow() {
  		JPanel mainPanel = new JPanel(new BorderLayout());
  		addPlayPanel(mainPanel);
a89c030d   pfrison   VRGNYMusicLights ...
41
  		addTimeLine(mainPanel);
742429d1   pfrison   VRGNYMusicLight b...
42
43
44
45
46
47
48
  		add(mainPanel);
  	}
  	
  	private void addPlayPanel(JPanel parent) {
  		JPanel playPanel = new JPanel(new BorderLayout());
  		
  		// title
a89c030d   pfrison   VRGNYMusicLights ...
49
  		JLabel title = new JLabel("Visualizer :");
742429d1   pfrison   VRGNYMusicLight b...
50
51
52
53
  		title.setFont(titleFont);
  		playPanel.add(title, BorderLayout.NORTH);
  		
  		// lights
a89c030d   pfrison   VRGNYMusicLights ...
54
55
  		LightCanvasJPanel lightCanvas = new LightCanvasJPanel();
  		playPanel.add(lightCanvas, BorderLayout.CENTER);
742429d1   pfrison   VRGNYMusicLight b...
56
57
  		
  		// controls
a89c030d   pfrison   VRGNYMusicLights ...
58
  		animPlayer = new AnimationPlayer(lightCanvas, musicList);
742429d1   pfrison   VRGNYMusicLight b...
59
60
61
62
63
  		animPlayer.setAlignmentX(CENTER_ALIGNMENT);
  		playPanel.add(animPlayer, BorderLayout.SOUTH);
  		
  		parent.add(playPanel, BorderLayout.SOUTH);
  	}
a89c030d   pfrison   VRGNYMusicLights ...
64
65
66
67
  
  	private void addTimeLine(JPanel parent) {
  		JPanel timeLine = new JPanel();
  	}
742429d1   pfrison   VRGNYMusicLight b...
68
  }