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);
}
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();
}
}
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());
}
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);
}
}
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;
}
Aggregations