Package ca.corbett.extras.image
Class LogoProperty
java.lang.Object
ca.corbett.extras.properties.AbstractProperty
ca.corbett.extras.image.LogoProperty
Represents a configuration preset for logo images, to be used with LogoGenerator.
- Author:
- scorbo2
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class ca.corbett.extras.properties.AbstractProperty
categoryName, DEFAULT_CATEGORY, DEFAULT_PROPERTY_NAME, extraAttributes, fullyQualifiedName, helpText, isEnabled, isExposed, isInitiallyEditable, isInitiallyVisible, propertyLabel, propertyName, subCategoryName -
Constructor Summary
ConstructorsConstructorDescriptionLogoProperty(String fullyQualifiedName) LogoProperty(String fullyQualifiedName, String label) -
Method Summary
Modifier and TypeMethodDescriptionprotected FormFieldDescendant classes must implement this method to generate a FormField associated with this property.Gets the logo image background color.Returns the desired background fill, which is either a solid colour or a gradient fill.Returns the GradientConfig for this logo image, if one is in use.Returns the border color of the logo image.Gets the border color type for this logo image, which is either a solid colour or a gradient fill.Returns the GradientConfig for the border of this logo image, if one is in use.intReturns the pixel width of the border of the logo image.getFont()Returns the Font used in the generated image.intReturns the height of the logo image that will be generated from this config.intReturns the width of the logo image that will be generated from this config.Gets the text color.Gets the text color type for this logo image, which is either a solid colour or a gradient fill.Returns the GradientConfig for the text of this logo image, if one is in use.intReturns 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.booleanIndicates whether or not the generated logo image will have a border applied to it.booleanIndicates whether auto font sizing is enabled.voidloadFromFormField(FormField field) Populates this Property's value(s) from the given form field, assuming the field is of the correct type.voidloadFromProps(Properties props) Loads the value(s) for this property from the given Properties instance, overwriting any current value.voidResets this configuration object to reasonable default values.voidsaveToProps(Properties props) Saves the current value(s) of this property to the given Properties instance.voidsetAutoSize(boolean auto) Enables or disables font auto-sizing on the generated image.voidsetBgColor(Color bgColor) Sets the logo image background color.voidsetBgColorType(LogoProperty.ColorType bgColorType) Sets the background fill type for this logo image, which is either a solid colour or a gradient fill.voidsetBgGradient(Gradient bgGradient) Sets the gradient fill type for the image background.voidsetBorderColor(Color borderColor) Sets the border color of the logo image.voidsetBorderColorType(LogoProperty.ColorType borderColorType) Sets the border color type for this logo image, which is either a solid colour or a gradient fill.voidsetBorderGradient(Gradient borderGradient) Sets the gradient fill type for the image border.voidsetBorderWidth(int borderWidth) Sets the width, in pixels, of the border of the generated logo image.voidSets the Font to use in the generated image.voidsetFontByFamilyName(String fontName) Allows setting the font by specifying just the family name.voidsetFontPointSize(int fontPointSize) Sets the desired font point size to use with the generated image.voidsetHasBorder(boolean hasBorder) Enables or disables the border of the generated image.voidsetLogoHeight(int height) Sets the desired pixel height of the logo image which will be generated from this config.voidsetLogoWidth(int width) Sets the desired pixel width of the logo image which will be generated from this config.voidsetTextColor(Color textColor) Sets the text color to use with the generated logo image.voidsetTextColorType(LogoProperty.ColorType textColorType) Sets the text color type for this logo image, which is either a solid colour or a gradient fill.voidsetTextGradient(Gradient textGradient) Sets the gradient type for text color of the image.voidsetYTweak(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.Methods inherited from class ca.corbett.extras.properties.AbstractProperty
addAllExtraAttributes, addFormFieldChangeListener, clearExtraAttribute, clearExtraAttributes, equals, fireFormFieldChangedEvent, generateFormField, generateFormField, getCategoryName, getExtraAttribute, getFullyQualifiedName, getHelpText, getPropertyLabel, getPropertyName, getSubCategoryName, hashCode, isEnabled, isExposed, isInitiallyEditable, isInitiallyVisible, removeAllListeners, removeFormFieldChangeListener, setAllExtraAttributes, setEnabled, setExposed, setExtraAttribute, setHelpText, setInitiallyEditable, setInitiallyVisible, setPropertyLabel
-
Constructor Details
-
LogoProperty
-
LogoProperty
-
-
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
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
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
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
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
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
Sets the logo image background color.- Parameters:
bgColor- The background color of the logo image.
-
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
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
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
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
Returns the border color of the logo image.- Returns:
- The border color of the logo image.
-
setBorderColor
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
Returns the Font used in the generated image.- Returns:
- A Font object.
-
setFont
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
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
Gets the text color.- Returns:
- The font color for the logo image.
-
setTextColor
Sets the text color to use with the generated logo image.- Parameters:
textColor- The font color to use.
-
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
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
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
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
Description copied from class:AbstractPropertySaves the current value(s) of this property to the given Properties instance.- Specified by:
saveToPropsin classAbstractProperty- Parameters:
props- Any Properties instance which will receive the value(s) of this property.
-
loadFromProps
Description copied from class:AbstractPropertyLoads 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:
loadFromPropsin classAbstractProperty- Parameters:
props- Any Properties instance which contains value(s) for this property.
-
generateFormFieldImpl
Description copied from class:AbstractPropertyDescendant 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:
generateFormFieldImplin classAbstractProperty- Returns:
- A FormField associated with this property.
-
loadFromFormField
Description copied from class:AbstractPropertyPopulates this Property's value(s) from the given form field, assuming the field is of the correct type.- Specified by:
loadFromFormFieldin classAbstractProperty- Parameters:
field- The FormField containing a value for this property.
-