/[svn]/jsampler/trunk/src/org/jsampler/view/fantasia/FantasiaUtils.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/view/fantasia/FantasiaUtils.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1785 - (show annotations) (download)
Tue Oct 7 00:07:14 2008 UTC (15 years, 6 months ago) by iliev
File size: 5689 byte(s)
* Fantasia: Implemented multiple channels panels
* Fantasia: Refactoring - all basic UI components moved to
  org.jsampler.view.fantasia.basic package

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.Cursor;
26 import java.awt.Dialog;
27 import java.awt.Dimension;
28 import java.awt.Frame;
29 import java.awt.Graphics;
30 import java.awt.Graphics2D;
31 import java.awt.Insets;
32
33 import javax.swing.Action;
34 import javax.swing.BorderFactory;
35 import javax.swing.JButton;
36 import javax.swing.JComboBox;
37 import javax.swing.JLabel;
38 import javax.swing.JPanel;
39 import javax.swing.JToolBar;
40
41 import javax.swing.plaf.basic.BasicButtonUI;
42 import javax.swing.plaf.basic.BasicLabelUI;
43
44 import org.jsampler.view.InstrumentsDbTreeModel;
45
46 import org.jsampler.view.fantasia.basic.FantasiaPainter;
47
48 import org.jsampler.view.std.JSDbInstrumentChooser;
49 import org.jsampler.view.std.JSInstrumentChooser;
50 import org.jsampler.view.std.JSInstrumentsDbTree;
51
52
53 /**
54 *
55 * @author Grigor Iliev
56 */
57 public class FantasiaUtils {
58
59 /** Forbits the instantiation of the class */
60 private
61 FantasiaUtils() { }
62
63 public static JComboBox
64 createEnhancedComboBox() {
65 return new JComboBox();
66 }
67
68 public static JSInstrumentChooser
69 createInstrumentChooser(Frame owner) {
70 return new InstrumentChooser(owner);
71 }
72
73 public static JLabel
74 createScreenLabel(String s) { return new ScreenLabel(s); }
75
76 public static JButton
77 createScreenButton(String s) { return new ScreenButton(s); }
78
79 public static JToolBar
80 createSubToolBar() { return new ToolBar(); }
81
82 public static JPanel
83 createBottomSubPane() { return new BottomSubPane(); }
84
85
86 private static class InstrumentChooser extends JSInstrumentChooser {
87 InstrumentChooser(Frame owner) {
88 super(owner);
89 }
90
91 protected JComboBox
92 createComboBox() { return createEnhancedComboBox(); }
93
94 @Override
95 protected JSDbInstrumentChooser
96 createDbInstrumentChooser(Dialog owner) {
97 return new DbInstrumentChooser(owner);
98 }
99 }
100
101 private static class DbInstrumentChooser extends JSDbInstrumentChooser {
102 DbInstrumentChooser(Dialog owner) {
103 super(owner);
104 }
105
106 @Override
107 protected JButton
108 createToolbarButton(Action a) { return new ToolbarButton(a); }
109
110 @Override
111 protected JSInstrumentsDbTree
112 createInstrumentsDbTree(InstrumentsDbTreeModel m) {
113 return new FantasiaInstrumentsDbTree(m);
114 }
115 }
116
117 private static class ScreenLabel extends JLabel {
118 ScreenLabel() { this(""); }
119
120 ScreenLabel(String s) {
121 super(s);
122 setFont(Res.fontScreen);
123 setForeground(new java.awt.Color(0xFFA300));
124 }
125
126 @Override
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 @Override
140 public void
141 updateUI() { setUI(new BasicLabelUI()); }
142 }
143
144 private static class ScreenButton extends JButton {
145 protected
146 ScreenButton(String s) {
147 super(s);
148 setContentAreaFilled(false);
149 setFocusPainted(false);
150 setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
151 setMargin(new Insets(0, 0, 0, 0));
152
153 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
154 setFont(Res.fontScreen);
155 setForeground(new java.awt.Color(0xFFA300));
156 }
157
158 @Override
159 protected void
160 paintComponent(Graphics g) {
161 Graphics2D g2d = (Graphics2D)g;
162
163 g2d.setRenderingHint (
164 java.awt.RenderingHints.KEY_TEXT_ANTIALIASING,
165 java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON
166 );
167
168 super.paintComponent(g2d);
169 }
170
171 @Override
172 public void
173 updateUI() { setUI(new BasicButtonUI()); }
174 }
175
176
177
178 private static class ToolBar extends JToolBar {
179 ToolBar() {
180 setFloatable(false);
181 setOpaque(false);
182 setPreferredSize(new Dimension(77, 29));
183 setMinimumSize(getPreferredSize());
184 //setBackground(Color.BLACK);
185 }
186
187 @Override
188 protected void
189 paintComponent(Graphics g) {
190 super.paintComponent(g);
191
192 double h = getSize().getHeight();
193 double w = getSize().getWidth();
194
195 FantasiaPainter.paintGradient((Graphics2D)g, 0, 0, w - 1, h - 1);
196
197 FantasiaPainter.RoundCorners rc =
198 new FantasiaPainter.RoundCorners(true, false, false, true);
199
200 FantasiaPainter.paintOuterBorder((Graphics2D)g, 0, 0, w - 1, h - 1, rc);
201 }
202 }
203
204 private static class BottomSubPane extends JPanel {
205 BottomSubPane() {
206 setLayout(new java.awt.BorderLayout());
207 setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
208 }
209
210 @Override
211 protected void
212 paintComponent(Graphics g) {
213 super.paintComponent(g);
214
215 Graphics2D g2 = (Graphics2D)g;
216 double h = getSize().getHeight();
217 double w = getSize().getWidth();
218
219 FantasiaPainter.paintGradient(g2, 0, 0, w - 1, h - 1);
220
221 FantasiaPainter.RoundCorners rc =
222 new FantasiaPainter.RoundCorners(false, true, true, false);
223
224 FantasiaPainter.paintOuterBorder(g2, 0, 0, w - 1, h - 1, rc);
225
226 FantasiaPainter.paintInnerBorder(g2, 4, 4, w - 5, h - 5, true);
227 }
228 }
229 }

  ViewVC Help
Powered by ViewVC