Example usage for com.badlogic.gdx.scenes.scene2d.ui Image Image

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

Introduction

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

Prototype

public Image() 

Source Link

Document

Creates an image with no region or patch, stretched, and aligned center.

Usage

From source file:com.agateau.pixelwheels.screens.PwStageScreen.java

License:Open Source License

public PwStageScreen(UiAssets uiAssets) {
    super(new ScalingViewport(Scaling.fit, WIDTH, HEIGHT));

    Image image = new Image();
    image.setDrawable(new TiledDrawable(uiAssets.background));
    image.setFillParent(true);/*  w  ww  . j a va 2 s  .c om*/
    getStage().addActor(image);
}

From source file:com.agateau.ui.UiBuilder.java

License:Apache License

protected Image createImage(XmlReader.Element element) {
    Image image = new Image();
    TextureAtlas atlas = getAtlasForElement(element);
    String attr = element.getAttribute("name", "");
    if (!attr.isEmpty()) {
        if (attr.endsWith(".9")) {
            initImageFromNinePatchName(image, atlas, attr);
        } else {// www  .  j  a  v a 2 s. com
            boolean tiled = element.getBooleanAttribute("tiled", false);
            initImageFromRegionName(image, atlas, attr, tiled);
        }
    }
    return image;
}

From source file:com.bladecoder.engineeditor.ui.components.HeaderPanel.java

License:Apache License

@SuppressWarnings("unchecked")
public HeaderPanel(Skin skin, String title) {
    titleLbl = new Label(title, skin);
    north = new HorizontalGroup();
    collapseImg = new Image();
    collapseImg.setScaling(Scaling.none);

    if (collapsable) {
        north.addActor(collapseImg);//from   w  w w  . j  a va2 s .c  o  m
        collapseImg.setDrawable(new TextureRegionDrawable(Ctx.assetManager.getIcon("ic_open")));
    }

    top().left();

    north.addActor(titleLbl);
    north.align(Align.left);
    north.fill();
    add(north).expandX().fillX();
    row();
    Image image = new Image(skin.getDrawable("white_pixel"));
    image.setColor(skin.getColor("separator-color"));
    add(image).height(2).padBottom(4f).expandX().fill();
    row().top().left();
    contentCell = add().expand().fill();

    if (collapsable) {
        titleLbl.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                toggleCollapse();
                invalidateHierarchy();
            }
        });

        collapseImg.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                toggleCollapse();
                invalidateHierarchy();
            }
        });
    }

    //      setDebug(true);
}

From source file:com.bladecoder.engineeditor.ui.EditSceneDialog.java

License:Apache License

