Blame view

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