Example usage for com.badlogic.gdx.scenes.scene2d Actor setHeight

List of usage examples for com.badlogic.gdx.scenes.scene2d Actor setHeight

Introduction

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

Prototype

public void setHeight(float height) 

Source Link

Usage

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

License:Apache License

protected void applyActorProperties(Actor actor, XmlReader.Element element, Group parentActor) {
    AnchorGroup anchorGroup = null;//w  w w .  j  a va2  s .co  m
    if (parentActor != null) {
        parentActor.addActor(actor);
        if (parentActor instanceof AnchorGroup) {
            anchorGroup = (AnchorGroup) parentActor;
        }
    }
    String attr = element.getAttribute("x", "");
    if (!attr.isEmpty()) {
        actor.setX(Float.parseFloat(attr));
    }
    attr = element.getAttribute("y", "");
    if (!attr.isEmpty()) {
        actor.setY(Float.parseFloat(attr));
    }
    attr = element.getAttribute("width", "");
    if (!attr.isEmpty()) {
        actor.setWidth(Float.parseFloat(attr));
    }
    attr = element.getAttribute("height", "");
    if (!attr.isEmpty()) {
        actor.setHeight(Float.parseFloat(attr));
    }
    attr = element.getAttribute("originX", "");
    if (!attr.isEmpty()) {
        actor.setOriginX(Float.parseFloat(attr));
    }
    attr = element.getAttribute("originY", "");
    if (!attr.isEmpty()) {
        actor.setOriginY(Float.parseFloat(attr));
    }
    attr = element.getAttribute("visible", "");
    if (!attr.isEmpty()) {
        actor.setVisible(Boolean.parseBoolean(attr));
    }
    attr = element.getAttribute("color", "");
    if (!attr.isEmpty()) {
        actor.setColor(Color.valueOf(attr));
    }
    attr = element.getAttribute("debug", "");
    if (!attr.isEmpty()) {
        if (actor instanceof Group) {
            Group group = (Group) actor;
            attr = attr.toLowerCase();
            if (attr.equals("true")) {
                group.debug();
            } else if (attr.equals("all")) {
                group.debugAll();
            }
        } else {
            actor.setDebug(Boolean.parseBoolean(attr));
        }
    }
    for (int idx = 0, size = ANCHOR_NAMES.length; idx < size; ++idx) {
        String anchorName = ANCHOR_NAMES[idx];
        attr = element.getAttribute(anchorName, "");
        if (!attr.isEmpty()) {
            if (anchorGroup == null) {
                throw new RuntimeException("Parent of " + actor + " is not an anchor group");
            }
            PositionRule rule = parseRule(attr, anchorGroup.getSpacing());
            rule.target = actor;
            rule.targetAnchor = ANCHORS[idx];
            anchorGroup.addRule(rule);
        }
    }
}

From source file:com.vlaaad.common.gdx.scene2d.TabPane.java

License:Open Source License

@Override
public void layout() {
    if (selectedIndex == -1)
        return;/*  w ww .j a  v a  2 s. c  om*/
    // left offset
    float bordersHeight = 0f;
    headersLeftOffset = 0f;
    if (selectedIndex == 0) {
        if (style.activeBorderLeftEdge != null) {
            headersLeftOffset = style.activeBorderLeftEdge.getMinWidth();
            bordersHeight = style.activeBorderLeftEdge.getMinHeight();
        }
    } else {
        if (style.inactiveBorderLeftEdge != null) {
            headersLeftOffset = style.inactiveBorderLeftEdge.getMinWidth();
            bordersHeight = Math.max(bordersHeight, style.inactiveBorderLeftEdge.getMinHeight());
        }
    }
    //right offset
    headersRightOffset = 0f;
    if (selectedIndex == headers.size - 1) {
        if (style.activeBorderRightEdge != null) {
            headersRightOffset = style.activeBorderRightEdge.getMinWidth();
            bordersHeight = Math.max(bordersHeight, style.activeBorderRightEdge.getMinHeight());
        }
    } else {
        if (style.inactiveBorderRightEdge != null) {
            headersRightOffset = style.inactiveBorderRightEdge.getMinWidth();
            bordersHeight = Math.max(bordersHeight, style.inactiveBorderRightEdge.getMinHeight());
        }
    }
    //size between headers
    headersBetweenOffset = 0f;
    if (style.inactiveBorder != null) {
        headersBetweenOffset = style.inactiveBorder.getMinWidth();
        bordersHeight = Math.max(bordersHeight, style.inactiveBorder.getMinHeight());
    }
    if (style.activeBorderLeft != null) {
        headersBetweenOffset = Math.max(style.activeBorderLeft.getMinWidth(), headersBetweenOffset);
        bordersHeight = Math.max(bordersHeight, style.activeBorderLeft.getMinHeight());
    }
    if (style.activeBorderRight != null) {
        headersBetweenOffset = Math.max(style.activeBorderRight.getMinWidth(), headersBetweenOffset);
        bordersHeight = Math.max(bordersHeight, style.activeBorderRight.getMinHeight());
    }
    headersHeight = bordersHeight;
    for (Actor header : headers) {
        headersHeight = Math.max(headersHeight,
                header instanceof Layout ? ((Layout) header).getPrefHeight() : header.getHeight());
    }
    headerWidth = (getWidth() - headersLeftOffset - headersRightOffset
            - headersBetweenOffset * (headers.size - 1)) / headers.size;
    int i = 0;
    contentHeight = getHeight() - headersHeight;
    for (Actor header : headers) {
        header.setWidth(headerWidth);
        header.setHeight(headersHeight);
        header.setPosition(i * headerWidth + headersLeftOffset + headersBetweenOffset * i, contentHeight);
        if (header instanceof Layout) {
            ((Layout) header).layout();
        }
        i++;
    }
    Actor content = contents.get(selectedIndex);
    content.setWidth(getWidth());
    content.setHeight(contentHeight);
    content.setPosition(0, 0);
    if (content instanceof Layout)
        ((Layout) content).layout();
}

