Class TerraTheme


  • public final class TerraTheme
    extends Theme
    The default (and only) Pivot theme ("Terra"), which is highly customizable as far as color and style using configuration files and runtime attributes.
    • Constructor Summary

      Constructors 
      Constructor Description
      TerraTheme()
      Construct the "Terra" theme and set the default skin classes for each component.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.awt.Color brighten​(java.awt.Color color)  
      static java.awt.Color darken​(java.awt.Color color)  
      java.awt.Color getBaseColor​(int index)
      Gets a color from the theme's base color palette.
      java.awt.Color getColor​(int index)
      Gets a value from the theme's complete color palette (including derived colors, if any).
      java.awt.Color getDefaultBackgroundColor()
      Gets the theme's default background color.
      java.awt.Color getDefaultForegroundColor()
      Gets the theme's default foreground color.
      java.awt.Font getFont()
      Gets the theme's font.
      Image getMessageIcon​(MessageType messageType)
      Gets the image that this theme uses to represent messages of the specified type.
      int getNumberOfColors()
      Gets the total number of Colors (including derived colors, if any).
      int getNumberOfPaletteColors()
      Gets the number of Palette Colors.
      Image getSmallMessageIcon​(MessageType messageType)
      Gets the small image that this theme uses to represent messages of the specified type.
      boolean isThemeDark()
      Tell if the theme is dark.
      Usually this means that (if true) any color will be transformed in the opposite way (brightening instead of darkening, and darkening instead of brightening).
      boolean isThemeFlat()
      Tell if the theme is flat.
      Usually this means that (if true) any border/shadow will not be drawn.
      boolean isThickFocusRectangle()
      Tell if the theme has thick focus rectangles, which may be more visible in some color schemes, or some screen resolutions.
      boolean isTransitionEnabled()
      Tell if the theme has transitions enabled.
      Usually this means that (if false) any effect/transition will not be drawn.
      void setBaseColor​(int index, java.awt.Color baseColor)
      Sets a color in the theme's base color palette.
      void setColor​(int index, java.awt.Color color)
      Sets a value in the theme's complete color palette (including derived colors, if any).
      <T extends ComponentSkin>
      void
      setDefaultStyles​(T skin)
      Set appropriate default styles for the given skin object, specified by the current theme.
      void setFont​(java.awt.Font newFont)
      Sets the theme's font.
      void setMessageIcon​(MessageType messageType, Image messageIcon)
      Sets the image that this theme uses to represent messages of the specified type.
      void setSmallMessageIcon​(MessageType messageType, Image smallMessageIcon)
      Sets the small image that this theme uses to represent messages of the specified type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOCATION_PROPERTY

        public static final java.lang.String LOCATION_PROPERTY
        Property map key for the location of the theme classes.
        See Also:
        Constant Field Values
      • FONT_PROPERTY

        public static final java.lang.String FONT_PROPERTY
        Property map key for the default font for the theme.
        See Also:
        Constant Field Values
      • COLOR_MULTIPLIER_PROPERTY

        public static final java.lang.String COLOR_MULTIPLIER_PROPERTY
        Property map key for the default color multiplier to use for the theme.
        See Also:
        Constant Field Values
      • THEME_IS_DARK_PROPERTY

        public static final java.lang.String THEME_IS_DARK_PROPERTY
        Property map key for the "isDark" flag for the theme.
        See Also:
        Constant Field Values
      • THEME_IS_FLAT_PROPERTY

        public static final java.lang.String THEME_IS_FLAT_PROPERTY
        Property map key for the "isFlat" flag for this theme.
        See Also:
        Constant Field Values
      • TRANSITION_ENABLED_PROPERTY

        public static final java.lang.String TRANSITION_ENABLED_PROPERTY
        Property map key for the "transitionEnabled" flag for the theme.
        See Also:
        Constant Field Values
      • THICK_FOCUS_RECTANGLE_PROPERTY

        public static final java.lang.String THICK_FOCUS_RECTANGLE_PROPERTY
        Property map key for the "thickFocusRectangle" flag for the theme.
        See Also:
        Constant Field Values
      • COLORS_PROPERTY

        public static final java.lang.String COLORS_PROPERTY
        Property map key for the list of base colors for the theme.
        See Also:
        Constant Field Values
      • DEFAULT_STYLES_PROPERTY

        public static final java.lang.String DEFAULT_STYLES_PROPERTY
        Property map key for the name of the default styles file.
        See Also:
        Constant Field Values
      • NAMED_STYLES_PROPERTY

        public static final java.lang.String NAMED_STYLES_PROPERTY
        Property map key for the name of the named styles file.
        See Also:
        Constant Field Values
      • MESSAGE_ICONS_PROPERTY

        public static final java.lang.String MESSAGE_ICONS_PROPERTY
        Property map key for the message icons.
        See Also:
        Constant Field Values
      • SMALL_MESSAGE_ICONS_PROPERTY

        public static final java.lang.String SMALL_MESSAGE_ICONS_PROPERTY
        Property map key for the small message icons.
        See Also:
        Constant Field Values
      • DEFAULT_BACKGROUND_COLOR_PROPERTY

        public static final java.lang.String DEFAULT_BACKGROUND_COLOR_PROPERTY
        Property map key for the default background color for this theme.
        See Also:
        Constant Field Values
      • DEFAULT_FOREGROUND_COLOR_PROPERTY

        public static final java.lang.String DEFAULT_FOREGROUND_COLOR_PROPERTY
        Property map key for the default foreground color for the theme.
        See Also:
        Constant Field Values
      • COMMAND_BUTTON_STYLE

        public static final java.lang.String COMMAND_BUTTON_STYLE
        The style name for our "command" buttons (such as "OK" and "Cancel").
        See Also:
        Constant Field Values
      • DEFAULT_STYLES_FILE

        public static final java.lang.String DEFAULT_STYLES_FILE
        Name of the file to read for setting default styles for each component skin.
        See Also:
        Constant Field Values
      • NAMED_STYLES_FILE

        public static final java.lang.String NAMED_STYLES_FILE
        Name of the file containing our theme's default style definitions.
        See Also:
        Constant Field Values
    • Constructor Detail

      • TerraTheme

        public TerraTheme()
        Construct the "Terra" theme and set the default skin classes for each component.
    • Method Detail

      • getFont

        public java.awt.Font getFont()
        Gets the theme's font.
        Specified by:
        getFont in class Theme
        Returns:
        The theme's font.
      • setFont

        public void setFont​(java.awt.Font newFont)
        Sets the theme's font.
        Specified by:
        setFont in class Theme
        Parameters:
        newFont - The new font to use for this theme.
      • getColor

        public java.awt.Color getColor​(int index)
        Gets a value from the theme's complete color palette (including derived colors, if any).
        Specified by:
        getColor in class Theme
        Parameters:
        index - the index of the color, starting from 0
        Returns:
        A value from the theme's complete color palette (including derived colors, if any).
      • setColor

        public void setColor​(int index,
                             java.awt.Color color)
        Sets a value in the theme's complete color palette (including derived colors, if any).
        Specified by:
        setColor in class Theme
        Parameters:
        index - the index of the color, starting from 0
        color - the color to set
      • getBaseColor

        public java.awt.Color getBaseColor​(int index)
        Gets a color from the theme's base color palette.
        Specified by:
        getBaseColor in class Theme
        Parameters:
        index - the index of the color, starting from 0
        Returns:
        A color from the theme's base color palette.
      • setBaseColor

        public void setBaseColor​(int index,
                                 java.awt.Color baseColor)
        Sets a color in the theme's base color palette.
        Specified by:
        setBaseColor in class Theme
        Parameters:
        index - the index of the color, starting from 0
        baseColor - the color to set
      • getNumberOfPaletteColors

        public int getNumberOfPaletteColors()
        Gets the number of Palette Colors.
        Specified by:
        getNumberOfPaletteColors in class Theme
        Returns:
        the number of colors in the base palette
      • getNumberOfColors

        public int getNumberOfColors()
        Gets the total number of Colors (including derived colors, if any).
        Specified by:
        getNumberOfColors in class Theme
        Returns:
        Total number of theme colors.
      • isThemeDark

        public boolean isThemeDark()
        Tell if the theme is dark.
        Usually this means that (if true) any color will be transformed in the opposite way (brightening instead of darkening, and darkening instead of brightening).
        Specified by:
        isThemeDark in class Theme
        Returns:
        true if dark, false otherwise (default)
      • isThemeFlat

        public boolean isThemeFlat()
        Tell if the theme is flat.
        Usually this means that (if true) any border/shadow will not be drawn.
        Specified by:
        isThemeFlat in class Theme
        Returns:
        true if flat, false otherwise (default)
      • isTransitionEnabled

        public boolean isTransitionEnabled()
        Tell if the theme has transitions enabled.
        Usually this means that (if false) any effect/transition will not be drawn.
        Specified by:
        isTransitionEnabled in class Theme
        Returns:
        true if enabled (default), false otherwise
      • isThickFocusRectangle

        public boolean isThickFocusRectangle()
        Tell if the theme has thick focus rectangles, which may be more visible in some color schemes, or some screen resolutions.
        Specified by:
        isThickFocusRectangle in class Theme
        Returns:
        true if the focus rectangle should be thick, or false for thin (one-pixel) ones (the default for earlier versions).
      • getMessageIcon

        public Image getMessageIcon​(MessageType messageType)
        Gets the image that this theme uses to represent messages of the specified type.
        Parameters:
        messageType - The desired message type.
        Returns:
        The icon image for this message type.
      • setMessageIcon

        public void setMessageIcon​(MessageType messageType,
                                   Image messageIcon)
        Sets the image that this theme uses to represent messages of the specified type.
        Parameters:
        messageType - The message type to change.
        messageIcon - The new icon image for this type.
      • getSmallMessageIcon

        public Image getSmallMessageIcon​(MessageType messageType)
        Gets the small image that this theme uses to represent messages of the specified type.
        Parameters:
        messageType - The message type to query.
        Returns:
        The small image.
      • setSmallMessageIcon

        public void setSmallMessageIcon​(MessageType messageType,
                                        Image smallMessageIcon)
        Sets the small image that this theme uses to represent messages of the specified type.
        Parameters:
        messageType - The message type to change.
        smallMessageIcon - The new small icon for this type.
      • getDefaultBackgroundColor

        public java.awt.Color getDefaultBackgroundColor()
        Gets the theme's default background color.
        Overrides:
        getDefaultBackgroundColor in class Theme
        Returns:
        The color if set, or White if the theme is not dark (default), or Black.
      • getDefaultForegroundColor

        public java.awt.Color getDefaultForegroundColor()
        Gets the theme's default foreground color.
        Overrides:
        getDefaultForegroundColor in class Theme
        Returns:
        The color if set, or Black if the theme is not dark (default), or White.
      • brighten

        public static java.awt.Color brighten​(java.awt.Color color)
        Parameters:
        color - The color to brighten.
        Returns:
        A brighter version of the specified color. Specifically, it increases the brightness (in the HSB color model) by the brightenColorMultiplier factor already set.
      • darken

        public static java.awt.Color darken​(java.awt.Color color)
        Parameters:
        color - The color to darken.
        Returns:
        A darker version of the specified color. Specifically, it decreases the brightness (in the HSB color model) by the darkenColorMultiplier factor already set.
      • setDefaultStyles

        public <T extends ComponentSkin> void setDefaultStyles​(T skin)
        Set appropriate default styles for the given skin object, specified by the current theme.
        Specified by:
        setDefaultStyles in class Theme
        Type Parameters:
        T - The skin class whose type we are dealing with.
        Parameters:
        skin - The skin object of that type whose styles are to be set.
        Throws:
        ThemeNotFoundException - if the default styles cannot be located for the skin.