use of com.xenoage.zong.musiclayout.stampings.SystemCursorStamping in project Zong by Xenoage.
the class PlaybackLayouter method createCursorAt.
/**
* Returns a new {@link SystemCursorStamping} at the given {@link Time},
* representing the current playback position, or null if there is none.
*/
public SystemCursorStamping createCursorAt(Time time) {
ScoreFrameLayout frame = scoreLayout.getScoreFrameLayout(time.getMeasure());
if (frame != null) {
StaffStamping topStaff = frame.getStaffStamping(0, time.getMeasure());
StaffStamping bottomStaff = frame.getStaffStamping(scoreLayout.score.getStavesCount() - 1, time.getMeasure());
if (topStaff != null && bottomStaff != null)
return new SystemCursorStamping(topStaff, bottomStaff, frame.getPositionX(time));
}
return null;
}
use of com.xenoage.zong.musiclayout.stampings.SystemCursorStamping in project Zong by Xenoage.
the class SystemCursorRenderer method draw.
/**
* Draws the given {@link SystemCursorStamping} on the given {@link Canvas},
* using the given {@link RendererArgs}.
*/
@Override
public void draw(Stamping stamping, Canvas canvas, RendererArgs args) {
SystemCursorStamping cursor = (SystemCursorStamping) stamping;
float viewScaling = args.targetScaling;
StaffStamping topStaff = cursor.topStaff;
StaffStamping bottomStaff = cursor.bottomStaff;
float x, y1, y2;
x = topStaff.positionMm.x + cursor.xMm;
if (canvas.getFormat() == CanvasFormat.Raster) {
float staffY = topStaff.positionMm.y;
BitmapStaff ss = topStaff.getBitmapInfo().getBitmapStaff(viewScaling);
// top staff: top line
y1 = staffY + ss.getYMm(topStaff.linesCount * 2);
// bottom staff: bottom line
staffY = bottomStaff.positionMm.y;
ss = bottomStaff.getBitmapInfo().getBitmapStaff(viewScaling);
y2 = staffY + ss.getYMm(-2);
} else {
y1 = topStaff.computeYMm(topStaff.linesCount * 2);
y2 = bottomStaff.computeYMm(-2);
}
canvas.drawLine(new Point2f(x, y1), new Point2f(x, y2), Companion.color(50, 50, 230), getCursorWidth(viewScaling));
}
use of com.xenoage.zong.musiclayout.stampings.SystemCursorStamping in project Zong by Xenoage.
the class PlaybackLayouter method setCursorAt.
/**
* Sets a {@link SystemCursorStamping} at the given {@link MP},
* representing the current playback position.
*/
public void setCursorAt(Time time) {
// remove old playback cursors
removePlaybackStampings();
// create new one
SystemCursorStamping cursor = createCursorAt(time);
// find frame
if (cursor != null) {
ScoreFrameLayout frame = scoreLayout.getScoreFrameLayout(time.getMeasure());
frame.setPlaybackStampings(ilist(cursor));
}
}
Aggregations