278cdee0
pfrison
VRGNYMusicLights ...
|
1
2
3
4
|
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
|
d175ba55
pfrison
VRGNYMusicLight a...
|
5
|
import javax.swing.JLabel;
|
278cdee0
pfrison
VRGNYMusicLights ...
|
6
7
8
9
10
11
12
|
import javax.swing.JPanel;
public class PatternJPanel extends JPanel {
private static final long serialVersionUID = 1L;
private static final int HEIGHT = 50;
private static final int PADDING = 2;
public static final int ZOOM_MULTIPLIER = 10;
|
d175ba55
pfrison
VRGNYMusicLight a...
|
13
|
public static final int PATTERN_HEIGHT = (int) (HEIGHT + new JLabel(" ").getPreferredSize().height);
|
278cdee0
pfrison
VRGNYMusicLights ...
|
14
15
16
17
18
19
20
21
|
private Music music;
private TimeLineJPanel timeLine;
private int end;
public PatternJPanel(Music music, TimeLineJPanel timeLine) {
this.music = music;
this.timeLine = timeLine;
|
d175ba55
pfrison
VRGNYMusicLight a...
|
22
|
end = Util.transformZoom(music.getMusicPattern().getStop(), timeLine.getZoomLevel());
|
278cdee0
pfrison
VRGNYMusicLights ...
|
23
24
25
26
|
setPreferredSize(new Dimension((int) end, HEIGHT));
}
public void refreshPreferedSize() {
|
d175ba55
pfrison
VRGNYMusicLight a...
|
27
|
end = Util.transformZoom(music.getMusicPattern().getStop(), timeLine.getZoomLevel());
|
278cdee0
pfrison
VRGNYMusicLights ...
|
28
29
30
31
32
33
34
35
36
37
38
|
setPreferredSize(new Dimension((int) end, HEIGHT));
}
public int getEnd() { return end; }
public Music getMusic() { return music; }
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.WHITE);
|
d175ba55
pfrison
VRGNYMusicLight a...
|
39
40
|
int begin = Util.transformZoom(music.getMusicPattern().getBegin(), timeLine.getZoomLevel());
g.fillRect(begin, 0, end - begin, HEIGHT);
|
278cdee0
pfrison
VRGNYMusicLights ...
|
41
42
43
44
|
MusicPattern pattern = music.getMusicPattern();
g.setColor(Color.BLACK);
for(int i=0; i<pattern.getRepeat(); i++) {
|
d175ba55
pfrison
VRGNYMusicLight a...
|
45
|
int repeatAddition = Util.transformZoom(pattern.getTotalLength() * i, timeLine.getZoomLevel()) + begin;
|
278cdee0
pfrison
VRGNYMusicLights ...
|
46
|
g.drawLine(repeatAddition, HEIGHT - PADDING,
|
d175ba55
pfrison
VRGNYMusicLight a...
|
47
48
49
50
51
52
53
54
55
|
Util.transformZoom(pattern.getPatternTiming()[0], timeLine.getZoomLevel()) + repeatAddition, HEIGHT - PADDING);
g.drawLine(Util.transformZoom(pattern.getPatternTiming()[0], timeLine.getZoomLevel()) + repeatAddition, HEIGHT - PADDING,
Util.transformZoom(pattern.getPatternTiming()[1], timeLine.getZoomLevel()) + repeatAddition, PADDING);
g.drawLine(Util.transformZoom(pattern.getPatternTiming()[1], timeLine.getZoomLevel()) + repeatAddition, PADDING,
Util.transformZoom(pattern.getPatternTiming()[2], timeLine.getZoomLevel()) + repeatAddition, PADDING);
g.drawLine(Util.transformZoom(pattern.getPatternTiming()[2], timeLine.getZoomLevel()) + repeatAddition, PADDING,
Util.transformZoom(pattern.getPatternTiming()[3], timeLine.getZoomLevel()) + repeatAddition, HEIGHT - PADDING);
g.drawLine(Util.transformZoom(pattern.getPatternTiming()[3], timeLine.getZoomLevel()) + repeatAddition, HEIGHT - PADDING,
Util.transformZoom(pattern.getPatternTiming()[4], timeLine.getZoomLevel()) + repeatAddition, HEIGHT - PADDING);
|
278cdee0
pfrison
VRGNYMusicLights ...
|
56
57
|
}
}
|
278cdee0
pfrison
VRGNYMusicLights ...
|
58
|
}
|