Package pythagoras.f

Examples of pythagoras.f.Dimension


        public IDimension psize (AbsoluteLayout layout, Element<?> elem) {
            float fwidth = size.width(), fheight = size.height();
            if (fwidth > 0 && fheight > 0) return size;
            // if either forced width or height is zero, use preferred size in that dimension
            IDimension psize = layout.preferredSize(elem, fwidth, fheight);
            if (fwidth > 0) return new Dimension(fwidth, psize.height());
            else if (fheight > 0) return new Dimension(psize.width(), fheight);
            else return psize;
        }
View Full Code Here


            _pos = pos;
            _stretch = stretch;
        }

        protected Dimension adjust (IDimension pref, Rectangle boundary) {
            Dimension dim = new Dimension(pref);
            if (_stretch) {
                if ((_pos.orient & 1) != 0) {
                    dim.width = boundary.width;
                }
                if ((_pos.orient & 2) != 0) {
View Full Code Here

            }
        }

        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

        public final Background barBG = resolveStyle(BAR_BACKGROUND);
        public final Icon thumbImage = resolveStyle(THUMB_IMAGE);
        public final IPoint thumbOrigin = resolveStyle(THUMB_ORIGIN);

        @Override public Dimension computeSize (float hintX, float hintY) {
            return new Dimension(barWidth + thumbImage.width(),
                                 Math.max(barHeight, thumbImage.height()));
        }
View Full Code Here

            }

            // configure our bar background instance
            if (_barInst != null) _barInst.destroy();
            if (width > 0 && height > 0) {
                _barInst = barBG.instantiate(new Dimension(width-thumbWidth, barHeight));
                _barInst.addTo(layer, _thumbLeft, top + (height - barHeight)/2, 1);
            }

            // finally update the thumb position
            updateThumb();
View Full Code Here

                                  float left, float top, float width, float height) {
        Style.HAlign halign = resolveStyle(elems, Style.HALIGN);
        Metrics m = computeMetrics(elems, width, height);
        float y = top + resolveStyle(elems, Style.VALIGN).offset(m.size.height, height);
        for (int elemIdx = 0, row = 0, size = m.rowBreaks.size(); row < size; ++row) {
            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

        // adjust our maximum width if appropriate
        if (_wrapWidth != null) width = _wrapWidth;

        // 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);
            }
        }
View Full Code Here

        return _columns.length;
    }

    @Override public Dimension computeSize (Container<?> elems, float hintX, float hintY) {
        Metrics m = computeMetrics(elems, hintX, hintY);
        return new Dimension(m.totalWidth(_colgap), m.totalHeight(_rowgap));
    }
View Full Code Here

    /** Simple layout for positioning the menu within the transient {@code Root}. */
    protected static class RootLayout extends Layout
    {
        @Override public Dimension computeSize (Container<?> elems, float hintX, float hintY) {
            return new Dimension(preferredSize(elems.childAt(0), hintX, hintY));
        }
View Full Code Here

     * to update some internal layout state that relies on the width. */
    protected void didUpdateWidth (float oldWidth) {}

    /** Sets the estimated height for entries that are currently not in view. */
    protected void setEstimatedHeight (float height) {
        _estimatedSize = new Dimension(1, height);
        _entriesGroup.invalidate();
    }
View Full Code Here

TOP

Related Classes of pythagoras.f.Dimension

Copyright © 2018 www.massapicom. 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.