package jmsltestsuite; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.*; import com.didkovsky.portview.PVButton; import com.didkovsky.portview.PVPanel; import com.softsynth.jmsl.*; import com.softsynth.jmsl.view.*; // import java.io.*; /** * A convenience Frame with a MusicShapeEditor panel. You can set a Composable to be launched. * * @author Nick Didkovsky, Feb 17, 2003 (blizzard!) * */ public class MusicShapeEditorFrame extends PVFrameAdapter implements ActionListener { private MusicShapeEditor musicShapeEditor; private Composable composable; private PVButton launchButton; private PVButton finishButton; public MusicShapeEditorFrame(MusicShapeEditor editorPanel, Composable composable) { setMusicShapeEditor(editorPanel); setComposable(composable); setFrameLayout(new BorderLayout()); add(BorderLayout.NORTH, editorPanel.getComponent()); PVPanel p = new PVPanelAdapter(); p.setLayout(new FlowLayout()); p.add((launchButton = JMSL.getViewFactory().createButton("launch")).getComponent()); p.add((finishButton = JMSL.getViewFactory().createButton("finish")).getComponent()); add(BorderLayout.SOUTH, p.getComponent()); launchButton.addActionListener(this); finishButton.addActionListener(this); } private void setMusicShapeEditor(MusicShapeEditor editorPanel) { this.musicShapeEditor = editorPanel; } /** Set the Composable that will be launched when launch button clicked */ private void setComposable(Composable composable) { this.composable = composable; } public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source == launchButton) { if (this.composable != null) { this.composable.launch(JMSL.now(), null); } } if (source == finishButton) { if (this.composable != null) { this.composable.finishAll(); } } } public static void main(String args[]) { MusicShape s = new MusicShape(5); s.setDimensionName(0, "aoogie"); s.setDimensionName(1, "boogie"); s.setDimensionName(2, "coogie"); s.setDimensionName(3, "doogie"); s.setDimensionName(4, "eoogie"); for (int i = 0; i < 20; i++) { s.add(0.5 + i % 2, i, i, i, i); } MusicShapeEditor editor = new MusicShapeEditor(); editor.addMusicShape(s); MusicShapeEditorFrame frame = new MusicShapeEditorFrame(editor, s); frame.pack(); frame.setVisible(true); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); } }