Example usage for com.badlogic.gdx.scenes.scene2d.ui Table left

List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Table left

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d.ui Table left.

Prototype

public Table left() 

Source Link

Document

Adds Align#left and clears Align#right for the alignment of the logical table within the table actor.

Usage

From source file:at.highstreeto.xnllayoutparser.element.TableParser.java

License:Apache License

@Override
public Actor load(Element element, LayoutParserContext context) throws LayoutParseException {
    Table table = new Table();

    if (element.getAttributes().containsKey("fillParent")) {
        table.setFillParent(element.getBooleanAttribute("fillParent"));
    }/*from   w ww.j  a va2s.  c  o m*/
    if (element.getAttributes().containsKey("debug")) {
        String[] parts = element.getAttribute("debug").split(" ");
        for (String i : parts) {
            if ("cell".equals(i)) {
                table.debugCell();
            } else if ("table".equals(i)) {
                table.debugTable();
            }
        }
    }
    // Combination of c (Center), t (Top), b (Bottom), l (Left), r (Right)
    if (element.getAttributes().containsKey("align")) {
        String[] parts = element.getAttribute("align").split(" ");
        for (String i : parts) {
            if ("c".equals(i)) {
                table.center();
            } else if ("t".equals(i)) {
                table.top();
            } else if ("b".equals(i)) {
                table.bottom();
            } else if ("l".equals(i)) {
                table.left();
            } else if ("r".equals(i)) {
                table.right();
            }
        }
    }

    context.addActor(table, element);
    ElementParserHelper.setActorName(element, table);

    for (int i = 0; i < element.getChildCount(); i++) {
        Element child = element.getChild(i);
        context.getParsers().getParserByElementName(child).load(child, context);
    }
    return table;
}

From source file:com.bladecoder.engineeditor.scneditor.ScnEditor.java

License:Apache License

public ScnEditor(Skin skin) {
    super(skin);/*from  www .j  a v  a  2s. c o m*/

    scnWidget = new ScnWidget(skin);
    testButton = new TextButton("Test", skin);

    buttonGroup = new ButtonGroup<Button>();
    buttonGroup.setMaxCheckCount(1);
    buttonGroup.setMinCheckCount(0);
    buttonGroup.setUncheckLast(true);

    walkZoneButton = new TextButton(CREATE_WALK_ZONE_TEXT, skin);
    toolsButton = new TextButton("Tools", skin);
    viewButton = new TextButton("View", skin);

    buttonGroup.add(toolsButton);
    buttonGroup.add(viewButton);

    viewWindow = new ViewWindow(skin, scnWidget);
    toolsWindow = new ToolsWindow(skin, scnWidget);

    add(scnWidget).expand().fill();
    row();

    Table bottomTable = new Table(skin);
    bottomTable.left();
    add(bottomTable).fill();

    bottomTable.add(viewButton);
    bottomTable.add(toolsButton);
    bottomTable.add(testButton);
    bottomTable.add(walkZoneButton).right().expandX();

    walkZoneButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {

            if (scnWidget.getScene().getPolygonalNavGraph() == null) {

                float[] verts = new float[8];

                float width = scnWidget.getScene().getCamera().getScrollingWidth();
                float height = scnWidget.getScene().getCamera().getScrollingHeight();

                verts[3] = height;
                verts[4] = width;
                verts[5] = height;
                verts[6] = width;

                Polygon poly = new Polygon(verts);
                PolygonalNavGraph pf = new PolygonalNavGraph();
                pf.setWalkZone(poly);
                scnWidget.getScene().setPolygonalNavGraph(pf);
                Ctx.project.setModified();
                walkZoneButton.setText(DELETE_WALK_ZONE_TEXT);
                viewWindow.showWalkZone();

            } else {
                new Dialog("Delete Walk Zone", getSkin()) {
                    protected void result(Object object) {
                        if (((Boolean) object).booleanValue()) {
                            walkZoneButton.setText(CREATE_WALK_ZONE_TEXT);

                            scnWidget.getScene().setPolygonalNavGraph(null);
                            Ctx.project.setModified();
                        }
                    }
                }.text("Are you sure you want to delete the Walk Zone?").button("Yes", true).button("No", false)
                        .key(Keys.ENTER, true).key(Keys.ESCAPE, false).show(getStage());
            }

            event.cancel();
        }
    });

    toolsButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, com.badlogic.gdx.scenes.scene2d.Actor actor) {
            if (toolsButton.isChecked()) {
                scnWidget.getParent().addActor(toolsWindow);
                toolsWindow.setPosition(getScnWidget().getX() + 5, getScnWidget().getY() + 5);
                toolsWindow.invalidate();
            } else {
                scnWidget.getParent().removeActor(toolsWindow);
            }
        }
    });

    viewButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, com.badlogic.gdx.scenes.scene2d.Actor actor) {
            if (viewButton.isChecked()) {
                scnWidget.getParent().addActor(viewWindow);
                viewWindow.setPosition(getScnWidget().getX() + 5, getScnWidget().getY() + 5);
                viewWindow.invalidate();
            } else {
                scnWidget.getParent().removeActor(viewWindow);
            }
        }
    });

    testButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, com.badlogic.gdx.scenes.scene2d.Actor actor) {
            test();
            event.cancel();
        }
    });

    Ctx.project.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent e) {
            EditorLogger.debug("ScnWidget Listener: " + e.getPropertyName());

            if (e.getPropertyName().equals(Project.NOTIFY_SCENE_SELECTED)) {
                if (Ctx.project.getSelectedScene() == null)
                    return;

                if (Ctx.project.getSelectedScene().getPolygonalNavGraph() != null) {
                    walkZoneButton.setText(DELETE_WALK_ZONE_TEXT);
                } else {
                    walkZoneButton.setText(CREATE_WALK_ZONE_TEXT);
                }
            }
        }
    });
}

