Example usage for com.badlogic.gdx.scenes.scene2d.ui Align BOTTOM

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

Introduction

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

Prototype

int BOTTOM

To view the source code for com.badlogic.gdx.scenes.scene2d.ui Align BOTTOM.

Click Source Link

Usage

From source file:com.gsn.engine.template.GsnLabel.java

License:Apache License

@Override
public void layout() {
    computeBounds();/*from w  w w  . ja  v  a  2  s  .com*/

    if (wrap) {
        float prefHeight = getPrefHeight();
        if (prefHeight != lastPrefHeight) {
            lastPrefHeight = prefHeight;
            invalidateHierarchy();
        }
    }

    float y;
    if ((labelAlign & Align.TOP) != 0) {
        y = cache.getFont().isFlipped() ? 0 : height - bounds.height;
        y += style.font.getDescent();
    } else if ((labelAlign & Align.BOTTOM) != 0) {
        y = cache.getFont().isFlipped() ? height - bounds.height : 0;
        y -= style.font.getDescent();
    } else
        y = (height - bounds.height) / 2;
    if (!cache.getFont().isFlipped())
        y += bounds.height;

    float x;
    if ((labelAlign & Align.LEFT) != 0)
        x = 0;
    else if ((labelAlign & Align.RIGHT) != 0) {
        x = width - bounds.width;
    } else
        x = (width - bounds.width) / 2;

    if (wrap)
        cache.setWrappedText(text, x, y, bounds.width, lineAlign);
    else
        cache.setMultiLineText(text, x, y, bounds.width, lineAlign);
}