1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005-2008 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.Container; |
26 |
import java.awt.Cursor; |
27 |
import java.awt.Frame; |
28 |
import java.awt.Graphics; |
29 |
import java.awt.Graphics2D; |
30 |
import java.awt.Insets; |
31 |
|
32 |
import javax.swing.BorderFactory; |
33 |
import javax.swing.JButton; |
34 |
import javax.swing.JComboBox; |
35 |
import javax.swing.JComponent; |
36 |
import javax.swing.JLabel; |
37 |
import javax.swing.JScrollBar; |
38 |
import javax.swing.JScrollPane; |
39 |
|
40 |
import javax.swing.plaf.basic.BasicButtonUI; |
41 |
import javax.swing.plaf.basic.BasicLabelUI; |
42 |
import javax.swing.plaf.basic.ComboPopup; |
43 |
|
44 |
import org.jsampler.view.std.JSInstrumentChooser; |
45 |
|
46 |
import org.jvnet.lafwidget.animation.FadeConfigurationManager; |
47 |
import org.jvnet.lafwidget.animation.FadeKind; |
48 |
|
49 |
import org.jvnet.substance.SubstanceComboBoxUI; |
50 |
import org.jvnet.substance.SubstanceLookAndFeel; |
51 |
|
52 |
/** |
53 |
* |
54 |
* @author Grigor Iliev |
55 |
*/ |
56 |
public class FantasiaUtils { |
57 |
|
58 |
/** Forbits the instantiation of the class */ |
59 |
private |
60 |
FantasiaUtils() { } |
61 |
|
62 |
public static JComboBox |
63 |
createEnhancedComboBox() { |
64 |
return new JComboBox(); |
65 |
} |
66 |
|
67 |
public static JSInstrumentChooser |
68 |
createInstrumentChooser(Frame owner) { |
69 |
return new InstrumentChooser(owner); |
70 |
} |
71 |
|
72 |
public static JLabel |
73 |
createScreenLabel(String s) { return new ScreenLabel(s); } |
74 |
|
75 |
public static JButton |
76 |
createScreenButton(String s) { return new ScreenButton(s); } |
77 |
|
78 |
|
79 |
private static class InstrumentChooser extends JSInstrumentChooser { |
80 |
InstrumentChooser(Frame owner) { |
81 |
super(owner); |
82 |
} |
83 |
|
84 |
protected JComboBox |
85 |
createComboBox() { return createEnhancedComboBox(); } |
86 |
} |
87 |
|
88 |
private static class ScreenLabel extends JLabel { |
89 |
ScreenLabel() { this(""); } |
90 |
|
91 |
ScreenLabel(String s) { |
92 |
super(s); |
93 |
setFont(Res.fontScreen); |
94 |
setForeground(new java.awt.Color(0xFFA300)); |
95 |
} |
96 |
|
97 |
protected void |
98 |
paintComponent(Graphics g) { |
99 |
Graphics2D g2d = (Graphics2D)g; |
100 |
|
101 |
g2d.setRenderingHint ( |
102 |
java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, |
103 |
java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON |
104 |
); |
105 |
|
106 |
super.paintComponent(g2d); |
107 |
} |
108 |
|
109 |
public void |
110 |
updateUI() { setUI(new BasicLabelUI()); } |
111 |
} |
112 |
|
113 |
private static class ScreenButton extends JButton { |
114 |
protected |
115 |
ScreenButton(String s) { |
116 |
super(s); |
117 |
setContentAreaFilled(false); |
118 |
setFocusPainted(false); |
119 |
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
120 |
setMargin(new Insets(0, 0, 0, 0)); |
121 |
|
122 |
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
123 |
setFont(Res.fontScreen); |
124 |
setForeground(new java.awt.Color(0xFFA300)); |
125 |
} |
126 |
|
127 |
protected void |
128 |
paintComponent(Graphics g) { |
129 |
Graphics2D g2d = (Graphics2D)g; |
130 |
|
131 |
g2d.setRenderingHint ( |
132 |
java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, |
133 |
java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON |
134 |
); |
135 |
|
136 |
super.paintComponent(g2d); |
137 |
} |
138 |
|
139 |
public void |
140 |
updateUI() { setUI(new BasicButtonUI()); } |
141 |
} |
142 |
} |