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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2288 - (hide annotations) (download)
Wed Nov 23 21:19:44 2011 UTC (12 years, 5 months ago) by iliev
File size: 5694 byte(s)
* Added option to select a sampler engine in Add/Edit Instrument dialog
* Moved all Swing dependent code outside the JSampler core

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

  ViewVC Help
Powered by ViewVC