1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
6 |
* This file is part of JSampler. |
7 |
* |
8 |
* JSampler is free software; you can redistribute it and/or modify |
9 |
* it under the terms of the GNU General Public License version 2 |
10 |
* as published by the Free Software Foundation. |
11 |
* |
12 |
* JSampler is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with JSampler; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 |
* MA 02111-1307 USA |
21 |
*/ |
22 |
|
23 |
package org.jsampler.view.fantasia; |
24 |
|
25 |
import java.awt.Graphics; |
26 |
import java.awt.Graphics2D; |
27 |
import java.awt.Insets; |
28 |
|
29 |
import javax.swing.BorderFactory; |
30 |
import javax.swing.JLabel; |
31 |
import javax.swing.JList; |
32 |
|
33 |
import org.jvnet.substance.api.renderers.SubstanceDefaultListCellRenderer; |
34 |
|
35 |
/** |
36 |
* |
37 |
* @author Grigor Iliev |
38 |
*/ |
39 |
public class FantasiaListCellRenderer extends SubstanceDefaultListCellRenderer { |
40 |
private FantasiaRenderer renderer = new FantasiaRenderer(); |
41 |
|
42 |
/** Creates a new instance of <code>FantasiaListCellRenderer</code> */ |
43 |
public |
44 |
FantasiaListCellRenderer() { |
45 |
|
46 |
} |
47 |
|
48 |
public java.awt.Component |
49 |
getListCellRendererComponent ( |
50 |
JList list, Object value, int index, boolean isSelected, boolean cellHasFocus |
51 |
) { |
52 |
if(index == -1) { |
53 |
renderer.setText(value == null ? "" : value.toString()); |
54 |
return renderer; |
55 |
} |
56 |
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
57 |
} |
58 |
|
59 |
static class FantasiaRenderer extends JLabel { |
60 |
private static java.awt.Color textColor = new java.awt.Color(0xFFA300); |
61 |
private static Insets pixmapInsets = new Insets(3, 5, 6, 5); |
62 |
|
63 |
FantasiaRenderer() { |
64 |
setOpaque(false); |
65 |
setBorder(BorderFactory.createEmptyBorder(4, 5, 6, 5)); |
66 |
setForeground(new java.awt.Color(0xFFA300)); |
67 |
setBackground(new java.awt.Color(0x818181)); |
68 |
setFont(Res.fontScreen); |
69 |
} |
70 |
|
71 |
protected void |
72 |
paintComponent(Graphics g) { |
73 |
Graphics2D g2d = (Graphics2D)g; |
74 |
|
75 |
g2d.setRenderingHint ( |
76 |
java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, |
77 |
java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON |
78 |
); |
79 |
|
80 |
PixmapPane.paintComponent(this, g, Res.gfxCbLabelBg, pixmapInsets); |
81 |
super.paintComponent(g); |
82 |
} |
83 |
|
84 |
public java.awt.Color |
85 |
getForeground() { return textColor; } |
86 |
|
87 |
public java.awt.Font |
88 |
getFont() { return Res.fontScreen; } |
89 |
} |
90 |
} |