Пример #1
0
        /** Get the hotspot for this object in screen coordinates.
         */
        public override FinalPoint getScreenHotspot()
        {
            if (_screenHotspot != null)
            {
                return(_screenHotspot);
            }

            Anchored anchor = getAnchor();

            if (!(anchor is Notehead))
            {
                // We never found a previous Notehead in the TimesSlice, which shouldn't
                //   happen.  Just use whatever anchor was found
                _screenHotspot = anchor.getScreenHotspot();
                return(_screenHotspot);
            }

            Notehead notehead = (Notehead)anchor;
            // Debug: very preliminary.  This does not account for the
            //  possibility of bumping into offset 2nds from the Stem, etc.
            int offsetX = notehead.getLeftEdge() - (graphicShape().getRightEdge() + 3);

            // offsetX should be negative
            _screenHotspot = new FinalPoint(notehead.getScreenHotspot(), offsetX, 0);
            return(_screenHotspot);
        }
Пример #2
0
        /** Return the Y screen coordinate of the bottom of the barline.  The
         * top is getScreenHotspot().  Even though this is private, we always
         * call this function to get the value so that invalidate() and caching
         * work properly.
         */
        private int getBottomY()
        {
            if (_bottomY.HasValue)
            {
                return(_bottomY.Value);
            }

            FinalPoint top = getScreenHotspot();

            // Get the default value.
            // Use staffStepOffsetY to get the position at the bottom of the staff.
            int result = top.y + Notehead.staffStepOffsetY(0);

            // Debug: Does not consider extendsTo, etc.
            if (_extendsTo == ExtendsTo.NEXT_STAFF)
            {
                Staff staff = getParentTimeSlice().getParentMeasureStart().getParentStaff();
                if (staff.getIndex() < staff.getParentSystem().getStaffCount() - 1)
                {
                    // This is not the last staff, so we can extend to the next
                    result =
                        staff.getParentSystem().getStaff(staff.getIndex() + 1).getScreenHotspot().y;
                }
            }

            _bottomY = result;
            return(_bottomY.Value);
        }
Пример #3
0
        /** Override the y position to use the value from staffStepOffsetY
         * from the parent time slice's position at the top of the staff.
         */
        public override FinalPoint getScreenHotspot()
        {
            if (_screenHotspot != null)
            {
                return(_screenHotspot);
            }

            // DEBUG: should handle multi-measure rests
            // DEBUG: should center half and whole rests
            // override the y position to use the value from staffStepOffsetY
            //   from the parent time slice's position at the top of the staff.
            _screenHotspot = new FinalPoint
                                 (getAnchor().getScreenHotspot().x,
                                 getParentTimeSlice().getScreenHotspot().y +
                                 Notehead.staffStepOffsetY(_staffStep));
            return(_screenHotspot);
        }
Пример #4
0
        /** Get the hotspot for this object in screen coordinates.
         */
        public override FinalPoint getScreenHotspot()
        {
            if (_screenHotspot != null)
            {
                return(_screenHotspot);
            }

            // debug: Very preliminary.  Should
            //   take into account the width of this and the previous shape, etc.
            // Use the Y value from staffStepOffsetY
            //   from the parent time slice's position at the top of the staff.
            _screenHotspot = new FinalPoint
                                 (findLeftPositionedX(),
                                 getParentTimeSlice().getScreenHotspot().y +
                                 Notehead.staffStepOffsetY(_staffStep));

            return(_screenHotspot);
        }
Пример #5
0
        public override void draw(IGraphics graphics)
        {
            if (getStaffCount() == 0)
            {
                // Nothing to draw
                return;
            }

            // Debug: should check for multistaff barline tags
            FinalPoint top     = getScreenHotspot();
            int        bottomY =
                getStaff(getStaffCount() - 1).getScreenHotspot().y +
                Notehead.staffStepOffsetY(0);

            graphics.DrawLine(top.x, top.y, top.x, bottomY);

            for (int i = 0; i < getStaffCount(); ++i)
            {
                getStaff(i).draw(graphics);
            }
        }
