Class DisplayRhythm

java.lang.Object
eu.bandm.music.entities.DisplayRhythm
Direct Known Subclasses:
DisplayTablature

public abstract class DisplayRhythm extends Object
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 Details

    • OFFSET_LEFT

      protected int OFFSET_LEFT
      X position to put the very first stem, in device coordinates
    • OFFSET_RIGHT

      protected int OFFSET_RIGHT
      X distance from the virtual start of the next measure to the end of the drawing space, in device coordinates
    • Y_STEMSTART

      protected int Y_STEMSTART
      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 by draw_headAndStem(java.awt.Graphics2D, boolean, int, int, eu.bandm.music.entities.RationalDuration.DottedBaseDuration, boolean, int).
    • Y_CONTRA_STEMSTART

      protected int Y_CONTRA_STEMSTART
      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 by draw_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_stem
      Whether 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_BASE
      Lowest vertical coordinate, determines the position of "ties".
    • Y_STEMEND

      protected int Y_STEMEND
      The 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_STEMEND
      The 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_START
      The visually lower end of all co-stemlets (which stand above a pause symbol)
    • Y_CONTRA_STEMLET_START

      protected int Y_CONTRA_STEMLET_START
      The visually higher end of all contra-stemlets (which stand above a pause symbol)
    • NOTEHEADSIZE

      protected int NOTEHEADSIZE
      Used as radius parameter when drawing note heads (in device coordinates)
    • DIA_PROLONGATION_DOT

      protected int DIA_PROLONGATION_DOT
      Used as diametera parameter for prolonation dots.
    • X_DIST_DOTS

      protected int X_DIST_DOTS
      Distance from note head to prolongation dot (in device coordinates)
    • BRACKET_X_OFFSET_LAST_STEM

      protected int BRACKET_X_OFFSET_LAST_STEM
      distance 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_STEM
      distance 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_WIDTH
      The 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_BEAM
      The horizontal size of a beamlet.
    • HEIGHT_BRACKET_LEVEL

      protected int HEIGHT_BRACKET_LEVEL
      Vertical shift between two adjacent tuplet brackets
    • BRACKET_HEIGHT

      protected int BRACKET_HEIGHT
      Vertical height of a tuplet bracket.
    • HEIGHT_BEAM

      protected int HEIGHT_BEAM
      Vertical height of a beam (if no feather factor applies)
    • Y_BEAM_DISTANCE

      protected int Y_BEAM_DISTANCE
      Vertical shift between adjacent beams (if no feather factor applies)
    • bracket_spans_whole_duration

      protected boolean bracket_spans_whole_duration
      can 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

      @Opt protected MSplitter.Result co_rhythm
      The currently drawn metric split result for the upward stems.
    • contra_rhythm

      @Opt protected MSplitter.Result contra_rhythm
      The currently drawn metric split result for the downard stems.
  • Constructor Details

    • DisplayRhythm

      public DisplayRhythm()
  • Method Details

    • drawNoteHead_1

      public void drawNoteHead_1(Graphics2D gr, int x, int y, int radius)
      Draw the head of a "whole note". FIXME LATER replace drawing by putting in GLYPH from some musical font !?!?!
    • drawNoteHead_2

      public static void drawNoteHead_2(Graphics2D gr, int x, int y, int radius)
      Draw the head of a "half note". FIXME LATER replace drawing by putting in GLYPH from some musical font !?!?!
    • drawNoteHead_4

      public static void drawNoteHead_4(Graphics2D gr, int x, int y, int radius)
      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

      public static void drawPause_1(Graphics2D gr, int x, int y)
      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

      public static void drawPause_half(Graphics2D gr, int x, int y)
      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

      public static void drawPause_quarter(Graphics2D gr, int x, int y)
      Draw a "quarter pause". FIXME LATER replace drawing by putting in GLYPH from some musical font !?!?!
    • drawPause_eighth

      public static void drawPause_eighth(Graphics2D gr, int x, int y, int flags)
      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 commands
      x - 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 constants OFFSET_RIGHT and OFFSET_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 approx Y_BASE + 5, where the tie arcs start.) FIXME
      tempoCurve - 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 painting
      skip - number of long beams above, when painting beamlets.
      draw - number of beams or beamlets
      leftX - x coordinate of left end of beam
      leftStart - y coordinate where topmost beam of aggregate starts (Attention, in Swing y coordinates grow downward)
      leftInc - distance of tops of beams on the left side
      leftHeight - height of all beams/beamlets on the left side
      rightX - , rightStart, rightInc, rightHeight: idem