use of com.xenoage.zong.musiclayout.notation.chord.ArticulationDisplacement in project Zong by Xenoage.
the class ArticulationsNotator method computeOtherArticulations.
/**
* Creates an {@link ArticulationsNotation} for the given {@link ArticulationType}s
* at the given notehead at the given side. The articulations are always placed
* outside the staff lines. The first one is placed as the innermost articulation,
* the last one as the outermost one.
*/
ArticulationsNotation computeOtherArticulations(List<Articulation> articulations, NoteDisplacement outerNote, VSide side, int staffLinesCount) {
// compute LP of the first articulation:
// if within staff, it must be moved outside
int lp = outerNote.lp + 2 * side.getDir();
if (// within staff
lp >= 0 && lp <= (staffLinesCount - 1) * 2)
lp = (side == VSide.Top ? (staffLinesCount - 1) * 2 + 1 : -1);
// collect displacements
ArticulationDisplacement[] arts = new ArticulationDisplacement[articulations.size()];
for (int i = 0; i < articulations.size(); i++) {
arts[i] = new ArticulationDisplacement(lp + 2 * i * side.getDir(), outerNote.xIs, articulations.get(i).getType());
}
// total height: 1 IS for each articulation
float heightIS = Math.abs(lp - outerNote.lp) / 2;
// create ArticulationsAlignment
return new ArticulationsNotation(arts, heightIS);
}
use of com.xenoage.zong.musiclayout.notation.chord.ArticulationDisplacement in project Zong by Xenoage.
the class ArticulationsNotator method computeSimpleArticulation.
/**
* Creates an {@link ArticulationsNotation} for the given {@link ArticulationType}
* at the given notehead at the given side. If possible, it is placed between
* the staff lines.
*/
ArticulationsNotation computeSimpleArticulation(ArticulationType articulation, NoteDisplacement outerNote, VSide side, int staffLinesCount) {
// compute LP of the articulation: if within staff, it must be
// between the staff lines (LP 1, 3, 5, ...)
int lp = outerNote.lp + 2 * side.getDir();
if (// within staff
lp >= 0 && lp <= (staffLinesCount - 1) * 2 && lp % 2 == 0) {
// on staff line
// move one LP further
lp += side.getDir();
}
// compute ArticulationsAlignment
// 1 IS
float height = 1;
ArticulationDisplacement[] arts = { new ArticulationDisplacement(lp, outerNote.xIs, articulation) };
return new ArticulationsNotation(arts, height);
}
Aggregations