@SuppressWarnings("unchecked")
public EditSceneDialog(Skin skin, World parent, Scene e) {

    super(skin);/*ww w .  java 2s . co m*/

    id = InputPanelFactory.createInputPanel(skin, "Scene ID",
            "The ID is mandatory for scenes. \nIDs can not contain '.' or '_' characters.", true);
    backgroundAtlas = InputPanelFactory.createInputPanel(skin, "Background Atlas",
            "The atlas where the background for the scene is located", atlasList, false);
    backgroundRegion = InputPanelFactory.createInputPanel(skin, "Background Region Id",
            "The region id for the background.", new String[0], false);
    depthVector = InputPanelFactory.createInputPanel(skin, "Depth Vector",
            "X: the actor 'y' position for a 0.0 scale, Y: the actor 'y' position for a 1.0 scale.",
            Param.Type.VECTOR2, false);
    state = InputPanelFactory.createInputPanel(skin, "State", "The initial state for the scene.", false);
    music = InputPanelFactory.createInputPanel(skin, "Music Filename", "The music for the scene", musicList,
            false);
    loopMusic = InputPanelFactory.createInputPanel(skin, "Loop Music", "If the music is playing in looping",
            Param.Type.BOOLEAN, false);
    initialMusicDelay = InputPanelFactory.createInputPanel(skin, "Initial music delay",
            "The time to wait before playing", Param.Type.FLOAT, true, "0");
    repeatMusicDelay = InputPanelFactory.createInputPanel(skin, "Repeat music delay",
            "The time to wait before repetitions", Param.Type.FLOAT, true, "0");

    sceneSize = InputPanelFactory.createInputPanel(skin, "Scene Dimension",
            "Sets the size of the scene. If empty, the background image size is used as the scene dimension.",
            Param.Type.DIMENSION, false);

    bgImage = new Image();
    bgImage.setScaling(Scaling.fit);
    infoContainer = new Container<Image>(bgImage);
    setInfo(INFO);

    ((SelectBox<String>) backgroundAtlas.getField()).addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            try {
                fillBGRegions(backgroundAtlas, backgroundRegion);
            } catch (Exception e) {
                Message.showMsg(getStage(), "Error loading regions from selected atlas", 4);
            }
        }
    });

    ((SelectBox<String>) backgroundRegion.getField()).addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            showBgImage(backgroundRegion.getText());
        }
    });

    try {
        fillBGRegions(backgroundAtlas, backgroundRegion);
    } catch (Exception e2) {
        EditorLogger.error("Error loading regions from selected atlas");
    }

    init(parent, e, new InputPanel[] { id, backgroundAtlas, backgroundRegion, depthVector, state, sceneSize,
            music, loopMusic, initialMusicDelay, repeatMusicDelay });
}

From source file:com.jmolina.orb.stages.GestureStage.java

License:Open Source License

/**
 * Constructor//from   w  ww.  j av  a  2s. com
 *
 * @param am AssetManager
 * @param vp Viewport
 * @param pixelsPerMeter Factor de conversion de pixeles a metros
 */
public GestureStage(AssetManager am, Viewport vp, float pixelsPerMeter) {
    super(vp);

    this.vp = vp;
    bufferedArrow = new Image();
    buffer = new FrameBuffer(Pixmap.Format.RGBA8888,
            vp.getScreenWidth() + (int) (OVERSIZE_RATIO * vp.getScreenWidth()),
            vp.getScreenHeight() + (int) (OVERSIZE_RATIO * vp.getScreenHeight()), false);

    start = new Vector2();
    end = new Vector2();
    arrow = new Arrow(am, pixelsPerMeter);
    pulse = new Pulse(am, pixelsPerMeter);

    pulse.setPosition(0.5f * vp.getWorldWidth() - 0.5f * pulse.getWidth(),
            0.5f * vp.getWorldHeight() - 0.5f * pulse.getHeight());

    bufferedArrow.setSize(Var.SCREEN_WIDTH + OVERSIZE_RATIO * Var.SCREEN_WIDTH,
            Var.SCREEN_HEIGHT + OVERSIZE_RATIO * Var.SCREEN_HEIGHT);

    float ratioX = Var.SCREEN_WIDTH / vp.getScreenWidth();
    float ratioY = Var.SCREEN_HEIGHT / vp.getScreenHeight();
    float offsetX = 0.5f * ratioX * (Gdx.graphics.getWidth() - vp.getScreenWidth());
    float offsetY = 0.5f * ratioY * (Gdx.graphics.getHeight() - vp.getScreenHeight());

    bufferedArrow.setPosition(-offsetX, -offsetY);
    arrow.setVisible(false);
    pulse.reset();

    addActor(pulse);
    addActor(arrow);
    addActor(bufferedArrow);
}

From source file:com.jmolina.orb.widgets.game.LinearField.java

License:Open Source License

/**
 * Constructor//from ww w  .j a va  2  s .  co m
 *
 * @param am AssetManager
 * @param ppm PixelsPerMeter
 * @param flavor Flavor
 * @param w Ancho del elemento (en unidades del mundo)
 * @param h Alto del elemento (en unidades del mundo)
 * @param threshold Umbral
 * @param polarity Polaridad
 */