From source file:com.exovum.test.animation.AnimatorMenuScreen.java

License:Creative Commons License

public AnimatorMenuScreen(final Game game) {
    this.batch = new SpriteBatch();
    this.game = game;
    screen = this;

    menuBackground = new Texture(Gdx.files.internal("beach-ocean-sea-bg/transparent-png/full_background.png"));
    menuMusic = Gdx.audio.newMusic(Gdx.files.internal("Carpe Diem.mp3"));

    stage = new Stage(new FitViewport(800, 480));
    Gdx.input.setInputProcessor(stage);/*from ww w  .  j a va2s.c om*/
    // Setup the UI skin. Pass the TextureAtlas too so it can find the default settings.
    TextureAtlas skinAtlas = new TextureAtlas(Gdx.files.internal("uiskin.atlas"));
    skin = new Skin(Gdx.files.internal("uiskin.json"), skinAtlas);

    mainTable = new Table(skin);
    //mainTable.defaults().expand().fill().padBottom(4f).padTop(4f);
    mainTable.setFillParent(true);

    // Add the title of the game at the top of the MenuScreen
    titleTable = new Table(skin);
    final Label titleLabel = new Label("Kordan Jirby", skin, "title");
    titleLabel.setColor(Color.FIREBRICK);
    //titleLabel.setStyle(new Label.LabelStyle(titleFont, Color.FIREBRICK));
    titleLabel.setAlignment(Align.center, Align.center);
    titleLabel.setPosition(stage.getWidth() / 2, stage.getHeight());
    //titleLabel.setFontScale(2.0f);
    titleTable.defaults().expand().fill().padBottom(4f).padTop(4f);

    titleTable.add(titleLabel);
    titleTable.padBottom(10f);

    // Bottom/Base Table: left-child holds buttonTable for menu buttons,
    //                    right-child holds some text info ie instructions or credits
    baseTable = new Table(skin);
    baseTable.defaults().expand().fill().padBottom(10f).padTop(10f);

    // Add the buttons for the user to press: play, help, credits, exit
    TextButton playButton = new TextButton("Play Game", skin, "small-font");
    TextButton helpButton = new TextButton("Instructions", skin, "small-font");
    TextButton creditsButton = new TextButton("Credits", skin, "small-font");
    TextButton exitButton = new TextButton("Exit", skin, "small-font");

    Table buttonTable = new Table(skin);
    // Add the button table as the left-child to baseTable
    baseTable.add(buttonTable);
    //menuTable.setBackground("console2");
    // Set the color of the BACKGROUND on the buttons
    Color buttonColor = Color.SKY;

    Gdx.app.log("AnimatorMenuScreen", "Color RGB SKY: " + Color.SKY.toString());
    playButton.setColor(buttonColor);
    helpButton.setColor(buttonColor);
    creditsButton.setColor(buttonColor);
    exitButton.setColor(buttonColor);
    // Set the color of the TEXT on the buttons
    //buttonColor = new Color(0.845f, 0.845f, 0.845f, 1);
    buttonColor = new Color(0.91f, 0.91f, 0.91f, 1);
    playButton.getLabel().setColor(buttonColor);
    helpButton.getLabel().setColor(buttonColor);
    creditsButton.getLabel().setColor(buttonColor);
    exitButton.getLabel().setColor(buttonColor);

    buttonTable.defaults().expand().fill().padBottom(8f).padTop(2f);
    buttonTable.add(playButton).width(180f).height(60f).row();
    buttonTable.add(helpButton).width(180f).height(60f).row();
    buttonTable.add(creditsButton).width(180f).height(60f).row();
    buttonTable.add(exitButton).width(180f).height(60f);
    buttonTable.padTop(30f).padBottom(30f);
    buttonTable.left();

    /*
    Temporary removal of infoTable
    It was not easy for me to add hidden/new text and for the layouts to update correctly.
    Changing plan to create a new Screen for Credits (and instructions too).
     */
    infoTable = new Table(skin); // = new Label("", skin, "small-font");
    infoTable.setVisible(false);
    infoTable.defaults().expand().fill().padBottom(8f).padTop(2f);
    //baseTable.add(infoTable);

    // Add title table at the top of mainTable
    mainTable.add(titleTable).row();
    // Add baseTable containing buttonTable to the next row of mainTable
    //mainTable.add(buttonTable);
    mainTable.add(baseTable);
    // Add mainTable to the stage
    stage.addActor(mainTable);

    // Event Listeners for the menu buttons
    playButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            Gdx.app.log("AnimatorMenuScreen", "Pressed playButton");
            //game.setScreen(new AnimatorGameScreen(game, screen));
            ((Game) Gdx.app.getApplicationListener()).setScreen(new AnimatorGameScreen(game, screen));
        }
    });
    helpButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            Gdx.app.log("AnimatorMenuScreen", "Pressed helpButton");
            //game.setScreen(new InstructionsScreen(game, screen));
            ((Game) Gdx.app.getApplicationListener()).setScreen(new InstructionsScreen(game, screen));
        }
    });
    creditsButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            Gdx.app.log("AnimatorMenuScreen", "Pressed creditsButton");
            //game.setScreen(new CreditsScreen(game, screen));
            ((Game) Gdx.app.getApplicationListener()).setScreen(new CreditsScreen(game, screen));
            /*
            *  Attempt at adding text next to the buttons.
            *  Status: Unsuccessful. Updating the layout once adding the credits text
            *           does not update as easily as I hoped.
            *          Changing plan to use different Screens for Credits & Instructions.
            // If the table is visible and already showing credits, then 'minimize' infoTable
            if(infoTable.isVisible() && infoTable.getName() != null && infoTable.getName().equals("Credits")) {
            Gdx.app.log("AnimatorMenuScreen", "Hide the credits menu");
            infoTable.setVisible(false);
            infoTable.clearChildren();
            } else {
            Gdx.app.log("AnimatorMenuScreen", "Display the credits text");
            // Otherwise, make the infoTable visible and set text to the credits
            infoTable.setVisible(true);
            infoTable.clearChildren();
            //infoTable.center();
            Label musicLabel = new Label("Music\n" + "Pixel Peeker Polka - slower Kevin MacLeod (incompetech.com)\n" +
                    "Licensed under Creative Commons: By Attribution 3.0 License\n" +
                    "http://creativecommons.org/licenses/by/3.0/",
                    skin, "small-font");
            musicLabel.setColor(Color.BLACK);
            //infoTable.addActor(musicLabel);
                    
            infoTable.addActor(musicLabel);
            infoTable.padLeft(20f);
                    
            //musicLabel.setPosition(stage.getWidth() / 2 + 50, stage.getHeight() / 2 + 100, Align.right);
            infoTable.defaults().expand().fill().padBottom(8f).padTop(2f);
            musicLabel.setWidth(200f);
            //musicLabel.setWrap(true);
            musicLabel.setAlignment(Align.center);
                    
            //musicLabel.setFillParent(true);
            // "Invalidates this actor's layout, causing layout() to happen next time
            // validate() is called
            infoTable.invalidate();
            baseTable.invalidate();
            infoTable.center();
                    
            //infoTable.setFillParent(true);
                    
            //titleTable.add(musicLabel);
            }
            infoTable.setName("Credits");
            */
        }
    });
    exitButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            Gdx.app.log("AnimatorMenuScreen", "Pressed exitButton - exiting application");
            Gdx.app.exit();
        }
    });

}

