/** 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); }
/** Draw this object */ public override void draw(IGraphics graphics) { // Draw the notehead graphicShape().draw(graphics, getScreenHotspot()); // Draw extension to the staff as necessary if (_staffStep >= 10) { // Notehead is above the staff, so draw staff line extensions. FinalPoint staffTop = getAnchor().getScreenHotspot(); for (int step = 10; step <= _staffStep; step += 2) { int y = staffTop.y + staffStepOffsetY(step); graphics.DrawLine(staffTop.x - 4, y, staffTop.x + 6, y); } } else if (_staffStep <= -2) { // Notehead is below the staff, so draw staff line extensions. FinalPoint staffTop = getAnchor().getScreenHotspot(); for (int step = -2; step >= _staffStep; step -= 2) { int y = staffTop.y + staffStepOffsetY(step); graphics.DrawLine(staffTop.x - 4, y, staffTop.x + 6, y); } } }
/** Get the hotspot for this object in screen coordinates. */ public FinalPoint getScreenHotspot() { if (_screenHotspot != null) { return(_screenHotspot); } // // Compute the position by locating our start time between the start time // // of the measure start and the start time of the next measure start. // // DEBUG: This all assumes that the measures in each staff of the staff // // system have the same beats in each measure. Maybe check this. // // DEBUG: must compute firstNoteOffset for real! // int firstNoteOffset = 10; // double pixelsPerDuration = // (getParent().getWidth() - firstNoteOffset) / getParent().getDuration().doubleValue(); // _screenHotspot = new FinalPoint // (getParent().getScreenHotspot(), // firstNoteOffset + (int)(_startTime.doubleValue() * pixelsPerDuration), // 0); int position = getParentMeasureStart().getSymbolPosition(_startTime); int x = 10 + (getParentMeasureStart().getWidth() - 10) * position / (getParentMeasureStart().getSymbolCount() - 1); _screenHotspot = new FinalPoint (getParentMeasureStart().getScreenHotspot(), x, 0); return(_screenHotspot); }
/** 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); }
/** Draw this object */ public override void draw(IGraphics graphics) { // This will force the hotspot to be computed if it isn't FinalPoint hotspot = getScreenHotspot(); if (_shape == Shape.G_CLEF) { if (_tags.smallSize()) { _gClefSmall.draw(graphics, hotspot); } else { _gClef.draw(graphics, hotspot); } } else if (_shape == Shape.F_CLEF) { if (_tags.smallSize()) { _fClefSmall.draw(graphics, hotspot); _fClefDot1.draw(graphics, hotspot.x, hotspot.y + 1); _fClefDot2.draw(graphics, hotspot); } else { _fClef.draw(graphics, hotspot); _fClefDot1.draw(graphics, hotspot); _fClefDot2.draw(graphics, hotspot); } } // Debug: must add other shapes }
/** Get the hotspot for this object in screen coordinates. */ public override FinalPoint getScreenHotspot() { if (_screenHotspot != null) { return(_screenHotspot); } int deltaY = 0; Anchored anchor = getAnchor(); AugmentationDot previousDot = getPreviousDot(); if (anchor is Notehead) { // Debug: should ensure that anchor is always a Notehead if (previousDot == null && ((Notehead)anchor).getStaffStep() % 2 == 0) { // Notehead is on a line and this is the first dot, so shift up the dot deltaY = -3; } } if (previousDot == null) { // This is the first dot _screenHotspot = new FinalPoint(anchor.getScreenHotspot(), 5, deltaY); } else { // Shift to the right from the previous dot _screenHotspot = new FinalPoint(previousDot.getScreenHotspot(), 3, deltaY); } return(_screenHotspot); }
/** This is a utility function to return the screen X position of * a left-positioned symbol (as defined by isLeftPositioned()). * This finds the hotspot of the next symbol in the time slice * which isLeftPositioned() (or the hotspot of the time slice itself * if there are no more) and subtracts from its X value * the (measure width - 10) / (the measure symbol count - 1). */ protected int findLeftPositionedX() { FinalPoint nextHotspot = null; for (int i = getIndex() + 1; i < getParentTimeSlice().getMusicSymbolCount(); ++i) { MusicSymbol nextSymbol = getParentTimeSlice().getMusicSymbol(i); if (nextSymbol.isLeftPositionedSymbol()) { nextHotspot = nextSymbol.getScreenHotspot(); break; } } if (nextHotspot == null) { // No next left positioned symbol, so use the time slice nextHotspot = getParentTimeSlice().getScreenHotspot(); } MeasureStartTimeSlice measure = getParentTimeSlice().getParentMeasureStart(); // Note that we know measure.getSymbolCount() is at least one return(nextHotspot.x - (measure.getWidth() - 10) / (measure.getSymbolCount() - 1)); }
/** 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. int width = 0; // DEBUG: maybe look at actual width of a sharp or flat instead of hardcode to 5 if (_standardCode >= 1 && _standardCode <= 7) { // sharps width = 5 * _standardCode; } else if (_standardCode >= 8 && _standardCode <= 14) { // flats width = 5 * (_standardCode - 7); } // DEBUG: need to handle negative standard code // Hotspot is at the left of the key signature _screenHotspot = new FinalPoint (findLeftPositionedX() - width / 2, getParentTimeSlice().getScreenHotspot().y); return(_screenHotspot); }
public override void draw(IGraphics graphics) { // DEBUG: should use shapes instead of drawString and handle cut time, etc. FinalPoint hotspot = getScreenHotspot(); graphics.DrawString("" + _topNumber, hotspot.x, hotspot.y + 10); graphics.DrawString("" + _bottomNumber, hotspot.x, hotspot.y + 20); }
/** Return the origin in screen coordinates of the top staff. */ public FinalPoint getStavesScreenHotspot() { if (_stavesScreenHotspot != null) return _stavesScreenHotspot; _stavesScreenHotspot = new FinalPoint(15, 25); return _stavesScreenHotspot; }
/** Draw this object */ public override void draw(IGraphics graphics) { FinalPoint hotspot = getScreenHotspot(); // The hotspot is defined as the center of the text. // Debug: need to properly compute the screen dimensions of the text. graphics.DrawString (_text, hotspot.x - 3 * _text.Length, hotspot.y + 4); }
/** Return the origin in screen coordinates of the top staff. */ public FinalPoint getStavesScreenHotspot() { if (_stavesScreenHotspot != null) { return(_stavesScreenHotspot); } _stavesScreenHotspot = new FinalPoint(15, 25); return(_stavesScreenHotspot); }
/** Draw this object */ public override void draw(IGraphics graphics) { // This will set _topNotehead and _bottomNotehead if not already set. FinalPoint tip = getScreenHotspot(); if (getTopNotehead() == null) { // No noteheads with a stem so don't even draw a stem. return; } bool stemDown = getStemDown(); if (stemDown) { // Make the up stem go from the top notehead past the bottom notehead // on the left side of the noteheads. graphics.DrawLine(tip.x, tip.y, tip.x, getTopNotehead().getScreenHotspot().y); } else { // Step is up // Make the up stem go from the bottom notehead past the top notehead // on the right side of the noteheads. graphics.DrawLine(tip.x, tip.y, tip.x, getBottomNotehead().getScreenHotspot().y); } if (_tags.numberOfFlags().HasValue) { int numberOfFlags = _tags.numberOfFlags().Value; // Draw flags. // DEBUG: assume there are not also beams. Maybe report an error. int y = tip.y; if (numberOfFlags > 1) { // Leave one flag at the tip, but for multiple, move closer to notehead y += (stemDown ? -3 : 3); } for (int i = 0; i < numberOfFlags; ++i) { if (stemDown) { _stemDownFlag.draw(graphics, tip.x, y); } else { _stemUpFlag.draw(graphics, tip.x, y); } y += (stemDown ? 4 : -4); } } }
/** 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. _screenHotspot = new FinalPoint (findLeftPositionedX(), getParentTimeSlice().getScreenHotspot().y); return _screenHotspot; }
public FinalPoint getScreenHotspot() { // debug: should compute this properly. if (_screenHotspot != null) { return(_screenHotspot); } _screenHotspot = new FinalPoint (getParentSystem().getScreenHotspot(), 0, (int)(getIndex() * getParentSystem().getParentPage().getStaffSpacingY())); return(_screenHotspot); }
/** 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. _screenHotspot = new FinalPoint (findLeftPositionedX(), getParentTimeSlice().getScreenHotspot().y); return(_screenHotspot); }
/** Draw this object */ public override void draw(IGraphics graphics) { // DEBUG: does not deal with barlines next to each other. FinalPoint top = getScreenHotspot(); int bottomY = getBottomY(); graphics.DrawLine(top.x, top.y, top.x, bottomY); if (_type == Type.THICK) { // Thicken by drawing more of the same line to the left graphics.DrawLine(top.x - 1, top.y, top.x - 1, bottomY); graphics.DrawLine(top.x - 2, top.y, top.x - 2, bottomY); } }
/** 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); } // 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 + staffStepOffsetY(_staffStep)); return(_screenHotspot); }
/** 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); }
/** 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); }
public override void draw(IGraphics graphics) { // This will force the hotspot to be computed if it isn't FinalPoint hotspot = getScreenHotspot(); int width = getParentSystem().getWidth(); // Draw the staff lines for (int y = 0; y <= 20; y += 5) { graphics.DrawLine(hotspot.x, hotspot.y + y, hotspot.x + width, hotspot.y + y); } // Draw all time slices. for (int i = 0; i < getMeasureStartCount(); ++i) { getMeasureStart(i).draw(graphics); } }
/** Get the hotspot for this object in screen coordinates. */ public FinalPoint getScreenHotspot() { if (_screenHotspot != null) { return(_screenHotspot); } // Compute the position by locating the start time within the staff duration. // DEBUG: This all assumes that the measures in each staff of the staff // system have the same number of measures. Maybe check this. StaffSystem parentSystem = getParentStaff().getParentSystem(); _screenHotspot = new FinalPoint (getParentStaff().getScreenHotspot(), (int)((_startTime.doubleValue() - parentSystem.getStartTime().doubleValue()) * parentSystem.getWidth() / parentSystem.getDuration().doubleValue()), 0); return(_screenHotspot); }
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); } }
public FinalPoint getScreenHotspot() { // debug: should compute this properly relative to the page. if (_screenHotspot != null) { return(_screenHotspot); } // The staff system has a vertical offset from the stavesHotspot // based on how many total staves there are above this system. int stavesAbove = 0; for (int i = 0; i < getIndex(); ++i) { stavesAbove += getParentPage().getSystem(i).getStaffCount(); } _screenHotspot = new FinalPoint (getParentScore().getStavesScreenHotspot(), 0, (int)(stavesAbove * getParentPage().getStaffSpacingY())); return(_screenHotspot); }
/** Draw this object */ public override void draw(IGraphics graphics) { int multiNodeCount = getMultiNodeCount(); if (multiNodeCount == 0) { // Only the defining Beam draws the beams for all in the multi-node group return; } if (multiNodeCount != 2) { // DEBUG: should handle this case return; } Tie leftNode = getMultiNode(0); Tie rightNode = getMultiNode(1); FinalPoint leftHotspot = leftNode.getAnchor().getScreenHotspot(); FinalPoint rightHotspot = rightNode.getAnchor().getScreenHotspot(); Staff leftNodeParentStaff = leftNode.getParentTimeSlice().getParentMeasureStart().getParentStaff(); if (leftNodeParentStaff != rightNode.getParentTimeSlice().getParentMeasureStart().getParentStaff()) { // The two ends of the tie are on different staves. Assume that // the left end should extend to the end of the staff and that // the right end should have a little continuation from the beginning int endX = leftNodeParentStaff.getParentSystem().getScreenHotspot().x + leftNodeParentStaff.getParentSystem().getWidth() + 10; drawTie(graphics, leftHotspot.x + 3, leftHotspot.y, endX); drawTie(graphics, rightHotspot.x - 12, rightHotspot.y, rightHotspot.x - 3); } else { drawTie(graphics, leftHotspot.x + 3, leftHotspot.y, rightHotspot.x - 3); } }
/** 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); }
/** 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)); } } }
/** Get the hotspot for this object in screen coordinates. */ public override FinalPoint getScreenHotspot() { if (_screenHotspot != null) return _screenHotspot; int deltaY = 0; Anchored anchor = getAnchor(); AugmentationDot previousDot = getPreviousDot(); if (anchor is Notehead) { // Debug: should ensure that anchor is always a Notehead if (previousDot == null && ((Notehead)anchor).getStaffStep() % 2 == 0) // Notehead is on a line and this is the first dot, so shift up the dot deltaY = -3; } if (previousDot == null) // This is the first dot _screenHotspot = new FinalPoint(anchor.getScreenHotspot(), 5, deltaY); else // Shift to the right from the previous dot _screenHotspot = new FinalPoint(previousDot.getScreenHotspot(), 3, deltaY); return _screenHotspot; }
/** 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; }
public FinalPoint getScreenHotspot() { // debug: should compute this properly relative to the page. if (_screenHotspot != null) return _screenHotspot; // The staff system has a vertical offset from the stavesHotspot // based on how many total staves there are above this system. int stavesAbove = 0; for (int i = 0; i < getIndex(); ++i) stavesAbove += getParentPage().getSystem(i).getStaffCount(); _screenHotspot = new FinalPoint (getParentScore().getStavesScreenHotspot(), 0, (int)(stavesAbove * getParentPage().getStaffSpacingY())); return _screenHotspot; }
/** 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. int width = 0; // DEBUG: maybe look at actual width of a sharp or flat instead of hardcode to 5 if (_standardCode >= 1 && _standardCode <= 7) // sharps width = 5 * _standardCode; else if (_standardCode >= 8 && _standardCode <= 14) // flats width = 5 * (_standardCode - 7); // DEBUG: need to handle negative standard code // Hotspot is at the left of the key signature _screenHotspot = new FinalPoint (findLeftPositionedX() - width / 2, getParentTimeSlice().getScreenHotspot().y); return _screenHotspot; }
/** 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; // 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 + staffStepOffsetY(_staffStep)); return _screenHotspot; }
/** 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); }
/** 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; }
/** 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; }
/** Draw this object */ public override void draw(IGraphics graphics) { int multiNodeCount = getMultiNodeCount(); if (multiNodeCount == 0) { // Only the defining Beam draws the beams for all in the multi-node group return; } if (multiNodeCount == 1) { // DEBUG: should handle this case return; } FinalPoint left = getScreenHotspot(); double slope = getSlope(); int maxParts = getMaxParts(); int stemDirection = getStemDirection(); for (int i = 0; i < multiNodeCount; ++i) { Beam beam = getMultiNode(i); Beam previousBeam = null, nextBeam = null; if (i > 0) { previousBeam = getMultiNode(i - 1); } if (i < (multiNodeCount - 1)) { nextBeam = getMultiNode(i + 1); } FinalPoint stemTip = beam.getAnchor().getScreenHotspot(); // Get X and Y for this beam int beamX = stemTip.x; int beamY = (int)(left.y + slope * (beamX - left.x)); // First, extend the stem. graphics.DrawLine(beamX, beamY, stemTip.x, stemTip.y); // For each of the possible parts, draw as needed to the left or right for (int part = 1; part <= maxParts; part++) { if (i > 0) { // Only do parts to left if we are not the leftmost stem if (part <= beam._partsToLeft && part > previousBeam._partsToRight) { // Draw a stub to the left // DEBUG: should make sure this doesn't run into the other stem drawBeam(graphics, beamX, beamY, beamX - 6); } // The case where the beam would extend all the way was handled // by the previousBeam drawing to here. } if (i < (multiNodeCount - 1)) { // Only do parts to right if we are not the rightmost stem if (part <= beam._partsToRight && part > nextBeam._partsToLeft) { // Draw a stub to the right // DEBUG: should make sure this doesn't run into the other stem drawBeam(graphics, beamX, beamY, beamX + 6); } if (part <= beam._partsToRight && part <= nextBeam._partsToLeft) { // Draw beam extended over to the other drawBeam(graphics, beamX, beamY, nextBeam.getAnchor().getScreenHotspot().x); } } beamY += -stemDirection * SPACING; } } }
/** Get the hotspot for this object in screen coordinates. */ public FinalPoint getScreenHotspot() { if (_screenHotspot != null) return _screenHotspot; // Compute the position by locating the start time within the staff duration. // DEBUG: This all assumes that the measures in each staff of the staff // system have the same number of measures. Maybe check this. StaffSystem parentSystem = getParentStaff().getParentSystem(); _screenHotspot = new FinalPoint (getParentStaff().getScreenHotspot(), (int)((_startTime.doubleValue() - parentSystem.getStartTime().doubleValue()) * parentSystem.getWidth() / parentSystem.getDuration().doubleValue()), 0); return _screenHotspot; }
/** 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. */ public override void invalidate() { _multiNodes = null; _screenHotspot = null; _anchor = null; }
public override FinalPoint getScreenHotspot() { if (_screenHotspot != null) return _screenHotspot; if (getParentTimeSlice().getStartTime().getN() == 0) // Usually a Barline is given as the last time slice in a measure, // but this barline is at the time zero time slice in the measure, // so make sure that it appears at the beginning of the whole // measure instead of the place where a note with a time zero // time slice would appear. _screenHotspot = getParentTimeSlice().getParentMeasureStart().getScreenHotspot(); else // Use the hot spot of the time slice. _screenHotspot = getParentTimeSlice().getScreenHotspot(); return _screenHotspot; }
/** This is automatically called after the object is modified to force * this and all child objects to recompute their values when the "get" * method is called for the value. */ public void invalidate() { for (int i = 0; i < getMusicSymbolCount(); ++i) getMusicSymbol(i).invalidate(); _screenHotspot = null; }
/** Get the hotspot for this object in screen coordinates. */ public FinalPoint getScreenHotspot() { if (_screenHotspot != null) return _screenHotspot; // // Compute the position by locating our start time between the start time // // of the measure start and the start time of the next measure start. // // DEBUG: This all assumes that the measures in each staff of the staff // // system have the same beats in each measure. Maybe check this. // // DEBUG: must compute firstNoteOffset for real! // int firstNoteOffset = 10; // double pixelsPerDuration = // (getParent().getWidth() - firstNoteOffset) / getParent().getDuration().doubleValue(); // _screenHotspot = new FinalPoint // (getParent().getScreenHotspot(), // firstNoteOffset + (int)(_startTime.doubleValue() * pixelsPerDuration), // 0); int position = getParentMeasureStart().getSymbolPosition(_startTime); int x = 10 + (getParentMeasureStart().getWidth() - 10) * position / (getParentMeasureStart().getSymbolCount() - 1); _screenHotspot = new FinalPoint (getParentMeasureStart().getScreenHotspot(), x, 0); return _screenHotspot; }
/** 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; }
/** Creates a new FinalPoint with the coordinates of point added to * deltaX and deltaY. */ public FinalPoint(FinalPoint point, int deltaX, int deltaY) : this(point.x + deltaX, point.y + deltaY) { }
/** This is automatically called after the object is modified to force * this and all child objects to recompute their values when the "get" * method is called for the value. */ public void invalidate() { _data.invalidate(); _stavesScreenHotspot = null; }
/** If this is the defining node, return the screen hotspot, computing it if * called for the first time. The screen hotspot for the beam group is * the position of the left end of the beam group at the beam farthest from * the notehead. If not the defining node, return the * anchor hotspot. * Strictly speaking, this is the hotspot of the left end of the beam, which * is not necessarily the defining node. * This also sets _maxParts and other values 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; int multiNodeCount = getMultiNodeCount(); if (multiNodeCount == 0) { // Not the defining node. Just use the anchor's hot spot _screenHotspot = getAnchor().getScreenHotspot(); return _screenHotspot; } if (multiNodeCount == 1) { // This is an unexpected case with the beam on only one stem. _screenHotspot = getAnchor().getScreenHotspot(); return _screenHotspot; } // A beam is either horizontal (if the first and last stem tip are // at the same y value) or slanted with one end of the beam // 5 points higher or lower than the beginning, based on whether // the last stem tip is higher or lower. // Don't assume that this defining node is the leftmost, but do // assume multiNode(0) is leftmost. // Assume the anchor for a beam is the stem whos hotspot is its tip. Point hotspot = getMultiNode(0).getAnchor().getScreenHotspot().newPoint(); FinalPoint rightmost = getMultiNode (multiNodeCount - 1).getAnchor().getScreenHotspot(); if (rightmost.y == hotspot.y) _slope = 0.0; else if (rightmost.y > hotspot.y) _slope = 5.0 / (rightmost.x - hotspot.x); else _slope = -5.0 / (rightmost.x - hotspot.x); // DEBUG: this assumes all stems in the same direction. _stemDirection = ((Stem)getMultiNode(0).getAnchor()).getStemDown() ? 1 : -1; // The Y position along the beam at x is // hotspot.y + _slope * (x - hotspot.x). // Check each stem tip and adjust the hotspot.y as necessary // to make sure the beam does not cross the stem. for (int i = 1; i < multiNodeCount; ++i) { FinalPoint stemTip = getMultiNode(i).getAnchor().getScreenHotspot(); int beamY = (int)(hotspot.y + _slope * (stemTip.x - hotspot.x)); // Note that larger Y is lower on the screen! // _stemDirection > 0 means stems down. if (_stemDirection > 0 && stemTip.y > beamY) hotspot.translate (0, stemTip.y - beamY); else if (_stemDirection < 0 && stemTip.y < beamY) hotspot.translate (0, -(beamY - stemTip.y)); } // Compute _maxParts to be used later. _maxParts = 0; for (int i = 0; i < multiNodeCount; ++i) { Beam beam = getMultiNode(i); if (beam._partsToLeft > _maxParts) _maxParts = beam._partsToLeft; if (beam._partsToRight > _maxParts) _maxParts = beam._partsToRight; } // Move the hotspot to the beam farthest from the notehead. hotspot.translate (0, (_maxParts - 1) * _stemDirection * SPACING); if (_maxParts > 1) // As a special case for 16th notes and higher, move the beams // closer to the notehead. hotspot.translate (0, - _stemDirection * SPACING); _screenHotspot = new FinalPoint (hotspot); return _screenHotspot; }
/** 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. */ public override void invalidate() { _anchor = null; _screenHotspot = null; _noteheads = null; }
/** This is automatically called after the object is modified to force * this and all child objects to recompute their values when the "get" * method is called for the value. */ public void invalidate() { for (int i = 0; i < getTimeSliceCount(); ++i) getTimeSlice(i).invalidate(); _screenHotspot = null; _duration = null; _width = null; _symbolPositioner = null; }
/** 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; }
/** This is automatically called after the object is modified to force * this and all child objects to recompute their values when the "get" * method is called for the value. */ public void invalidate() { for (int i = 0; i < getStaffCount(); ++i) getStaff(i).invalidate(); _screenHotspot = null; _startTime = null; _duration = null; }
public FinalPoint getScreenHotspot() { // debug: should compute this properly. if (_screenHotspot != null) return _screenHotspot; _screenHotspot = new FinalPoint (getParentSystem().getScreenHotspot(), 0, (int)(getIndex() * getParentSystem().getParentPage().getStaffSpacingY())); return _screenHotspot; }
/** This is automatically called after the object is modified to to force * this to recompute all its values when the "get" * method is called for the value. */ public override void invalidate() { _screenHotspot = null; }
/** This is automatically called after the object is modified to force * this and all child objects to recompute their values when the "get" * method is called for the value. */ public void invalidate() { for (int i = 0; i < getMeasureStartCount(); ++i) getMeasureStart(i).invalidate(); _screenHotspot = null; }
/** If this is the defining node, return the screen hotspot, computing it if * called for the first time. The screen hotspot for the beam group is * the position of the left end of the beam group at the beam farthest from * the notehead. If not the defining node, return the * anchor hotspot. * Strictly speaking, this is the hotspot of the left end of the beam, which * is not necessarily the defining node. * This also sets _maxParts and other values 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); } int multiNodeCount = getMultiNodeCount(); if (multiNodeCount == 0) { // Not the defining node. Just use the anchor's hot spot _screenHotspot = getAnchor().getScreenHotspot(); return(_screenHotspot); } if (multiNodeCount == 1) { // This is an unexpected case with the beam on only one stem. _screenHotspot = getAnchor().getScreenHotspot(); return(_screenHotspot); } // A beam is either horizontal (if the first and last stem tip are // at the same y value) or slanted with one end of the beam // 5 points higher or lower than the beginning, based on whether // the last stem tip is higher or lower. // Don't assume that this defining node is the leftmost, but do // assume multiNode(0) is leftmost. // Assume the anchor for a beam is the stem whos hotspot is its tip. Point hotspot = getMultiNode(0).getAnchor().getScreenHotspot().newPoint(); FinalPoint rightmost = getMultiNode(multiNodeCount - 1).getAnchor().getScreenHotspot(); if (rightmost.y == hotspot.y) { _slope = 0.0; } else if (rightmost.y > hotspot.y) { _slope = 5.0 / (rightmost.x - hotspot.x); } else { _slope = -5.0 / (rightmost.x - hotspot.x); } // DEBUG: this assumes all stems in the same direction. _stemDirection = ((Stem)getMultiNode(0).getAnchor()).getStemDown() ? 1 : -1; // The Y position along the beam at x is // hotspot.y + _slope * (x - hotspot.x). // Check each stem tip and adjust the hotspot.y as necessary // to make sure the beam does not cross the stem. for (int i = 1; i < multiNodeCount; ++i) { FinalPoint stemTip = getMultiNode(i).getAnchor().getScreenHotspot(); int beamY = (int)(hotspot.y + _slope * (stemTip.x - hotspot.x)); // Note that larger Y is lower on the screen! // _stemDirection > 0 means stems down. if (_stemDirection > 0 && stemTip.y > beamY) { hotspot.translate(0, stemTip.y - beamY); } else if (_stemDirection < 0 && stemTip.y < beamY) { hotspot.translate(0, -(beamY - stemTip.y)); } } // Compute _maxParts to be used later. _maxParts = 0; for (int i = 0; i < multiNodeCount; ++i) { Beam beam = getMultiNode(i); if (beam._partsToLeft > _maxParts) { _maxParts = beam._partsToLeft; } if (beam._partsToRight > _maxParts) { _maxParts = beam._partsToRight; } } // Move the hotspot to the beam farthest from the notehead. hotspot.translate(0, (_maxParts - 1) * _stemDirection * SPACING); if (_maxParts > 1) { // As a special case for 16th notes and higher, move the beams // closer to the notehead. hotspot.translate(0, -_stemDirection * SPACING); } _screenHotspot = new FinalPoint(hotspot); return(_screenHotspot); }
/** 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. */ public override void invalidate() { _previousDot = null; _anchor = null; _screenHotspot = null; }