Class LogoProperty


public final class LogoProperty extends AbstractProperty
Represents a configuration preset for logo images, to be used with LogoGenerator.
Author:
scorbo2
  • Constructor Details

    • LogoProperty

      public LogoProperty(String fullyQualifiedName)
    • LogoProperty

      public LogoProperty(String fullyQualifiedName, String label)
  • Method Details

    • getLogoWidth

      public int getLogoWidth()
      Returns the width of the logo image that will be generated from this config.
      Returns:
      A pixel width of the logo image to be generated.
    • setLogoWidth

      public void setLogoWidth(int width)
      Sets the desired pixel width of the logo image which will be generated from this config.
      Parameters:
      width - Desired logo image width in pixels.
    • getLogoHeight

      public int getLogoHeight()
      Returns the height of the logo image that will be generated from this config.
      Returns:
      A pixel height of the logo image to be generated.
    • setLogoHeight

      public void setLogoHeight(int height)
      Sets the desired pixel height of the logo image which will be generated from this config.
      Parameters:
      height - Desired logo image height in pixels.
    • setYTweak

      public void setYTweak(int tweak)
      Kludge alert: the vertical centering of text is sometimes wonky, so this property can be used to adjust up or down by supplying a negative or positive pixel value here. Through trial and error, you can property vertically center the image, if Graphics2D gives us incorrect text height values for your text.
      Parameters:
      tweak - A positive or negative pixel value to adjust logo text vertically. Default 0.
    • getYTweak

      public int getYTweak()
      Returns the positive or negative pixel offset that's applied to the text to try to better center it vertically, or 0 if this value has not been set.
      Returns:
      See setYTweak.
    • getBgColorType

      public LogoProperty.ColorType getBgColorType()
      Returns the desired background fill, which is either a solid colour or a gradient fill.
      Returns:
      The ColorType for the background of this logo image.
    • getBgGradient

      public Gradient getBgGradient()
      Returns the GradientConfig for this logo image, if one is in use. See setBgType.
      Returns:
      A GradientConfig object for the background fill of this logo image.
    • setBgColorType

      public void setBgColorType(LogoProperty.ColorType bgColorType)
      Sets the background fill type for this logo image, which is either a solid colour or a gradient fill.
      Parameters:
      bgColorType - A ColorType to use for the background of this logo image.
    • setBgGradient

      public void setBgGradient(Gradient bgGradient)
      Sets the gradient fill type for the image background. This property is ignored unless the BgType is set to GRADIENT.
      Parameters:
      bgGradient - The GradientConfig to use with this object.
    • getBgColor

      public Color getBgColor()
      Gets the logo image background color. This property is only used if the BgType is set to SOLID.
      Returns:
      The background color of the logo image.
    • setBgColor

      public void setBgColor(Color bgColor)
      Sets the logo image background color.
      Parameters:
      bgColor - The background color of the logo image.
    • getBorderColorType

      public LogoProperty.ColorType getBorderColorType()
      Gets the border color type for this logo image, which is either a solid colour or a gradient fill.
      Returns:
      The ColorType of the border color.
    • getBorderGradient

      public Gradient getBorderGradient()
      Returns the GradientConfig for the border of this logo image, if one is in use. See setBorderColorType.
      Returns:
      A GradientConfig object for the border of this logo image.
    • setBorderColorType

      public void setBorderColorType(LogoProperty.ColorType borderColorType)
      Sets the border color type for this logo image, which is either a solid colour or a gradient fill.
      Parameters:
      borderColorType - A ColorType to use with this logo image.
    • setBorderGradient

      public void setBorderGradient(Gradient borderGradient)
      Sets the gradient fill type for the image border. This property is ignored unless the BorderColorType is set to GRADIENT.
      Parameters:
      borderGradient - The GradientConfig to use for the border of this object.
    • getBorderColor

      public Color getBorderColor()
      Returns the border color of the logo image.
      Returns:
      The border color of the logo image.
    • setBorderColor

      public void setBorderColor(Color borderColor)
      Sets the border color of the logo image. This property is ignored if hasBorder() is false.
      Parameters:
      borderColor - The border color for the generated logo image, if it has a border.
    • getBorderWidth

      public int getBorderWidth()
      Returns the pixel width of the border of the logo image.
      Returns:
      The width, in pixels, of the border of the image.
    • setBorderWidth

      public void setBorderWidth(int borderWidth)
      Sets the width, in pixels, of the border of the generated logo image. Calling setBorderWidth(0) is equivalent to calling setHasBorder(false).
      Parameters:
      borderWidth - The desired pixel width of the image border, or 0 for no border.
    • hasBorder

      public boolean hasBorder()
      Indicates whether or not the generated logo image will have a border applied to it. The border can be explicitly disabled by calling setHasBorder(false), or by calling setBorderWidth(0).
      Returns:
      Whether or not the generated image should have a border.
    • setHasBorder

      public void setHasBorder(boolean hasBorder)
      Enables or disables the border of the generated image.
      Parameters:
      hasBorder - Whether the generated image should have a border or not.
    • getFont

      public Font getFont()
      Returns the Font used in the generated image.
      Returns:
      A Font object.
    • setFont

      public void setFont(Font font)
      Sets the Font to use in the generated image. Font style information is also taken from here, but the font point size in the given object will be ignored. Use setFontPointSize() to control text size, or use setAutoSize() to allow the size to be calculated automatically.
      Parameters:
      font - Any Font object.
    • setFontByFamilyName

      public void setFontByFamilyName(String fontName)
      Allows setting the font by specifying just the family name. The resulting font will be styled as Font.PLAIN.
      Parameters:
      fontName - A font family name, such as "Serif" or "Sans-Serif".
    • getTextColor

      public Color getTextColor()
      Gets the text color.
      Returns:
      The font color for the logo image.
    • setTextColor

      public void setTextColor(Color textColor)
      Sets the text color to use with the generated logo image.
      Parameters:
      textColor - The font color to use.
    • getTextColorType

      public LogoProperty.ColorType getTextColorType()
      Gets the text color type for this logo image, which is either a solid colour or a gradient fill.
      Returns:
      The ColorType of the text color.
    • getTextGradient

      public Gradient getTextGradient()
      Returns the GradientConfig for the text of this logo image, if one is in use. See setTextColorType.
      Returns:
      A GradientConfig object for the text of this logo image.
    • setTextColorType

      public void setTextColorType(LogoProperty.ColorType textColorType)
      Sets the text color type for this logo image, which is either a solid colour or a gradient fill.
      Parameters:
      textColorType - A ColorType to use with for the text color of this logo image.
    • setTextGradient

      public void setTextGradient(Gradient textGradient)
      Sets the gradient type for text color of the image. This property is ignored unless the TextColorType is set to GRADIENT.
      Parameters:
      textGradient - The GradientConfig to use with for the text of this object.
    • setFontPointSize

      public void setFontPointSize(int fontPointSize)
      Sets the desired font point size to use with the generated image. If this method is invoked to manually set the font point size, then auto-sizing of the text is automatically turned off. You can re-enable auto-sizing by invoking setAutoSize(true), in which case this font point size will be ignored (but will be stored for later use in case you do setAutoSize(false)).
      Parameters:
      fontPointSize - The desired font point size. If 0, we set autoSize to true.
    • isAutoSize

      public boolean isAutoSize()
      Indicates whether auto font sizing is enabled. If true, fontPointSize is ignored, and instead, the text will be rendered in a size appropriate to the dimensions of the image.
      Returns:
      Whether or not font auto-sizing is in use.
    • setAutoSize

      public void setAutoSize(boolean auto)
      Enables or disables font auto-sizing on the generated image. If disabled, then the size in our Font property will be used to determine the font size.
      Parameters:
      auto - Whether or not to auto-size the text to fit the image.
    • resetToDefaults

      public void resetToDefaults()
      Resets this configuration object to reasonable default values.
    • saveToProps

      public void saveToProps(Properties props)
      Description copied from class: AbstractProperty
      Saves the current value(s) of this property to the given Properties instance.
      Specified by:
      saveToProps in class AbstractProperty
      Parameters:
      props - Any Properties instance which will receive the value(s) of this property.
    • loadFromProps

      public void loadFromProps(Properties props)
      Description copied from class: AbstractProperty
      Loads the value(s) for this property from the given Properties instance, overwriting any current value. The current value of this property will be used as a default value in the event that this property does not exist in the given Properties instance.
      Specified by:
      loadFromProps in class AbstractProperty
      Parameters:
      props - Any Properties instance which contains value(s) for this property.
    • generateFormFieldImpl

      protected FormField generateFormFieldImpl()
      Description copied from class: AbstractProperty
      Descendant classes must implement this method to generate a FormField associated with this property. The generateFormField() method in this class will call this abstract method to create the FormField, which will then be augmented with our fully qualified name, read-only state, help text, and extra attributes.
      Specified by:
      generateFormFieldImpl in class AbstractProperty
      Returns:
      A FormField associated with this property.
    • loadFromFormField

      public void loadFromFormField(FormField field)
      Description copied from class: AbstractProperty
      Populates this Property's value(s) from the given form field, assuming the field is of the correct type.
      Specified by:
      loadFromFormField in class AbstractProperty
      Parameters:
      field - The FormField containing a value for this property.