Package jmsltestsuite

Class MusicGlyphRendererTest

java.lang.Object
jmsltestsuite.MusicGlyphRendererTest
All Implemented Interfaces:
MusicCurveRenderer, MusicGlyphRendererProxyListener

public class MusicGlyphRendererTest
extends java.lang.Object
implements MusicGlyphRendererProxyListener, MusicCurveRenderer
JMSL Score lets you add custom music glyph renderers, that might use a real music font for example. Here we test two such renderers, one that uses Sonata music font for most glyphs, but gives the priority to another renderer for microtonal accidentals (Accidentals font by Matthew Hindson, see http://www.hindson.com.au/wordpress/free-fonts-available-for-download/ The order you add MusicGlyphRenderers to JMSL determines the priority. The first renderer to successfully render a glyph returns true and stops the chain. If they all fall through or if none exist, JMSL uses line drawing routines. Test SonataMusicGlyphRenderer and AccidentalsMusicGlyphRenderer
  • Constructor Summary

    Constructors
    Constructor Description
    MusicGlyphRendererTest()  
  • Method Summary

    Modifier and Type Method Description
    void draw​(java.awt.Graphics g, java.lang.String graphicsCommand, java.util.Hashtable properties)
    Here's what you get in the hashtable when this callback happens:
    static void main​(java.lang.String[] args)  
    void notifyRenderMusicGlyph​(java.lang.String msg)  

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MusicGlyphRendererTest

      public MusicGlyphRendererTest()
  • Method Details

    • notifyRenderMusicGlyph

      public void notifyRenderMusicGlyph​(java.lang.String msg)
      Specified by:
      notifyRenderMusicGlyph in interface MusicGlyphRendererProxyListener
    • draw

      public void draw​(java.awt.Graphics g, java.lang.String graphicsCommand, java.util.Hashtable properties)
      Description copied from interface: MusicCurveRenderer
      Here's what you get in the hashtable when this callback happens:
          
              STAFF LINES
                      properties.put("zoom", new Double(zoom));
                      properties.put("x1", new Double(drawingAnchor.x));
                      properties.put("y1", new Double(y));
                      properties.put("x2", new Double(drawingAnchor.x + w));
                      properties.put("y2", new Double(y));
                      properties.put("StaffLineIndex", new Double(i));
                      properties.put("staff", this);
              properties.put("selected", isSelected);
                      String graphicsCommand = "StaffLine";
                      
              LEDGER LINES
                      properties.put("zoom", new Double(zoom));
                      properties.put("x1", new Double(xPosLeft));
                      properties.put("y1", new Double(yPos));
                      properties.put("x2", new Double(xPosRight));
                      properties.put("y2", new Double(yPos));
                      properties.put("LedgerLineIndex", new Double(i));
                      properties.put("note", note);
                      String graphicsCommand = "LedgerLine";  
              
          For ties and slurs imagine an arc bounded by a wide flat rectangle
              SLURS
                      properties.put("zoom", new Double(zoom));
                      properties.put("x", new Double(rectX));
                      properties.put("y", new Double(rectY));
                      properties.put("width", new Double(rectWidth));
                      properties.put("height", new Double(rectHeight));
                      properties.put("curvature",  "down" : "up");
                      properties.put("note1", firstNoteOfSlur);
                      properties.put("note2", lastNoteOfSlur);
                      String graphicsCommand = "Slur";
              TIE
              properties.put("zoom", new Double(zoom));
              properties.put("x", new Double(rectX));
              properties.put("y", new Double(rectY));
              properties.put("width", new Double(rectWidth));
              properties.put("height", new Double(rectHeight));
              properties.put("curvature",  "down" : "up");
              properties.put("note1", n1);
              properties.put("note2", n2);
              String graphicsCommand = "Tie";
              
            TIED OUT (when the note is tied to the next but is the last in a system) 
              properties.put("zoom", new Double(zoom));
              properties.put("x", new Double(rectX));
              properties.put("y", new Double(rectY));
              properties.put("height", new Double(rectHeight));
              properties.put("width", new Double(rectWidth));
              properties.put("curvature",  "down" : "up");
              properties.put("note", n1);
              String graphicsCommand = "TieOut";
            
            TIED IN (when the note is tied in from the previous but is the first note in a system) 
                properties.put("zoom", new Double(zoom));
                properties.put("x", new Double(n1.getDrawingAnchor().x));
                properties.put("y", new Double(n1.getDrawingAnchor().y));
                properties.put("height", new Double(rectHeight));
                properties.put("curvature",  "down" : "up");
                properties.put("note", n1);
                String graphicsCommand = "TieIn";
            
            CRESC/DECRESC
                  properties.put("zoom", new Double(zoom));
                  properties.put("x1", new Double(x1));
                  properties.put("x2", new Double(x2));
                  properties.put("y", new Double(y));
                  properties.put("startContinued", new Boolean(startContinued));
                  properties.put("endContinued", new Boolean(endContinued));
                  properties.put("n1", n1);
                  properties.put("n2", n2);
                  String graphicsCommand = "decresc";
                  if (isCresc) {
                      graphicsCommand = "cresc";
                  }
              
             BARLINES
                 properties.put("zoom", new Double(zoom));
                 properties.put("x", new Double(x));
                 properties.put("barTop", new Double(barTop));
                 properties.put("barBottom", new Double(barBottom));
                 properties.put("barThickness", new Double(thickness));
                 properties.put("measure", measure);
                 String graphicsCommand = "barline";
               
             REPEATDOTS
                  properties.put("zoom", new Double(zoom));
                  properties.put("x", new Double(x));
                  properties.put("y", new Double(y));
                  properties.put("levelOfTopLine", new Double(staff.levelOfTopLine()));                
                  properties.put("staff", staff);
                  String graphicsCommand = "RepeatDots";
                  
             GLISS
                  properties.put("zoom", new Double(zoom));
                  properties.put("x1", new Double(fromPoint.getX()));
                  properties.put("y1", new Double(fromPoint.getY()));
                  properties.put("x2", new Double(toPoint.getX()));
                  properties.put("y2", new Double(toPoint.getY()));
                  properties.put("note1", glissOutNote);
                  properties.put("note2", glissInNote);
                  String graphicsCommand = "Gliss";     
                  
             BEAM
                  properties.put("zoom", new Double(zoom));
                  properties.put("x", new Double(xPos));
                  properties.put("y", new Double(beamPositionY));
                  properties.put("width", new Double(rectWidth));
                  properties.put("height", new Double(rectHeight));
                  properties.put("note1", firstnoteOfBeam);
                  properties.put("note2", lastnoteOfBeam == null ? firstnoteOfBeam : lastnoteOfBeam);
                  String graphicsCommand = "Beam";
                      
      Specified by:
      draw in interface MusicCurveRenderer
    • main

      public static void main​(java.lang.String[] args)