com.jmex.bui
Class BStyleSheet

java.lang.Object
  extended by com.jmex.bui.BStyleSheet
All Implemented Interfaces:
BStyleConstants

public class BStyleSheet
extends java.lang.Object
implements BStyleConstants

Defines a stylesheet which is used to configure the style (font family, font size, foreground and background color, etc.) of components in the BUI library. The BUI stylesheets syntax is a subset of the Cascading Style Sheet sytnax and follows its semantic conventions as well where possible.

A basic stylesheet enumerating most usable values is as follows:

 style_class {*   // foreground and background properties
   color: 0 0 0;
   background: solid #00000088; // note the 50% alpha
   background: image monkey.png XX; // XX = centerx|centery|centerxy|
                                    //      scalex|scaley|scalexy|
                                    //      tilex|tiley|tilexy|
                                    //      framex|framey|framexy
   background: image monkey.png framexy top right bottom left;
   cursor: name;
 

// text properties font: Helvetica XX 12; // XX = normal|bold|italic|bolditalic text-align: XX; // XX = left|center|right vertical-align: XX; // XX = top|center|bottom text-effect: XX; // XX = none|outline|shadow|glow line-spacing: -2; // XX = amount of space to add/remove between lines

// box properties padding: top; // right=top, bottom=top, left=top padding: top, right; // bottom=top, left=right padding: top, right, bottom, left; border: 1 solid #FFCC99; border: 1 blank; size: 250 100; // overrrides component preferred size

// explicit inheritance parent: other_class; // other_class must be defined *before* this one

tooltip: other_class; // used to define the style class for the tool_tip }*

Each component is identified by its default stylesheet class, which are derived from the component's Java class name: window, label, textfield, component, popupmenu, etc. The component's stylesheet class can be overridden with a call to # setStyleClass .

A component's style is resolved in the following manner:

This resolution process is followed at the time the component is added to the interface hierarchy and the result is used to configure the component. We tradeoff the relative expense of doing the lookup every time the component is rendered (every frame) with the memory expense of storing the style of every component in memory.


Field Summary
protected  ResourceProvider _rsrcprov
           
 java.util.HashMap<java.lang.String,Rule> _rules
           
static java.lang.String BOLD
          A font style constant.
static java.lang.String BOLD_ITALIC
          A font style constant.
static java.lang.String ITALIC
          A font style constant.
static java.lang.String PLAIN
          A font style constant.
 
Fields inherited from interface com.jmex.bui.BStyleConstants
COLON, DOUBLE_QUOTE, END_BRACE, SEMI_COLON, SINGLE_QUOTE, START_BRACE
 
Constructor Summary
BStyleSheet(java.io.Reader reader, ResourceProvider rsrcprov)
          Creates a stylesheet from the specified textual source.
 
Method Summary
 java.lang.Object createProperty(java.lang.String name, java.util.ArrayList args)
           
protected  java.lang.Object findProperty(BComponent component, java.lang.String pseudoClass, java.lang.String property, boolean climb)
           
 BBackground getBackground(BComponent component, java.lang.String pseudoClass)
           
 BBorder getBorder(BComponent component, java.lang.String pseudoClass)
           
 com.jme.renderer.ColorRGBA getColor(BComponent component, java.lang.String pseudoClass)
           
 BCursor getCursor(BComponent component, java.lang.String pseudoClass)
           
 com.jme.renderer.ColorRGBA getEffectColor(BComponent component, java.lang.String pseudoClass)
           
 int getEffectSize(BComponent component, java.lang.String pseudoClass)
           
 BIcon getIcon(BComponent component, java.lang.String pseudoClass)
           
 Insets getInsets(BComponent component, java.lang.String pseudoClass)
           
 BKeyMap getKeyMap(BComponent component, java.lang.String pseudoClass)
           
 int getLineSpacing(BComponent component, java.lang.String pseudoClass)
           
protected  java.lang.Object getProperty(java.lang.String fqClass, java.lang.String property)
           
 Dimension getSize(BComponent component, java.lang.String pseudoClass)
           
 HorizontalAlignment getTextAlignment(BComponent component, java.lang.String pseudoClass)
           
 TextEffect getTextEffect(BComponent component, java.lang.String pseudoClass)
           
 BTextFactory getTextFactory(BComponent component, java.lang.String pseudoClass)
           
 java.lang.String getTooltipStyle(BComponent component, java.lang.String pseudoClass)
           
 VerticalAlignment getVerticalAlignment(BComponent component, java.lang.String pseudoClass)
           
protected  com.jme.renderer.ColorRGBA parseColor(java.lang.String hex)
           
protected  int parseInt(java.lang.Object arg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLAIN

public static final java.lang.String PLAIN
A font style constant.

See Also:
Constant Field Values

BOLD

public static final java.lang.String BOLD
A font style constant.

See Also:
Constant Field Values

ITALIC

public static final java.lang.String ITALIC
A font style constant.

See Also:
Constant Field Values

BOLD_ITALIC

public static final java.lang.String BOLD_ITALIC
A font style constant.

See Also:
Constant Field Values

_rsrcprov

protected ResourceProvider _rsrcprov

_rules

public java.util.HashMap<java.lang.String,Rule> _rules
Constructor Detail

BStyleSheet

public BStyleSheet(java.io.Reader reader,
                   ResourceProvider rsrcprov)
Creates a stylesheet from the specified textual source.

Parameters:
reader - Reader
rsrcprov - ResourceProvider
Method Detail

getColor

public com.jme.renderer.ColorRGBA getColor(BComponent component,
                                           java.lang.String pseudoClass)

getBackground

public BBackground getBackground(BComponent component,
                                 java.lang.String pseudoClass)

getIcon

public BIcon getIcon(BComponent component,
                     java.lang.String pseudoClass)

getCursor

public BCursor getCursor(BComponent component,
                         java.lang.String pseudoClass)

getTextFactory

public BTextFactory getTextFactory(BComponent component,
                                   java.lang.String pseudoClass)

getTextAlignment

public HorizontalAlignment getTextAlignment(BComponent component,
                                            java.lang.String pseudoClass)

getVerticalAlignment

public VerticalAlignment getVerticalAlignment(BComponent component,
                                              java.lang.String pseudoClass)

getTextEffect

public TextEffect getTextEffect(BComponent component,
                                java.lang.String pseudoClass)

getLineSpacing

public int getLineSpacing(BComponent component,
                          java.lang.String pseudoClass)

getEffectSize

public int getEffectSize(BComponent component,
                         java.lang.String pseudoClass)

getEffectColor

public com.jme.renderer.ColorRGBA getEffectColor(BComponent component,
                                                 java.lang.String pseudoClass)

getInsets

public Insets getInsets(BComponent component,
                        java.lang.String pseudoClass)

getBorder

public BBorder getBorder(BComponent component,
                         java.lang.String pseudoClass)

getSize

public Dimension getSize(BComponent component,
                         java.lang.String pseudoClass)

getTooltipStyle

public java.lang.String getTooltipStyle(BComponent component,
                                        java.lang.String pseudoClass)

getKeyMap

public BKeyMap getKeyMap(BComponent component,
                         java.lang.String pseudoClass)

findProperty

protected java.lang.Object findProperty(BComponent component,
                                        java.lang.String pseudoClass,
                                        java.lang.String property,
                                        boolean climb)

getProperty

protected java.lang.Object getProperty(java.lang.String fqClass,
                                       java.lang.String property)

createProperty

public java.lang.Object createProperty(java.lang.String name,
                                       java.util.ArrayList args)

parseColor

protected com.jme.renderer.ColorRGBA parseColor(java.lang.String hex)

parseInt

protected int parseInt(java.lang.Object arg)


Copyright © 2011 Michael Bayne. All Rights Reserved.