Package pythagoras.f

Examples of pythagoras.f.Rectangle


    }

    protected Rectangle getNativeFieldBounds () {
        Insets insets = resolveStyle(Style.BACKGROUND).insets;
        Point screenCoords = Layer.Util.layerToScreen(layer, insets.left(), insets.top());
        return new Rectangle(screenCoords.x, screenCoords.y,
                             _size.width - insets.width(), _size.height - insets.height());
    }
View Full Code Here


     * Computes the total bounds of the layer hierarchy rooted at {@code root}.
     * The returned Rectangle will be in {@code root}'s coordinate system.
     */
    public static Rectangle totalBounds (Layer root) {
        // account for root's origin
        Rectangle r = new Rectangle(root.originX(), root.originY(), 0, 0);
        addBounds(root, root, r, new Point());
        return r;
    }
View Full Code Here

        return elem;
    }

    @Override public Dimension computeSize (Container<?> elems, float hintX, float hintY) {
        // 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) {
        Style.HAlign halign = resolveStyle(elems, Style.HALIGN);
        Style.VAlign valign = resolveStyle(elems, Style.VALIGN);
        Slots slots = new Slots(elems);
        Rectangle bounds = new Rectangle(left, top, width, height);
        slots.layoutNs(Position.NORTH, halign, bounds);
        slots.layoutNs(Position.SOUTH, halign, bounds);
        slots.layoutWe(Position.WEST, valign, bounds);
        slots.layoutWe(Position.EAST, valign, bounds);
View Full Code Here

    /** Tries to place the inner bounds within the outer bounds, such that the inner bounds does
     * not contain the position. */
    protected static boolean avoidPoint (IRectangle outer, Rectangle inner, IRectangle fingerprint)
    {
        Rectangle checkBounds = new Rectangle();
        Rectangle best = new Rectangle(inner);
        float bestDist = Float.MAX_VALUE, edge;

        // confine to the left
        edge = fingerprint.x();
        checkBounds.setBounds(outer.x(), outer.y(), edge - outer.x(), outer.height());
View Full Code Here

        // don't bother if there isn't even enough space
        if (outer.width() <= inner.width() || outer.height() < inner.height()) return bestDist;

        // confine
        Rectangle confined = confine(outer, new Rectangle(inner));

        // check distance and overwrite the best fit if we have a new winner
        float dx = confined.x - inner.x(), dy = confined.y - inner.y();
        float dist = dx * dx + dy * dy;
        if (dist < bestDist) {
View Full Code Here

        /**
         * Optionally confines the menu area to the given screen area. By default the menu is
         * confined by the host's screen area (see {@link MenuHost#getScreenArea()}).
         */
        public Pop inScreenArea (IRectangle area) {
            bounds = new Rectangle(area);
            return this;
        }
View Full Code Here

         */
        public Pop inElement (Element<?> elem) {
            Point tl = Layer.Util.layerToScreen(elem.layer, 0, 0);
            Point br = Layer.Util.layerToScreen(
                elem.layer, elem.size().width(), elem.size().height());
            bounds = new Rectangle(tl.x(), tl.y(), br.x() - tl.x(), br.y() - tl.y());
            return this;
        }
View Full Code Here

            Point tpos = position.getLocation(pop.trigger, pop.pointer);
            Point mpos = origin.resolve(0, 0, width, height, new Point());

            // figure out the best place to put the menu, in screen coordinates; starting with
            // the requested popup position
            Rectangle bounds = new Rectangle(tpos.x - mpos.x, tpos.y - mpos.y, width, height);

            // make sure the menu lies inside the requested bounds if the menu doesn't do
            // that itself
            if (pop.menu.automaticallyConfine()) {
                confine(pop.bounds, bounds);

                // fudge is the number of pixels around the menu that we don't need to avoid
                // TODO: can we get the menu's Background's insets?
                float fudge = 2;

                // TODO: do we need any of this finger avoidance stuff if the popup is not
                // relative to the pointer? E.g. a combo box with its menu off to the right

                // keep the bounds from overlapping the position
                if (bounds.width > fudge * 2 && bounds.height > fudge * 2) {
                    Rectangle ibounds = new Rectangle(bounds);
                    ibounds.grow(-fudge, -fudge);

                    // set up the fingerprint
                    float fingerRadius = touch().hasTouch() ? 10 : 3;
                    IPoint fingerPos = pop.pointer == null ? tpos : pop.pointer;
                    Rectangle fingerBox = new Rectangle(
                        fingerPos.x() - fingerRadius, fingerPos.y() - fingerRadius,
                        fingerRadius * 2, fingerRadius * 2);

                    // try and place the menu so it isn't under the finger
                    if (!avoidPoint(pop.bounds, ibounds, fingerBox)) {
                        log.warning("Oh god, menu doesn't fit", "menu", pop.menu);
                    }
                    bounds.setLocation(ibounds.x() - fudge, ibounds.y() - fudge);
                }
            }

            // save a copy of bounds in screen coordinates
            Rectangle screenBounds = new Rectangle(bounds);

            // relocate to layer coordinates
            bounds.setLocation(Layer.Util.screenToLayer(elems.layer, bounds.x, bounds.y));

            // set the menu bounds
View Full Code Here

     * also not interact with the native widgets within the area.
     * @param area the new area to hide, in screen coordinates, or null to show all */
    public void hideNativeOverlays (IRectangle area) {
        if ((_hidden == null && area == null) ||
                (_hidden != null && _hidden.equals(area))) return;
        _hidden = area == null ? null : new Rectangle(area);
        updateHidden();
    }
View Full Code Here

TOP

Related Classes of pythagoras.f.Rectangle

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.