Package pythagoras.f

Examples of pythagoras.f.IDimension


        Group sizeCtrl = new Group(AxisLayout.horizontal()).add(new Label("Size:"), width, height);
        final Group group = new Group(new AbsoluteLayout());
        group.layer.add(PlayN.graphics().createImmediateLayer(new ImmediateLayer.Renderer() {
            Point pt = new Point();
            @Override public void render (Surface surface) {
                IDimension size = group.size();
                position.point.get().resolve(size, pt);
                surface.save();
                surface.setFillColor(Colors.BLACK);
                surface.fillRect(pt.x - 2, pt.y - 2, 5, 5);
                surface.restore();
View Full Code Here


        // hide the layer of any child of content that isn't in bounds
        float x = hrange._cpos, y = vrange._cpos, wid = hrange._size, hei = vrange._size;
        float bx = _elementBuffer.width(), by = _elementBuffer.height();
        for (Element<?> child : (Container<?>)content) {
            IDimension size = child.size();
            if (child.isVisible()) child.layer.setVisible(
                child.x() - bx < x + wid && child.x() + size.width() + bx > x &&
                child.y() - by < y + hei && child.y() + size.height() + by > y);
        }
    }
View Full Code Here

    }

    /** Dispatches a {@link Listener#viewChanged()} to listeners. */
    protected void fireViewChanged () {
        if (_lners == null) return;
        IDimension csize = contentSize(), ssize = viewSize();
        for (Listener lner : _lners) {
            lner.viewChanged(csize, ssize);
        }
    }
View Full Code Here

            m.count++;

            // only compute the preferred size for the fixed elements in this pass
            Constraint c = constraint(elem);
            if (!c.stretch) {
                IDimension psize = preferredSize(elem, hintX, hintY);
                float pwidth = psize.width(), pheight = psize.height();
                m.prefWidth += pwidth;
                m.prefHeight += pheight;
                m.maxWidth = Math.max(m.maxWidth, pwidth);
                m.maxHeight = Math.max(m.maxHeight, pheight);
                m.fixWidth += pwidth;
                m.fixHeight += pheight;
            } else {
                m.stretchers++;
                m.totalWeight += c.weight;
            }
        }

        // now compute the preferred size for the stretched elements, providing them with more
        // accurate width/height hints
        for (Element<?> elem : elems) {
            if (!elem.isVisible()) continue;
            Constraint c = constraint(elem);
            if (!c.stretch) continue;

            // the first argument to computeSize is not used for stretched elements
            float availX = hintX - m.gaps(_gap), availY = hintY - m.gaps(_gap);
            float ehintX = vert ? availX : c.computeSize(0, m.totalWeight, availX - m.fixWidth);
            float ehintY = vert ? c.computeSize(0, m.totalWeight, availY - m.fixHeight) : availY;
            IDimension psize = preferredSize(elem, ehintX, ehintY);
            float pwidth = psize.width(), pheight = psize.height();
            m.unitWidth = Math.max(m.unitWidth, pwidth / c.weight);
            m.unitHeight = Math.max(m.unitHeight, pheight / c.weight);
            m.maxWidth = Math.max(m.maxWidth, pwidth);
            m.maxHeight = Math.max(m.maxHeight, pheight);
        }
View Full Code Here

            float stretchHeight = Math.max(0, height - m.gaps(_gap) - m.fixHeight);
            float y = top + ((m.stretchers > 0) ? 0 :
                             valign.offset(m.fixHeight + m.gaps(_gap), height));
            for (Element<?> elem : elems) {
                if (!elem.isVisible()) continue;
                IDimension psize = preferredSize(elem, width, height); // will be cached
                Constraint c = constraint(elem);
                float ewidth = _offPolicy.computeSize(psize.width(), m.maxWidth, width);
                float eheight = c.computeSize(psize.height(), m.totalWeight, stretchHeight);
                setBounds(elem, left + halign.offset(ewidth, width), y, ewidth, eheight);
                y += (eheight + _gap);
            }
        }
View Full Code Here

            float stretchWidth = Math.max(0, width - m.gaps(_gap) - m.fixWidth);
            float x = left + ((m.stretchers > 0) ? 0 :
                              halign.offset(m.fixWidth + m.gaps(_gap), width));
            for (Element<?> elem : elems) {
                if (!elem.isVisible()) continue;
                IDimension psize = preferredSize(elem, width, height); // will be cached
                Constraint c = constraint(elem);
                float ewidth = c.computeSize(psize.width(), m.totalWeight, stretchWidth);
                float eheight = _offPolicy.computeSize(psize.height(), m.maxHeight, height);
                setBounds(elem, x, top + valign.offset(eheight, height), ewidth, eheight);
                x += (ewidth + _gap);
            }
        }
View Full Code Here

        // report a size large enough to contain all of our elements
        Rectangle bounds = new Rectangle();
        for (Element<?> elem : elems) {
            if (!elem.isVisible()) continue;
            Constraint c = constraint(elem);
            IDimension psize = c.psize(this, elem);
            bounds.add(new Rectangle(c.pos(0, 0, psize), psize));
        }
        return new Dimension(bounds.width, bounds.height);
    }
View Full Code Here

    @Override public void layout (Container<?> elems,
                                  float left, float top, float width, float height) {
        for (Element<?> elem : elems) {
            if (!elem.isVisible()) continue;
            Constraint c = constraint(elem);
            IDimension psize = c.psize(this, elem); // this should return a cached size
            IPoint pos = c.pos(width, height, psize);
            setBounds(elem, left + pos.x(), top + pos.y(), psize.width(), psize.height());
        }
    }
View Full Code Here

        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

        slots.layoutNs(Position.SOUTH, halign, bounds);
        slots.layoutWe(Position.WEST, valign, bounds);
        slots.layoutWe(Position.EAST, valign, bounds);

        Position p = Position.CENTER;
        IDimension dim = slots.size(p, bounds.width, bounds.height);
        if (dim == null) {
            return;
        }

        Constraint c = slots.constraint(p);
        dim = c.adjust(dim, bounds);
        slots.setBounds(p,
            c.align(bounds.x, halign.offset(dim.width(), bounds.width)),
            c.align(bounds.y, valign.offset(dim.height(), bounds.height)), dim);
    }
View Full Code Here

TOP

Related Classes of pythagoras.f.IDimension

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.