Пример #6
0
        /** Get the hotspot for this object in screen coordinates.
         *  Note that the hotspot for a Lyric is the center of the text.
         */
        public override FinalPoint getScreenHotspot()
        {
            if (_screenHotspot != null)
            {
                return(_screenHotspot);
            }

            // Debug: Maybe we need to find the lowest notehead, not just the anchor.
            Anchored anchor = getAnchor();
            int      staffStep;

            if (anchor is Notehead)
            {
                staffStep = ((Notehead)anchor).getStaffStep();
            }
            else
            {
                // Not a Notehead, but staffStep will be adjusted below.
                staffStep = 0;
            }

            // Adjust so we put the text below the note
            staffStep -= 6;

            if (staffStep > -8)
            {
                // Note is high enough that we need to keep the text below the staff
                staffStep = -8;
            }

            _screenHotspot = new FinalPoint
                                 (anchor.getScreenHotspot().x,
                                 getParentTimeSlice().getScreenHotspot().y +
                                 Notehead.staffStepOffsetY(staffStep));

            return(_screenHotspot);
        }
Пример #7
0
        /** Draw this object
         */
        public override void draw(IGraphics graphics)
        {
            // Look at the clef we are in and shift the staff step given
            //  by SHARP_STEPS, etc. accordingly.  Use G_CLEF as default.
            int clefStepOffset = 0;

            if (getClefShape() == Clef.Shape.F_CLEF)
            {
                clefStepOffset = -2;
            }
            // DEBUG: add support for clefs other than G clef and F clef.

            FinalPoint hotspot = getScreenHotspot();

            // DEBUG: does not handle negative standard code.
            if (_standardCode >= 1 && _standardCode <= 7)
            {
                // sharps
                for (int i = 0; i < _standardCode; ++i)
                {
                    Accidental._sharp.draw
                        (graphics, hotspot.x + i * 5,
                        hotspot.y + Notehead.staffStepOffsetY(SHARP_STEPS[i] + clefStepOffset));
                }
            }
            else if (_standardCode >= 8 && _standardCode <= 14)
            {
                // flats
                for (int i = 0; i < _standardCode - 7; ++i)
                {
                    Accidental._flat.draw
                        (graphics, hotspot.x + i * 5,
                        hotspot.y + Notehead.staffStepOffsetY(FLAT_STEPS[i] + clefStepOffset));
                }
            }
        }
Пример #8
0
        /** Return the screen hotspot, computing it if called for the first time.
         * This also sets _topNotehead and _bottomNotehead used internally.
         *
         * @return  The position of the hotspot in screen coordinates.
         */
        public override FinalPoint getScreenHotspot()
        {
            if (_screenHotspot != null)
            // We have already computed it
            return _screenHotspot;

              // Set up _topNotehead and _bottomNotehead.
              _topNotehead = null;
              _bottomNotehead = null;
              for (int i = 0; i < getNoteheadCount(); ++i) {
            Notehead notehead = getNotehead(i);

            if (notehead.getShape() == Notehead.Shape.BREVE ||
            notehead.getShape() == Notehead.Shape.WHOLE)
              // Lime has a bug where it defines a stem for these, so ignore
              continue;
            // DEBUG: should also check height of zero as described in the NIFF spec.

            if (_topNotehead == null) {
              // This is the first one, so just initialize and continue.
              _topNotehead = notehead;
              _bottomNotehead = notehead;
              continue;
            }

            int hotspotY = notehead.getScreenHotspot().y;

            if (hotspotY < _topNotehead.getScreenHotspot().y)
              _topNotehead = notehead;
            if (hotspotY > _bottomNotehead.getScreenHotspot().y)
              _bottomNotehead = notehead;
              }

              if (_topNotehead == null) {
            // There will not be a stem.  Just use the anchor's hotspot.
            _screenHotspot = getAnchor().getScreenHotspot();
            return _screenHotspot;
              }

              _stemDown = false;
              if (_tags.logicalPlacement() != null) {
            if (_tags.logicalPlacement().getVertical() == LogicalPlacement.BELOW)
              _stemDown = true;
              }

              // The hotspot is the tip of the stem
              if (_stemDown) {
            // Make the up stem go from the top notehead past the bottom notehead
            //   on the left side of the noteheads.
            // The notehead's hotspot is in the middle of the notehead, so move
            //   to its left, and move down to the bottom of the stem.
            _screenHotspot = new FinalPoint
            (_bottomNotehead.getScreenHotspot(), _bottomNotehead.getLeftEdge(), 16);
              } else {
            // Stem is up
            // Make the up stem go from the bottom notehead past the top notehead
            //   on the right side of the noteheads.
            // The notehead's hotspot is in the middle of the notehead, so move to
            //    its right, and move up to the top of the stem.
            _screenHotspot = new FinalPoint
            (_topNotehead.getScreenHotspot(), _bottomNotehead.getRightEdge(), -16);
              }

              return _screenHotspot;
        }
