Package generic.theme
Class IconModifier
java.lang.Object
generic.theme.IconModifier
Class that can transform one icon into another. Useful for scaling, translating, disabling,
or overlaying an icon.
-
Constructor Summary
ConstructorDescriptionIconModifier
(Dimension size, Point translation, Integer rotation, boolean disabled, boolean mirror, boolean flip) Creates an IconModifier that can scale, translate, or disable an icon. -
Method Summary
Modifier and TypeMethodDescriptionReturns a string that can be parsed by theparse(String)
method of this classmodify
(Icon icon, GThemeValueMap values) Modifies the given icon by the any of the modifiers set.static IconModifier
Parses the given string as one or more icon modifiersvoid
Sets this modifier to disable an iconvoid
setFlip()
Sets the modifier to flip the icon side to sidevoid
Sets the modifier to flip the icon side to sidevoid
setMoveModifier
(Point point) Sets the translation for this modifier.void
setRotationModifer
(int degrees) Sets the rotation for this modifier.void
setSizeModifier
(Dimension size) Sets size modifier.
-
Constructor Details
-
IconModifier
public IconModifier(Dimension size, Point translation, Integer rotation, boolean disabled, boolean mirror, boolean flip) Creates an IconModifier that can scale, translate, or disable an icon.- Parameters:
size
- if non-null, scales an icon to this size.translation
- if non-null, translates an icon by this amountrotation
- if non-null, the amount in degrees to rotate the icondisabled
- if true, creates a disabled version of the iconmirror
- if true, the image will have its x values swapped (left to right)flip
- if true, the image will have its y values swapped (turned upside down)
-
-
Method Details
-
setSizeModifier
Sets size modifier. Icons that are modified by this IconModifier will be scaled to this size.- Parameters:
size
- the size to scale modified icons.
-
setMoveModifier
Sets the translation for this modifier. Icons that are modified by this IconModifier will be translated by the amount of the given point.- Parameters:
point
- the x,y amount to translate an image
-
setRotationModifer
public void setRotationModifer(int degrees) Sets the rotation for this modifier. Icons that are modified by this IconModifier will be rotated by the given amount (in degrees)- Parameters:
degrees
- the rotation amount;
-
setDisabled
public void setDisabled()Sets this modifier to disable an icon -
setMirror
public void setMirror()Sets the modifier to flip the icon side to side -
setFlip
public void setFlip()Sets the modifier to flip the icon side to side -
modify
Modifies the given icon by the any of the modifiers set.- Parameters:
icon
- the icon to be modifiedvalues
- the ThemeValueMap needed if the modify action is to overlay other icons. The values are used to resolve indirect overlay icon references- Returns:
- A new Icon that is a modified version of the given icon
-
getSerializationString
Returns a string that can be parsed by theparse(String)
method of this class- Returns:
- a string that can be parsed by the
parse(String)
method of this class
-
parse
Parses the given string as one or more icon modifiers- Parameters:
iconModifierString
- the string to parse as modifiers- Returns:
- an IconModifier as specified by the given string
- Throws:
ParseException
- if the iconModifierString in not properly formatted icon modifier
-