Package com.simsilica.lemur.component
Class TbtQuadBackgroundComponent
java.lang.Object
com.simsilica.lemur.component.AbstractGuiComponent
com.simsilica.lemur.component.TbtQuadBackgroundComponent
- All Implemented Interfaces:
ColoredComponent,GuiComponent,Cloneable
public class TbtQuadBackgroundComponent
extends AbstractGuiComponent
implements Cloneable, ColoredComponent
A texture-covered background quad.
All coordinates are relative to the lower-left border.
The texture is split up into a three-by-three grid in this fashion:
+---+--------------+-------+
| | <-----> | |
y2 +---+--------------+-------+
| | | |
| ^ | ^ | ^ |
| | | | | | |
| | | <-----> | | |
| | | | | | |
| v | v | v |
| | | |
y1 +---+--------------+-------+
| | <-----> | |
+---+--------------+-------+
x1 x2
Arrows indicate the direction in which each grid cell will stretch to fill
the area given by the component.All coordinates are relative to the lower-left border.
Common pitfalls
- Placing controls on a fractional coordinate. This usually happens when centering controls.
- Having a contrast at the border between stretched and unstretched texture
zone (e.g. a black border and a white center). Stretching involves
interpolating colors with the neighbouring pixels (i.e. you'll get a
black-to-white color gradient).
The easiest workaround is to make the border one pixel wider so that the contrast will be safely inside the unstretched area. - Using a texture that is larger than the quad.
-
Constructor Summary
ConstructorsConstructorDescriptionTbtQuadBackgroundComponent(TbtQuad quad, Texture texture) TbtQuadBackgroundComponent(TbtQuad quad, Texture texture, float xMargin, float yMargin) TbtQuadBackgroundComponent(TbtQuad quad, Texture texture, float xMargin, float yMargin, float zOffset, boolean lit) -
Method Summary
Modifier and TypeMethodDescriptionvoidattach(GuiControl parent) voidclone()static TbtQuadBackgroundComponentstatic TbtQuadBackgroundComponentcreate(String texture, float imageScale, int x1, int y1, int x2, int y2, float zOffset, boolean lit) protected voidprotected voidvoiddetach(GuiControl parent) floatgetAlpha()Returns the current alpha multiplier that is applied to the color when set to the actual visuals.getColor()Returns the current color of this component.floatprotected voidrefreshBackground(Vector3f size) protected voidvoidvoidsetAlpha(float f) Sets an alpha multiplier that will be applied to the color when set to the actual visuals.voidSets the color for this component.voidsetMargin(float x, float y) voidvoidvoidsetZOffset(float z) toString()Methods inherited from class com.simsilica.lemur.component.AbstractGuiComponent
getGuiControl, getNode, invalidate, isAttached
-
Constructor Details
-
TbtQuadBackgroundComponent
-
TbtQuadBackgroundComponent
-
TbtQuadBackgroundComponent
-
TbtQuadBackgroundComponent
-
-
Method Details
-
create
public static TbtQuadBackgroundComponent create(String texture, float imageScale, int x1, int y1, int x2, int y2, float zOffset, boolean lit) -
create
public static TbtQuadBackgroundComponent create(Texture t, float imageScale, int x1, int y1, int x2, int y2, float zOffset, boolean lit) -
clone
- Specified by:
clonein interfaceGuiComponent- Overrides:
clonein classAbstractGuiComponent
-
attach
- Specified by:
attachin interfaceGuiComponent- Overrides:
attachin classAbstractGuiComponent
-
detach
- Specified by:
detachin interfaceGuiComponent- Overrides:
detachin classAbstractGuiComponent
-
setColor
Description copied from interface:ColoredComponentSets the color for this component.- Specified by:
setColorin interfaceColoredComponent
-
resetColor
protected void resetColor() -
getColor
Description copied from interface:ColoredComponentReturns the current color of this component.- Specified by:
getColorin interfaceColoredComponent
-
setAlpha
public void setAlpha(float f) Description copied from interface:ColoredComponentSets an alpha multiplier that will be applied to the color when set to the actual visuals.- Specified by:
setAlphain interfaceColoredComponent
-
getAlpha
public float getAlpha()Description copied from interface:ColoredComponentReturns the current alpha multiplier that is applied to the color when set to the actual visuals.- Specified by:
getAlphain interfaceColoredComponent
-
setTexture
-
getTexture
-
setMargin
public void setMargin(float x, float y) -
setMargin
-
getMargin
-
setZOffset
public void setZOffset(float z) -
getZOffset
public float getZOffset() -
getMaterial
-
calculatePreferredSize
- Specified by:
calculatePreferredSizein interfaceGuiComponent
-
reshape
- Specified by:
reshapein interfaceGuiComponent
-
createMaterial
protected void createMaterial() -
createGeometry
protected void createGeometry() -
refreshBackground
-
toString
-