Examples of IDimension


Examples of pythagoras.f.IDimension

        Dimension computeSize (float hintX, float hintY) {
            int wce = count(WCE);
            Dimension nsSize = new Dimension();
            for (Position pos : NS) {
                IDimension dim = size(pos, hintX, 0);
                if (dim == null) {
                    continue;
                }
                nsSize.height += dim.height();
                nsSize.width = Math.max(nsSize.width, dim.width());
                if (wce > 0) {
                    nsSize.height += vgap;
                }
            }

            float ehintY = Math.max(0, hintY - nsSize.height);
            Dimension weSize = new Dimension();
            for (Position pos : WE) {
                IDimension dim = size(pos, 0, ehintY);
                if (dim == null) {
                    continue;
                }
                weSize.width += dim.width();
                weSize.height = Math.max(weSize.height, dim.height());
            }

            weSize.width += Math.max(wce - 1, 0) * hgap;
            float ehintX = Math.max(0, hintX - weSize.width);

            IDimension csize = size(Position.CENTER, ehintX, ehintY);
            if (csize != null) {
                weSize.width += csize.width();
                nsSize.height += csize.height();
            }
            return new Dimension(
                Math.max(weSize.width, nsSize.width),
                Math.max(weSize.height, nsSize.height));
        }
View Full Code Here

Examples of pythagoras.f.IDimension

                Math.max(weSize.width, nsSize.width),
                Math.max(weSize.height, nsSize.height));
        }

        void layoutNs (Position p, Style.HAlign halign, Rectangle bounds) {
            IDimension dim = size(p, bounds.width, 0);
            if (dim == null) {
                return;
            }
            Constraint c = constraint(p);
            dim = c.adjust(dim, bounds);
            float y = bounds.y;
            if (p == Position.NORTH) {
                bounds.y += dim.height() + vgap;
            } else {
                y += bounds.height - dim.height();
            }
            bounds.height -= dim.height() + vgap;
            setBounds(p, c.align(bounds.x, halign.offset(dim.width(), bounds.width)), y, dim);
        }
View Full Code Here

Examples of pythagoras.f.IDimension

            bounds.height -= dim.height() + vgap;
            setBounds(p, c.align(bounds.x, halign.offset(dim.width(), bounds.width)), y, dim);
        }

        void layoutWe (Position p, Style.VAlign valign, Rectangle bounds) {
            IDimension dim = size(p, 0, bounds.height);
            if (dim == null) {
                return;
            }
            Constraint c = constraint(p);
            dim = c.adjust(dim, bounds);
            float x = bounds.x;
            if (p == Position.WEST) {
                bounds.x += dim.width() + hgap;
            } else {
                x += bounds.width - dim.width();
            }
            bounds.width -= dim.width() + hgap;
            setBounds(p, x, c.align(bounds.y, valign.offset(dim.height(), bounds.height)), dim);
        }
View Full Code Here

Examples of pythagoras.f.IDimension

            Dimension rowSize = m.rows.get(row);
            float x = left + halign.offset(rowSize.width, width);
            for (; elemIdx < m.rowBreaks.get(row).intValue(); ++elemIdx) {
                Element<?> elem = elems.childAt(elemIdx);
                if (!elem.isVisible()) continue;
                IDimension esize = preferredSize(elem, width, height);
                if (_valign == null) {
                    setBounds(elem, x, y, esize.width(), rowSize.height());
                } else {
                    setBounds(elem, x, y + _valign.offset(esize.height(), rowSize.height()),
                        esize.width(), esize.height());
                }
                x += esize.width() + _hgap;
            }
            y += _vgap + rowSize.height;
        }
    }
View Full Code Here

Examples of pythagoras.f.IDimension

        // fill in components horizontally, breaking rows as needed
        Dimension rowSize = new Dimension();
        for (int ii = 0, ll = elems.childCount(); ii < ll; ++ii) {
            Element<?> elem = elems.childAt(ii);
            if (!elem.isVisible()) continue;
            IDimension esize = preferredSize(elem, width, height);
            if (rowSize.width > 0 && width > 0 && rowSize.width + _hgap + esize.width() > width) {
                m.addBreak(ii, rowSize);
                rowSize = new Dimension(esize);
            } else {
                rowSize.width += (rowSize.width > 0 ? _hgap : 0) + esize.width();
                rowSize.height = Math.max(esize.height(), rowSize.height);
            }
        }
        m.addBreak(elems.childCount(), rowSize);
        return m;
    }