public LinearField(AssetManager am, float ppm, WorldElement.Flavor flavor, float w, float h, float threshold,
        Magnetic.Polarity polarity) {
    super(am, threshold, polarity);

    filler = new Image();
    filler.setSize(Utils.cell(w), Utils.cell(threshold));
    filler.setPosition(0, 0);

    TextureRegion region = findRegion(Atlas.GAME_MAGNETIC_PARTICLE_LINEAR);
    particle = new Image(region);
    particle.setSize(Utils.cell(0.25f), Utils.cell(0.25f));
    particle.setPosition(0, Utils.cell(threshold));
    particle.setScaleX(ppm * w / region.getRegionWidth());
    particle.setOriginY(Utils.cell(0));

    resetParticleAction();
    particle.addAction(getParticleAction());

    field = new Image(findRegion(Atlas.GAME_MAGNETIC_FIELD_LINEAR));
    field.setSize(Utils.cell(w), Utils.cell(threshold));
    field.setPosition(0, Utils.cell(threshold));

    body = new Image(getBodyTextureRegion(flavor));
    body.setSize(Utils.cell(w), Utils.cell(h));
    body.setPosition(0, Utils.cell(threshold) - 0.5f * Utils.cell(h));

    addActor(field);
    addActor(filler);
    addActor(particle);
    addActor(body);

    setSize(Utils.cell(w), 2 * Utils.cell(threshold));
    setOrigin(0.5f * getWidth(), 0.5f * getHeight());
    setScale(ppm / Var.GRID_CELL_SIZE);
}

From source file:com.jumpbuttonstudios.vikingdodge.ui.popup.PlayerAvatarPopup.java

License:Apache License

@Override
public void create() {
    avatarTable = new Table();
    avatar = new Image();
    if (Network.isLoggedIn()) {
        avatar.setDrawable(Assets.skin.get("avatar", TextureRegionDrawable.class));
        avatarBox = new Image(Assets.skin.get("avatarBoxLogged", TextureRegionDrawable.class));
    } else {/* w  w w . jav  a2s. c  o m*/
        avatarBox = new Image(Assets.skin.get("avatarBox", TextureRegionDrawable.class));
    }
    name = new Label(Network.getUsername(), Assets.skin.get("label", LabelStyle.class));

    setScreenPositions(-400, vikingDodge.getUi().getHeight() - (getAvatarBox().getHeight() + 10), 10,
            vikingDodge.getUi().getHeight() - (getAvatarBox().getHeight() + 10));

    avatarBox.setName(AVATAR_NAME);
    name.setName(USERNAME_NAME);
}

From source file:com.kotcrab.vis.ui.widget.VisImageButton.java

License:Apache License

private void init() {
    image = new Image();
    image.setScaling(Scaling.fit);// ww w . j  a v a2 s . c o  m
    add(image);
    setSize(getPrefWidth(), getPrefHeight());

    addListener(new InputListener() {
        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            if (isDisabled() == false)
                FocusManager.switchFocus(getStage(), VisImageButton.this);
            return false;
        }
    });

    updateImage();
}

From source file:com.mygdx.game.screens.touchme.GenererPartieTouchMeScreen.java

public GenererPartieTouchMeScreen(ICGame game) {
    this.game = game;
    batch = new SpriteBatch();
    stage = new Stage(new ScreenViewport());
    checkpoints = new ArrayList();
    imgCheckpoint = new Texture(Gdx.files.internal("checkpoint.png"));

    background = new Image();
    background.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    stage.addActor(background);/*from ww  w .j a v  a2  s  . com*/

    skin = new Skin(Gdx.files.internal("./skin/uiskin.json"));
    save = new TextButton("Sauvegarder", skin);
    jouerCurrent = new TextButton("Jouer avec ce modle", skin);
    nouvelEnregistrement = new TextButton("Nouveau modle", skin);
    quitter = new TextButton("Quitter", skin);

    table = new Table();
    table.add(save, jouerCurrent, nouvelEnregistrement, quitter);
    table.setPosition(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() - 20);
    stage.addActor(table);

    Gdx.input.setInputProcessor(stage);
}

