jMonkey LorisGUI - Components

The layered, visual display elements of a Control

Home Overview Visuals XML Style Model Controls Components Layouts
 

Component Layers

Various components are layered on top of one another to produce the visual display for every Control.

<insets>
Define the component that occupies the insets layer. The do not provide any visual display but rather adjust the position and size of all interior layers. By default, an InsetsComponent is created.
<border>
Define the component that occupies the border layer. The border provides a rectangular border for its Control based on a gutter that surrounds the background. By default, a BackgroundComponent is created.
<background>
Define the component that occupies the background layer. The background provides a color/texture that becomes the backdrop for all interior layers. By default, a BackgroundComponent is created.
<icon>
Define the component that occupies the icon layer. The icon provides a special decoration on top of the background. By default, an IconComponent is created.
<layout class='...'>
Define the component that occupies the layout layer. Layout is used by Container and its subclasses to provide visual organization to child Controls. A GuiLayout of a given class is created. If no explicit class is provided, a TileLayout is created.
text
shadowText
The text and shadowText layers are internal constructs, created and managed by controls like Label, TextString, etc. A TextComponent is used to handle the visual display duties of these component layers. However, there is very limited need for a Loris developer to create/configure a TextComponent directly from XML.
 

BackgroundComponent

The BackgroundComponent provides a rectangular fill for its Control. This fill may be a simple color, an image/texture, or a 3D construct. Typically, a background consumes no inherent space other than the size of its margins.

alpha='aFloat'
Provide an override alpha value in the range 0.0 to 1.0. A value of -1.0 disables the override.
color='#rrggbbaa/#rgba'
<color r='aFloat' g='aFloat' b='aFloat' a='aFloat'>
The background color, as defined by 0.0 to 1.0 aFloat values for red, green, blue, and alpha. Or by the hex string where rr, gg, bb, and aa are hex digits in the range 00 to ff (or 0 to f for the short form).
<fill class='fillQuad/multiQuad/tbtQuad/scaledQuad/fillGeometry'>
Define the fill that makes up the background. The type of fill is determined by the class selected.
image='imagepath'
<image class='com.jme3.texture.Texture'>
If not given an explicit <fill>, then an image can be supplied, either as a simple path to an image file or as a fully specified Texture.
margin='value'
xMargin='value' yMargin='value'
leftMargin='value' rightMargin='value' topMargin='value' bottomMargin='value'
Establish gutters around the components interior to the background. 'margin' applies to all four sides, 'xMargin' applies to the right and left sides. 'yMargin' applies to the top and bottom sides.
reserveInherentSize='true/false'
When true, the background ensures a minimal size that equals the size of the fill image.
<stateAdapters>
Define 1 or more state adapters that alter this component based on the active control display state.
 

IconComponent

The IconComponent provides a special decoration layered on top of the background. Whereas a background typically consumes no space expect for its margins, an icon will consume enough space to match its associated image.

alignH='Left/Center/Right'
How to align the icon horizontally in its given space.
alignV='Top/Middle/Bottom'
How to align the icon vertically in its given space.
<offset x='value' y='value' />
Optional bias to apply when positioning the icon.
overlay='true/false'
Flag that controls if the icon consumes space or not. If acting as an overlay, the icon does not affect the size. If not an overlay (the default), then the width is bumped for Left/Right, and the height is bumped for Top/Bottom. For Center/Middle, the width/height are only adjusted to ensure there is minimum that accepts the icon size.
SEE ALSO:
BackgroundComponent
 

InsetsComponent

The InsetsComponent defines positioning and resizing for its Control. It supports two aspects: a static, fixed gutter around the outer edge, and dynamic positioning. The fixed gutter is defined independently for all four sides. For any non-zero gutter, the corresponding width/height is incremented during the preferred size calculation, and the starting position is kicked left and down accordingly. The Insets has no visual aspect, so the parent control shines through the gutters.

