Search in sources :

Example 6 with Rectangle2f

use of com.xenoage.utils.math.geom.Rectangle2f in project Zong by Xenoage.

the class ImageFrameRenderer method paintTransformed.

@Override
protected void paintTransformed(Frame frame, Canvas canvas, RendererArgs args) {
    ImageFrame imageFrame = (ImageFrame) frame;
    String imagePath = imageFrame.getImagePath();
    Rectangle2f rect = getLocalRect(frame);
    canvas.drawImage(rect, imagePath);
}
Also used : ImageFrame(com.xenoage.zong.layout.frames.ImageFrame) Rectangle2f(com.xenoage.utils.math.geom.Rectangle2f)

Example 7 with Rectangle2f

use of com.xenoage.utils.math.geom.Rectangle2f in project Zong by Xenoage.

the class ScoreFrameRenderer method paintTransformed.

@Override
protected void paintTransformed(Frame frame, Canvas canvas, RendererArgs args) {
    Rectangle2f rect = getLocalRect(frame);
    // draw musical elements
    ScoreFrame scoreFrame = (ScoreFrame) frame;
    ScoreFrameLayout scoreLayout = scoreFrame.getScoreFrameLayout();
    if (scoreLayout != null) {
        // the coordinates of the layout elements are relative to the upper left
        // corner, so we have to translate them
        canvas.transformSave();
        canvas.transformTranslate(rect.x1(), rect.y1());
        // get musical stampings, and in interactive mode, also
        // stampings like for playback and selection
        Iterable<Stamping> stampings = (canvas.getDecoration() == CanvasDecoration.Interactive ? scoreLayout.getAllStampings() : scoreLayout.getMusicalStampings());
        // render them
        for (Stamping s : stampings) {
            StampingRenderer.drawAny(s, canvas, args);
        }
        // restore old transformation
        canvas.transformRestore();
    }
}
Also used : Stamping(com.xenoage.zong.musiclayout.stampings.Stamping) ScoreFrame(com.xenoage.zong.layout.frames.ScoreFrame) Rectangle2f(com.xenoage.utils.math.geom.Rectangle2f) ScoreFrameLayout(com.xenoage.zong.musiclayout.ScoreFrameLayout)

Example 8 with Rectangle2f

use of com.xenoage.utils.math.geom.Rectangle2f in project Zong by Xenoage.

the class TextFrameRenderer method paintTransformed.

@Override
protected void paintTransformed(Frame frame, Canvas canvas, RendererArgs args) {
    TextFrame textFrame = (TextFrame) frame;
    Rectangle2f rect = getLocalRect(textFrame);
    canvas.drawText(textFrame.getTextWithLineBreaks(), null, rect.position, false, rect.width());
}
Also used : TextFrame(com.xenoage.zong.layout.frames.TextFrame) Rectangle2f(com.xenoage.utils.math.geom.Rectangle2f)

Example 9 with Rectangle2f

use of com.xenoage.utils.math.geom.Rectangle2f in project Zong by Xenoage.

the class StampingRenderer method drawBoundingShape.

/**
 * Draws the bounding shape of the given stamping, if it is a
 * {@link Rectangle2f}.
 */
public void drawBoundingShape(Stamping stamping, Canvas canvas) {
    if (stamping.getBoundingShape() instanceof Rectangle2f) {
        Rectangle2f r = (Rectangle2f) stamping.getBoundingShape();
        Color ci = Companion.color(0, 0, 255, 100);
        canvas.drawLine(r.nw(), r.ne(), ci, 0.5f);
        canvas.drawLine(r.ne(), r.se(), ci, 0.5f);
        canvas.drawLine(r.se(), r.sw(), ci, 0.5f);
        canvas.drawLine(r.sw(), r.nw(), ci, 0.5f);
    }
}
Also used : Color(com.xenoage.utils.color.Color) Rectangle2f(com.xenoage.utils.math.geom.Rectangle2f)

Example 10 with Rectangle2f

use of com.xenoage.utils.math.geom.Rectangle2f in project Zong by Xenoage.

the class KeySignatureStamping method getBoundingShape.

@Override
public Shape getBoundingShape() {
    if (cachedBoundingShape == null)
        return cachedBoundingShape;
    // compute bounding shape
    int fifth = key.element.getFifths();
    if (fifth == 0)
        return null;
    boolean useSharps = (fifth > 0);
    // create bounding shape
    fifth = Math.abs(fifth);
    float interlineSpace = parentStaff.is;
    for (int i = 0; i < fifth; i++) {
        int linePosition = Companion.getLinePosition(i, useSharps, key.c4Lp, key.minLp);
        Rectangle2f bounds = symbol.getBoundingRect();
        bounds = bounds.scale(interlineSpace);
        bounds = bounds.move(xMm + i * distanceMm * interlineSpace, parentStaff.computeYMm(linePosition));
        if (cachedBoundingShape == null)
            cachedBoundingShape = bounds;
        else
            cachedBoundingShape = cachedBoundingShape.extend(bounds);
    }
    return cachedBoundingShape;
}
Also used : Rectangle2f(com.xenoage.utils.math.geom.Rectangle2f)

Aggregations

Rectangle2f (com.xenoage.utils.math.geom.Rectangle2f)15 Point2f (com.xenoage.utils.math.geom.Point2f)4 Color (com.xenoage.utils.color.Color)2 Stamping (com.xenoage.zong.musiclayout.stampings.Stamping)2 ImageFrame (com.xenoage.zong.layout.frames.ImageFrame)1 ScoreFrame (com.xenoage.zong.layout.frames.ScoreFrame)1 TextFrame (com.xenoage.zong.layout.frames.TextFrame)1 ScoreFrameLayout (com.xenoage.zong.musiclayout.ScoreFrameLayout)1 StaffStamping (com.xenoage.zong.musiclayout.stampings.StaffStamping)1 StampingMock (com.xenoage.zong.musiclayout.stampings.StampingMock)1 StemStamping (com.xenoage.zong.musiclayout.stampings.StemStamping)1 BitmapLine (com.xenoage.zong.musiclayout.stampings.bitmap.BitmapLine)1 BitmapStaff (com.xenoage.zong.musiclayout.stampings.bitmap.BitmapStaff)1 Test (org.junit.Test)1