From source file:com.exovum.test.animation.CreditsScreen.java

License:Creative Commons License

public CreditsScreen(final Game game, Screen parentScreen) {
    this.batch = new SpriteBatch();
    this.game = game;
    this.parent = parentScreen;

    Gdx.app.log("CreditsScreen", "Creating CreditsScreen");

    menuBackground = new Texture(Gdx.files.internal("beach-ocean-sea-bg/transparent-png/full_background.png"));

    stage = new Stage(new FitViewport(800, 480));
    Gdx.input.setInputProcessor(stage);//from  ww  w  .  j  a  v a 2 s .c  om
    skin = new Skin(Gdx.files.internal("uiskin.json"));

    mainTable = new Table(skin);
    //mainTable.defaults().expand().fill().padBottom(4f).padTop(4f);
    mainTable.setFillParent(true);

    baseTable = new Table(skin);
    baseTable.defaults().expand().fill().padBottom(10f).padTop(10f);

    Label myHeader = new Label("General", skin, "small-font");
    myHeader.setColor(Color.FIREBRICK);
    myHeader.setAlignment(Align.center);

    Label myCredits = new Label("Programming and Development\n" + "Caleb Stevenson", skin, "small-font");
    myCredits.setColor(Color.BLACK);
    myCredits.setAlignment(Align.center);

    Label musicHeader = new Label("Music", skin, "small-font");
    musicHeader.setColor(Color.FIREBRICK);
    musicHeader.setAlignment(Align.center);

    Label musicCredits = new Label("\"Capre Diem\", \"Hidden Past\", \"Pixel Peeker Polka - slower\"\n"
            + "Kevin MacLeod (incompetech.com)\n" + "Licensed under Creative Commons: By Attribution 3.0\n"
            + "http://creativecommons.org/licenses/by/3.0/", skin, "small-font");
    musicCredits.setColor(Color.BLACK);
    musicCredits.setAlignment(Align.center);

    Label artHeader = new Label("Artwork", skin, "small-font");
    artHeader.setColor(Color.FIREBRICK);
    artHeader.setAlignment(Align.center);

    Label artCredits = new Label("Background and Tree Sprites\n" + "http://bevouliin.com\nopengameart.org",
            skin, "small-font");
    artCredits.setColor(Color.BLACK);

    artCredits.setAlignment(Align.center);

    TextButton exitButton = new TextButton("Back to Menu", skin, "small-font");

    Table buttonTable = new Table(skin);
    baseTable.add(myHeader).row();
    baseTable.add(myCredits).row();
    baseTable.add(musicHeader).row();
    baseTable.add(musicCredits).row();
    baseTable.add(artHeader).row();
    baseTable.add(artCredits).row();
    baseTable.add(buttonTable);
    //menuTable.setBackground("console2");
    // Set the color of the BACKGROUND on the buttons
    Color buttonColor = Color.SKY;
    exitButton.setColor(buttonColor);
    // Set the color of the TEXT on the buttons
    exitButton.getLabel().setColor(new Color(0.91f, 0.91f, 0.91f, 1));

    buttonTable.defaults().expand().fill().padBottom(4f).padTop(2f);
    buttonTable.add(exitButton).width(180f).height(60f);
    //buttonTable.padTop(20f).padBottom(20f);
    buttonTable.left();

    // Add baseTable containing buttonTable to the next row of mainTable
    //mainTable.add(buttonTable);
    mainTable.add(baseTable);
    // Add mainTable to the stage
    stage.addActor(mainTable);

    exitButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            Gdx.app.log("CreditsScreen", "Exiting to main menu");
            //game.setScreen(new AnimatorMenuScreen(game));
            //game.setScreen(parent);
            //((Game) Gdx.app.getApplicationListener()).setScreen(parent);
            ((Game) Gdx.app.getApplicationListener()).setScreen(new AnimatorMenuScreen(game));
        }
    });

    //Use an InputMultiplexer so that the Stage and keyDown input processors can both be used
    InputMultiplexer multiplexer = new InputMultiplexer();
    multiplexer.addProcessor(stage);
    multiplexer.addProcessor(new InputAdapter() {
        // If the back key is pressed, go to main menu
        // This also handles the Android 'back' button
        @Override
        public boolean keyDown(int keycode) {
            if (keycode == Input.Keys.BACK) {
                // Handle the back button
                Gdx.app.log("CreditsScreen", "KeyDown: BACK pressed");
                //AnimatorMenuScreen newMenu = new AnimatorMenuScreen(batch, game);
                //game.setScreen(newMenu);
                //game.setScreen(parent);
                //((Game) Gdx.app.getApplicationListener()).setScreen(parent);
                ((Game) Gdx.app.getApplicationListener()).setScreen(new AnimatorMenuScreen(game));
                return true;
            }
            return false;
        }
    });

    Gdx.input.setInputProcessor(multiplexer);
}

