Class GThemes

java.lang.Object
com.iizix.prop.ui.device.GThemes
All Implemented Interfaces:
Cloneable

public class GThemes extends Object implements Cloneable
This is a data holder class for UI themes, specifying UI type (desktop/mobile) and the themes that are selected or possible.
Author:
Christopher Mindus
  • Field Details

    • ANY

      public static final int ANY
      The type: ANY.
      See Also:
    • DESKTOP

      public static final int DESKTOP
      The type: DESKTOP.
      See Also:
    • MOBILE

      public static final int MOBILE
      The type: MOBILE.
      See Also:
    • NONE

      public static final GThemes NONE
      The "NONE" themes mask when intersection is too narrow.
    • DEFAULT_DESKTOP

      public static final GThemes DEFAULT_DESKTOP
      The default theme selection for desktop, i.e. Flat, Bootstrap and Claro.
    • DEFAULT_MOBILE

      public static final GThemes DEFAULT_MOBILE
      The default theme selection for mobile, all default desktop theme and all mobile themes.
    • DEFAULT_MASK

      public static final GThemes DEFAULT_MASK
      The default theme selection: allow all, both desktop and mobile.
    • MOBILE_MASK

      public static final GThemes MOBILE_MASK
      The default theme selection for any mobile theme and no desktop themes.
    • DESKTOP_MASK

      public static final GThemes DESKTOP_MASK
      The default theme selection for any desktop theme and no mobile themes.
    • DEFAULT_STARTUP

      public static final GThemes DEFAULT_STARTUP
      The default start-up theme for the app: Flat and iOS7+.
    • ANY_MASK

      public static final GThemes ANY_MASK
      The "ANY_MASK" themes mask, could replace a mask with "null" value (note: not the same NONE).
  • Constructor Details

    • GThemes

      public GThemes(int type, UIThemes.Name[] desktop, UIThemes.Name[] mobile)
      Creates a new instance of themes.
      Parameters:
      type - The theme type: ANY=-1 for any, DESKTOP=0, MOBILE=1.
      desktop - The array of themes for desktop, or null for any.
      mobile - The array of themes for mobile, or null for any.
      Throws:
      IllegalArgumentException - If type is not ANY, DESKTOP or MOBILE, or if the theme names are invalid for the type.
      NullPointerException - If any theme instance in the array is null.
  • Method Details

    • from

      public static GThemes from(int type, UIThemes.Name[] desktop, UIThemes.Name[] mobile)
      Creates a new instance of themes or grabs a cached copy.
      Parameters:
      type - The theme type: ANY=-1 for any, DESKTOP=0, MOBILE=1.
      desktop - The array of themes for desktop, or null for any.
      mobile - The array of themes for mobile, or null for any.
      Returns:
      A cached instance of GThemes. The instance might be just newly created.
      Throws:
      IllegalArgumentException - If type is not ANY, DESKTOP or MOBILE, or if the theme names are invalid for the type.
      NullPointerException - If any theme instance in the array is null.
    • from

      public static GThemes from(String string)
      Creates an instance of the themes from a string.

      The format of the string must be the same as the one returned in dataToString().

      Parameters:
      string - The string.
      Throws:
      IllegalArgumentException - If the string type or theme name is wrong.
      NoSuchElementException - If there are no more tokens in this tokenizer's string.
    • from

      public static GThemes from(ReadTransaction trans)
      Creates a color from a transaction.
      Parameters:
      trans - The transaction.
      Throws:
      IllegalArgumentException - If there is a Transaction error.
    • fromMobile

      public static GThemes fromMobile(UIThemes.Name name)
      Gets a cached mobile theme from a name using the default desktop name.
      Parameters:
      name - The name.
      Returns:
      A cached instance for the theme for the name.
      Throws:
      IllegalArgumentException - If the name is not of mobile type.
    • fromDesktop

      public static GThemes fromDesktop(UIThemes.Name name)
      Gets a cached desktop theme from a name using with no mobile themes.
      Parameters:
      name - The name.
      Returns:
      A cached instance for the theme for the name.
      Throws:
      IllegalArgumentException - If the name is not of desktop type.
    • append

      public void append(SendTransaction trans)
      Appends the themes to a transaction.
    • equals

      public boolean equals(Object o)
      Checks if two color objects are equal.
      Overrides:
      equals in class Object
    • isDesktop

      public boolean isDesktop()
      Checks if this theme is for desktop. The theme can be mobile also.
      Returns:
      true if the type is DESKTOP or ANY, false otherwise.
    • isMobile

      public boolean isMobile()
      Checks if this theme is for mobile. The theme can be for desktop also.
      Returns:
      true if the type is MOBILE or ANY, false otherwise.
    • getDesktopThemes

      public UIThemes.Name[] getDesktopThemes()
      Gets the desktop themes.
      Returns:
      An array of desktop themes possible, or null for any. DO NOT MODIFY THE RETURNED ARRAY!
    • getMobileThemes

      public UIThemes.Name[] getMobileThemes()
      Gets the mobile themes.
      Returns:
      An array of mobile themes possible, or null for any. DO NOT MODIFY THE RETURNED ARRAY!
    • dataToString

      public String dataToString()
      The data string representation.
    • toString

      public String toString()
      Returns a string representation of this class instance and its values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of this class instance.
    • computeIntersection

      public GThemes computeIntersection(GThemes mask)
      Computes the "intersection" of this mask and another one.
      Parameters:
      mask - The mask to "intersect" with.
      Returns:
      The "intersection" mask, or the special value NONE that is not allowed to be serialized (saved to XML, stored in ThemesProp or sent over a transaction).
    • isNullMask

      public boolean isNullMask()
      Returns if this mask is a "null" mask, or a NONE mask.
      Returns:
      true if no themes are present, i.e. a "null" mask or NONE mask, false if there is a type present.
    • verify

      public String verify(GThemes mask)
      Verifies if the current theme is not "masked away" from its initial intents. This method is intended to be used on a panel theme and a mask applies from parent folders.
      Parameters:
      mask - The mask from parent folders.
      Returns:
      null if it is valid, otherwise an error message of the problem.
    • contains

      public boolean contains(UIThemes.Name name)
      Checks if the theme name is contained in this theme instances mask.
      Parameters:
      name - The themes name to test.
      Returns:
      true if it is contained in either mobile or desktop.
    • toClientThemesString

      public String toClientThemesString()
      Returns the representation of the theme for the client to use.
      Returns:
      String formatted as "desktop,[mobile]".