/* * Created on Oct 22, 2010 by Nick * */ package jmsltestsuite; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.IOException; import com.softsynth.jmsl.score.Score; import com.softsynth.jmsl.score.ScoreFrame; /** * Problem reported by Jason Freeman * * You should be able to load a Score from a file without it displaying in ScoreFrame. * You should be able to copy notes from it and paste into a displayed score and supress rendering of loaded score. * * OLD BAD BEHAVIOR: * The frame would open and instead of showing firstScore it would show secondScore which was loaded from disk. This is because * Score was sharing a canvas and a newly loaded score calls ownCanvas() to gain rendering ownership. * Supressing ownCanvas was not enough. Calls to copy() would call render() which would result in the invisible score being rendered * * NEW BEHAVIOR: * load() the score with false flag which does not permit ownCanvas on the first call to Score.build(). It also setRenderAllowed(false) * * @author Nick Didkovsky, (c) 2005 Nick Didkovsky, nick@didkovsky.com * */ public class TestRenderAllowed { public static void main(String[] args) { ScoreFrame frame = new ScoreFrame(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent arg0) { System.exit(0); } }); Score firstScore = new Score(1); firstScore.addMeasure(); firstScore.addMeasure(); frame.addScore(firstScore); frame.setVisible(true); try { Score secondScore = Score.load("C:/Documents and Settings/Nick.PUNOS-F12CF7479/Desktop/Untitled-0.xml", false); Thread.sleep(5000); // copy stuff from second score and paste into first score System.out.println("copying notes from loaded score and pasting into second measure of second score"); secondScore.selectAll(); secondScore.getEditManager().copy(); firstScore.setSelectedMeasure(firstScore.getMeasure(1)); firstScore.setSelectedStaff(firstScore.getMeasure(1).getStaff(0)); firstScore.getEditManager().setStaffInsertionIndex(0); firstScore.getEditManager().paste(); Thread.sleep(5000); // now show the second score System.out.println("adding score to score frame"); secondScore.setRenderAllowed(true); frame.addScore(secondScore); } catch (IOException e) { System.out.println("ERROR: " + e); e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } }