use of com.xenoage.zong.core.music.format.Placement in project Zong by Xenoage.
the class DirectionStamper method computePosition.
/**
* Computes the position for the given {@link Direction}
* within the given {@link StaffStamping}.
*/
private SP computePosition(Direction direction, StaffStamping staffStamping, float defaultLP, float defaultLPAbove, float defaultLPBelow) {
Positioning customPos = direction.getPositioning();
MP mp = direction.getMP();
if (mp == null)
// TODO. Happens. But just with offical MusicXML sample Telemann.xml
return SP.sp(0, 0);
float x, lp;
// default positioning
x = notNull(staffStamping.system.getXMmAt(mp.getTime()), 0f) + staffStamping.positionMm.x;
lp = defaultLP;
// custom positioning
if (customPos instanceof Placement) {
Placement placement = (Placement) customPos;
if (placement == Placement.Above)
lp = defaultLPAbove;
else
lp = defaultLPBelow;
} else if (customPos instanceof Position) {
// coordinates
Position pos = (Position) customPos;
if (pos.x != null)
x = pos.x;
x += Position.getRelativeX(pos);
// vertical position
if (pos.y != null)
lp = pos.y;
lp += Position.getRelativeY(pos);
}
return sp(x, lp);
}
Aggregations