The dynamic positioning only applies when the actual available size exceeds the preferred size. In this case, the excess is divvied up and applied to the starting position. The dynamic positioning is represented by a percentage applied to all four edges. The most common example is 50% applied left and right, with 50% applied top and bottom. This results in the Viewable being centered within the excess space.

NOTE that if your static gutter definitions are all <= 1.0, then they are treated as a dynamic setting.

margin='value'
xMargin='value' yMargin='value'
leftMargin='value' rightMargin='value' topMargin='value' bottomMargin='value'
Establish gutters around all other components. 'margin' applies to all four sides, 'xMargin' applies to the right and left sides. 'yMargin' applies to the top and bottom sides.
position='Center/NW/North/NE/West/East/SW/South/SE'
Set the dynamic insets to match corresponding given position.
<dynamic ...margin settings.../>
If position is not used, then you can set the dynamic margins individually. The margins given are scaled to ensure both the width and height settings sum to 1.0.
 

TextComponent

The TextComponent defines a run of text characters in a given font/size/color. An instance of a TextComponent is rarely explicitly constructed, since most text presentation is embedded within text oriented controls, such as Label or TextString. But a TextComponent is just like any other component and can be explicitly used as such.

charCount='aFloat'
Reserve minimal space for a given count of characters (em space). This count can be fractional since the em space can be a bit wide.
font='pathToFont'
Select the font used to display the text.
fontSize='aFloat'
The size of the font used to display the text.
lineCount='anInt'
Reserve minimal space for a given count of rows.
maxTextHeight='height'
The maximum height allowed for the text box.
maxTextWidth='width'
The maximum width allowed for the text box.
<textStateAdapters>
Define a set of state adapters that modify the text attributes as the control changes state.
text='aString'
Define the run of text characters to display in this Label. A newline can be included by the combination \n and a tab can be included by the combination \t.
textColor='#rrggbbaa/#rgba'
<textColor r='aFloat' g='aFloat' b='aFloat' a='aFloat'>
Define the color of the text.
textAlignH='Left/Center/Right'
How to align the text horizontally in its given space.
textAlignV='Top/Middle/Bottom'
How to align the text vertically in its given space.
 

Fill

Fill is used to provide the pixels that populate a background or icon. Most fill is based on a flat Quad providing pixels in two dimensions. But there also exists a FillGeometry, based on an arbitrary Mesh, which in only flattened into 2D by the Camera associated with the GUI Viewport.

 
FillQuad

The simplest fill is based on a 2D rectangular Quad populated by a single texture.

<bias x='value' y='value'/>
Apply a right/down bias when rendering the texture.
height='value'
Override the height of the underlying texture.
image='pathToImageFile
texture='pathToImageFile
Load the texture from the given file.
repeatTexture='true/false'
Control flag indicating if this is a repeating texture or not.
<texture class='com.jme3.texture.Texture' allTextureAttrsHere />
Use the in-line definition of the texture.
width='value'
Override the width of the underlying texture.
 
MultiQuad

A MutltiQuad is a 2D rectangular Quad populated by a compound image that contains a repeating set of equally sized images. One such image is selected to act as the fill. The image set can be vertically oriented (index selects a row), horizontally oriented (index selects a column), or tabular (indexes select row and column).

xCount='count of images in a row'
Multiple images exist in a row within the given texture.
yCount='count of images in a column'
Multiple images exist in a column within the given texture.
xActive='column index'
Select which sub-texture to render based on its column.
yActive='row index'
Select which sub-texture to render based on its row.
SEE ALSO:
FillQuad
 
ScaledQuad

The scaled fill is based on a 2D rectangular Quad populated by a single image, with possibly scaling applied to the texture. A ScaledQuad can also be set to 'tile' an area larger than the image, rather than stretching the image.

textureScaleX='value'
Scaling to apply in the X dimension.
textureScaleY='value'
Scaling to apply in the Y dimension.
tileToCover='true/false'
Control flag that determines if the texture will be stretched or tiled.
SEE ALSO:
FillQuad
 
