Java源码示例:com.jme3.font.BitmapFont.Align

示例1
protected void resetAlignment() {
    if( textBox == null )
        return;

    switch( hAlign ) {
        case Left:
            bitmapText.setAlignment(Align.Left);
            break;
        case Right:
            bitmapText.setAlignment(Align.Right);
            break;
        case Center:
            bitmapText.setAlignment(Align.Center);
            break;
    }
    switch( vAlign ) {
        case Top:
            bitmapText.setVerticalAlignment(VAlign.Top);
            break;
        case Bottom:
            bitmapText.setVerticalAlignment(VAlign.Bottom);
            break;
        case Center:
            bitmapText.setVerticalAlignment(VAlign.Center);
            break;
    }
}
 
示例2
protected void resetAlignment() {
    if( textBox == null )
        return;

    switch( hAlign ) {
        case Left:
            bitmapText.setAlignment(Align.Left);
            break;
        case Right:
            bitmapText.setAlignment(Align.Right);
            break;
        case Center:
            bitmapText.setAlignment(Align.Center);
            break;
    }
    switch( vAlign ) {
        case Top:
            bitmapText.setVerticalAlignment(VAlign.Top);
            break;
        case Bottom:
            bitmapText.setVerticalAlignment(VAlign.Bottom);
            break;
        case Center:
            bitmapText.setVerticalAlignment(VAlign.Center);
            break;
    }
}
 
示例3
/**
 * Set horizontal alignment. Applicable only when text bound is set.
 * @param align
 */
public void setAlignment(BitmapFont.Align align) {
    if (block.getTextBox() == null && align != Align.Left) {
        throw new RuntimeException("Bound is not set");
    }
    block.setAlignment(align);
    letters.invalidate();
    needRefresh = true;
}
 
示例4
/**
 *
 * @param text the text that the StringBlock will hold
 * @param textBox the rectangle that constrains the text
 * @param alignment the initial alignment of the text
 * @param size the size in pixels (vertical size of a single line)
 * @param color the initial color of the text
 * @param kerning
 */
StringBlock(String text, Rectangle textBox, BitmapFont.Align alignment, float size, ColorRGBA color,
        boolean kerning) {
    this.text = text;
    this.textBox = textBox;
    this.alignment = alignment;
    this.size = size;
    this.color.set(color);
    this.kerning = kerning;
}
 
示例5
StringBlock(){
    this.text = "";
    this.textBox = null;
    this.alignment = Align.Left;
    this.size = 100;
    this.color.set(ColorRGBA.White);
    this.kerning = true;
}
 
示例6
/**
 * Set horizontal alignment. Applicable only when text bound is set.
 * @param align
 */
public void setAlignment(BitmapFont.Align align) {
    if (block.getTextBox() == null && align != Align.Left) {
        throw new RuntimeException("Bound is not set");
    }
    block.setAlignment(align);
    letters.invalidate();
    needRefresh = true;
}
 
示例7
/**
 *
 * @param text the text that the StringBlock will hold
 * @param textBox the rectangle that constrains the text
 * @param alignment the initial alignment of the text
 * @param size the size in pixels (vertical size of a single line)
 * @param color the initial color of the text
 * @param kerning
 */
StringBlock(String text, Rectangle textBox, BitmapFont.Align alignment, float size, ColorRGBA color,
        boolean kerning) {
    this.text = text;
    this.textBox = textBox;
    this.alignment = alignment;
    this.size = size;
    this.color.set(color);
    this.kerning = kerning;
}
 
示例8
StringBlock(){
    this.text = "";
    this.textBox = null;
    this.alignment = Align.Left;
    this.size = 100;
    this.color.set(ColorRGBA.White);
    this.kerning = true;
}
 
示例9
public BitmapFont.Align getAlignment() {
    return block.getAlignment();
}
 
示例10
private void align() {
    final Align alignment = block.getAlignment();
    final VAlign valignment = block.getVerticalAlignment();
    if (block.getTextBox() == null || (alignment == Align.Left && valignment == VAlign.Top))
        return;
    LetterQuad cursor = tail.getPrevious();
    cursor.setEndOfLine();
    final float width = block.getTextBox().width;
    final float height = block.getTextBox().height;
    float lineWidth = 0;
    float gapX = 0;
    float gapY = 0;
    validateSize();
    if (totalHeight < height) { // align vertically only for no overflow
        switch (valignment) {
        case Top:
            gapY = 0;
            break;
        case Center:
            gapY = (height - totalHeight) * 0.5f;
            break;
        case Bottom:
            gapY = height - totalHeight;
            break;
        }
    }
    while (!cursor.isHead()) {
        if (cursor.isEndOfLine()) {
            lineWidth = cursor.getX1()-block.getTextBox().x;
            if (alignment == Align.Center) {
                gapX = (width-lineWidth)/2;
            } else if (alignment == Align.Right) {
                gapX = width-lineWidth;
            } else {
                gapX = 0;
            }
        }
        cursor.setAlignment(gapX, gapY);
        cursor = cursor.getPrevious();
    }
}
 
示例11
BitmapFont.Align getAlignment() {
    return alignment;
}
 
示例12
void setAlignment(BitmapFont.Align alignment) {
    this.alignment = alignment;
}
 
示例13
public BitmapFont.Align getAlignment() {
    return block.getAlignment();
}
 
示例14
private void align() {
    final Align alignment = block.getAlignment();
    final VAlign valignment = block.getVerticalAlignment();
    if (block.getTextBox() == null || (alignment == Align.Left && valignment == VAlign.Top))
        return;
    LetterQuad cursor = tail.getPrevious();
    cursor.setEndOfLine();
    final float width = block.getTextBox().width;
    final float height = block.getTextBox().height;
    float lineWidth = 0;
    float gapX = 0;
    float gapY = 0;
    validateSize();
    if (totalHeight < height) { // align vertically only for no overflow
        switch (valignment) {
        case Top:
            gapY = 0;
            break;
        case Center:
            gapY = (height-totalHeight)*0.5f;
            break;
        case Bottom:
            gapY = height-totalHeight;
            break;
        }
    }
    while (!cursor.isHead()) {
        if (cursor.isEndOfLine()) {
            lineWidth = cursor.getX1()-block.getTextBox().x;
            if (alignment == Align.Center) {
                gapX = (width-lineWidth)/2;
            } else if (alignment == Align.Right) {
                gapX = width-lineWidth;
            } else {
                gapX = 0;
            }
        }
        cursor.setAlignment(gapX, gapY);
        cursor = cursor.getPrevious();
    }
}
 
示例15
BitmapFont.Align getAlignment() {
    return alignment;
}
 
示例16
void setAlignment(BitmapFont.Align alignment) {
    this.alignment = alignment;
}