Package com.ardor3d.scenegraph

Examples of com.ardor3d.scenegraph.Spatial


                _clipRectangleStore.set(getHudX() + getTotalLeft(), getHudY() + getTotalBottom(), getContentWidth(),
                        getContentHeight());
                renderer.pushClip(_clipRectangleStore);
                needsPop = true;
            }
            Spatial child;
            for (int i = 0, cSize = getNumberOfChildren(); i < cSize; i++) {
                child = getChild(i);
                if (child != null) {
                    child.onDraw(renderer);
                }
            }
            if (needsPop) {
                renderer.popClip();
            }
View Full Code Here


    }

    @Override
    public void fireStyleChanged() {
        super.fireStyleChanged();
        Spatial child;
        for (int i = 0, cSize = getNumberOfChildren(); i < cSize; i++) {
            child = getChild(i);
            if (child != null) {
                if (child instanceof UIComponent) {
                    ((UIComponent) child).fireStyleChanged();
View Full Code Here

        // Grab a list of components, squeezing them down to their min size on the flow axis
        List<UIComponent> comps = Lists.newArrayList();
        List<UIComponent> compsBack = Lists.newArrayList();
        for (int i = 0; i < content.size(); i++) {
            final Spatial spat = content.get(i);
            if (spat instanceof UIComponent) {
                final UIComponent comp = (UIComponent) spat;
                final Rectangle2 rect = comp.getRelativeComponentBounds(storeA);
                final Rectangle2 minRect = comp.getRelativeMinComponentBounds(storeB);
                if (_horizontal) {
                    comp.fitComponentIn(minRect.getWidth(), rect.getHeight());
                } else {
                    comp.fitComponentIn(rect.getWidth(), minRect.getHeight());
                }
                comps.add(comp);
            }
        }

        // if we have components to layout...
        if (!comps.isEmpty()) {

            // Determine how much space we feel we need.
            final int reqSpace = _horizontal ? getSumOfAllWidths(content) : getSumOfAllHeights(content);

            // How much extra space do we have?
            int freeSpace = (_horizontal ? container.getContentWidth() : container.getContentHeight()) - reqSpace;

            int relaxIndex = 0;
            // cycle through until we've given away all of the space
            while ((freeSpace > 0 || relaxIndex == 0) && !comps.isEmpty() && relaxIndex < RowLayout.MAX_RELAX) {
                final int extraPerComp = freeSpace / comps.size();
                while (!comps.isEmpty()) {
                    final UIComponent comp = comps.remove(0);
                    Rectangle2 rect = comp.getRelativeComponentBounds(storeA);
                    final Rectangle2 origRect = storeB.set(rect);
                    if (freeSpace < 0) {
                        freeSpace = 0;
                    }
                    if (_horizontal) {
                        final int height = _expandsVertically ? container.getContentHeight() : rect.getHeight();
                        final int width = (_expandsHorizontally ? extraPerComp : 0) + rect.getWidth();
                        if (height == rect.getHeight() && width == rect.getWidth()) {
                            continue;
                        }

                        comp.fitComponentIn(width, height);
                        rect = comp.getRelativeComponentBounds(storeA);
                        if (Math.abs(rect.getWidth() - width) <= 1) {
                            compsBack.add(comp);
                        }
                        freeSpace -= rect.getWidth() - origRect.getWidth();
                    } else {
                        final int width = _expandsHorizontally ? container.getContentWidth() : rect.getWidth();
                        final int height = (_expandsVertically ? extraPerComp : 0) + rect.getHeight();
                        if (height == rect.getHeight() && width == rect.getWidth()) {
                            continue;
                        }

                        comp.fitComponentIn(width, height);
                        rect = comp.getRelativeComponentBounds(storeA);
                        if (Math.abs(rect.getHeight() - height) <= 1) {
                            compsBack.add(comp);
                        }
                        freeSpace -= rect.getHeight() - origRect.getHeight();
                    }
                }
                final List<UIComponent> compsTemp = comps;
                comps = compsBack;
                compsBack = compsTemp;
                relaxIndex++;
            }

            int x = 0;
            int y = !_expandsVertically && !_horizontal ? container.getContentHeight() - reqSpace : 0;

            // Now, go through children and set proper location.
            for (int i = 0; i < content.size(); i++) {
                final Spatial spat = _horizontal ? content.get(i) : content.get(content.size() - i - 1);

                if (!(spat instanceof UIComponent)) {
                    continue;
                }
                final UIComponent comp = (UIComponent) spat;
View Full Code Here

        super.layout();

        // Make sure all of our visible and non-visible contents are properly resized.
        if (_contents != null) {
            for (int x = 0, max = _contents.size(); x < max; x++) {
                final Spatial child = _contents.get(x);
                if (child instanceof UIComponent) {
                    final UIComponent comp = (UIComponent) child;
                    comp.setLocalComponentSize(getViewedComponent().getLocalComponentWidth(), getViewedComponent()
                            .getLocalComponentHeight());
                    comp.layout();
View Full Code Here

     * @return an array of tabs from our tab panel.
     */
    private ArrayList<UITab> getTabs() {
        final ArrayList<UITab> buttons = new ArrayList<UITab>();
        for (int x = 0, max = _tabsPanel.getNumberOfChildren(); x < max; x++) {
            final Spatial spat = _tabsPanel.getChild(x);
            if (spat instanceof UITab) {
                buttons.add((UITab) spat);
            }
        }
        return buttons;
View Full Code Here

        _records.put(container, new AnchorRecord());

        // go through all children of a container
        for (int x = container.getNumberOfChildren(); --x >= 0;) {
            // set them all to relative position 0,0
            final Spatial child = container.getChild(x);
            if (child instanceof UIComponent) {
                final UIComponent childComp = (UIComponent) child;

                // add an anchor for the component, if missing.
                if (_records.get(childComp) == null) {
View Full Code Here

     */
    @Override
    public void detachAllChildren() {
        if (getNumberOfChildren() > 0) {
            for (int i = getNumberOfChildren() - 1; i >= 0; i--) {
                final Spatial spat = getChild(i);
                if (spat instanceof UIComponent) {
                    remove((UIComponent) spat);
                } else {
                    detachChildAt(i);
                }
View Full Code Here

                return found;
            }
        }

        for (int i = getNumberOfChildren(); --i >= 0;) {
            final Spatial s = getChild(i);
            if (s instanceof UIComponent) {
                final UIComponent comp = (UIComponent) s;
                if (!comp.isVisible()) {
                    continue;
                }
View Full Code Here

     */
    @Override
    public void draw(final Renderer r) {
        r.setOrtho();
        try {
            Spatial child;
            int i, max;
            for (i = 0, max = getNumberOfChildren(); i < max; i++) {
                child = getChild(i);
                if (child != null) {
                    child.onDraw(r);
                }
            }
            if (!_popupMenus.isEmpty()) {
                for (i = 0, max = _popupMenus.size(); i < max; i++) {
                    _popupMenus.get(i).onDraw(r);
View Full Code Here

    @Override
    public void targetChanged(final InteractManager manager) {
        if (_dragging) {
            endDrag(manager);
        }
        final Spatial target = manager.getSpatialTarget();
        if (target != null) {
            _handle.setScale(Math.max(MoveMultiPlanarWidget.MIN_SCALE, target.getWorldBound().getRadius()
                    + target.getWorldTranslation().subtract(target.getWorldBound().getCenter(), _calcVec3A).length()));
        }
        targetDataUpdated(manager);
    }
View Full Code Here

TOP

Related Classes of com.ardor3d.scenegraph.Spatial

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.