From source file:com.o2d.pkayjava.editor.view.ui.properties.panels.UIBasicItemProperties.java

License:Apache License

public UIBasicItemProperties() {
    super();/*from ww w .  ja v  a2s.  co  m*/

    initMaps();

    Validators.FloatValidator floatValidator = new Validators.FloatValidator();

    itemType = createLabel("");
    itemType.setAlignment(Align.left);
    itemTypeIcon = new Image();

    libraryLinkLabel = createLabel("");
    libraryLinkLabel.setAlignment(Align.left);
    linkImage = new VisImageButton("library-link-button");
    linkImage.setWidth(22);

    VisTable iconContainer = new VisTable();
    iconContainer.add(itemTypeIcon).width(22).right();

    linkageContainer = new VisTable();
    linkageContainer.setVisible(false);
    linkageContainer.add(linkImage).width(22);
    linkageContainer.add(libraryLinkLabel);
    linkageContainer.row();

    idBox = StandardWidgetsFactory.createTextField();
    xValue = StandardWidgetsFactory.createValidableTextField(floatValidator);
    yValue = StandardWidgetsFactory.createValidableTextField(floatValidator);
    widthValue = StandardWidgetsFactory.createValidableTextField(floatValidator);
    heightValue = StandardWidgetsFactory.createValidableTextField(floatValidator);
    scaleXValue = StandardWidgetsFactory.createValidableTextField(floatValidator);
    scaleYValue = StandardWidgetsFactory.createValidableTextField(floatValidator);
    flipVertical = new VisCheckBox(null);
    flipHorizontal = new VisCheckBox(null);
    tintColorComponent = new TintButton(29, 21);
    rotationValue = StandardWidgetsFactory.createValidableTextField(floatValidator);
    customVarsButton = new VisTextButton("Custom Vars");
    tagsButton = new VisTextButton("Tags");

    nonExistantComponents = new VisSelectBox<>();
    addComponentButton = new VisTextButton("add");

    VisTable componentsTable = new VisTable();
    componentsTable.add(nonExistantComponents).left().width(150).padRight(10);
    componentsTable.add(addComponentButton).right().height(21);
    componentsTable.row();

    add(iconContainer).padRight(3).right().fillX();
    add(itemType).width(143).height(21).colspan(2).left();
    row();
    addSeparator().padTop(9).padBottom(6).colspan(3);
    add(createLabel("Identifier:", Align.left)).fillX();
    add(idBox).width(151).right().height(21).colspan(2);
    row();
    add(linkageContainer).colspan(3).right();
    row().padTop(2);
    add(createLabel("Position:")).padRight(3).left().top();
    add(getAsTable("X:", xValue, "Y:", yValue)).left();
    add(getAsTable("Width:", widthValue, "Height:", heightValue)).right();
    row().padTop(6);
    add(createLabel("Rotation:")).padRight(3).left();
    add(rotationValue).width(45).height(21).left().padLeft(13);
    add(getTintTable()).width(45).height(21).right().padLeft(13);
    row().padTop(6);
    add(createLabel("Scale:")).padRight(3).left().top();
    add(getAsTable("X:", scaleXValue, "Y:", scaleYValue)).left();
    VisTable buttonsTable = new VisTable();
    buttonsTable.add(customVarsButton);
    buttonsTable.row();
    buttonsTable.add(tagsButton).right().padTop(2);
    add(buttonsTable).height(45).left().top().padLeft(13);
    row();
    addSeparator().padTop(9).padBottom(6).colspan(3);
    add(createLabel("Add additional components:", Align.left)).fillX().colspan(3);
    row().padTop(6);
    add(componentsTable).left().colspan(3);
    row();

    setListeners();
}