Search in sources :

Example 1 with FrameTextStamping

use of com.xenoage.zong.musiclayout.stampings.FrameTextStamping 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);
}
Also used : Point2f(com.xenoage.utils.math.geom.Point2f) StaffStamping(com.xenoage.zong.musiclayout.stampings.StaffStamping) FormattedTextStyle(com.xenoage.zong.core.text.FormattedTextStyle) FrameTextStamping(com.xenoage.zong.musiclayout.stampings.FrameTextStamping) FormattedText(com.xenoage.zong.core.text.FormattedText) MaybeNull(com.xenoage.utils.annotations.MaybeNull)

Aggregations

MaybeNull (com.xenoage.utils.annotations.MaybeNull)1 Point2f (com.xenoage.utils.math.geom.Point2f)1 FormattedText (com.xenoage.zong.core.text.FormattedText)1 FormattedTextStyle (com.xenoage.zong.core.text.FormattedTextStyle)1 FrameTextStamping (com.xenoage.zong.musiclayout.stampings.FrameTextStamping)1 StaffStamping (com.xenoage.zong.musiclayout.stampings.StaffStamping)1