Example usage for com.badlogic.gdx.math Rectangle setHeight

List of usage examples for com.badlogic.gdx.math Rectangle setHeight

Introduction

In this page you can find the example usage for com.badlogic.gdx.math Rectangle setHeight.

Prototype

public Rectangle setHeight(float height) 

Source Link

Document

Sets the height of this rectangle

Usage

From source file:com.bitfire.postprocessing.demo.TopPanelAnimator.java

License:Apache License

private void showing(float elapsed) {
    if (hotZone.isIn) {
        if (elapsed > InHotZoneSecondsBeforeShowing) {
            setState(State.Idle);

            panel.addAction(Actions.moveTo(panel.getX(), yShow, 0.5f, Interpolation.exp10));
            panel.addAction(Actions.alpha(1f, 0.5f, Interpolation.exp10));

            // resize hotzone rect to let the user move in the whole area
            Rectangle hz = hotZone.getHotZone();
            hz.setHeight(openedHotZoneHeight);
            hotZone.setHotZone(hz);/*from w  ww.  j  a v  a2s.  co  m*/

            // Gdx.app.log( "PanelAnimator", "Start showing" );
        }
    } else {
        setState(State.Idle);
        // Gdx.app.log( "PanelAnimator", "Show canceled." );
    }
}

From source file:com.bitfire.postprocessing.demo.TopPanelAnimator.java

License:Apache License

private void hiding(float elapsed) {
    if (!hotZone.isIn) {
        if (elapsed > OutHotZoneSecondsBeforeHiding) {
            setState(State.Idle);

            panel.addAction(Actions.moveTo(panel.getX(), yHidden, 0.5f, Interpolation.exp10));
            panel.addAction(Actions.alpha(0.5f, 0.5f, Interpolation.exp10));

            // restore original hotzone height
            Rectangle hz = hotZone.getHotZone();
            hz.setHeight(closedHotZoneHeight);
            hotZone.setHotZone(hz);/*from   w w  w.  j  ava 2  s. c  o  m*/

            // Gdx.app.log( "PanelAnimator", "Start hiding" );
        }
    } else {
        setState(State.Idle);
        // Gdx.app.log( "PanelAnimator", "Hide canceled." );
    }
}

From source file:com.forerunnergames.peril.client.ui.widgets.messagebox.DefaultMessageBox.java

License:Open Source License

public DefaultMessageBox(final MessageBoxStyle style, final WidgetFactory widgetFactory) {
    Arguments.checkIsNotNull(style, "style");
    Arguments.checkIsNotNull(widgetFactory, "widgetFactory");

    this.style = style;
    this.widgetFactory = widgetFactory;

    table = new Table();

    configureTable();//from   w  ww . j  a  v  a  2  s  . c  o  m

    scrollPane = new ScrollPane(table,
            widgetFactory.createScrollPaneStyle(style.getScrollPaneStyle(), style.getScrollbarStyle())) {
        private final int scissorsDeltaY = 2 + DefaultMessageBox.this.style.getScrollPaddingBottom();
        private final int scissorsDeltaHeight = 1 - DefaultMessageBox.this.style.getScrollPaddingTop()
                - DefaultMessageBox.this.style.getScrollPaddingBottom();

        @Override
        protected void drawChildren(final Batch batch, final float parentAlpha) {
            final Rectangle scissors = ScissorStack.popScissors();
            scissors.setY(scissors.getY() + scissorsDeltaY);
            scissors.setHeight(scissors.getHeight() + scissorsDeltaHeight);
            ScissorStack.pushScissors(scissors);
            super.drawChildren(batch, parentAlpha);
        }
    };

    scrollPane.setOverscroll(false, false);
    scrollPane.setFlickScroll(true);
    scrollPane.setForceScroll(false, style.areScrollbarsRequired());
    scrollPane.setFadeScrollBars(false);
    scrollPane.setScrollingDisabled(true, false);
    scrollPane.setScrollBarPositions(true, true);
    scrollPane.setScrollbarsOnTop(false);
    scrollPane.setSmoothScrolling(true);
    scrollPane.setVariableSizeKnobs(true);

    scrollPane.addListener(new InputListener() {
        @Override
        public void enter(final InputEvent event, final float x, final float y, final int pointer,
                final Actor fromActor) {
            if (scrollPane.getStage() == null)
                return;

            scrollPane.getStage().setScrollFocus(scrollPane);
        }

        @Override
        public void exit(final InputEvent event, final float x, final float y, final int pointer,
                final Actor toActor) {
            if (scrollPane.getStage() == null)
                return;

            scrollPane.getStage().setScrollFocus(null);
        }
    });
}

