use of com.xenoage.utils.annotations.MaybeNull in project Zong by Xenoage.
the class DynamicsFinder method getWedgeEndAt.
/**
* Checks, if there is a {@link WedgeEnd} at the given time within the given staff (not a voice).
* If yes, the given open wedge is closed and returned.
*/
@MaybeNull
private GradientDynamics getWedgeEndAt(int staff, Time time, GradientDynamics openWedge) {
val measure = score.getMeasure(atMeasure(staff, time.getMeasure()));
val foundDynamic = (Dynamic) measure.getDirections().get(time.getBeat(), MusicElementType.Dynamic);
val foundWedgeEnd = (WedgeEnd) measure.getDirections().get(time.getBeat(), MusicElementType.WedgeEnd);
if (foundWedgeEnd != null) {
val endDynamicValue = (foundDynamic != null ? foundDynamic.getValue() : openWedge.end);
return new GradientDynamics(openWedge.start, endDynamicValue);
}
return null;
}
use of com.xenoage.utils.annotations.MaybeNull in project Zong by Xenoage.
the class MxlTime method read.
/**
* Returns null, if the time signature is unsupported.
*/
@MaybeNull
public static MxlTime read(XmlReader reader) {
MxlTimeSymbol symbol = MxlTimeSymbol.read(reader);
MxlTimeContent content = null;
if (reader.openNextChildElement()) {
String n = reader.getElementName();
switch(n) {
case "beats":
content = MxlNormalTime.read(reader);
break;
case "senza-misura":
content = MxlSenzaMisura.read();
reader.closeElement();
break;
default:
reader.closeElement();
break;
}
}
if (content != null)
return new MxlTime(content, symbol);
else
return null;
}
use of com.xenoage.utils.annotations.MaybeNull in project Zong by Xenoage.
the class DirectionReader method readPedal.
@MaybeNull
private Pedal readPedal() {
MxlPedal mxlPedal = (MxlPedal) currentMxlDirType;
Pedal.Type type = null;
switch(mxlPedal.getType()) {
case Start:
type = Type.Start;
break;
case Stop:
type = Type.Stop;
break;
default:
return null;
}
Pedal pedal = new Pedal(type);
pedal.setPositioning(readPositioning());
return pedal;
}
use of com.xenoage.utils.annotations.MaybeNull in project Zong by Xenoage.
the class FontInfoReader method read.
/**
* Reads the font from the given element, if it is a {@link MxlPrintStyleContent} element
* and contains font information. The returned font is based on the given default font.
*/
@MaybeNull
public static FontInfo read(Object printStyleElement, FontInfo defaultFont) {
if (false == printStyleElement instanceof MxlPrintStyleContent)
return null;
MxlPrintStyle mxlPrintStyle = ((MxlPrintStyleContent) printStyleElement).getPrintStyle();
MxlFont mxlFont = mxlPrintStyle.getFont();
return new FontInfoReader(mxlFont, defaultFont).read();
}
use of com.xenoage.utils.annotations.MaybeNull in project Zong by Xenoage.
the class OtherReader method readBezierPoint.
@MaybeNull
public static BezierPoint readBezierPoint(MxlPosition mxlPosition, MxlBezier mxlBezier, float tenthsMm, int staffLinesCount, float noteLP, Fraction chordDuration) {
Float px = mxlPosition.getDefaultX();
Float py = mxlPosition.getDefaultY();
Float cx = (mxlBezier != null ? mxlBezier.getBezierX() : null);
Float cy = (mxlBezier != null ? mxlBezier.getBezierY() : null);
SP point = null;
SP control = null;
float halfNoteWidth = getNoteheadWidth(chordDuration) / 2;
if (px != null && py != null) {
float fpx = notNull(px, 0).floatValue();
float fpy = notNull(py, 0).floatValue();
// default-x is relative to left side of note. thus, substract the half width
// of a note (TODO: note type. e.g., whole note is wider)
point = sp((fpx / 10 - halfNoteWidth) * tenthsMm, (staffLinesCount - 1) * 2 + fpy / 10 * 2 - noteLP);
}
if (cx != null && cy != null) {
float fcx = notNull(cx, 0).floatValue();
float fcy = notNull(cy, 0).floatValue();
control = sp((fcx / 10 - halfNoteWidth) * tenthsMm, fcy / 10 * 2);
}
if (point != null || control != null)
return new BezierPoint(point, control);
else
return null;
}
Aggregations