23 |
package org.jsampler.view.fantasia; |
package org.jsampler.view.fantasia; |
24 |
|
|
25 |
import java.awt.Container; |
import java.awt.Container; |
|
import java.awt.Cursor; |
|
26 |
import java.awt.Dimension; |
import java.awt.Dimension; |
27 |
import java.awt.Graphics; |
import java.awt.Graphics; |
28 |
import java.awt.Graphics2D; |
import java.awt.Graphics2D; |
39 |
import java.beans.PropertyChangeEvent; |
import java.beans.PropertyChangeEvent; |
40 |
import java.beans.PropertyChangeListener; |
import java.beans.PropertyChangeListener; |
41 |
|
|
42 |
|
import java.text.NumberFormat; |
43 |
|
|
44 |
import java.util.logging.Level; |
import java.util.logging.Level; |
45 |
|
|
46 |
import javax.swing.Action; |
import javax.swing.Action; |
50 |
import javax.swing.DefaultListCellRenderer; |
import javax.swing.DefaultListCellRenderer; |
51 |
import javax.swing.JButton; |
import javax.swing.JButton; |
52 |
import javax.swing.JComboBox; |
import javax.swing.JComboBox; |
53 |
|
import javax.swing.JComponent; |
54 |
import javax.swing.JLabel; |
import javax.swing.JLabel; |
55 |
import javax.swing.JMenuItem; |
import javax.swing.JMenuItem; |
56 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
73 |
|
|
74 |
import org.jsampler.AudioDeviceModel; |
import org.jsampler.AudioDeviceModel; |
75 |
import org.jsampler.CC; |
import org.jsampler.CC; |
76 |
|
import org.jsampler.HF; |
77 |
import org.jsampler.MidiDeviceModel; |
import org.jsampler.MidiDeviceModel; |
78 |
import org.jsampler.MidiInstrumentMap; |
import org.jsampler.MidiInstrumentMap; |
79 |
import org.jsampler.SamplerChannelModel; |
import org.jsampler.SamplerChannelModel; |
97 |
import org.jsampler.view.std.JSChannelOutputRoutingDlg; |
import org.jsampler.view.std.JSChannelOutputRoutingDlg; |
98 |
import org.jsampler.view.std.JSFxSendsPane; |
import org.jsampler.view.std.JSFxSendsPane; |
99 |
import org.jsampler.view.std.JSInstrumentChooser; |
import org.jsampler.view.std.JSInstrumentChooser; |
100 |
|
import org.jsampler.view.std.JSVolumeEditorPopup; |
|
import org.jvnet.lafwidget.animation.FadeConfigurationManager; |
|
|
import org.jvnet.lafwidget.animation.FadeKind; |
|
101 |
|
|
102 |
import org.jvnet.substance.SubstanceImageCreator; |
import org.jvnet.substance.SubstanceImageCreator; |
|
import org.jvnet.substance.SubstanceLookAndFeel; |
|
103 |
|
|
104 |
import org.linuxsampler.lscp.AudioOutputDevice; |
import org.linuxsampler.lscp.AudioOutputDevice; |
105 |
import org.linuxsampler.lscp.MidiInputDevice; |
import org.linuxsampler.lscp.MidiInputDevice; |
109 |
|
|
110 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
111 |
import static org.jsampler.view.fantasia.FantasiaPrefs.*; |
import static org.jsampler.view.fantasia.FantasiaPrefs.*; |
112 |
|
import static org.jsampler.view.fantasia.FantasiaUtils.*; |
113 |
|
import static org.jsampler.view.std.JSVolumeEditorPopup.VolumeType; |
114 |
|
|
115 |
|
|
116 |
/** |
/** |
265 |
} |
} |
266 |
}); |
}); |
267 |
|
|
268 |
|
String vmud = VOL_MEASUREMENT_UNIT_DECIBEL; |
269 |
|
preferences().addPropertyChangeListener(vmud, new PropertyChangeListener() { |
270 |
|
public void |
271 |
|
propertyChange(PropertyChangeEvent e) { |
272 |
|
boolean b; |
273 |
|
b = preferences().getBoolProperty(VOL_MEASUREMENT_UNIT_DECIBEL); |
274 |
|
screen.updateVolumeInfo(dialVolume.getValue()); |
275 |
|
} |
276 |
|
}); |
277 |
|
|
278 |
getModel().addSamplerChannelListener(getHandler()); |
getModel().addSamplerChannelListener(getHandler()); |
279 |
|
|
280 |
updateChannelInfo(); |
updateChannelInfo(); |
392 |
|
|
393 |
if(vol == dialVolume.getValue()) return; |
if(vol == dialVolume.getValue()) return; |
394 |
|
|
|
|
|
395 |
/* |
/* |
396 |
* If the model's volume is not equal to the dial knob |
* If the model's volume is not equal to the dial knob |
397 |
* value we assume that the change is due to user input. |
* value we assume that the change is due to user input. |
415 |
|
|
416 |
if(sc.isSoloChannel()) btnSolo.setIcon(Res.gfxSoloOn); |
if(sc.isSoloChannel()) btnSolo.setIcon(Res.gfxSoloOn); |
417 |
else btnSolo.setIcon(Res.gfxSoloOff); |
else btnSolo.setIcon(Res.gfxSoloOff); |
|
|
|
418 |
dialVolume.setValue((int)(sc.getVolume() * 100)); |
dialVolume.setValue((int)(sc.getVolume() * 100)); |
419 |
|
|
420 |
boolean b = sc.getEngine() != null; |
boolean b = sc.getEngine() != null; |
671 |
private final Channel channel; |
private final Channel channel; |
672 |
|
|
673 |
private final InstrumentPane instrumentPane; |
private final InstrumentPane instrumentPane; |
674 |
private JButton btnInstr = new ScreenButton(i18n.getButtonLabel("ChannelScreen.btnInstr")); |
|
675 |
|
private JButton btnInstr = |
676 |
|
createScreenButton(i18n.getButtonLabel("ChannelScreen.btnInstr")); |
677 |
|
|
678 |
private final JButton btnEditInstr = |
private final JButton btnEditInstr = |
679 |
new ScreenButton(i18n.getButtonLabel("ChannelScreen.btnEditInstr")); |
createScreenButton(i18n.getButtonLabel("ChannelScreen.btnEditInstr")); |
680 |
private final ScreenButtonBg sbbEditInstr = new ScreenButtonBg(btnEditInstr); |
private final ScreenButtonBg sbbEditInstr = new ScreenButtonBg(btnEditInstr); |
681 |
|
|
682 |
private final JButton btnFxSends = |
private final JButton btnFxSends = |
683 |
new ScreenButton(i18n.getButtonLabel("ChannelScreen.btnFxSends")); |
createScreenButton(i18n.getButtonLabel("ChannelScreen.btnFxSends")); |
684 |
|
|
685 |
private final JButton btnEngine |
private final JButton btnEngine |
686 |
= new ScreenButton(i18n.getButtonLabel("ChannelScreen.btnEngine")); |
= createScreenButton(i18n.getButtonLabel("ChannelScreen.btnEngine")); |
687 |
|
|
688 |
private final JPopupMenu menuEngines = new JPopupMenu(); |
private final JPopupMenu menuEngines = new JPopupMenu(); |
689 |
|
|
690 |
private final JLabel lVolume = new ScreenLabel(""); |
private final JButton btnVolume = createScreenButton(""); |
691 |
private final JLabel lStreams = new ScreenLabel(" --"); |
private JSVolumeEditorPopup popupVolume; |
|
private final JLabel lVoices = new ScreenLabel("-- "); |
|
692 |
|
|
693 |
private InformationDialog fxSendsDlg = null; |
private final JLabel lStreams = createScreenLabel(" --"); |
694 |
|
private final JLabel lVoices = createScreenLabel("-- "); |
695 |
|
|
696 |
private Dimension dimVolume; |
private InformationDialog fxSendsDlg = null; |
697 |
|
|
698 |
private Timer timer; |
private Timer timer; |
699 |
|
|
700 |
|
private static NumberFormat numberFormat = NumberFormat.getInstance(); |
701 |
|
static { |
702 |
|
numberFormat.setMaximumFractionDigits(1); |
703 |
|
} |
704 |
|
|
705 |
ChannelScreen(final Channel channel) { |
ChannelScreen(final Channel channel) { |
706 |
super(Res.gfxChannelScreen); |
super(Res.gfxChannelScreen); |
707 |
setPixmapInsets(new Insets(6, 6, 6, 6)); |
setPixmapInsets(new Insets(6, 6, 6, 6)); |
708 |
setBorder(BorderFactory.createEmptyBorder(5, 4, 5, 4)); |
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
709 |
|
|
710 |
this.channel = channel; |
this.channel = channel; |
711 |
|
popupVolume = new JSVolumeEditorPopup(btnVolume, VolumeType.CHANNEL); |
712 |
|
|
713 |
setOpaque(false); |
setOpaque(false); |
714 |
|
|
724 |
JPanel p = new JPanel(); |
JPanel p = new JPanel(); |
725 |
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
726 |
p.setAlignmentX(CENTER_ALIGNMENT); |
p.setAlignmentX(CENTER_ALIGNMENT); |
727 |
p.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); |
p.setBorder(BorderFactory.createEmptyBorder(5, 2, 0, 0)); |
728 |
|
|
729 |
btnFxSends.setToolTipText(i18n.getButtonLabel("ChannelScreen.btnFxSends.tt")); |
btnFxSends.setToolTipText(i18n.getButtonLabel("ChannelScreen.btnFxSends.tt")); |
730 |
btnFxSends.addActionListener(new ActionListener() { |
btnFxSends.addActionListener(new ActionListener() { |
746 |
|
|
747 |
p.add(btnFxSends); |
p.add(btnFxSends); |
748 |
|
|
749 |
p.add(Box.createRigidArea(new Dimension(6, 0))); |
//p.add(Box.createRigidArea(new Dimension(6, 0))); |
750 |
|
p.add(Box.createGlue()); |
751 |
|
|
752 |
btnEngine.setIcon(Res.iconEngine12); |
btnEngine.setIcon(Res.iconEngine12); |
753 |
|
btnEngine.setIconTextGap(1); |
754 |
p.add(btnEngine); |
p.add(btnEngine); |
755 |
//p.add(new Label("|")); |
//p.add(new Label("|")); |
756 |
|
|
762 |
|
|
763 |
lStreams.setFont(Res.fontScreenMono); |
lStreams.setFont(Res.fontScreenMono); |
764 |
lStreams.setHorizontalAlignment(JLabel.RIGHT); |
lStreams.setHorizontalAlignment(JLabel.RIGHT); |
765 |
|
lStreams.setToolTipText(i18n.getLabel("ChannelScreen.streamVoiceCount")); |
766 |
p.add(lStreams); |
p.add(lStreams); |
767 |
|
|
768 |
JLabel l = new ScreenLabel("/"); |
JLabel l = createScreenLabel("/"); |
769 |
l.setFont(Res.fontScreenMono); |
l.setFont(Res.fontScreenMono); |
770 |
|
l.setToolTipText(i18n.getLabel("ChannelScreen.streamVoiceCount")); |
771 |
p.add(l); |
p.add(l); |
772 |
|
|
773 |
lVoices.setFont(Res.fontScreenMono); |
lVoices.setFont(Res.fontScreenMono); |
774 |
|
lVoices.setToolTipText(i18n.getLabel("ChannelScreen.streamVoiceCount")); |
775 |
p.add(lVoices); |
p.add(lVoices); |
776 |
|
|
777 |
lVolume.setIcon(Res.iconVolume14); |
btnVolume.setIcon(Res.iconVolume14); |
778 |
lVolume.setAlignmentX(RIGHT_ALIGNMENT); |
btnVolume.setIconTextGap(2); |
779 |
|
btnVolume.setAlignmentX(RIGHT_ALIGNMENT); |
780 |
|
btnVolume.setHorizontalAlignment(btnVolume.LEFT); |
781 |
updateVolumeInfo(100); |
updateVolumeInfo(100); |
782 |
dimVolume = lVolume.getPreferredSize(); |
Dimension d = btnVolume.getPreferredSize(); |
783 |
p.add(lVolume); |
d.width = 60; |
784 |
p.setPreferredSize(new Dimension(250, p.getPreferredSize().height)); |
btnVolume.setPreferredSize(d); |
785 |
|
btnVolume.setMinimumSize(d); |
786 |
|
|
787 |
|
btnVolume.addActionListener(new ActionListener() { |
788 |
|
public void |
789 |
|
actionPerformed(ActionEvent e) { |
790 |
|
if(popupVolume.isVisible()) { |
791 |
|
popupVolume.commit(); |
792 |
|
popupVolume.hide(); |
793 |
|
} else { |
794 |
|
float vol = channel.getModel().getChannelInfo().getVolume(); |
795 |
|
popupVolume.setCurrentVolume(vol); |
796 |
|
popupVolume.show(); |
797 |
|
} |
798 |
|
} |
799 |
|
}); |
800 |
|
|
801 |
|
popupVolume.addActionListener(new ActionListener() { |
802 |
|
public void |
803 |
|
actionPerformed(ActionEvent e) { |
804 |
|
channel.getModel().setBackendVolume(popupVolume.getVolumeFactor()); |
805 |
|
} |
806 |
|
}); |
807 |
|
|
808 |
|
p.add(btnVolume); |
809 |
|
p.setPreferredSize(new Dimension(260, p.getPreferredSize().height)); |
810 |
p.setMinimumSize(p.getPreferredSize()); |
p.setMinimumSize(p.getPreferredSize()); |
811 |
p.setMaximumSize(p.getPreferredSize()); |
p.setMaximumSize(p.getPreferredSize()); |
812 |
|
|
829 |
private void |
private void |
830 |
createEngineMenu() { |
createEngineMenu() { |
831 |
for(final SamplerEngine engine : CC.getSamplerModel().getEngines()) { |
for(final SamplerEngine engine : CC.getSamplerModel().getEngines()) { |
832 |
JMenuItem mi = new JMenuItem(engine.getDescription()); |
JMenuItem mi = new JMenuItem(engine.getName() + " engine"); |
833 |
|
mi.setToolTipText(engine.getDescription()); |
834 |
|
|
835 |
mi.addActionListener(new ActionListener() { |
mi.addActionListener(new ActionListener() { |
836 |
public void |
public void |
910 |
instrumentPane.update(); |
instrumentPane.update(); |
911 |
|
|
912 |
if(sc.getEngine() != null) { |
if(sc.getEngine() != null) { |
913 |
String s = sc.getEngine().getDescription(); |
String s = sc.getEngine().getName(); |
914 |
if(!s.equals(btnEngine.getText())) btnEngine.setText(s); |
s += " engine"; |
915 |
|
if(!s.equals(btnEngine.getText())) { |
916 |
|
btnEngine.setText(s); |
917 |
|
btnEngine.setToolTipText(sc.getEngine().getDescription()); |
918 |
|
} |
919 |
} |
} |
920 |
|
|
921 |
} |
} |
922 |
|
|
923 |
protected void |
protected void |
924 |
updateVolumeInfo(int volume) { |
updateVolumeInfo(int volume) { |
925 |
lVolume.setText(i18n.getLabel("ChannelScreen.volume", volume)); |
if(CC.getViewConfig().isMeasurementUnitDecibel()) { |
926 |
lVolume.setMinimumSize(dimVolume); |
String s = numberFormat.format(HF.percentsToDecibels(volume)); |
927 |
lVolume.setPreferredSize(dimVolume); |
btnVolume.setText(s + "dB"); |
928 |
|
} else { |
929 |
|
btnVolume.setText(String.valueOf(volume) + "%"); |
930 |
|
} |
931 |
} |
} |
932 |
|
|
933 |
/** |
/** |
1034 |
} |
} |
1035 |
} |
} |
1036 |
|
|
|
static class ScreenButton extends JButton { |
|
|
ScreenButton(String s) { |
|
|
super(s); |
|
|
setContentAreaFilled(false); |
|
|
setFocusPainted(false); |
|
|
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
|
|
setMargin(new Insets(0, 0, 0, 0)); |
|
|
|
|
|
putClientProperty ( |
|
|
SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE |
|
|
); |
|
|
|
|
|
putClientProperty ( |
|
|
SubstanceLookAndFeel.BUTTON_PAINT_NEVER_PROPERTY, Boolean.TRUE |
|
|
); |
|
|
|
|
|
putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); |
|
|
|
|
|
FadeConfigurationManager.getInstance().disallowFades(FadeKind.ROLLOVER, this); |
|
|
|
|
|
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
|
setFont(Res.fontScreen); |
|
|
setForeground(new java.awt.Color(0xFFA300)); |
|
|
} |
|
|
|
|
|
protected void |
|
|
paintComponent(Graphics g) { |
|
|
Graphics2D g2d = (Graphics2D)g; |
|
|
|
|
|
g2d.setRenderingHint ( |
|
|
java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, |
|
|
java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON |
|
|
); |
|
|
|
|
|
super.paintComponent(g2d); |
|
|
} |
|
|
} |
|
|
|
|
1037 |
static class ScreenButtonBg extends PixmapPane { |
static class ScreenButtonBg extends PixmapPane { |
1038 |
ScreenButtonBg(JButton btn) { |
ScreenButtonBg(JButton btn) { |
1039 |
super(Res.gfxScreenBtnBg); |
super(Res.gfxScreenBtnBg); |
1051 |
} |
} |
1052 |
|
|
1053 |
|
|
|
|
|
|
static class ScreenLabel extends JLabel { |
|
|
ScreenLabel() { this(""); } |
|
|
|
|
|
ScreenLabel(String s) { |
|
|
super(s); |
|
|
setFont(Res.fontScreen); |
|
|
setForeground(new java.awt.Color(0xFFA300)); |
|
|
} |
|
|
|
|
|
protected void |
|
|
paintComponent(Graphics g) { |
|
|
Graphics2D g2d = (Graphics2D)g; |
|
|
|
|
|
g2d.setRenderingHint ( |
|
|
java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, |
|
|
java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON |
|
|
); |
|
|
|
|
|
super.paintComponent(g2d); |
|
|
} |
|
|
} |
|
|
|
|
1054 |
private final EventHandler eventHandler = new EventHandler(); |
private final EventHandler eventHandler = new EventHandler(); |
1055 |
|
|
1056 |
private EventHandler |
private EventHandler |