278cdee0
pfrison
VRGNYMusicLights ...
|
1
2
|
import java.awt.Color;
import java.awt.Component;
|
d175ba55
pfrison
VRGNYMusicLight a...
|
3
4
|
import java.awt.Dimension;
import java.awt.Font;
|
278cdee0
pfrison
VRGNYMusicLights ...
|
5
6
7
8
9
10
11
12
13
14
15
16
|
import java.util.ArrayList;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
public class MusicRenderer extends JPanel implements ListCellRenderer<Music> {
private static final long serialVersionUID = 1L;
private static final Color DEFAULT_BACKGROUND = new JPanel().getBackground();
|
d175ba55
pfrison
VRGNYMusicLight a...
|
17
|
private static final Font defaultFont = new Font(new JLabel().getFont().getName(), Font.PLAIN, new JLabel().getFont().getSize());
|
278cdee0
pfrison
VRGNYMusicLights ...
|
18
19
|
private TimeLineJPanel timeLine;
|
d175ba55
pfrison
VRGNYMusicLight a...
|
20
|
private int infoPadding = 0;
|
278cdee0
pfrison
VRGNYMusicLights ...
|
21
22
23
24
25
26
27
28
|
public ArrayList<PatternJPanel> patterns;
public MusicRenderer(TimeLineJPanel timeLine) {
this.timeLine = timeLine;
this.patterns = new ArrayList<>();
}
|
d175ba55
pfrison
VRGNYMusicLight a...
|
29
30
|
public void setInfoPadding(int infoPadding) { this.infoPadding = infoPadding; }
|
278cdee0
pfrison
VRGNYMusicLights ...
|
31
32
33
34
|
@Override
public Component getListCellRendererComponent(JList<? extends Music> list, Music music, int index,
boolean isSelected, boolean cellHasFocus) {
removeAll();
|
d175ba55
pfrison
VRGNYMusicLight a...
|
35
36
|
if(music == null)
return this;
|
278cdee0
pfrison
VRGNYMusicLights ...
|
37
38
39
40
41
|
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
JPanel infoPanel = new JPanel();
infoPanel.setLayout(new BoxLayout(infoPanel, BoxLayout.LINE_AXIS));
|
d175ba55
pfrison
VRGNYMusicLight a...
|
42
43
44
45
46
47
48
|
infoPanel.add(Box.createRigidArea(new Dimension(infoPadding, 0)));
JLabel infoLabel = new JLabel("Pattern " + String.valueOf(index) + " : "
+ "(vol : " + String.valueOf(music.getVolume()) + ", "
+ "effect : " + MusicPath.pathNames[music.getMusicPath().getAnimation()] + ", "
+ "effect duration : " + Util.tickToText(music.getMusicPath().getEffectDuration()) + ")");
infoLabel.setFont(defaultFont);
infoPanel.add(infoLabel);
|
278cdee0
pfrison
VRGNYMusicLights ...
|
49
|
infoPanel.add(Box.createHorizontalGlue());
|
d175ba55
pfrison
VRGNYMusicLight a...
|
50
51
52
53
54
55
56
|
if(isSelected) {
infoPanel.setBackground(Color.LIGHT_GRAY);
} else {
infoPanel.setBackground(DEFAULT_BACKGROUND);
}
|
278cdee0
pfrison
VRGNYMusicLights ...
|
57
58
59
60
61
62
63
64
65
66
67
68
|
add(infoPanel);
PatternJPanel pattern = new PatternJPanel(music, timeLine);
if(patterns.size() > index)
patterns.set(index, pattern);
else
patterns.add(pattern);
add(pattern);
return this;
}
}
|