From source file:com.mygdx.java.screens.MenuScreen.java

License:Apache License

private Table buildLogosLayer() {
    Table layer = new Table();
    layer.left().top();
    // + Game Logo
    imgLogo = new Image(skinCanyonBunny, "logo");
    layer.add(imgLogo);//from  ww w .  j a  v a2 s.  c om
    layer.row().expandY();
    // + Info Logos
    imgInfo = new Image(skinCanyonBunny, "info");
    layer.add(imgInfo).bottom();
    if (debugEnabled)
        layer.debug();
    return layer;
}

From source file:com.sczr.symulator_windy.ui.MainStage.java

License:Open Source License

/*************************************************************************| 
|                    _        _____                                       |
|                  (_)      / ____|                                      |
|    _ __ ___   __ _ _ _ __ | (___   __ _  __ _  ___                      |   
|   | '_ ` _ \ / _` | | '_ \ \___ \ / _` |/ _` |/ _ \                     |   
|   | | | | | | (_| | | | | |____) | (_| | (_| |  __/                     |   
|   |_| |_| |_|\__,_|_|_| |_|_____/ \__,_|\__, |\___|                     |   
|                                          __/ |                          |   
|                                         |___/                           |   
|                                                                         |   
|                                                                         |   
|    This program is free software: you can redistribute it and/or modify |    
|   it under the terms of the GNU General Public License as published by  |  
|   the Free Software Foundation, either version 3 of the License, or     |   
|   (at your option) any later version.                                   |  
|                                                                         |  
|   This program is distributed in the hope that it will be useful,       |  
|   but WITHOUT ANY WARRANTY; without even the implied warranty of        |  
|    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        |  
|    GNU General Public License for more details.                         |  
|                                                                         |  
|    You should have received a copy of the GNU General Public License    |  
|   along with this program.  If not, see <http://www.gnu.org/licenses/>. |                                      
 *************************************************************************/
//Author: Junior JavaScript Software Developer Szymon Mysiak
//Date: 2014-12-21 00:16:32:12621
//Date of Edition --
//Power Supply: CODEGEN 800W

