Package eu.bandm.music.entities
Class DisplayRhythm
java.lang.Object
eu.bandm.music.entities.DisplayRhythm
- Direct Known Subclasses:
DisplayTablature
Write one or two results of metric-split (= sequence of rational time points and events)
to a graphic output.
Usage: call only constructor (= default constructor) and invoke
paintOneMeasure(Graphics,int,MSplitter.Result,List,MSplitter.Result,List)
.
Most graphic sizes and distances are defined by constants, which can be overridden.
The drawing of stem and notehead is done by a hook method, which can be overridden.-
Field Summary
Modifier and TypeFieldDescriptionprotected int
Vertical height of a tuplet bracket.protected boolean
can be overwritten by subclasses:protected int
distance of the last stem contained in a tuplet-bracket to the end of the bracket.protected int
distance of the first note NOT contained in a tuplet-bracket to the end of the bracket.protected MSplitter.Result
The currently drawn metric split result for the upward stems.protected MSplitter.Result
The currently drawn metric split result for the downard stems.protected int
Used as diametera parameter for prolonation dots.protected int
The space kept clear in the middle of a tuplet bracket for the numeric information.(package private) boolean
Whether to mark half notes by double stem.protected int
Vertical height of a beam (if no feather factor applies)protected int
Vertical shift between two adjacent tuplet bracketsprotected boolean
protected boolean
protected int
Used as radius parameter when drawing note heads (in device coordinates)protected int
X position to put the very first stem, in device coordinatesprotected int
X distance from the virtual start of the next measure to the end of the drawing space, in device coordinatesprotected boolean
protected int
The horizontal size of a beamlet.protected int
Distance from note head to prolongation dot (in device coordinates)protected int
Lowest vertical coordinate, determines the position of "ties".protected int
Vertical shift between adjacent beams (if no feather factor applies)protected int
The lower end of all contra-stems (with feather factor = 1.0) = the vertical bottom of the visually lowest = numerically highest beam.protected int
The visually higher end of all contra-stemlets (which stand above a pause symbol)protected int
Vertical position of contra-note-heads (in device coordinates, for standard note head rendering) = distance from note headto beam in "one-ptich" pure rhythm notation, as done bydraw_headAndStem(java.awt.Graphics2D, boolean, int, int, eu.bandm.music.entities.RationalDuration.DottedBaseDuration, boolean, int)
.protected int
The upper end of all co-stems (with feather factor = 1.0) = the vertical top of the visually highest = numerically lowest beam.protected int
The visually lower end of all co-stemlets (which stand above a pause symbol)protected int
Vertical position of co-note-heads (in device coordinates, for standard note head rendering) = defines distance from note head to beam in "one-ptich" pure rhythm notation, as done bydraw_headAndStem(java.awt.Graphics2D, boolean, int, int, eu.bandm.music.entities.RationalDuration.DottedBaseDuration, boolean, int)
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract int
correctionShift
(boolean is_co, int index) Calculate horizontal shift for avoiding collicions.protected void
draw_headAndStem
(Graphics2D g, boolean is_co, int xpos, int index, RationalDuration.DottedBaseDuration duration, boolean isSound, int stemend_T) Default implementation for conventional CWN noteheads and stems.protected void
draw_pauses
(Graphics2D g, int xpos, RationalDuration.DottedBaseDuration duration, int stemend_T) void
drawNoteHead_1
(Graphics2D gr, int x, int y, int radius) Draw the head of a "whole note".static void
drawNoteHead_2
(Graphics2D gr, int x, int y, int radius) Draw the head of a "half note".static void
drawNoteHead_4
(Graphics2D gr, int x, int y, int radius) Draw the head of a "quarter note".static void
drawPause_1
(Graphics2D gr, int x, int y) Draw a "whole pause", i.e.static void
drawPause_eighth
(Graphics2D gr, int x, int y, int flags) Draw an "eights pause", or "sixteenth", "thirty-second", etc.static void
drawPause_half
(Graphics2D gr, int x, int y) Draw a "half pause", i.e.static void
drawPause_quarter
(Graphics2D gr, int x, int y) Draw a "quarter pause".static void
paintFeatherBeam
(Graphics2D gr, int skip, int draw, double leftX, double leftStart, double leftInc, double leftHeight, double rightX, double rightStart, double rightInc, double rightHeight) Draw one beam or beamlet (or several adjacents with the same lemgth) from a feathered beam aggregate.void
paintOneMeasure
(Graphics gr, int width, MSplitter.Result co_rhythm, @Opt List<Tuple3<Rational, Integer, Double>> co_tempoCurve, MSplitter.Result contra_rhythm, @Opt List<Tuple3<Rational, Integer, Double>> contra_tempoCurve) Central Service Point: Paint the result of a MSplitter call to the given graphics output context.protected void
paintOneMeasureOneVoice
(Graphics2D g, int width, boolean is_co, MSplitter.Result rhythm, @Opt List<Tuple3<Rational, Integer, Double>> tempoCurve) Paints one of the two voices possible in one measure.
-
Field Details
-
OFFSET_LEFT
protected int OFFSET_LEFTX position to put the very first stem, in device coordinates -
OFFSET_RIGHT
protected int OFFSET_RIGHTX distance from the virtual start of the next measure to the end of the drawing space, in device coordinates -
Y_STEMSTART
protected int Y_STEMSTARTVertical position of co-note-heads (in device coordinates, for standard note head rendering) = defines distance from note head to beam in "one-ptich" pure rhythm notation, as done bydraw_headAndStem(java.awt.Graphics2D, boolean, int, int, eu.bandm.music.entities.RationalDuration.DottedBaseDuration, boolean, int)
. -
Y_CONTRA_STEMSTART
protected int Y_CONTRA_STEMSTARTVertical position of contra-note-heads (in device coordinates, for standard note head rendering) = distance from note headto beam in "one-ptich" pure rhythm notation, as done bydraw_headAndStem(java.awt.Graphics2D, boolean, int, int, eu.bandm.music.entities.RationalDuration.DottedBaseDuration, boolean, int)
. -
half_note_by_double_stem
boolean half_note_by_double_stemWhether to mark half notes by double stem. Is used in some tablature styles, where note heads (or sim) do not allow to differentiate between 1/4 ans 1/2 -
Y_BASE
protected int Y_BASELowest vertical coordinate, determines the position of "ties". -
Y_STEMEND
protected int Y_STEMENDThe upper end of all co-stems (with feather factor = 1.0) = the vertical top of the visually highest = numerically lowest beam. -
Y_CONTRA_STEMEND
protected int Y_CONTRA_STEMENDThe lower end of all contra-stems (with feather factor = 1.0) = the vertical bottom of the visually lowest = numerically highest beam. -
Y_STEMLET_START
protected int Y_STEMLET_STARTThe visually lower end of all co-stemlets (which stand above a pause symbol) -
Y_CONTRA_STEMLET_START
protected int Y_CONTRA_STEMLET_STARTThe visually higher end of all contra-stemlets (which stand above a pause symbol) -
NOTEHEADSIZE
protected int NOTEHEADSIZEUsed as radius parameter when drawing note heads (in device coordinates) -
DIA_PROLONGATION_DOT
protected int DIA_PROLONGATION_DOTUsed as diametera parameter for prolonation dots. -
X_DIST_DOTS
protected int X_DIST_DOTSDistance from note head to prolongation dot (in device coordinates) -
BRACKET_X_OFFSET_LAST_STEM
protected int BRACKET_X_OFFSET_LAST_STEMdistance of the last stem contained in a tuplet-bracket to the end of the bracket. -
BRACKET_X_OFFSET_NEXT_STEM
protected int BRACKET_X_OFFSET_NEXT_STEMdistance of the first note NOT contained in a tuplet-bracket to the end of the bracket. -
HALF_BRACKET_LABEL_WIDTH
protected int HALF_BRACKET_LABEL_WIDTHThe space kept clear in the middle of a tuplet bracket for the numeric information. Device coordinates, divided by two. -
WIDTH_SHORT_BEAM
protected int WIDTH_SHORT_BEAMThe horizontal size of a beamlet. -
HEIGHT_BRACKET_LEVEL
protected int HEIGHT_BRACKET_LEVELVertical shift between two adjacent tuplet brackets -
BRACKET_HEIGHT
protected int BRACKET_HEIGHTVertical height of a tuplet bracket. -
HEIGHT_BEAM
protected int HEIGHT_BEAMVertical height of a beam (if no feather factor applies) -
Y_BEAM_DISTANCE
protected int Y_BEAM_DISTANCEVertical shift between adjacent beams (if no feather factor applies) -
bracket_spans_whole_duration
protected boolean bracket_spans_whole_durationcan be overwritten by subclasses: -
pauses_have_stemlets
protected boolean pauses_have_stemlets -
hide_all_brackets
protected boolean hide_all_brackets -
hide_all_numerators
protected boolean hide_all_numerators -
co_rhythm
The currently drawn metric split result for the upward stems. -
contra_rhythm
The currently drawn metric split result for the downard stems.
-
-
Constructor Details
-
DisplayRhythm
public DisplayRhythm()
-
-
Method Details
-
drawNoteHead_1
Draw the head of a "whole note". FIXME LATER replace drawing by putting in GLYPH from some musical font !?!?! -
drawNoteHead_2
Draw the head of a "half note". FIXME LATER replace drawing by putting in GLYPH from some musical font !?!?! -
drawNoteHead_4
Draw the head of a "quarter note". Also used for eighths, etc. FIXME LATER replace drawing by putting in GLYPH from some musical font !?!?! -
drawPause_1
Draw a "whole pause", i.e. a block hanging from a ledger line. FIXME LATER replace drawing by putting in GLYPH from some musical font !?!?! -
drawPause_half
Draw a "half pause", i.e. a block standing on a ledger line. FIXME LATER replace drawing by putting in GLYPH from some musical font !?!?! -
drawPause_quarter
Draw a "quarter pause". FIXME LATER replace drawing by putting in GLYPH from some musical font !?!?! -
drawPause_eighth
Draw an "eights pause", or "sixteenth", "thirty-second", etc. First a slanted line is drawn as the "backbone":/ -5 (Sixteenth) | / | / | / / -2 (Eighth) | / / / (0) | / | | <-- +2 -2 2
To this, the "feathers" are attached, pointing to the left.
FIXME LATER replace drawing by putting in GLYPH from some musical font !?!?!
- Parameters:
gr
- target of the draw commandsx
- where to map the local horizontal "0"y
- where to map the local vertical "0"flags
- number of flags
-
paintOneMeasure
public void paintOneMeasure(Graphics gr, int width, @Opt MSplitter.Result co_rhythm, @Opt @Opt List<Tuple3<Rational, Integer, Double>> co_tempoCurve, @Opt MSplitter.Result contra_rhythm, @Opt @Opt List<Tuple3<Rational, Integer, Double>> contra_tempoCurve) Central Service Point: Paint the result of a MSplitter call to the given graphics output context.- Parameters:
rhythm
- the result of an metric split process, contains all beam and bracket information and references to events (which can be attached to further information.)gr
- instance of Graphics2D}. May come from swing/gui call-back, or be provided explicitly by the user for printing to a graphics file.width
- the width of the graphics into which the rhythm shall fit. The drawing area is assumed to start at x=0, and the constantsOFFSET_RIGHT
andOFFSET_LEFT
will be applied to find the x-pos of the first note/pause and the start of the (imaginary) subsequent measure start. (The HEIGHT is currently fixed to approxY_BASE
+ 5, where the tie arcs start.) FIXMEtempoCurve
- optional sequence of triples: Rational time point of the validity of integer BPM and factor for shrining/enlarging the beam widht and distance. The sequence must be sorted in the first components. At most two tuples with the same first component. The first is the ending state of the arriving beams, the second is the start of the beginning beam. Assert that the list starts at time-point "0/1". Assert that it ends later than measure.
-
correctionShift
protected abstract int correctionShift(boolean is_co, int index) Calculate horizontal shift for avoiding collicions. -
paintOneMeasureOneVoice
protected void paintOneMeasureOneVoice(Graphics2D g, int width, boolean is_co, MSplitter.Result rhythm, @Opt @Opt List<Tuple3<Rational, Integer, Double>> tempoCurve) Paints one of the two voices possible in one measure. -
draw_headAndStem
protected void draw_headAndStem(Graphics2D g, boolean is_co, int xpos, int index, RationalDuration.DottedBaseDuration duration, boolean isSound, int stemend_T) Default implementation for conventional CWN noteheads and stems. Override for different optics. FIXME is_co berücksichtigen !!! -
draw_pauses
protected void draw_pauses(Graphics2D g, int xpos, RationalDuration.DottedBaseDuration duration, int stemend_T) -
paintFeatherBeam
public static void paintFeatherBeam(Graphics2D gr, int skip, int draw, double leftX, double leftStart, double leftInc, double leftHeight, double rightX, double rightStart, double rightInc, double rightHeight) Draw one beam or beamlet (or several adjacents with the same lemgth) from a feathered beam aggregate.- Parameters:
gr
- graphic context for paintingskip
- number of long beams above, when painting beamlets.draw
- number of beams or beamletsleftX
- x coordinate of left end of beamleftStart
- y coordinate where topmost beam of aggregate starts (Attention, in Swing y coordinates grow downward)leftInc
- distance of tops of beams on the left sideleftHeight
- height of all beams/beamlets on the left siderightX
- , rightStart, rightInc, rightHeight: idem
-