1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005-2010 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.basic; |
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.ImageIcon; |
31 |
import javax.swing.JLabel; |
32 |
import javax.swing.JList; |
33 |
|
34 |
import org.jsampler.view.fantasia.Res; |
35 |
import org.jsampler.view.std.StdUtils; |
36 |
|
37 |
import org.pushingpixels.substance.api.renderers.SubstanceDefaultListCellRenderer; |
38 |
|
39 |
/** |
40 |
* |
41 |
* @author Grigor Iliev |
42 |
*/ |
43 |
public class FantasiaListCellRenderer extends SubstanceDefaultListCellRenderer { |
44 |
private FantasiaRenderer renderer = new FantasiaRenderer(); |
45 |
|
46 |
/** Creates a new instance of <code>FantasiaListCellRenderer</code> */ |
47 |
public |
48 |
FantasiaListCellRenderer() { |
49 |
|
50 |
} |
51 |
|
52 |
@Override |
53 |
public java.awt.Component |
54 |
getListCellRendererComponent ( |
55 |
JList list, Object value, int index, boolean isSelected, boolean cellHasFocus |
56 |
) { |
57 |
if(index == -1) { |
58 |
renderer.setText(value == null ? "" : value.toString()); |
59 |
return renderer; |
60 |
} |
61 |
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
62 |
} |
63 |
|
64 |
public static class FantasiaRenderer extends JLabel { |
65 |
private static java.awt.Color textColor = new java.awt.Color(0xFFA300); |
66 |
private static Insets pixmapInsets = new Insets(3, 5, 6, 5); |
67 |
private static ImageIcon bgImage = null; |
68 |
|
69 |
FantasiaRenderer() { |
70 |
setOpaque(false); |
71 |
setBorder(BorderFactory.createEmptyBorder(4, 5, 6, 5)); |
72 |
setForeground(new java.awt.Color(0xFFA300)); |
73 |
setBackground(new java.awt.Color(0x818181)); |
74 |
setFont(Res.fontScreen); |
75 |
|
76 |
if(bgImage == null) bgImage = StdUtils.createImageIcon ( |
77 |
Res.gfxCbLabelBg.getImage(), new java.awt.Color(0x818181) |
78 |
); |
79 |
} |
80 |
|
81 |
@Override |
82 |
protected void |
83 |
paintComponent(Graphics g) { |
84 |
Graphics2D g2d = (Graphics2D)g; |
85 |
|
86 |
g2d.setRenderingHint ( |
87 |
java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, |
88 |
java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON |
89 |
); |
90 |
|
91 |
PixmapPane.paintComponent(this, g, bgImage, pixmapInsets); |
92 |
super.paintComponent(g); |
93 |
} |
94 |
|
95 |
@Override |
96 |
public java.awt.Color |
97 |
getForeground() { return textColor; } |
98 |
|
99 |
@Override |
100 |
public java.awt.Font |
101 |
getFont() { return Res.fontScreen; } |
102 |
} |
103 |
} |