use of org.terasology.nui.HorizontalAlign in project Terasology by MovingBlocks.
the class HTMLUtils method createParagraphRenderStyleFromCommonAttributes.
public static ParagraphRenderStyle createParagraphRenderStyleFromCommonAttributes(Attributes attributes) {
Color textColor = getTextColor(attributes);
ParagraphRenderStyle.FloatStyle floatStyle = getFloatStyle(attributes);
ParagraphRenderStyle.ClearStyle clearStyle = getClearStyle(attributes);
HorizontalAlign horizontalAlign = getHorizontalAlign(attributes);
Color backgroundColor = getBackgroundColor(attributes);
ContainerInteger paragraphMarginTop = getParagraphMarginTop(attributes);
ContainerInteger paragraphMarginBottom = getParagraphMarginBottom(attributes);
ContainerInteger paragraphMarginLeft = getParagraphMarginLeft(attributes);
ContainerInteger paragraphMarginRight = getParagraphMarginRight(attributes);
ContainerInteger paragraphPaddingTop = getParagraphPaddingTop(attributes);
ContainerInteger paragraphPaddingBottom = getParagraphPaddingBottom(attributes);
ContainerInteger paragraphPaddingLeft = getParagraphPaddingLeft(attributes);
ContainerInteger paragraphPaddingRight = getParagraphPaddingRight(attributes);
ContainerInteger minimumWidth = getMinimumWidth(attributes);
return new ParagraphRenderStyle() {
@Override
public Color getColor(boolean hyperlink) {
return textColor;
}
@Override
public FloatStyle getFloatStyle() {
return floatStyle;
}
@Override
public ClearStyle getClearStyle() {
return clearStyle;
}
@Override
public HorizontalAlign getHorizontalAlignment() {
return horizontalAlign;
}
@Override
public Color getParagraphBackground() {
return backgroundColor;
}
@Override
public ContainerInteger getParagraphMarginTop() {
return paragraphMarginTop;
}
@Override
public ContainerInteger getParagraphMarginBottom() {
return paragraphMarginBottom;
}
@Override
public ContainerInteger getParagraphMarginLeft() {
return paragraphMarginLeft;
}
@Override
public ContainerInteger getParagraphMarginRight() {
return paragraphMarginRight;
}
@Override
public ContainerInteger getParagraphPaddingTop() {
return paragraphPaddingTop;
}
@Override
public ContainerInteger getParagraphPaddingBottom() {
return paragraphPaddingBottom;
}
@Override
public ContainerInteger getParagraphPaddingLeft() {
return paragraphPaddingLeft;
}
@Override
public ContainerInteger getParagraphPaddingRight() {
return paragraphPaddingRight;
}
@Override
public ContainerInteger getParagraphMinimumWidth() {
return minimumWidth;
}
};
}
use of org.terasology.nui.HorizontalAlign in project Terasology by MovingBlocks.
the class LwjglCanvasRenderer method drawText.
@Override
public void drawText(String text, Font font, HorizontalAlign hAlign, VerticalAlign vAlign, Rectanglei absoluteRegionRectangle, Colorc color, Colorc shadowColor, float alpha, boolean underlined) {
Rectanglei absoluteRegion = new Rectanglei(absoluteRegionRectangle);
TextCacheKey key = new TextCacheKey(text, font, absoluteRegion.getSizeX(), hAlign, color, shadowColor, underlined);
usedText.add(key);
Map<Material, Mesh> fontMesh = cachedText.get(key);
List<String> lines = TextLineBuilder.getLines(font, text, absoluteRegion.getSizeX());
if (fontMesh != null) {
for (Mesh mesh : fontMesh.values()) {
if (mesh.isDisposed()) {
fontMesh = null;
break;
}
}
}
if (fontMesh == null) {
fontMesh = fontMeshBuilder.createTextMesh((org.terasology.engine.rendering.assets.font.Font) font, lines, absoluteRegion.getSizeX(), hAlign, color, shadowColor, underlined);
cachedText.put(key, fontMesh);
}
Vector2i offset = new Vector2i(absoluteRegion.minX, absoluteRegion.minY);
offset.y += vAlign.getOffset(lines.size() * font.getLineHeight(), absoluteRegion.lengthY());
fontMesh.entrySet().stream().filter(entry -> entry.getKey().isRenderable()).forEach(entry -> {
entry.getKey().bindTextures();
entry.getKey().setMatrix4("projectionMatrix", projMatrix);
entry.getKey().setMatrix4("modelViewMatrix", modelMatrixStack);
entry.getKey().setFloat4(CROPPING_BOUNDARIES_PARAM, requestedCropRegion.minX, requestedCropRegion.maxX, requestedCropRegion.minY, requestedCropRegion.maxY);
entry.getKey().setFloat2("offset", offset.x, offset.y);
entry.getKey().setFloat("alpha", alpha);
entry.getValue().render();
});
}
Aggregations