TimeLineJList.java
889 Bytes
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());
}
}