Using the ThemeManager

See Also

Computed Styles

theme.xml

<?xml version="1.0" encoding="UTF-8"?>
<theme ${name} ${ref} xmlns="http://metova.com/schemas/model">
  <application>
    <icon-sets>
      <icon-set ${name}>
        <normal/>
        <rollover/>
      </icon-set>
      [...]
    </icon-sets>
  </application>
  <classes>
    <class ${name} ${ref} ${abstract}>
      <style>
        <attribute ${name} ${screen} ${touchScreen}/>
        [...]
      </style>
      <images>
        <image ${name} ${screen} ${touchScreen}/>
        [...]
      </images>
    </class>
    [...]
  </classes>
</theme>

theme.name

  • The name of the theme.
  • This can be referenced in JAVA through the generated ThemeManager constants. Example: ThemeManager.defaultTheme.NAME.
  • The name must match the name of the folder it is contained in. If the theme name is defaultTheme, then the theme.xml must be under the folder structure "src/main/resources/theme/defaultTheme".

theme.ref

  • The ${theme.name} of the parent theme to inherit from.

icon-set.name

  • Accepted Values:
    • default = If there is no match found using the OS preferred icon size, the default icon-set will be used.
    • #x# = Example: 80x80, where the OS preferred icon size is 80 width x 80 height.

icon-set.normal

  • A path to the image that should be shown when the ribbon icon does not have focus.

icon-set.rollover

  • A path to the image that should be shown when the ribbon icon gains focus.

class.name

  • The ${class.name} "name", "NAME" and all other case variants is reserved and cannot be used. This is so NAME can be used by the generated ThemeManager for storing the ${theme.name}. Example: ThemeManager.defaultTheme.NAME.

class.ref

  • The ${class} to inherit from. If nothing is specified it will inherit from ${class} "default".
  • All ${class} elements will inherit from "default" automatically, even if a ${class.ref} is specified. This is because there can be no cyclical references, and at the end of the reference chain, there will be a ${class} that does not specify a reference.
  • See Referencing a style class that doesn't exist.

class.abstract

  • Allows a style class that is only referenced within the theme.xml to not be generated into JAVA runtime code. This is useful for reusing styles within the theme.xml and still reducing memory usage at runtime by not generating unused classes.
  • Accepts a boolean.

attribute

  • See Computed Styles.
  • Values that can be converted into primitive types, will be at compile time. This ensures better performance at runtime.
  • All colors will be automatically parsed into an integer at compile time. Supported color value formats are: integer, HEX and RGB.
  • Prevent values from being automatically parsed into primitives by surrounding them in quotes. Example: #000000 will be converted to 0, however "#000000" will not and remain as a string minus the quotes.

attribute.name

attribute.screen

  • A ${attribute.screen} modifier can be added to limit use of an ${attribute} to a specific Screen dimension or a range of Screen dimensions. Wild cards can be used to specify a range of Screen dimensions based on width or height. The supported wild card is the standard asterisk character (*).
  • If there are multiple ${attribute} elements using the same ${attribute.name} that all have ${attribute.screen} modifiers matching the current Screen dimension, an ${attribute} specifying a direct match for both width and height will be preferred. Otherwise, the last matching ${attribute} specified will be used.
  • Accepted Values:
    • #x# = Example: 240x320, where the Screen dimension is 240 width x 320 height.
    • #x* = Example: 240x*, where the width can only be 240 and is matched with any height.
    • *x# = Example: *x320, where the height can only be 320 and is matched with any width.
    • *x* = This is the same as specifying no ${screen} modifier at all.

attribute.touchScreen

  • A ${attribute.touchScreen} modifier can be added to limit use of an ${attribute} to only touchscreen devices, or to only trackball devices.
  • This is especially useful for making buttons larger so they can be selected by touching the screen, whereas trackball devices can acceptably use smaller buttons since precision is easier when rolling the trackball through Fields.
  • This modifier accepts a boolean as the value.

image

  • A prefix of "/" specifies that the image is located at the root of the resources directory ("/src/main/resources/". Without the prefix, the theme directory will be the root ("/src/main/resources/theme/defaultTheme/").

image.name

  • The name of the image.

image.screen

  • See ${attribute.screen}.

image.touchScreen

  • See ${attribute.touchScreen}.

ThemeManager.java

  • Access ${theme.name} directly. Example: ThemeManager.defaultTheme.NAME.
  • Access ${style.class.name} directly. Example: ThemeManager.defaultTheme.h1.

Changing style classes

There are two main ways to change the style class for a Field. If the class is already stylable (implements Stylable) then you can call getStyleManager().setStyleClass("className"). However, if the Field does not have a default style class, then you would likely override the getStyleClass() method of the Field. The abstract Managers (i.e. AbstractVerticalFieldManager) do not have a default style class, so if you call getStyleManager() the result will be NULL.

Building

mvn generate-sources

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

© 2011 Metova, Inc.