[jmsl] EditManager question
jmsl at music.columbia.edu
jmsl at music.columbia.edu
Sat Jan 12 18:04:16 EST 2008
Hi Peter
Nice problem. You should set the staff insertion index using the edit
manager. The else clause of your useManufactured if-statemt only needs
two lines of code:
// ...
} else {
score.setSelectedStaff(score.getMeasure(1).getStaff(0));
score.getEditManager().setStaffInsertionIndex(0);
}
// ...
Thanks
Nick D.
jmsl at music.columbia.edu wrote:
> Hi all,
>
> I've been looking through the documentation, and I can't figure out
> how to copy one measure into another measure (possibly on another
> staff) without faking mouse-clicks, which is definitely kludge-ish.
> It looks like it should be easy with EditManager, but I'm having
> problems. Here's a demonstration.
>
> What all is EditManager doing when scoreCanvasClicked() is called?
> (that doesn't happen with setCurrentMeasure, etc.)
>
> thanks,
> Peter McCulloch
>
>
>
> package demos;
>
> import java.awt.event.MouseEvent;
> import java.awt.event.WindowAdapter;
> import java.awt.event.WindowEvent;
>
> import com.softsynth.jmsl.JMSL;
> import com.softsynth.jmsl.score.CopyBuffer;
> import com.softsynth.jmsl.score.Score;
> import com.softsynth.jmsl.score.ScoreFrame;
>
> public class EditManagerProblem {
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> // TODO Auto-generated method stub
>
> Score score = new Score(2);
> score.addMeasures(10, 4, 4);
> score.setCurrentMeasureNumber(0);
> score.setCurrentStaffNumber(0);
> for (int i = 0; i < 4; i++) {
> score.addNote(1., 60. + i, 0.5, 0.8);
> }
>
> score.setSelectedMeasure(score.getMeasure(0));
> score.setCurrentMeasureNumber(0);
> score.setSelectedStaff(score.getMeasure(0).getStaff(0));
> score.getEditManager().selectAllInStaff();
>
> CopyBuffer cb = new CopyBuffer();
> score.getEditManager().copy(cb);
>
> ScoreFrame frame = new ScoreFrame();
> frame.addScore(score);
>
> frame.addWindowListener(new WindowAdapter() {
> @Override
> public void windowClosing(WindowEvent e) {
> JMSL.closeMusicDevices();
> System.exit(0);
> }
> });
>
> frame.setVisible(true);
>
> boolean useManufactured = false;
>
> if (useManufactured) {
>
>
> score.getEditManager().scoreCanvasClicked(score.getScoreCanvas(),
> score.getSelectedStaff().getDrawingAnchor(),
> new MouseEvent(score.getScoreCanvas().getComponent(),
> 0, 0, 0, 0, 0, 0, false));
> } else {
> // Try to copy from first measure into second measure
> score.setCurrentMeasureNumber(1);
> score.setSelectedMeasure(score.getMeasure(1));
> score.setCurrentStaffNumber(0);
> score.setSelectedStaff(score.getMeasure(1).getStaff(0));
>
> score.getMeasure(1).getStaff(0).getActiveTrack().setInsertionIndex(0);
> }
> score.getEditManager().freeflowPaste(cb);
>
> }
>
> }
>
>
> _______________________________________________
> jmsl mailing list
> jmsl at music.columbia.edu
> http://music.columbia.edu/mailman/listinfo/jmsl
More information about the jmsl
mailing list