org.niffty
Class Notehead

java.lang.Object
  |
  +--org.niffty.HeirarchyNode
        |
        +--org.niffty.MusicSymbol
              |
              +--org.niffty.Notehead
All Implemented Interfaces:
Anchored

public class Notehead
extends MusicSymbol

A Notehead has a shape, staff step, and duration and optional tags: logical or absolute placement, part ID, voice ID, MIDI performance, grace note, cue note, small size, large size, invisible, split stem, silent


Nested Class Summary
static class Notehead.Shape
          A Notehead.Shape has constants for the legal shapes.
 
Field Summary
 
Fields inherited from class org.niffty.MusicSymbol
_tags
 
Constructor Summary
Notehead(Notehead.Shape shape, int staffStep, Rational duration, Tags tags)
          Creates a new Notehead with the given parameters.
 
Method Summary
 void draw(java.awt.Graphics graphics)
          Draw this object
 Rational getDuration()
          Returns the duration RATIONAL
 int getLeftEdge()
          Return the left edge of the shape which is the offset from the screenHotspot().
 int getRightEdge()
          Return the right edge of the shape which is the offset from the screenHotspot().
 FinalPoint getScreenHotspot()
          Override the y position to use the value from staffStepOffsetY from the parent time slice's position at the top of the staff.
 Notehead.Shape getShape()
          Returns the shape.
 int getStaffStep()
          Returns the staff step for the notehead.
 void invalidate()
          This is automatically called after the object is modified to force this to recompute all its values when the "get" method is called for the value.
static int staffStepOffsetY(int staffStep)
          Convert a staff step to vertical offset from hotspot at top of staff.
 java.lang.String toString()
           
 
Methods inherited from class org.niffty.MusicSymbol
findDefaultAnchor, findLeftPositionedX, findMultiNodes, getIndex, getParentTimeSlice, getTags, isLeftPositionedSymbol, nextInstanceOfInScore, previousInstanceOf, previousInstanceOfInScore, previousInstanceOfInStaff
 
Methods inherited from class org.niffty.HeirarchyNode
addChild, getChild, getChildCount, getParentNode, nextInHeirarchy, previousInHeirarchy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Notehead

public Notehead(Notehead.Shape shape,
                int staffStep,
                Rational duration,
                Tags tags)
Creates a new Notehead with the given parameters.

Parameters:
shape - the Shape constant. This must not be null.
staffStep - see getStaffStep()
duration - see getDuration()
tags - the tags for this music symbol. If this is null, then this uses an empty Tags object.
Method Detail

getShape

public Notehead.Shape getShape()
Returns the shape.


getStaffStep

public int getStaffStep()
Returns the staff step for the notehead. The bottom line is 0, 1 is the space above it, 2 is the line above that, etc.


getDuration

public Rational getDuration()
Returns the duration RATIONAL


staffStepOffsetY

public static int staffStepOffsetY(int staffStep)
Convert a staff step to vertical offset from hotspot at top of staff.

Parameters:
staffStep - 0 is the bottom line, 1 is the space above it, 2 is the line above that, etc.
Returns:
the screen offset from the top line. Note that while a greater staff step moves upward on the staff, the return value is in screen coordinates where a greater value moves down the screen.

invalidate

public void invalidate()
This is automatically called after the object is modified to force this to recompute all its values when the "get" method is called for the value.

Overrides:
invalidate in class MusicSymbol

getScreenHotspot

public FinalPoint getScreenHotspot()
Override the y position to use the value from staffStepOffsetY from the parent time slice's position at the top of the staff.

Specified by:
getScreenHotspot in interface Anchored
Overrides:
getScreenHotspot in class MusicSymbol
Returns:
The position of the hotspot in screen coordinates from top-left of screen (not relative to an anchor). This is a FinalPoint and not a Point so that the class can give access to its screen hotspot object knowing that the caller will not modify it. This is more efficient that returning a new Point every time getScreenHotspot() is called.
See Also:
FinalPoint.newPoint()

getRightEdge

public int getRightEdge()
Return the right edge of the shape which is the offset from the screenHotspot().


getLeftEdge

public int getLeftEdge()
Return the left edge of the shape which is the offset from the screenHotspot().


draw

public void draw(java.awt.Graphics graphics)
Draw this object

Overrides:
draw in class MusicSymbol

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object