// ~ Methods ------------------------------------------------------------ @Override public void onEvent(UserEvent event) { try { // Ignore RELEASING if (event.movement == MouseMovement.RELEASING) { return; } if (event instanceof GlyphEvent) { BarsChecker.GlyphContext context = null; GlyphEvent glyphEvent = (GlyphEvent) event; Glyph glyph = glyphEvent.getData(); if (glyph != null) { // Make sure this is a rather vertical stick if (Math.abs(glyph.getInvertedSlope()) <= constants.maxCoTangentForCheck.getValue()) { // Apply a fresh suite context = new BarsChecker.GlyphContext(glyph); applySuite(new BarCheckSuite(), context); return; } } tellObject(null); } } catch (Exception ex) { logger.warn(getClass().getName() + " onEvent error", ex); } }
// ~ Methods ------------------------------------------------------------ // Retrieve the distance with proper staff border @Override protected double getValue(GlyphContext context) { Glyph stick = context.stick; Point2D stop = stick.getStopPoint(VERTICAL); // Which staff area contains the bottom of the stick? StaffInfo staff = staffManager.getStaffAt(stop); // How far are we from the stop of the staff? double staffBottom = staff.getLastLine().yAt(stop.getX()); double dy = sheet.getScale().pixelsToFrac(Math.abs(staffBottom - stop.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.botStaff = context.bottomArea; } 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 ------------------------------------------------------------ // Retrieve the distance with proper staff border @Override protected double getValue(GlyphContext context) { Glyph stick = context.stick; Point2D stop = stick.getStopPoint(VERTICAL); // Which staff area contains the bottom of the stick? StaffInfo staff = staffManager.getStaffAt(stop); // How far are we from the stop of the staff? double staffBottom = staff.getLastLine().yAt(stop.getX()); double dy = sheet.getScale().pixelsToFrac(Math.abs(staffBottom - stop.getY())); return dy; }