use of com.xenoage.utils.annotations.MaybeNull in project Zong by Xenoage.
the class MxlDirectionType method read.
/**
* Returns null, if content is unsupported.
*/
@MaybeNull
public static MxlDirectionType read(XmlReader reader) {
MxlDirectionTypeContent content = null;
if (reader.openNextChildElement()) {
String n = reader.getElementName();
switch(// switch for performance
n.charAt(0)) {
case 'c':
if (n.equals(MxlCoda.elemName))
content = MxlCoda.read(reader);
break;
case 'd':
if (n.equals(MxlDynamics.elemName))
content = MxlDynamics.read(reader);
break;
case 'i':
if (n.equals("image"))
content = MxlImage.read(reader);
break;
case 'p':
if (n.equals(MxlPedal.elemName))
content = MxlPedal.read(reader);
break;
case 'm':
if (n.equals(MxlMetronome.elemName))
content = MxlMetronome.read(reader);
break;
case 's':
if (n.equals(MxlSegno.elemName))
content = MxlSegno.read(reader);
break;
case 'w':
if (n.equals(MxlWedge.elemName))
content = MxlWedge.read(reader);
else if (n.equals(MxlWords.elemName))
content = MxlWords.read(reader);
break;
}
reader.closeElement();
}
if (content != null)
return new MxlDirectionType(content);
else
return null;
}
use of com.xenoage.utils.annotations.MaybeNull in project Zong by Xenoage.
the class MxlLyric method read.
/**
* Reads and returns the lyric content of the given element,
* or returns null if unsupported.
*/
@MaybeNull
public static MxlLyric read(XmlReader reader) {
String number = reader.getAttribute("number");
MxlLyricContent content = null;
if (reader.openNextChildElement()) {
String n = reader.getElementName();
if (n.equals("syllabic") || n.equals("text")) {
content = MxlSyllabicText.read(reader);
} else if (n.equals("extend")) {
content = MxlExtend.read();
}
reader.closeElement();
}
if (content != null) {
return new MxlLyric(content, number);
} else {
return null;
}
}
use of com.xenoage.utils.annotations.MaybeNull in project Zong by Xenoage.
the class MxlMetronome method read.
/**
* Returns null, if the given element contains an unsupported metronome type.
*/
@MaybeNull
public static MxlMetronome read(XmlReader reader) {
// attributes
MxlPrintStyle printStyle = MxlPrintStyle.read(reader);
// elements
String sBeatUnit = null;
int dotsCount = 0;
Integer perMinute = null;
while (reader.openNextChildElement()) {
String n = reader.getElementName();
switch(n) {
case "beat-unit":
sBeatUnit = reader.getText();
break;
case "beat-unit-dot":
dotsCount++;
break;
case "per-minute":
perMinute = parseIntegerNull(reader.getText());
break;
}
reader.closeElement();
}
if (sBeatUnit != null && perMinute != null) {
MxlNoteTypeValue beatUnit = MxlNoteTypeValue.read(sBeatUnit);
return new MxlMetronome(beatUnit, dotsCount, perMinute, printStyle);
} else {
return null;
}
}
use of com.xenoage.utils.annotations.MaybeNull in project Zong by Xenoage.
the class PartNameStamper method stamp.
@MaybeNull
public FrameTextStamping stamp(Part part, int firstStaffIndex, List<StaffStamping> systemStaves, Style style) {
StaffStamping firstStaff = systemStaves.get(firstStaffIndex);
StaffStamping lastStaff = systemStaves.get(firstStaffIndex + part.getStavesCount() - 1);
String name = (style == Style.Full ? part.getName() : part.getAbbreviation());
if (name == null || name.length() == 0)
return null;
// in the middle of the staves
float top = firstStaff.positionMm.y;
float bottom = lastStaff.positionMm.y + (lastStaff.linesCount - 1) * lastStaff.is;
FormattedText text = // TODO
Companion.fText(// TODO
name, // TODO
new FormattedTextStyle(firstStaff.is * 2.5f * 2.67f), Alignment.Right);
if (text.getParagraphs().size() == 0)
return null;
// TODO correction of baseline. /3 looks good.
float middle = (top + bottom) / 2 + text.getFirstParagraph().getMetrics().getAscent() / 3;
return new FrameTextStamping(text, new Point2f(firstStaff.positionMm.x - firstStaff.is * 2.5f, middle), // TODO
null);
}
use of com.xenoage.utils.annotations.MaybeNull in project Zong by Xenoage.
the class VoltaGroups method getVoltaAt.
/**
* Gets the {@link Volta} and its start measure over the given measure.
*/
@MaybeNull
public VoltaStartMeasure getVoltaAt(int measure) {
val group = getVoltaGroupAt(measure);
if (group == null)
return null;
VoltaStartMeasure volta = null;
for (val v : group.voltasStartMeasures) {
volta = v;
if (measure < v.startMeasure + v.volta.getLength())
break;
}
return volta;
}
Aggregations