From source file:de.bitbrain.craft.ui.elements.ElementConnector.java

License:Open Source License

private Actor addSpacing(String id) {
    Actor spacing = new Actor();
    spacing.setWidth(group.getWidth());/*from   w  ww. j av a  2s.c o m*/
    spacing.setHeight(SPACING);
    spacings.put(id, spacing);
    return spacing;
}

From source file:mobi.shad.s3lib.gui.GuiUtil.java

License:Apache License

/**
 * @param actor//from   w w w  . j  a va2 s.  c  o  m
 * @param sizeX
 * @param sizeY
 * @return
 */
public static Actor normalizeSize(Actor actor, float sizeX, float sizeY) {
    if (sizeX < 0.0) {
        sizeX = 0;
    } else if (sizeX > 1) {
        sizeX = 1;
    }
    if (sizeY < 0.0) {
        sizeY = 0;
    } else if (sizeY > 1) {
        sizeY = 1;
    }
    actor.setWidth(sizeX * S3Screen.width);
    actor.setHeight(sizeY * S3Screen.height);
    return actor;
}

From source file:mobi.shad.s3lib.gui.widget.HtmlView.java

License:Apache License

private void addActor(final Element element, final Actor actor, final Table mainTable) {
    CssStyle style = parseCssStyle(element);
    mainTable.row();/*from  w ww. j  a  v a 2 s .  co m*/
    String src = element.getAttribute("src", "");
    String align = element.getAttribute("align", "");
    int width = element.getIntAttribute("width", 0);
    int height = element.getIntAttribute("height", 0);
    int collSpan = element.getIntAttribute("collspan", 1);
    int padding = element.getIntAttribute("padding", 0);
    int cellwidth = element.getIntAttribute("cellwidth", 0);
    int cellheight = element.getIntAttribute("cellheight", 0);
    int fill = element.getIntAttribute("fill", 0);

    int size = element.getIntAttribute("size", S3Constans.textureImageSize);
    int length = 0;
    if (element.getText() != null) {
        length = element.getText().length();
    }

    if (width > 0) {
        actor.setWidth(width);
    }
    if (height > 0) {
        actor.setHeight(height);
    }

    if (align.equalsIgnoreCase("center")) {
        mainTable.row();
        Cell cell = mainTable.add(actor).center().colspan(collSpan).pad(padding);
        if (width > 0) {
            cell.width(width);
        }
        if (height > 0) {
            cell.height(height);
        }
        if (cellwidth > 0) {
            cell.width(cellwidth);
        }
        if (cellheight > 0) {
            cell.height(cellheight);
        }
        if (fill > 0) {
            cell.fill();
        }
        if (length > 0) {
            mainTable.row();
            addTableNode(element, style, mainTable);
        }
    } else if (align.equalsIgnoreCase("left")) {
        mainTable.row();
        Cell cell = mainTable.add(actor).left().colspan(collSpan).pad(padding).uniform();
        if (width > 0) {
            cell.width(width);
        }
        if (height > 0) {
            cell.height(height);
        }
        if (cellwidth > 0) {
            cell.width(cellwidth);
        }
        if (cellheight > 0) {
            cell.height(cellheight);
        }
        if (fill > 0) {
            cell.fill();
        }
        if (length > 0) {
            addTableNode(element, style, mainTable);
        }
    } else if (align.equalsIgnoreCase("right")) {
        mainTable.row();
        if (length > 0) {
            addTableNode(element, style, mainTable);
        }
        Cell cell = mainTable.add(actor).right().colspan(collSpan).pad(padding).uniform();
        if (width > 0) {
            cell.width(width);
        }
        if (height > 0) {
            cell.height(height);
        }
        if (cellwidth > 0) {
            cell.width(cellwidth);
        }
        if (cellheight > 0) {
            cell.height(cellheight);
        }
        if (fill > 0) {
            cell.fill();
        }
    } else {
        mainTable.row();
        Cell cell = mainTable.add(actor).colspan(collSpan).pad(padding);
        if (width > 0) {
            cell.width(width);
        }
        if (height > 0) {
            cell.height(height);
        }
        if (cellwidth > 0) {
            cell.width(cellwidth);
        }
        if (cellheight > 0) {
            cell.height(cellheight);
        }
        if (fill > 0) {
            cell.fill();
        }
        if (length > 0) {
            addTableNode(element, style, mainTable);
        }
    }
}

From source file:net.mwplay.cocostudio.ui.DemoScreen.java

License:Apache License

private void initDemoChange(InputMultiplexer multiplexer) {
    Stage demoChangeStage = new Stage(new StretchViewport(DemoGame.GAME_WIDTH, DemoGame.GAME_HEIGHT));
    Actor actor = new Actor();
    actor.setWidth(stage.getWidth());//from  w  w w. j  av a2s . co  m
    actor.setHeight(stage.getHeight());
    actor.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            updateCurrentIndex();
            changeDemo();
        }
    });
    demoChangeStage.addActor(actor);
    multiplexer.addProcessor(demoChangeStage);
}

From source file:org.ams.core.SceneUtil.java

License:Open Source License

public static void fillAndCenter(Stage stage, Actor actor) {
    actor.setWidth(stage.getWidth());/*  ww  w .  j  a  v  a 2  s.  com*/
    actor.setHeight(stage.getHeight());

    float x = stage.getWidth() * 0.5f;
    float y = stage.getHeight() * 0.5f;

    actor.setPosition(x, y, Align.center);

}