TbtQuad

The TbtQuad is based on a 2D rectangular Quad treated as a three-by-three grid. When stretching the Quad to fill a space larger than the inherent image, NW, NE, SW, and SE cells are not stretched at all. West/East are stretched only vertically, and North/South are stretched only horizontally. The Center is stretched both ways. This gives you image that stretches nicely without being distorted. The TbtQuad is inherently a MultiQuad so that multiple 3by3 images can be included in a single file.

          +-----+--------------+-------+
          |     |    <----->   |       |
       y2 +-----+--------------+-------+
          |     |              |       |
          |  ^  |       ^      |   ^   |
          |  |  |       |      |   |   |
          |  |  |    <----->   |   |   |
          |  |  |       |      |   |   |
          |  v  |       v      |   v   |
          |     |              |       |
       y1 +-----+--------------+-------+
          |     |    <----->   |       |
          +-----+--------------+-------+
               x1              x2
	    
x1='value' x2='value' y1='value' y2='value
Define where the boundaries within the image are for locating the cells.
imageScale='factor'
Define the scaling factor applied to the inherent image size and given coordinates. The default value is 1.0, which means scaling does not apply.
SEE ALSO:
FillQuad, MultiQuad
 
FillGeometry

FillGeometry is not based on a Quad, but rather renders any arbitrary mesh. It extends com.jme3.scene.Geometry and uses the standard XML import process to load the geometry mesh. You can also provide a texture to use with the Geometry.

<mesh class='SomeMeshClassThatDefinesYourShape' />
Provide the mesh that defines the Geometry to display.
<transform class='com.jme3.math.Transform' ...transform attributes... />
You will often use a custom transform to scale the mesh to an appropriate size.
height='value'
Override the height of the underlying Geometry.
image='pathToImageFile
texture='pathToImageFile
Load the texture from the given file.
<textrue class='com.jme3.texture.Texture' allTextureAttrsHere />
Use the in-line definition of the texture.
width='value'
Override the width of the underlying Geometry.
 

Display State Adapters

A DisplayStateAdapter alters its associated component based on the active display state of the associated Viewable. While every adapter can support a comprehensive set of different display states, providing a different action for every state permutation, in most cases only a few special states are identified, and these actions cover a rather wide range of individual states. For example, a single action defined for the Inactive state will apply to FocusInactive, HoverInactive, etc.

  • Disabled - The Viewable is disabled and not taking an active part in any interaction. This represents the most generic of all states and will be used if no other state is supported.
  • Inactive - The Viewable is a participant in on-going interactions, but has not currently been selected in any way. For something like a Checkbox, this would be used for the 'off' state. Viewables that can never be Active will always be considered to be Inactive
  • Active - The Viewable has been selected in some way. For a Checkbox, it is currently 'on'.
  • FocusInactive - The Viewable is Inactive, and has the current key Focus
  • FocusActive - The Viewable is Active, and has the current key Focus
  • HoverInactive - The Viewable is Inactive, and the Mouse is hovering over it
  • HoverActive - The Viewable is Active, and the Mouse is hovering over it
  • HoverFocusInactive - The Viewable is Inactive, with key Focus, and the Mouse is hovering over
  • HoverFocusActive - The Viewable is Active, with key Focus, and the Mouse is hovering over
  • CustomInactive - Custom variant of Inactive
  • CustomActive - Custom variant of Active
  • Pressed - Mouse Button/Key is actively being pressed, not yet released

The various state adapters apply different adjustments based on the kind of adapter:

 ColorStateAdapter
Each state is associated with a Color, applied to the Component when that state is in force.
<colorStateAdapter>
    <states>
        <Inactive><color r='0' g='0' b='0' a='1' /></Inactive>
        <Active><color r='1' g='1' b='1' a='1' /></Active>
    </states>
</colorStateAdapter>
	    	    
 AlphaStateAdapter