public MainStage(Skin skin, int storeyCount, int storeyHeight, int elevatorWidth, Client client) {
    this.client = client;
    stories = Model.NUMBER_OF_FLOORS;/*from   w ww.  j  a v  a  2 s  .com*/
    storeyLabels = new Label[stories];
    passengerLists = new ListLabel[stories];
    peopleWaitingOnStorey = new int[stories];

    storeyHeight = (int) this.getHeight() / storeyCount;

    this.elevator = new ElevatorCar(ElevatorCarModel.ELEVATOR_WIDTH, Model.FLOOR_HEIGHT, ELEVATOR_X);
    addActor(elevator);
    this.listener = new ModelUpdatesListener(elevator, this);
    //client.addListener(listener);

    for (int i = 0; i < stories; i++) {
        Label label = new Label("", skin);
        label.setY((getFloorLevel(i)) + 5);
        addActor(label);
        storeyLabels[i] = label;

        passengerLists[i] = new ListLabel(skin);
        addActor(passengerLists[i].label);
        passengerLists[i].label.setY(getFloorLevel(i) + 20);
        passengerLists[i].label.setX(300);

        TextButton addPersonButton = new TextButton("dodaj", skin);
        addPersonButton.setY(getFloorLevel(i));
        addPersonButton.setX(150);
        addPersonButton.setName(i + "");
        addActor(addPersonButton);
        addPersonButton.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                Random random = new Random();
                //peopleWaitingOnStorey[Integer.parseInt(event.getListenerActor().getName())]+=1;
                int dest = Math.abs(random.nextInt() % stories);
                while (dest == Integer.parseInt(event.getListenerActor().getName())) {
                    dest = Math.abs(random.nextInt() % stories);
                }
                client.sendTCP(new NewPassengerPacket(lastClientID++, dest,
                        Integer.parseInt(event.getListenerActor().getName())));
                Model.incrementCounter();
            }
        });
    }

    client.addListener(new Listener() {
        @Override
        public void received(Connection c, Object o) {
            if (o instanceof NewPassengerPacket) {
                NewPassengerPacket packet = (NewPassengerPacket) o;
                if (packet.floor > stories) {
                    return;
                }
                peopleWaitingOnStorey[packet.floor] += 1;
                passengerLists[packet.floor].addPassenger(packet.ID, packet.floor, packet.destination);
            } else if (o instanceof PassengerEnterPacket) {
                PassengerEnterPacket p = (PassengerEnterPacket) o;
                passengerLists[p.floor].removePassenger(p.id, p.floor, p.destination);
            }
        }
    });

    ElevatorCallButton groundFloorButton = new ElevatorCallButton("^", skin, Direction.UP, 0);
    ElevatorCallButton topFloorButton = new ElevatorCallButton("v", skin, Direction.DOWN, stories - 1);
    topFloorButton.setPosition(ELEVATOR_X + elevator.ELEVATOR_WIDTH,
            (stories * storeyHeight) - (storeyHeight / 2));
    groundFloorButton.setPosition(ELEVATOR_X + elevator.ELEVATOR_WIDTH, storeyHeight / 2);
    topFloorButton.addListener(new ElevatorButtonListener(4, Direction.DOWN));
    groundFloorButton.addListener(new ElevatorButtonListener(0, Direction.UP));

    ArrayList<ElevatorCallButton> callButtons = new ArrayList<ElevatorCallButton>();
    callButtons.add(groundFloorButton);
    callButtons.add(topFloorButton);
    //przyciski na pietrach nieskrajnych
    for (int i = storeyHeight, buttonCount = 1; i < (stories - 1) * storeyHeight; i += storeyHeight) {
        ElevatorCallButton up = new ElevatorCallButton("^", skin, Direction.UP, buttonCount);
        ElevatorCallButton down = new ElevatorCallButton("v", skin, Direction.DOWN, buttonCount);
        up.setPosition(ELEVATOR_X + elevator.ELEVATOR_WIDTH, i + storeyHeight / 2);
        down.setPosition(ELEVATOR_X + elevator.ELEVATOR_WIDTH, i + storeyHeight / 4);
        callButtons.add(up);
        callButtons.add(down);
        up.addListener(new ElevatorButtonListener(buttonCount, Direction.UP));
        down.addListener(new ElevatorButtonListener(buttonCount, Direction.DOWN));
        buttonCount++;
    }
    for (ElevatorCallButton elevatorCallButton : callButtons) {
        addActor(elevatorCallButton);
    }

    Table table = new Table();
    table.setFillParent(true);
    addActor(table);
    Table leftCornerTable = new Table();
    peopleInsideLabel = new Label("", skin);
    leftCornerTable.add(peopleInsideLabel);
    table.add(leftCornerTable);
    table.left().top();
}

From source file:cs383.team1.input.ui.ItemsExtension.java