Пример #9
0
        /** Return the screen hotspot, computing it if called for the first time.
         * This also sets _topNotehead and _bottomNotehead used internally.
         *
         * @return  The position of the hotspot in screen coordinates.
         */
        public override FinalPoint getScreenHotspot()
        {
            if (_screenHotspot != null)
            {
                // We have already computed it
                return(_screenHotspot);
            }

            // Set up _topNotehead and _bottomNotehead.
            _topNotehead    = null;
            _bottomNotehead = null;
            for (int i = 0; i < getNoteheadCount(); ++i)
            {
                Notehead notehead = getNotehead(i);

                if (notehead.getShape() == Notehead.Shape.BREVE ||
                    notehead.getShape() == Notehead.Shape.WHOLE)
                {
                    // Lime has a bug where it defines a stem for these, so ignore
                    continue;
                }
                // DEBUG: should also check height of zero as described in the NIFF spec.

                if (_topNotehead == null)
                {
                    // This is the first one, so just initialize and continue.
                    _topNotehead    = notehead;
                    _bottomNotehead = notehead;
                    continue;
                }

                int hotspotY = notehead.getScreenHotspot().y;

                if (hotspotY < _topNotehead.getScreenHotspot().y)
                {
                    _topNotehead = notehead;
                }
                if (hotspotY > _bottomNotehead.getScreenHotspot().y)
                {
                    _bottomNotehead = notehead;
                }
            }

            if (_topNotehead == null)
            {
                // There will not be a stem.  Just use the anchor's hotspot.
                _screenHotspot = getAnchor().getScreenHotspot();
                return(_screenHotspot);
            }

            _stemDown = false;
            if (_tags.logicalPlacement() != null)
            {
                if (_tags.logicalPlacement().getVertical() == LogicalPlacement.BELOW)
                {
                    _stemDown = true;
                }
            }

            // The hotspot is the tip of the stem
            if (_stemDown)
            {
                // Make the up stem go from the top notehead past the bottom notehead
                //   on the left side of the noteheads.
                // The notehead's hotspot is in the middle of the notehead, so move
                //   to its left, and move down to the bottom of the stem.
                _screenHotspot = new FinalPoint
                                     (_bottomNotehead.getScreenHotspot(), _bottomNotehead.getLeftEdge(), 16);
            }
            else
            {
                // Stem is up
                // Make the up stem go from the bottom notehead past the top notehead
                //   on the right side of the noteheads.
                // The notehead's hotspot is in the middle of the notehead, so move to
                //    its right, and move up to the top of the stem.
                _screenHotspot = new FinalPoint
                                     (_topNotehead.getScreenHotspot(), _bottomNotehead.getRightEdge(), -16);
            }

            return(_screenHotspot);
        }