View Full Code Here

Examples of pythagoras.f.IDimension

            colWidth += (colspan - 1) * _colgap;

            Column ccfg = _columns[col];
            float rowHeight = m.rowHeights[row];
            if (colWidth > 0 && elem.isVisible()) {
                IDimension psize = preferredSize(elem, 0, 0); // will be cached, hints ignored
                float elemWidth = (colspan > 1 || ccfg._stretch) ? colWidth :
                    Math.min(psize.width(), colWidth);
                float elemHeight = _vstretch ? rowHeight : Math.min(psize.height(), rowHeight);
                setBounds(elem, x + ccfg._halign.offset(elemWidth, colWidth),
                          y + _rowVAlign.offset(elemHeight, rowHeight), elemWidth, elemHeight);
            }
            x += (colWidth + _colgap);
            if ((col += colspan) == columns) {
View Full Code Here

Examples of pythagoras.f.IDimension

        // compute the preferred size of the fixed columns
        int ii = 0;
        for (Element<?> elem : elems) {
            int col = ii % columns, row = ii / columns;
            if (elem.isVisible() && _columns[col]._weight == 0) {
                IDimension psize = preferredSize(elem, hintX, hintY);
                metrics.rowHeights[row] = Math.max(metrics.rowHeights[row], psize.height());

                // Elements which stretch across multiple columns shouldn't force their first column
                //  to have a large size. Ideally, this should somehow force the sum of the columns
                //  to be as wide as itself.
                if (colspan(elem) == 1) {
                    metrics.columnWidths[col] = Math.max(metrics.columnWidths[col], psize.width());
                }
            }
            ii += colspan(elem);
        }

        // determine the total width needed by the fixed columns, then compute the hint given to
        // free columns based on the remaining space
        float fixedWidth = _colgap*(columns-1); // start with gaps, add fixed col widths
        for (int cc = 0; cc < columns; cc++) fixedWidth += metrics.columnWidths[cc];
        float freeHintX = (hintX - fixedWidth) / freeWeight();

        ii = 0;
        for (Element<?> elem : elems) {
            int col = ii % columns, row = ii / columns;
            if (elem.isVisible() && _columns[col]._weight > 0) {
                // TODO: supply sane y hint?
                IDimension psize = preferredSize(elem, freeHintX, hintY);
                metrics.rowHeights[row] = Math.max(metrics.rowHeights[row], psize.height());
                metrics.columnWidths[col] = Math.max(metrics.columnWidths[col], psize.width());
            }
            ii += colspan(elem);
        }

        return metrics;
View Full Code Here

Examples of pythagoras.f.IDimension

     * Prepares the given {@link Glyph} (or creates a new one if null) that has been prepared to
     * this SizableWidget's {@link #preferredSize}. If that size is 0 in either dimension, a warning
     * is logged and null is returned.
     */
    protected Glyph prepareGlyph (Glyph glyph) {
        IDimension size = preferredSize.get();
        if (size.width() == 0 || size.height() == 0) {
            log.warning("SizableWidget cannot prepare a glyph with a 0 dimension", "size", size);
            return null;
        }

        glyph = glyph == null ? new Glyph(layer) : glyph;
View Full Code Here

Examples of pythagoras.f.IDimension

    /**
     * Sizes this element to its preferred size, computed using the supplied hints.
     */
    public Root pack (float widthHint, float heightHint) {
        IDimension psize = preferredSize(widthHint, heightHint);
        setSize(psize.width(), psize.height());
        return this;
    }
View Full Code Here

Examples of pythagoras.f.IDimension

    /**
     * Sizes this root element to the specified width and its preferred height.
     */
    public Root packToWidth (float width) {
        IDimension psize = preferredSize(width, 0);
        setSize(width, psize.height());
        return this;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.