Class TextIconData


  • public class TextIconData
    extends TextData

    A helper class that provides some functionality for components that can display both a text and an icon.

    This class simply holds attribute values for defining a text and/or an icon. At least one of these elements must be specified. There are also some evaluation methods, e.g. for retrieving the final caption (which may involve a resource access).

    Instances of this class are used by several tag classes for components that provide the functionality of displaying text and icons. Because some of these components are simple components and others are full featured input components it is not possible to place the functionality provided by this class in a common base class. Instead the delegation model has to be used.

    Version:
    $Id: TextIconData.java 205 2012-01-29 18:29:57Z oheger $
    Author:
    Oliver Heger
    • Constructor Detail

      • TextIconData

        public TextIconData​(FormBaseTag tag)
        Creates an instance of TextIconData and associates it with the specified tag.
        Parameters:
        tag - the associated tag
    • Method Detail

      • getIcon

        public Object getIcon()
        Returns the icon object.
        Returns:
        the icon (can be null )
      • setIcon

        public void setIcon​(Object icon)
        Sets the icon object.
        Parameters:
        icon - the icon
      • getAlignment

        public TextIconAlignment getAlignment()
        Returns the alignment of the icon relative to the text.
        Returns:
        the alignment
      • setAlignment

        public void setAlignment​(TextIconAlignment alignment)
        Sets the alignment of the icon relative to the text.
        Parameters:
        alignment - the alignment (must not be null )
      • getAlignmentString

        public String getAlignmentString()
        Returns the name of the current alignment.
        Returns:
        the alignment name
      • setAlignmentString

        public void setAlignmentString​(String name)
        Sets the alignment of the icon relative to the name as string. The passed in string must be the name of one of the literals of the TextIconAlignment class. Otherwise an IllegalArgumentException exception will be thrown.
        Parameters:
        name - the name of the alignment literal
      • getMnemonicResID

        public String getMnemonicResID()
        Returns the resource ID for the mnemonic.
        Returns:
        the mnemonic's resource ID
      • setMnemonicResID

        public void setMnemonicResID​(String mnemonicResID)
        Sets the resource ID for the mnemonic. (As group the group set by TextData.setResgrp(String) will be used.)
        Parameters:
        mnemonicResID - the resource ID of the mnemonic
      • getMnemonicKey

        public String getMnemonicKey()
        Returns the key code of the mnemonic.
        Returns:
        the mnemonic's key code
      • setMnemonicKey

        public void setMnemonicKey​(String mnemonicKey)
        Sets the mnemonic's key code.
        Parameters:
        mnemonicKey - the key code
      • getMnemonic

        public char getMnemonic()
        Returns the mnemonic character. If the mnemonic is defined through a resource, this resource is now resolved. If the mnemonic is a string with more than a single character, only the first character is returned.
        Returns:
        the mnemonic (0 for undefined)
      • isDefined

        public boolean isDefined()
        Checks whether this object is defined. To be defined at least one of the elements text and icon must be specified.
        Overrides:
        isDefined in class TextData
        Returns:
        a flag whether this object is defined