Blame view

VRGNYMusicLights/Sources/TimeLineJList.java 889 Bytes
278cdee0   pfrison   VRGNYMusicLights ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  import java.awt.Color;
  import java.awt.Graphics;
  
  import javax.swing.JList;
  import javax.swing.ListModel;
  
  public class TimeLineJList extends JList<Music> {
  	private static final long serialVersionUID = 1L;
  	private static final int MARK_WIDTH = 2;
  	
  	private Interface interf;
  
  	public TimeLineJList(ListModel<Music> dataModel, Interface interf) {
  		super(dataModel);
  		this.interf = interf;
  	}
  	
  	@Override
  	protected void paintComponent(Graphics g) {
  		super.paintComponent(g);
  		g.setColor(Color.BLACK);
  		
  		int maxHeight = getPreferredSize().height;
  		int maxWidth = getPreferredSize().width;
  		
  		int mark = transformZoon(interf.tick);
  		if(mark > maxWidth)
  			mark = maxWidth;
  		
  		g.fillRect(mark, 0, MARK_WIDTH, maxHeight);
  	}
  	
  	private int transformZoon(long n) {
  		return (int) ((double) n / (double) PatternJPanel.ZOOM_MULTIPLIER * interf.timeLinePanel.getZoomLevel());
  	}
  }