Exemple #1
0
 protected void AlignBarnumberX()
 {
     if (BarnumberMetrics != null)
     {
         BarnumberMetrics.Move(Metrics.OriginX - BarnumberMetrics.OriginX, 0);
     }
 }
Exemple #2
0
 protected void MoveBarnumberAboveRegionBox(BarnumberMetrics barnumberMetrics, FramedRegionInfoMetrics regionInfoMetrics)
 {
     if (barnumberMetrics != null && regionInfoMetrics != null)
     {
         double padding = Gap * 1.5;
         double shift   = barnumberMetrics.Bottom - regionInfoMetrics.Top + padding;
         barnumberMetrics.Move(0, -shift);
     }
 }
Exemple #3
0
 /// <summary>
 /// This virtual function writes the staff name and barnumber to the SVG file (if they are present).
 /// Overrides write the region info (if present).
 /// The barline itself is drawn when the system (and staff edges) is complete.
 /// </summary>
 public virtual void WriteDrawObjectsSVG(SvgWriter w)
 {
     if (StaffNameMetrics != null)
     {
         StaffNameMetrics.WriteSVG(w);
     }
     if (BarnumberMetrics != null)
     {
         BarnumberMetrics.WriteSVG(w);
     }
 }
Exemple #4
0
        public BarlineMetrics(Graphics graphics, Barline barline, float gap)
            : base()
        {
            _objectType = "barline";
            if (barline.BarlineType == BarlineType.end)
            {
                _left = -gap * 1.7F;
            }
            else
            {
                _left = -gap * 0.5F;
            }
            _originX = 0F;
            _right   = gap / 2F;

            if (graphics != null && barline != null)
            {
                foreach (DrawObject drawObject in barline.DrawObjects)
                {
                    Text text = drawObject as Text;
                    if (text != null)
                    {
                        Debug.Assert(text.TextInfo != null &&
                                     (text is StaffNameText || text is FramedBarNumberText));

                        if (text is StaffNameText)
                        {
                            _staffNameMetrics = new TextMetrics(graphics, null, text.TextInfo);
                            // move the staffname vertically to the middle of this staff
                            Staff staff       = barline.Voice.Staff;
                            float staffheight = staff.Gap * (staff.NumberOfStafflines - 1);
                            float dy          = (staffheight * 0.5F) + (gap * 0.8F);
                            _staffNameMetrics.Move(0F, dy);
                        }
                        else if (text is FramedBarNumberText)
                        {
                            _barnumberMetrics = new BarnumberMetrics(graphics, null, text.TextInfo, text.FrameInfo);
                            //_barnumberMetrics = new TextMetrics(graphics, null, text.TextInfo);
                            // move the bar number above this barline
                            float deltaY = (gap * 6F);
                            _barnumberMetrics.Move(0F, -deltaY);
                        }
                    }
                }
            }
        }
Exemple #5
0
        protected void SetCommonMetrics(Graphics graphics, List <DrawObject> drawObjects)
        {
            StaffMetrics staffMetrics = Voice.Staff.Metrics;

            foreach (DrawObject drawObject in DrawObjects)
            {
                if (drawObject is StaffNameText staffNameText)
                {
                    CSSObjectClass staffClass = CSSObjectClass.staffName;
                    StaffNameMetrics = new StaffNameMetrics(staffClass, graphics, staffNameText.TextInfo);
                    // move the staffname vertically to the middle of this staff
                    double staffheight = staffMetrics.StafflinesBottom - staffMetrics.StafflinesTop;
                    double dy          = (staffheight * 0.5F) + (Gap * 0.8F);
                    StaffNameMetrics.Move(0, dy);
                }
                if (drawObject is FramedBarNumberText framedBarNumberText)
                {
                    BarnumberMetrics = new BarnumberMetrics(graphics, framedBarNumberText.TextInfo, framedBarNumberText.FrameInfo);
                    // move the bar number to its default (=lowest) position above this staff.
                    BarnumberMetrics.Move(0, staffMetrics.StafflinesTop - BarnumberMetrics.Bottom - (Gap * 3));
                }
            }
        }
Exemple #6
0
        public BarlineMetrics(Graphics graphics, Barline barline, float gap)
            : base()
        {
            _objectType = "barline";
            if(barline.BarlineType == BarlineType.end)
                _left = -gap * 1.7F;
            else
                _left = -gap * 0.5F;
            _originX = 0F;
            _right = gap / 2F;

            if(graphics != null && barline != null)
            {
                foreach(DrawObject drawObject in barline.DrawObjects)
                {
                    Text text = drawObject as Text;
                    if(text != null)
                    {
                        Debug.Assert(text.TextInfo != null
                        && (text is StaffNameText || text is FramedBarNumberText));

                        if(text is StaffNameText)
                        {
                            _staffNameMetrics = new TextMetrics(graphics, null, text.TextInfo);
                            // move the staffname vertically to the middle of this staff
                            Staff staff = barline.Voice.Staff;
                            float staffheight = staff.Gap * (staff.NumberOfStafflines - 1);
                            float dy = (staffheight * 0.5F) + (gap * 0.8F);
                            _staffNameMetrics.Move(0F, dy);
                        }
                        else if(text is FramedBarNumberText)
                        {
                            _barnumberMetrics = new BarnumberMetrics(graphics, null, text.TextInfo, text.FrameInfo);
                            //_barnumberMetrics = new TextMetrics(graphics, null, text.TextInfo);
                            // move the bar number above this barline
                            float deltaY = (gap * 6F);
                            _barnumberMetrics.Move(0F, -deltaY);
                        }
                    }
                }
            }
        }
Exemple #7
0
 /// <summary>
 /// If there is a collision between them, move the barnumber above the first duration symbol in the voice.
 /// </summary>
 /// <param name="barnumberMetrics"></param>
 /// <param name="durationSymbolMetrics"></param>
 /// <param name="gap"></param>
 private void RemoveCollision(BarnumberMetrics barnumberMetrics, DurationSymbol durationSymbol, float gap)
 {
     ChordMetrics chordMetrics = durationSymbol.Metrics as ChordMetrics;
     float verticalOverlap = 0F;
     if(chordMetrics != null)
     {
         verticalOverlap = chordMetrics.OverlapHeight(barnumberMetrics, gap);
     }
     RestMetrics restMetrics = durationSymbol.Metrics as RestMetrics;
     if(restMetrics != null)
     {
         verticalOverlap = restMetrics.OverlapHeight(barnumberMetrics, gap);
         if(verticalOverlap > 0)
         {
             // fine tuning
             // compare with the extra padding given to these symbols in the RestMetrics constructor.
             switch(durationSymbol.DurationClass)
             {
                 case DurationClass.breve:
                 case DurationClass.semibreve:
                 case DurationClass.minim:
                 case DurationClass.crotchet:
                 case DurationClass.quaver:
                 case DurationClass.semiquaver:
                     break;
                 case DurationClass.threeFlags:
                     verticalOverlap -= gap;
                     break;
                 case DurationClass.fourFlags:
                     verticalOverlap -= gap * 2F;
                     break;
                 case DurationClass.fiveFlags:
                     verticalOverlap -= gap * 2.5F;
                     break;
             }
         }
     }
     if(verticalOverlap > 0)
         barnumberMetrics.Move(0F, -(verticalOverlap + gap));
 }