/* * Created on Jul 12, 2008 by Nick * */ package jmsltestsuite; import java.awt.*; import java.awt.geom.Line2D; import com.softsynth.jmsl.JMSLRandom; import com.softsynth.jmsl.score.Note; import com.softsynth.jmsl.score.NoteOrnament; /** * NoteOrnament subclasses allows users to create custom classes that draw into the note's Graphics * context. This example draws an random walk of line segments below the note. Use zoom in your * drawing to ensure that it scales */ public class SquigglyNoteOrnament extends NoteOrnament { public SquigglyNoteOrnament() { setName("SquigglyNoteOrnament"); } public void draw(Graphics g, double zoom, Note n) { double x = n.getDrawingAnchor().getX() + getXoffset() * zoom; double y = n.getDrawingAnchor().getY() + getYoffset() * zoom; g.setColor(Color.darkGray); for (int i = 0; i < 15; i++) { double x2 = x + JMSLRandom.choose(-1, 1) * zoom; double y2 = y + JMSLRandom.choose(8) * zoom; ((Graphics2D) g).draw(new Line2D.Double(x, y, x2, y2)); x = x2; y = y2; } g.setColor(Color.black); } }