Search in sources :

Example 26 with Size2f

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

the class TextEditor method computeOptimumSize.

/**
 * Computes the optimum size of this {@link TextEditor} in px.
 */
public Size2f computeOptimumSize() {
    View v = this.getUI().getRootView(this);
    v.setSize(Integer.MAX_VALUE, Integer.MAX_VALUE);
    return new Size2f(v.getPreferredSpan(View.X_AXIS), v.getPreferredSpan(View.Y_AXIS));
}
Also used : Size2f(com.xenoage.utils.math.geom.Size2f) View(javax.swing.text.View)

Example 27 with Size2f

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

the class LayoutFormatReader method readPageLayout.

private void readPageLayout() {
    MxlPageLayout mxlPageLayout = mxlLayout.getPageLayout();
    if (mxlPageLayout == null)
        return;
    Size2f size = PageFormat.Companion.getDefaultValue().getSize();
    // page-width and page-height
    Size2f mxlPageSize = mxlPageLayout.getPageSize();
    if (mxlPageSize != null)
        size = new Size2f(tenthsMm * mxlPageSize.width, tenthsMm * mxlPageSize.height);
    // page-margins
    PageMargins pageMarginsLeft = PageMargins.Companion.getDefaultValue();
    PageMargins pageMarginsRight = PageMargins.Companion.getDefaultValue();
    for (MxlPageMargins mxlMargins : mxlPageLayout.getPageMargins()) {
        PageMargins pageMargins = new PageMargins(tenthsMm * mxlMargins.getLeftMargin(), tenthsMm * mxlMargins.getRightMargin(), tenthsMm * mxlMargins.getTopMargin(), tenthsMm * mxlMargins.getBottomMargin());
        // left, right page or both? default: both
        switch(mxlMargins.getType()) {
            case Both:
                pageMarginsLeft = pageMargins;
                pageMarginsRight = pageMargins;
                break;
            case Odd:
                pageMarginsRight = pageMargins;
                break;
            case Even:
                pageMarginsRight = pageMargins;
                break;
        }
    }
    layoutFormat = new LayoutFormat(new PageFormat(size, pageMarginsLeft), new PageFormat(size, pageMarginsRight));
}
Also used : MxlPageMargins(com.xenoage.zong.musicxml.types.MxlPageMargins) PageMargins(com.xenoage.zong.core.format.PageMargins) PageFormat(com.xenoage.zong.core.format.PageFormat) MxlPageLayout(com.xenoage.zong.musicxml.types.MxlPageLayout) Size2f(com.xenoage.utils.math.geom.Size2f) LayoutFormat.defaultLayoutFormat(com.xenoage.zong.core.format.LayoutFormat.defaultLayoutFormat) LayoutFormat(com.xenoage.zong.core.format.LayoutFormat) MxlPageMargins(com.xenoage.zong.musicxml.types.MxlPageMargins)

Aggregations

Size2f (com.xenoage.utils.math.geom.Size2f)27 Page (com.xenoage.zong.layout.Page)10 PageFormat (com.xenoage.zong.core.format.PageFormat)6 PageMargins (com.xenoage.zong.core.format.PageMargins)5 ScoreFrame (com.xenoage.zong.layout.frames.ScoreFrame)5 Point2f (com.xenoage.utils.math.geom.Point2f)4 Score (com.xenoage.zong.core.Score)4 ScoreDoc (com.xenoage.zong.documents.ScoreDoc)4 Layout (com.xenoage.zong.layout.Layout)4 ScoreLayout (com.xenoage.zong.musiclayout.ScoreLayout)3 ScoreLayoutArea (com.xenoage.zong.musiclayout.layouter.ScoreLayoutArea)3 Target (com.xenoage.zong.musiclayout.layouter.Target)3 LayoutSettings (com.xenoage.zong.musiclayout.settings.LayoutSettings)3 SystemSpacing (com.xenoage.zong.musiclayout.spacing.SystemSpacing)3 AwtCanvas (com.xenoage.zong.renderer.awt.canvas.AwtCanvas)3 SymbolPool (com.xenoage.zong.symbols.SymbolPool)3 Graphics2D (java.awt.Graphics2D)3 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 Context2d (com.google.gwt.canvas.dom.client.Context2d)2