// ~ Methods ------------------------------------------------------------ // Retrieve the distance with proper staff border @Override protected double getValue(GlyphContext context) { Glyph stick = context.stick; Point2D start = stick.getStartPoint(VERTICAL); // Which staff area contains the top of the stick? StaffInfo staff = staffManager.getStaffAt(start); // How far are we from the start of the staff? double staffTop = staff.getFirstLine().yAt(start.getX()); double dy = sheet.getScale().pixelsToFrac(Math.abs(staffTop - start.getY())); // Change limits according to rough & partDefining if (rough && context.isPartDefining) { setLowHigh(constants.maxStaffShiftDyLowRough, constants.maxStaffShiftDyHighRough); } else { setLowHigh(constants.maxStaffShiftDyLow, constants.maxStaffShiftDyHigh); } // Side-effect if (dy <= getLow()) { context.topStaff = context.topArea; } return dy; }
// ~ Methods ------------------------------------------------------------ // Retrieve the difference between stick slope and global slope @Override protected double getValue(GlyphContext context) { Glyph stick = context.stick; Point2D start = stick.getStartPoint(VERTICAL); Point2D stop = stick.getStopPoint(VERTICAL); // Beware of sign of stickSlope (it is opposite of globalSlope) double stickSlope = -(stop.getX() - start.getX()) / (stop.getY() - start.getY()); return Math.abs(stickSlope - sheet.getSkew().getSlope()); }
// ~ Methods ------------------------------------------------------------ @Override protected Rectangle getBox(Glyph stick) { Point2D top = stick.getStartPoint(VERTICAL); Rectangle box = new Rectangle( (int) Math.rint(top.getX()), (int) Math.rint(top.getY() - (nHeight / 2)), nWidth, 2 * nHeight); stick.addAttachment("tr", box); return box; }
// ~ Methods ------------------------------------------------------------ // Retrieve the distance with proper staff line @Override protected double getValue(GlyphContext context) { Glyph stick = context.stick; Point2D start = stick.getStartPoint(VERTICAL); // Which staff area contains the top of the stick? StaffInfo staff = staffManager.getStaffAt(start); // How far are we from the start of the staff? double staffTop = staff.getFirstLine().yAt(start.getX()); double dy = sheet.getScale().pixelsToFrac(Math.abs(staffTop - start.getY())); return dy; }
// -------------------// // initializeContext // // -------------------// private void initializeContext(GlyphContext context) { Glyph stick = context.stick; StaffInfo startStaff = staffManager.getStaffAt(stick.getStartPoint(VERTICAL)); StaffInfo stopStaff = staffManager.getStaffAt(stick.getStopPoint(VERTICAL)); // Remember top & bottom areas context.topArea = staffManager.getIndexOf(startStaff); context.bottomArea = staffManager.getIndexOf(stopStaff); // Check whether this stick embraces more than one staff context.isPartDefining = context.topArea != context.bottomArea; // Remember if this is a thick stick context.isThick = isThickBar(stick); }