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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1286 - (show annotations) (download)
Fri Aug 10 20:24:23 2007 UTC (16 years, 8 months ago) by iliev
File size: 4599 byte(s)
- Updated to version 0.6a. The Fantasia distribution is now
  capable of controlling all features available in LinuxSampler

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.Cursor;
26 import java.awt.Dimension;
27 import java.awt.Graphics;
28 import java.awt.GridBagConstraints;
29 import java.awt.GridBagLayout;
30 import java.awt.Insets;
31
32 import java.awt.event.ActionEvent;
33 import java.awt.event.ActionListener;
34 import java.awt.event.MouseAdapter;
35 import java.awt.event.MouseEvent;
36
37 import javax.swing.Box;
38 import javax.swing.BoxLayout;
39 import javax.swing.JPanel;
40
41 import org.jsampler.CC;
42
43 import static org.jsampler.view.fantasia.FantasiaI18n.i18n;
44
45
46 /**
47 *
48 * @author Grigor Iliev
49 */
50 public class MainPane extends JPanel {
51 private final ChannelsBar channelsBar = new ChannelsBar();
52 private final ChannelsPane channelsPane = new ChannelsPane("");
53
54 /** Creates a new instance of <code>MainPane</code> */
55 public MainPane() {
56 GridBagLayout gridbag = new GridBagLayout();
57 GridBagConstraints c = new GridBagConstraints();
58
59 setLayout(gridbag);
60
61 c.gridx = 0;
62 c.gridy = 0;
63 c.weightx = 1.0;
64 c.insets = new Insets(0, 0, 7, 0);
65 c.fill = GridBagConstraints.HORIZONTAL;
66 gridbag.setConstraints(channelsBar, c);
67 add(channelsBar);
68
69 JPanel p = createChannelsPane();
70
71 c.gridx = 0;
72 c.gridy = 2;
73 c.weightx = 1.0;
74 c.weighty = 1.0;
75 c.insets = new Insets(0, 0, 0, 0);
76 c.fill = GridBagConstraints.BOTH;
77 gridbag.setConstraints(p, c);
78 add(p);
79
80 p = new JPanel();
81 p.setOpaque(false);
82
83 c.gridx = 0;
84 c.gridy = 3;
85 gridbag.setConstraints(p, c);
86 add(p);
87
88 setMaximumSize(new Dimension(420, Short.MAX_VALUE));
89 }
90
91 private JPanel
92 createChannelsPane() {
93 JPanel p = new JPanel();
94 p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
95 p.add(channelsPane);
96 p.add(new NewChannelPane());
97 p.add(Box.createGlue());
98 p.setOpaque(false);
99
100 return p;
101 }
102
103 public ChannelsPane
104 getChannelsPane() { return channelsPane; }
105
106 protected void
107 paintComponent(Graphics g) {
108 super.paintComponent(g);
109 int h = Res.gfxChannelsBg.getIconHeight();
110 if(h < 1) return;
111 int i = 0;
112 while(i < getHeight()) {
113 Res.gfxChannelsBg.paintIcon(this, g, 0, i);
114 i += h;
115 }
116 }
117
118 class NewChannelPane extends PixmapPane implements ActionListener {
119 private final PixmapButton btnNew = new PixmapButton(Res.gfxPowerOff);
120
121 NewChannelPane() {
122 super(Res.gfxCreateChannel);
123 setPixmapInsets(new Insets(3, 3, 3, 3));
124
125 setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
126 add(Box.createRigidArea(new Dimension(4, 0)));
127 add(btnNew);
128 add(Box.createRigidArea(new Dimension(3, 0)));
129
130 add(createVSeparator());
131
132 add(Box.createRigidArea(new Dimension(275, 0)));
133
134 add(createVSeparator());
135
136 add(Box.createRigidArea(new Dimension(29, 0)));
137
138 add(createVSeparator());
139
140 add(Box.createRigidArea(new Dimension(40, 0)));
141
142 add(createVSeparator());
143
144 setPreferredSize(new Dimension(420, 29));
145 setMinimumSize(getPreferredSize());
146 setMaximumSize(getPreferredSize());
147
148 btnNew.setPressedIcon(Res.gfxPowerOn);
149 btnNew.addActionListener(this);
150
151 addMouseListener(new MouseAdapter() {
152 public void
153 mouseClicked(MouseEvent e) {
154 if(e.getButton() != e.BUTTON1) {
155 return;
156 }
157
158 CC.getSamplerModel().addBackendChannel();
159 }
160 });
161
162 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
163
164 String s = i18n.getLabel("MainPane.NewChannelPane.newChannel");
165 btnNew.setToolTipText(s);
166 setToolTipText(s);
167 }
168
169 public void
170 actionPerformed(ActionEvent e) {
171 CC.getSamplerModel().addBackendChannel();
172 }
173
174 private JPanel
175 createVSeparator() {
176 PixmapPane p = new PixmapPane(Res.gfxVLine);
177 p.setOpaque(false);
178 p.setPreferredSize(new Dimension(2, 29));
179 p.setMinimumSize(p.getPreferredSize());
180 p.setMaximumSize(p.getPreferredSize());
181 return p;
182 }
183 }
184 }

  ViewVC Help
Powered by ViewVC