private Table statComp(String icn, Double i, double e1, double e2) {
    Table t;
    t = new Table();

    addIcon(icn, t);// w  w w  .  ja  va2s  .c  o m
    t.left().add(new Label(i.toString(), skin)).left().fillX().expandX().row();
    t.add(cmpStat(e1, i)).colspan(2).right().expandX();
    t.row();
    t.add(cmpStat(e2, i)).colspan(2).right().expandX();

    t.padRight(15);

    return t;
}

From source file:cs383.team1.input.ui.ItemsExtension.java

private Table statComp(String icn, Double i, double e1) {
    Table t;
    t = new Table();

    addIcon(icn, t);/*from w ww .  j  a  v  a 2s  .co  m*/
    t.left().add(new Label(i.toString(), skin)).left().fillX().expandX().row();
    t.add(cmpStat(e1, i)).colspan(2).right().expandX();

    t.padRight(15);

    return t;
}

From source file:es.eucm.ead.mockup.core.control.screens.gallery.ElementGallery.java

License:Open Source License

@Override
public void create() {
    setPreviousScreen(Screens.PROJECT_MENU);
    navigationGroup = UIAssets.getNavigationGroup();

    super.root = new Group();
    root.setVisible(false);//from w  ww . j  a va  2 s  .  c om

    topToolbar = new ToolBar(skin);
    ToolBar bottomToolbar = new ToolBar(skin);
    topToolbar.right();

    String search = "Buscar por ...";// TODO use i18n!
    TextField searchtf = new TextField("", skin);
    searchtf.setMessageText(search);
    searchtf.setMaxLength(search.length());
    String[] orders = new String[] { "Ordenar por ...", "nombre A-Z", "nombre Z-A", "ms recientes",
            "menos recientes" };// TODO use
    // i18n!
    SelectBox order = new SelectBox(orders, skin);

    /* filter panel */
    Button applyFilter = new TextButton("Filtrar", skin);

    CheckBox[] tags = new CheckBox[] { new CheckBox("Almohada", skin), new CheckBox("Camilla", skin),
            new CheckBox("Doctor", skin), new CheckBox("Enfermera", skin), new CheckBox("Guantes", skin),
            new CheckBox("Habitacin", skin), new CheckBox("Hospital", skin), new CheckBox("Quirfano", skin),
            new CheckBox("Medicamentos", skin), new CheckBox("Mdico", skin), new CheckBox("Paciente", skin),
            new CheckBox("Vehculo", skin) };
    Table tagList = new Table(skin);
    tagList.left();
    tagList.defaults().left();
    for (int i = 0; i < tags.length; ++i) {
        tagList.add(tags[i]);
        if (i < tags.length - 1)
            tagList.row();
    }
    ScrollPane tagScroll = new ScrollPane(tagList, skin, "opaque");

    final Panel filterPanel = new Panel(skin);
    filterPanel.setVisible(false);
    final float panelw = stagew * .26f, panelx = stagew - panelw;
    filterPanel.add(tagScroll).fill().colspan(3).left();
    filterPanel.row();
    filterPanel.add(applyFilter).colspan(3).expandX();
    filterPanel.setBounds(panelx, topToolbar.getHeight(), panelw, stageh - topToolbar.getHeight() * 2f);

    Button filterButton = new TextButton("Filtrar por tags", skin);
    ClickListener closeFilterListenerTmp = new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (filterPanel.isVisible()) {
                mockupController.hide(filterPanel);
            } else {
                mockupController.show(filterPanel);
            }
        }
    };
    applyFilter.addListener(closeFilterListenerTmp);
    filterButton.addListener(closeFilterListenerTmp);

    Label nombre = new Label("Galera de elementos", skin);

    topToolbar.add(nombre).expandX().left().padLeft(UIAssets.NAVIGATION_BUTTON_WIDTH_HEIGHT * 1.1f);
    topToolbar.add(order);
    topToolbar.add(filterButton);
    topToolbar.add(searchtf).width(skin.getFont("default-font").getBounds(search).width + 50); // FIXME
    // hardcoded
    // fixed
    // value
    /***/

    final int COLS = 4, ROWS = 6;
    gridPanel = new GalleryGrid<Actor>(skin, ROWS, COLS, root, new ToolBar[] { topToolbar, bottomToolbar }) {
        @Override
        protected void entityClicked(InputEvent event) {
            Actor target = event.getTarget();
            if (target instanceof Image) {
                ElementEdition.setELEMENT_INDEX((Integer) target.getUserObject());
                exitAnimation(Screens.ELEMENT_EDITION);
            } else if (target instanceof Label) {
                ElementEdition.setELEMENT_INDEX(null);
                exitAnimation(Screens.ELEMENT_EDITION);
            }
        }
    };
    boolean first = true;
    for (int i = 0; i < ROWS; ++i) {
        for (int j = 0; j < COLS; ++j) {
            if (first) {
                first = false;
                gridPanel.addItem(new TextButton("Imagen en blanco", skin), 0, 0).fill();
            } else {
                int rand = MathUtils.random(Loading.demoElementsThumbnail.length - 1);
                GalleryEntity auxImg = new GalleryEntity(Loading.demoElementsThumbnail[rand]);
                auxImg.setUserObject(Integer.valueOf(rand));
                gridPanel.addItem(auxImg, i, j);// .size(auxWidth,
                // auxHeight);
            }
        }
    }

    ScrollPane scrollPane = new ScrollPane(gridPanel);
    scrollPane.setScrollingDisabled(true, false);
    scrollPane.setBounds(0, topToolbar.getHeight(), stagew, stageh - 2 * topToolbar.getHeight());
    final float DEFAULT_ICON_LABEL_SPACE = 10f;
    final Button picButton = new Button(skin);
    picButton.defaults().space(DEFAULT_ICON_LABEL_SPACE);
    Label picLabel = new Label("Nuevo desde cmara", skin);
    Image picImage = new Image(skin.getDrawable("ic_photocamera"));
    picButton.add(picImage);
    picButton.add(picLabel);

    ClickListener mTransitionLIstener = new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            final Screens next = getNextScreen(event.getListenerActor());
            if (next == null) {
                return;
            }
            exitAnimation(next);
        }

        private Screens getNextScreen(Actor target) {
            Screens next = null;
            if (target == picButton) {
                next = Screens.PICTURE;
            }
            return next;
        }
    };
    picButton.addListener(mTransitionLIstener);

    bottomToolbar.setY(0);
    bottomToolbar.add(picButton).expandX().left();

    root.addActor(topToolbar);
    root.addActor(bottomToolbar);
    root.addActor(scrollPane);
    root.addActor(filterPanel);

    stage.addActor(root);
}

