Blame view

VRGNYMusicLights/Sources/Interface.java 1.71 KB
742429d1   pfrison   VRGNYMusicLight b...
1
  import java.awt.BorderLayout;
742429d1   pfrison   VRGNYMusicLight b...
2
3
4
  import java.awt.event.WindowAdapter;
  import java.awt.event.WindowEvent;
  
742429d1   pfrison   VRGNYMusicLight b...
5
  import javax.swing.JFrame;
742429d1   pfrison   VRGNYMusicLight b...
6
7
8
9
  import javax.swing.JPanel;
  
  public class Interface extends JFrame{
  	private static final long serialVersionUID = 1L;
278cdee0   pfrison   VRGNYMusicLights ...
10
11
  	//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 ...
12
  	
278cdee0   pfrison   VRGNYMusicLights ...
13
14
15
16
17
18
  	protected MusicList musicList;
  	protected AnimationPlayer animPlayer;
  	protected TimeLineJPanel timeLinePanel;
  	protected TimeLineJList timeLineList;
  	protected LightCanvasJPanel lightCanvas;
  	protected long tick = 0;
742429d1   pfrison   VRGNYMusicLight b...
19
  
a89c030d   pfrison   VRGNYMusicLights ...
20
  	public Interface(MusicList musicList, final Runnable executeOnClose) {
742429d1   pfrison   VRGNYMusicLight b...
21
  		super("VRGNYMusicLights");
a89c030d   pfrison   VRGNYMusicLights ...
22
  		this.musicList = musicList;
742429d1   pfrison   VRGNYMusicLight b...
23
24
25
26
  		setResizable(false);
  		populateWindow();
  		pack();
  		setLocationRelativeTo(null); // center window
278cdee0   pfrison   VRGNYMusicLights ...
27
  		getContentPane().requestFocus();
742429d1   pfrison   VRGNYMusicLight b...
28
29
30
31
          
  		addWindowListener(new WindowAdapter() {
          	@Override
          	public void windowClosing(WindowEvent e) {
a89c030d   pfrison   VRGNYMusicLights ...
32
33
          		if(animPlayer != null)
          			animPlayer.stopTickClock();
742429d1   pfrison   VRGNYMusicLight b...
34
35
36
37
38
39
40
          		if(executeOnClose != null)
          			executeOnClose.run();
          		dispose();
          	}
  		});
  	}
  	
278cdee0   pfrison   VRGNYMusicLights ...
41
42
43
44
45
46
  	protected void computeTick() {
  		lightCanvas.paintLights(musicList.render(tick));
  		timeLineList.repaint();
  		timeLinePanel.updateTick();
  	}
  	
742429d1   pfrison   VRGNYMusicLight b...
47
48
  	private void populateWindow() {
  		JPanel mainPanel = new JPanel(new BorderLayout());
278cdee0   pfrison   VRGNYMusicLights ...
49
50
51
52
  		timeLinePanel = new TimeLineJPanel(this, musicList);
  		mainPanel.add(timeLinePanel, BorderLayout.CENTER);
  		lightCanvas =  new LightCanvasJPanel();
  		mainPanel.add(new PlayJPanel(this, lightCanvas), BorderLayout.SOUTH);
742429d1   pfrison   VRGNYMusicLight b...
53
54
  		add(mainPanel);
  	}
742429d1   pfrison   VRGNYMusicLight b...
55
  }