use of com.xenoage.zong.core.music.chord.Stem in project Zong by Xenoage.
the class StemReader method read.
/**
* Reads and returns the stem of the given chord.
* If not available, {@link Stem#defaultStem} is returned.
* @param context the global context
* @param chord the chord, whose notes are already collected
* @param staff the staff index of the current chord
*/
public Stem read(Context context, Chord chord, int staff) {
if (mxlStem == null)
return Companion.getDefaultStem();
// direction
StemDirection direction = readStemDirection();
// length
Float length = null;
MxlPosition yPos = mxlStem.getPosition();
if (yPos.getDefaultY() != null) {
// convert position in tenths relative to topmost staff line into
// a length in interline spaces measured from the outermost chord note on stem side
float stemEndLinePosition = convertDefaultYToLP(context, yPos.getDefaultY(), staff);
VSide side = (direction == StemDirection.Up ? VSide.Top : VSide.Bottom);
length = Math.abs(stemEndLinePosition - getOuterNoteLp(context, chord, side, staff)) / 2;
}
// create stem
return new Stem(direction, length);
}
use of com.xenoage.zong.core.music.chord.Stem in project Zong by Xenoage.
the class SingleStemDirector method compute.
public StemDirection compute(Chord chord, MusicContext context) {
// stem specified in chord?
Stem stem = chord.getStem();
if (stem.getDirection() != StemDirection.Default)
return stem.getDirection();
// stem needed?
if (!isStemNeeded(chord))
return StemDirection.None;
// compute default stem
ChordLps chordLp = new ChordLps(chord, context);
int linesCount = context.getLinesCount();
return compute(chordLp, linesCount);
}
Aggregations