use of com.xenoage.utils.annotations.MaybeNull in project Zong by Xenoage.
the class MxlLyricFont method read.
@MaybeNull
public static MxlLyricFont read(XmlReader reader) {
String number = reader.getAttribute("number");
String name = reader.getAttribute("name");
MxlFont font = MxlFont.read(reader);
if (number != null || name != null || font != null)
return new MxlLyricFont(number, name, font);
else
return null;
}
use of com.xenoage.utils.annotations.MaybeNull in project Zong by Xenoage.
the class MxlSlurOrTied method read.
@MaybeNull
public static MxlSlurOrTied read(XmlReader reader) {
// element type
MxlElementType elementType = null;
String eName = reader.getElementName();
if (elemNameSlur.equals(eName))
elementType = MxlElementType.Slur;
else if (elemNameTied.equals(eName))
elementType = MxlElementType.Tied;
else
throw reader.dataException("slur or tied expected");
// type
MxlStartStopContinue type = MxlStartStopContinue.read(reader.getAttribute("type"));
if (type == MxlStartStopContinue.Continue && elementType == MxlElementType.Tied)
throw reader.dataException("tied can not be continued");
// other members
Integer number = reader.getAttributeInt("number");
if (elementType == MxlElementType.Slur)
number = notNull(number, defaultNumberForSlur);
MxlPosition position = MxlPosition.read(reader);
MxlPlacement placement = MxlPlacement.read(reader);
MxlBezier bezier = MxlBezier.read(reader);
return new MxlSlurOrTied(elementType, type, number, position, placement, bezier);
}
use of com.xenoage.utils.annotations.MaybeNull in project Zong by Xenoage.
the class DynamicsFinder method getStaffDynamicStartAt.
/**
* Returns the {@link DynamicsType} starting at the given time within the given staff (not a voice),
* or null, if nothing starts here.
*/
@MaybeNull
private DynamicsType getStaffDynamicStartAt(int staff, Time time, DynamicValue currentDynamicValue) {
val measure = score.getMeasure(atMeasure(staff, time.getMeasure()));
// when there is a Wedge (possible with a Dynamic as the start volume), create
// a gradient dynamic, when there is only a Dynamic, create a fixed dynamic
val foundDynamic = (Dynamic) measure.getDirections().get(time.getBeat(), MusicElementType.Dynamic);
val foundWedge = (Wedge) measure.getDirections().get(time.getBeat(), MusicElementType.Wedge);
if (foundWedge != null) {
// gradient
val startDynamicValue = (foundDynamic != null ? foundDynamic.getValue() : currentDynamicValue);
val endDynamicValue = startDynamicValue.getWedgeEndValue(foundWedge.getType());
// can be replaced later, when end dynamic is found
return new GradientDynamics(startDynamicValue, endDynamicValue);
} else if (foundDynamic != null) {
// fixed value
return new FixedDynamics(foundDynamic.getValue());
}
return null;
}
use of com.xenoage.utils.annotations.MaybeNull in project Zong by Xenoage.
the class DynamicsPeriods method get.
/**
* Gets the {@link DynamicsPeriod} for the given position.
* The highest priority has a dynamic in the current voice. If there is none,
* the last dynamic of the part is searched. When there are multiple candidates
* on different staves, the current staff wins.
* @param mp the position where to find the dynamic
* @param repetition the index of the {@link Repetition}
* @param partStaves the staves indices in the part
*/
@MaybeNull
public DynamicsPeriod get(MP mp, int repetition, Range partStaves) {
val time = mp.getTime();
// first, find voice dynamics
val voicePeriods = getVoicePeriods(mp.getStaff(), mp.getVoice(), repetition);
val voicePeriod = getPeriod(voicePeriods, time);
if (voicePeriod != null)
return voicePeriod;
// then, for all staves in the part, look for last period(s) - when there
// is more than one at the same time, prefer the one at the own staff
Time maxStartTime = time;
DynamicsPeriod bestMatch = null;
for (int iStaff : partStaves) {
val staffPeriods = getStaffPeriods(mp.getStaff(), repetition);
val staffPeriod = getPeriod(staffPeriods, time);
int compare = staffPeriod.startTime.compareTo(maxStartTime);
if (staffPeriod != null && compare > 0 || (compare >= 0 && iStaff == mp.getStaff())) {
// new best match
maxStartTime = staffPeriod.startTime;
bestMatch = null;
}
}
return bestMatch;
}
use of com.xenoage.utils.annotations.MaybeNull in project Zong by Xenoage.
the class VoltaGroups method getStateAt.
/**
* Gets information about the volta group over the given measure.
*/
@MaybeNull
public VoltaGroupState getStateAt(int measure) {
val group = getVoltaGroupAt(measure);
val volta = getVoltaAt(measure);
if (volta == null)
return null;
return new VoltaGroupState(group, volta.volta, volta.startMeasure, volta.startMeasure + volta.volta.getLength() - 1);
}
Aggregations