From source file:es.eucm.ead.mockup.core.control.screens.gallery.Gallery.java

License:Open Source License

@Override
public void create() {
    setPreviousScreen(Screens.PROJECT_MENU);
    navigationGroup = UIAssets.getNavigationGroup();

    super.root = new Group();
    root.setVisible(false);/*  w w w.j  a  v  a 2s.  c  o  m*/

    topToolbar = new ToolBar(skin);
    ToolBar bottomToolbar = new ToolBar(skin);
    topToolbar.right();

    String search = "Buscar por ...";// TODO use i18n!
    TextField searchtf = new TextField("", skin);
    searchtf.setMessageText(search);
    searchtf.setMaxLength(search.length());
    String[] orders = new String[] { "Ordenar por ...", "nombre A-Z", "nombre Z-A", "ms recientes",
            "menos recientes" };// TODO use
    // i18n!
    SelectBox order = new SelectBox(orders, skin);

    /* filter panel */
    CheckBox cbs = new CheckBox("Escenas", skin);
    cbs.setChecked(true);
    CheckBox cbe = new CheckBox("Elementos", skin);
    cbe.setChecked(true);
    CheckBox cbi = new CheckBox("Imgenes", skin);
    cbi.setChecked(true);// TODO use i18n!
    Button applyFilter = new TextButton("Filtrar", skin);

    CheckBox[] tags = new CheckBox[] { new CheckBox("Almohada", skin), new CheckBox("Camilla", skin),
            new CheckBox("Doctor", skin), new CheckBox("Enfermera", skin), new CheckBox("Guantes", skin),
            new CheckBox("Habitacin", skin), new CheckBox("Hospital", skin), new CheckBox("Quirfano", skin),
            new CheckBox("Medicamentos", skin), new CheckBox("Mdico", skin), new CheckBox("Paciente", skin),
            new CheckBox("Vehculo", skin) };
    Table tagList = new Table(skin);
    tagList.left();
    tagList.defaults().left();
    for (int i = 0; i < tags.length; ++i) {
        tagList.add(tags[i]);
        if (i < tags.length - 1)
            tagList.row();
    }
    ScrollPane tagScroll = new ScrollPane(tagList, skin, "opaque");

    final Panel filterPanel = new Panel(skin);
    filterPanel.setVisible(false);
    final float panelw = stagew * .45f, panelx = stagew - panelw;
    filterPanel.setBounds(panelx, topToolbar.getHeight(), panelw, stageh - topToolbar.getHeight() * 2f);
    filterPanel.add(cbe).expandX();
    filterPanel.add(cbs).expandX();
    filterPanel.add(cbi).expandX();
    filterPanel.row();
    filterPanel.add(tagScroll).fill().colspan(3).left();
    filterPanel.row();
    filterPanel.add(applyFilter).colspan(3).expandX();

    Button filterButton = new TextButton("Filtrar por tags", skin);
    ClickListener closeFilterListenerTmp = new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (filterPanel.isVisible()) {
                mockupController.hide(filterPanel);
            } else {
                mockupController.show(filterPanel);
            }
        }
    };
    applyFilter.addListener(closeFilterListenerTmp);
    filterButton.addListener(closeFilterListenerTmp);

    Label nombre = new Label("Galera", skin);

    topToolbar.add(nombre).expandX().left().padLeft(UIAssets.NAVIGATION_BUTTON_WIDTH_HEIGHT * 1.1f);
    topToolbar.add(order);
    topToolbar.add(filterButton);
    topToolbar.add(searchtf).width(skin.getFont("default-font").getBounds(search).width + 50); // FIXME
    // hardcoded
    // fixed
    // value

    /***/

    final int COLS = 4, ROWS = 6;
    gridPanel = new GalleryGrid<Actor>(skin, ROWS, COLS, root, new ToolBar[] { topToolbar, bottomToolbar }) {
        @Override
        protected void entityClicked(InputEvent event) {
            Actor target = event.getTarget();
            if (target instanceof Image) {
                // TODO distinguish between elements and scenes
                String[] auxAttr = String.valueOf(target.getUserObject()).split(" ");
                Integer index = Integer.valueOf(auxAttr[0]);
                if (Boolean.valueOf(auxAttr[1])) { // isElement
                    ElementEdition.setELEMENT_INDEX(index);
                    exitAnimation(Screens.ELEMENT_EDITION);
                } else {
                    SceneEdition.setSCENE_INDEX(index);
                    exitAnimation(Screens.SCENE_EDITION);
                }
            } else if (target instanceof Label) {
                // We've clicked new from blank page...
                // TODO ask for choise
                SCENE_EDITION = true;
                showDialog();
            }
        }
    };
    boolean first = true;
    for (int i = 0; i < ROWS; ++i) {
        for (int j = 0; j < COLS; ++j) {
            if (first) {
                first = false;
                gridPanel.addItem(new TextButton("Crear nuevo\nen blanco", skin), 0, 0).fill();
            } else {
                Texture tex;
                int rand;
                boolean isElement;
                if (MathUtils.randomBoolean()) {
                    isElement = false;
                    rand = MathUtils.random(Loading.demoScenesThumbnail.length - 1);
                    tex = Loading.demoScenesThumbnail[rand];
                } else {
                    isElement = true;
                    rand = MathUtils.random(Loading.demoElementsThumbnail.length - 1);
                    tex = Loading.demoElementsThumbnail[rand];
                }
                GalleryEntity auxImg = new GalleryEntity(tex);
                auxImg.setUserObject(rand + " " + isElement);
                gridPanel.addItem(auxImg, i, j);
            }
        }
    }
    ScrollPane scrollPane = new ScrollPane(gridPanel);
    scrollPane.setScrollingDisabled(true, false);
    scrollPane.setBounds(0, topToolbar.getHeight(), stagew, stageh - 2 * topToolbar.getHeight());
    final float DEFAULT_ICON_LABEL_SPACE = 10f;
    final Button picButton = createButton("Nuevo desde cmara", "ic_photocamera", DEFAULT_ICON_LABEL_SPACE,
            false);
    final Button vidButton = createButton("Grabar desde Escena", "ic_videocamera", DEFAULT_ICON_LABEL_SPACE,
            true);
    ClickListener showDialogListener = new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            SCENE_EDITION = false;
            exitAnimation(Screens.PICTURE);
        }
    };
    picButton.addListener(showDialogListener);
    vidButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            exitAnimation(Screens.RECORDING);
        }
    });

    // Coice dialog panel
    mDialogPanel = new Panel(skin, "dialog");
    mDialogPanel.setVisible(false);
    mDialogPanel.setModal(true);
    mDialogPanel.pad(DEFAULT_ICON_LABEL_SPACE);
    mDialogPanel.defaults().space(DEFAULT_ICON_LABEL_SPACE).uniform().expand().fill();
    final float PANEL_W = stagew * .3f, PANEL_H = UIAssets.NAVIGATION_BUTTON_WIDTH_HEIGHT * 3f,
            PANEL_X = halfstagew - PANEL_W * .5F, PANEL_Y = halfstageh - PANEL_H * .5f;
    mDialogPanel.setBounds(PANEL_X, PANEL_Y, PANEL_W, PANEL_H);
    final Button newElement = createButton("Nuevo elemento", "ic_editelement", DEFAULT_ICON_LABEL_SPACE, false);
    final Button newScene = createButton("Escena nueva", "ic_editstage", DEFAULT_ICON_LABEL_SPACE, false);
    mDialogPanel.add(newScene);
    mDialogPanel.row();
    mDialogPanel.add(newElement);
    ClickListener mTransitionLIstener = new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            final Screens next = getNextScreen(event.getListenerActor());
            if (next == null) {
                return;
            }
            exitAnimation(next);
        }

        private Screens getNextScreen(Actor target) {
            Screens next = null;
            if (SCENE_EDITION) {
                // We've clicked NewBlankImage
                if (target == newElement) {
                    next = Screens.ELEMENT_EDITION;
                    SCENE_EDITION = false;
                } else if (target == newScene) {
                    next = Screens.SCENE_EDITION;
                }
            }
            return next;
        }
    };
    newElement.addListener(mTransitionLIstener);
    newScene.addListener(mTransitionLIstener);

    bottomToolbar.setY(0);
    bottomToolbar.add(picButton).expandX().left();
    bottomToolbar.add(vidButton).expandX().right();

    root.addActor(topToolbar);
    root.addActor(bottomToolbar);
    root.addActor(scrollPane);
    root.addActor(filterPanel);
    root.addActor(mDialogPanel);

    stage.addActor(root);
}