Each state is associated with an Alpha factor override applied to the Component when that state is in force. The special factor value of -1.0 removes the override.
The AlphaStateAdapter has the ability to effect more than just its associated component. Whereas most StateAdapters only have meaning at the individual component level, Viewables can adjust the override alpha across all their components. You can therefore direct the adapter to affect just its component (Self), affect all components within the parent Viewable (Parent), affect all components within the parent viewable and affect all child Viewables, recursively (ParentTree), and affect all child Viewables, recursively, but not the parent Viewable itself (ParentChildren).
<alphaStateAdapter applyTo='Self/Parent/ParentTree/ParentChildren'>
    <states>
        <Disabled  value='0.3'/>
        <Inactive  value='-1' />
    </states>
</alphaStateAdapter>
	    	    
 MaterialStateAdapter
Each state is associated with a Material applied to the Component when that state is in force. The Material can be based on a color, an inline Texture, a TextureKey, or a texture loaded from an image.
<materialStateAdapter>
    <states>
        <Inactive><color r='0' g='0' b='0' a='1' /></Inactive>
        <Active><com.jme3.texture.Texture attrsThatDefineTheTexture /></Active>
        <FocusActive><com.jme3.asset.TextureKey name='pathToATexture' /></FocusActive>
        <HoverInactive  value='pathToAnImage' />
    </states>
</materialStateAdapter>
	    	    
 TextureStateAdapter
Each state is associated with a Texture applied to the Component when that state is in force. The Texture can be an inline Texture, a TextureKey, or a texture loaded from an image.
<textureStateAdapter>
    <states>
        <Active><com.jme3.texture.Texture attrsThatDefineTheTexture /></Active>
        <FocusActive><com.jme3.asset.TextureKey name='pathToATexture' /></FocusActive>
        <HoverInactive  value='pathToAnImage' />
    </states>
</textureStateAdapter>
	    	    
 MultiTextureStateAdapter
Each state is associated with a particular sub-texture taken from a MultiQuad. The value of the state is the index of the sub-texture, or the row/column indexes of a table of sub-textures within the MultiQuad.
<mutliTextureStateAdapter>
    <states>
        <Inactive  value='indexValue'/>
        <Active  value='colIndex,rowIndex' />
    </states>
</multiTextureStateAdapter>
	    	    
 OverlayStateAdapter
Each state is associated with an image overlaid on top of the component. The image can be provided by an image, a texture, or a complete BackgroundFill specification.
<overlayStateAdapter>
    <states>
        <Active><com.jme3.texture.Texture attrsThatDefineTheTexture /></Active>
        <FocusActive><com.jme3.asset.TextureKey name='pathToATexture' /></FocusActive>
        <HoverInactive  value='pathToAnImage' />
        <Pressed><fillQuad completeSpecificationOfTheQuad /></Pressed>
    </states>
</overlayStateAdapter>
	    	    
 TextStateAdapter
Each state is associated with a set of options that can affect a TextComponent. These options include changing the text itself, changing the color of the text (all or matching a pattern), changing the alpha override of the text (all or matching a pattern), changing the font style of the text (all or matching a pattern).
The style is selected by a styleID integer or if you are using BitmapFontLoris to merge a set of fonts defined in XML, you can reference any style tag defined therein.
The pattern is a text pattern matcher as defined by java.util.regex.Pattern.
<textStateAdapter>
    <states>
        <Active><textStateSpec color='#f00f' style='italic' alpha='0.5 /></Active>
        <FocusActive><textStateSpec text='Display This' styleID='0' pattern='XXX' >
            <color r='0.5' g='0.5 b='0.5' a='1.0'/>
        </FocusActive>
    </states>
</textStateAdapter>
				

For any single component, you can define one or more different adapters. You end up with something like this:

    <stateAdapters>
        <colorStateAdapter>
            ... 
        </colorStateAdapter>
        <textStateAdapter>
            ....
        </textStateAdapter>
    </stateAdapters>