use of com.xenoage.utils.kernel.Range in project Zong by Xenoage.
the class VoltaReader method readToContext.
public void readToContext(Context context) {
MxlStartStopDiscontinue type = mxlEnding.getType();
if (type == MxlStartStopDiscontinue.Start) {
Range range = readEndingRange(mxlEnding.getNumber());
context.openVolta(range, null);
} else if (type == MxlStartStopDiscontinue.Stop || type == MxlStartStopDiscontinue.Discontinue) {
boolean rightHook = (type == MxlStartStopDiscontinue.Stop);
ClosedVolta closedVolta = context.closeVolta(rightHook);
if (closedVolta != null)
context.writeColumnElement(closedVolta.volta, closedVolta.measure);
}
}
use of com.xenoage.utils.kernel.Range in project Zong by Xenoage.
the class VoltaStamper method stamp.
/**
* Creates a {@link VoltaStamping} for the given volta.
*
* The start and end measure may be outside the staff. If the start measure is outside the
* staff, no left hook and no caption is drawn, since the volta is continued.
* If the end measure is outside the staff, no right hook is drawn, since the
* volta is continued in the next system.
*/
public VoltaStamping stamp(Volta volta, StaffStamping staff, FormattedTextStyle textStyle) {
boolean leftHook = true;
boolean rightHook = volta.isRightHook();
boolean caption = true;
// clip start measure to staff
Range systemMeasures = staff.system.getMeasures();
int start = volta.getMP().measure;
if (start < systemMeasures.getStart()) {
start = systemMeasures.getStart();
leftHook = false;
caption = false;
}
// clip end measure to staff
int end = volta.getEndMeasureIndex();
if (end > systemMeasures.getStop()) {
end = systemMeasures.getStop();
rightHook = false;
}
// create stamping
return stampInStaff(volta, start, end, staff, textStyle, caption, leftHook, rightHook);
}
use of com.xenoage.utils.kernel.Range in project Zong by Xenoage.
the class WedgeStamper method stamp.
/**
* Creates a {@link WedgeStamping} for the given {@link Wedge} on the given staff.
* The start and end measure of the wedge may be outside the staff, then the
* wedge is clipped to the staff.
*/
public WedgeStamping stamp(Wedge wedge, StaffStamping staffStamping) {
SystemSpacing system = staffStamping.system;
Range systemMeasures = system.getMeasures();
// musical positions of wedge
MP p1 = MP.getMP(wedge);
MP p2 = MP.getMP(wedge.getWedgeEnd());
// clip start to staff
float x1Mm;
if (p1.measure < systemMeasures.getStart()) {
// begins before staff
x1Mm = system.getMeasureStartAfterLeadingMm(systemMeasures.getStart());
} else {
// begins within staff
x1Mm = system.getXMmAt(p1.getTime());
}
// clip end to staff
float x2Mm;
if (p2.measure > systemMeasures.getStop()) {
// ends after staff
x2Mm = system.getMeasureEndMm(systemMeasures.getStop());
} else {
// ends within staff
x2Mm = system.getXMmAt(p2.getTime());
}
// spread
float d1Is = 0;
float d2Is = 0;
float defaultSpreadIS = 1.5f;
if (wedge.getType() == WedgeType.Crescendo) {
d2Is = (wedge.getSpread() != null ? wedge.getSpread() : defaultSpreadIS);
} else if (wedge.getType() == WedgeType.Diminuendo) {
d1Is = (wedge.getSpread() != null ? wedge.getSpread() : defaultSpreadIS);
}
// custom horizontal position
Position customPos = asPosition(wedge.getPositioning());
float length = x2Mm - x1Mm;
if (customPos != null && customPos.x != null)
x1Mm = customPos.x;
x1Mm += Position.getRelativeX(customPos);
x2Mm = x1Mm + length;
// vertical position
float lp;
if (customPos != null && customPos.y != null)
lp = customPos.y;
else
lp = -6;
lp += Position.getRelativeY(customPos);
return new WedgeStamping(lp, x1Mm, x2Mm, d1Is, d2Is, staffStamping);
}
Aggregations