From source file:com.laex.cg2d.screeneditor.ScreenEditor.java

License:Open Source License

/**
 * Sets the up entity resource listener.
 *
 * @param input the new up entity resource listener
 * @throws CoreException the core exception
 *//*from   ww  w . j  a  va  2 s .  co m*/
private void setupEntityResourceListener(final IEditorInput input) throws CoreException {
    ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceListener,
            IResourceChangeEvent.POST_CHANGE | IResourceChangeEvent.PRE_DELETE);
    // if there are any changes in the entities, load em up in the editor

    resourceListener.addEntityChangeListener(new EntityChangeListener() {
        @Override
        public void entityChanged(final IResource resource) {
            /*
             * It is important to execute pallete creation safely because it
             * accesses GEF UI thread
             */
            SafeRunnable.run(new ISafeRunnable() {

                @Override
                public void run() throws Exception {
                    // Check if the resource is valid entity or not.
                    String entityPath = resource.getFullPath().toOSString();
                    Entity e = EntityManager.entityManager().findEntity(entityPath);

                    boolean isValid = ModelValidatorFactory.getValidator(Entity.class, e).isValid();

                    if (!isValid) {
                        removeDeletedOrInvalidEntities(resource);
                        return;
                    }

                    /*
                     * Recompute the frame for entities that might have changed
                     * Essentially, were re-creating a new shape by copying the old one.
                     * Following are the considerations for this: 1. The id for the new
                     * shape should be same as the old one 2. The rectagle bounds for
                     * the new shape should reflect the new image
                     */
                    CompoundCommand cc = new CompoundCommand();
                    for (Shape sh : model.getDiagram().getChildren()) {

                        if (!sh.getEditorShapeType().isEntity()) {
                            continue;
                        }

                        boolean isEntityUsed = entityPath.equals(sh.getEntityResourceFile().getResourceFile());
                        if (isEntityUsed) {
                            ShapeCopier copier = new ShapeCopier();
                            Shape newShape = (Shape) copier.copy(sh);
                            newShape.setId(sh.getId()); /* We use the same id */

                            /* update bounds */
                            Rectangle r = newShape.getBounds();
                            r.setWidth(e.getDefaultFrame().getBounds().width);
                            r.setHeight(e.getDefaultFrame().getBounds().height);
                            newShape.setBounds(r);
                            /* end update bounds */

                            ShapeDeleteCommand sdc = new ShapeDeleteCommand(model.getDiagram(), sh,
                                    DeleteCommandType.NON_UNDOABLE);
                            ShapeCreateCommand scc = new ShapeCreateCommand(newShape, model.getDiagram());
                            cc.add(sdc);
                            cc.add(scc);
                        }
                    }
                    getCommandStack().execute(cc);

                }

                @Override
                public void handleException(Throwable exception) {
                    exception.printStackTrace();
                }

            });
        }

        @Override
        public void entityRemoved(final IResource resource) {
            /*
             * Important: entity Removed is called in resource listener. Resource
             * listener might be run in whatever thread it was triggered in. So in
             * order to remove the entities from the pallette, we need to asyncExec
             * deletion. This will prevent invalid thread access error.
             */
            getSite().getShell().getDisplay().asyncExec(new Runnable() {
                @Override
                public void run() {
                    removeDeletedOrInvalidEntities(resource);
                    /* Also remove this entity from the map */
                    EntityManager.entityManager().removeEntity(resource.getFullPath().toOSString());
                }
            });
        }
    });
}

From source file:de.cubicvoxel.openspacebox.ingame.object.Station.java

License:Open Source License

private static Rectangle createShape(StationType stationType) {
    Rectangle rectangle = new Rectangle();
    rectangle.setWidth((float) stationType.getSize().getWidth());
    rectangle.setHeight((float) stationType.getSize().getHeight());
    return rectangle;
}