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

Annotation of /jsampler/trunk/src/org/jsampler/view/MidiMapTable.java

Parent Directory Parent Directory | Revision Log Revision Log


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

1 iliev 1286 /*
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;
24    
25     import java.awt.event.MouseAdapter;
26     import java.awt.event.MouseEvent;
27    
28     import javax.swing.JTable;
29     import javax.swing.ListSelectionModel;
30    
31     import org.jsampler.CC;
32     import org.jsampler.MidiInstrumentMap;
33    
34     /**
35     * A table for representing MIDI instrument maps.
36     * @author Grigor Iliev
37     */
38     public class MidiMapTable extends JTable {
39    
40     /** Creates a new instance of <code>MidiMapTable</code> */
41     public
42     MidiMapTable() {
43     super(new MidiMapTableModel());
44    
45     setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
46     setFillsViewportHeight(true);
47    
48     addMouseListener(new MouseAdapter() {
49     public void
50     mouseClicked(MouseEvent e) {
51     if(e.getButton() != e.BUTTON1) return;
52     int r = rowAtPoint(e.getPoint());
53     if(r == -1) {
54     clearSelection();
55     return;
56     }
57     }
58     });
59     }
60    
61     /**
62     * Gets the selected MIDI instrument map.
63     * @return The selected MIDI instrument map, or
64     * <code>null</code> if no MIDI instrument map is selected.
65     */
66     public MidiInstrumentMap
67     getSelectedMidiInstrumentMap() {
68     int i = getSelectedRow();
69     if(i == -1) return null;
70     return CC.getSamplerModel().getMidiInstrumentMap(i);
71     }
72    
73     /**
74     * Selects the specified MIDI instrument map. If <code>map</code> is
75     * <code>null</code> or is not in the table the current selection is cleared.
76     * @param map The MIDI instrument map to select.
77     */
78     public void
79     setSelectedOrchestra(MidiInstrumentMap map) {
80     int i = CC.getSamplerModel().getMidiInstrumentMapIndex(map);
81     if(i < 0) {
82     clearSelection();
83     return;
84     }
85    
86     setRowSelectionInterval(i, i);
87     }
88     }

  ViewVC Help
Powered by ViewVC