com.alee.utils
Class NinePatchUtils

java.lang.Object
  extended by com.alee.utils.NinePatchUtils

public final class NinePatchUtils
extends java.lang.Object

This class provides a set of utilities to work with various nine-patch images.

Author:
Mikle Garin

Field Summary
static java.lang.String INNER_SHADE_PREFIX
           
static java.lang.String OUTER_SHADE_PREFIX
          Shade prefixes.
 
Constructor Summary
NinePatchUtils()
           
 
Method Summary
static NinePatchIcon createInnerShadeIcon(int shadeWidth, int round, float shadeOpacity)
          Returns inner shade nine-patch icon.
static NinePatchIcon createShadeIcon(int shadeWidth, int round, float shadeOpacity)
          Returns shade nine-patch icon.
static NinePatchIcon getInnerShadeIcon(int shadeWidth, int round, float shadeOpacity)
          Returns cached inner shade nine-patch icon.
static NinePatchIcon getShadeIcon(int shadeWidth, int round, float shadeOpacity)
          Returns cached shade nine-patch icon.
static NinePatchIcon loadNinePatchIcon(java.lang.Object source)
          Returns NinePatchIcon which is read from the source.
static NinePatchIcon loadNinePatchIcon(ResourceFile resource)
          Returns NinePatchIcon which is read from specified ResourceFile.
static NinePatchIconPainter loadNinePatchIconPainter(java.lang.Object source)
          Returns NinePatchIconPainter which is read from the source.
static NinePatchIconPainter loadNinePatchIconPainter(ResourceFile resource)
          Returns NinePatchIconPainter which is read from specified ResourceFile.
static NinePatchStatePainter loadNinePatchStatePainter(java.lang.Object source)
          Returns NinePatchStatePainter which is read from the source.
static NinePatchStatePainter loadNinePatchStatePainter(ResourceMap resourceMap)
          Returns NinePatchStatePainter which is read from specified ResourceMap.
static java.util.List<NinePatchInterval> parseIntervals(java.awt.image.BufferedImage image, NinePatchIntervalType intervalType)
          Returns a list of nine-patch data intervals from the specified image.
static java.util.List<NinePatchInterval> parseStretchIntervals(boolean[] filled)
          Returns nine-patch stretch intervals.
static NinePatchIcon rotateIcon180(NinePatchIcon icon)
          Returns rotated by 180 degrees NinePatchIcon.
static NinePatchIcon rotateIcon90CCW(NinePatchIcon icon)
          Returns rotated by 90 degrees counter-clockwise NinePatchIcon.
static NinePatchIcon rotateIcon90CW(NinePatchIcon icon)
          Returns rotated by 90 degrees clockwise NinePatchIcon.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OUTER_SHADE_PREFIX

public static final java.lang.String OUTER_SHADE_PREFIX
Shade prefixes.

See Also:
Constant Field Values

INNER_SHADE_PREFIX

public static final java.lang.String INNER_SHADE_PREFIX
See Also:
Constant Field Values
Constructor Detail

NinePatchUtils

public NinePatchUtils()
Method Detail

getShadeIcon

public static NinePatchIcon getShadeIcon(int shadeWidth,
                                         int round,
                                         float shadeOpacity)
Returns cached shade nine-patch icon.

Parameters:
shadeWidth - shade width
round - corners round
shadeOpacity - shade opacity
Returns:
cached shade nine-patch icon

createShadeIcon

public static NinePatchIcon createShadeIcon(int shadeWidth,
                                            int round,
                                            float shadeOpacity)
Returns shade nine-patch icon.

Parameters:
shadeWidth - shade width
round - corners round
shadeOpacity - shade opacity
Returns:
shade nine-patch icon

getInnerShadeIcon

public static NinePatchIcon getInnerShadeIcon(int shadeWidth,
                                              int round,
                                              float shadeOpacity)
Returns cached inner shade nine-patch icon.

Parameters:
shadeWidth - shade width
round - corners round
shadeOpacity - shade opacity
Returns:
cached inner shade nine-patch icon

createInnerShadeIcon

public static NinePatchIcon createInnerShadeIcon(int shadeWidth,
                                                 int round,
                                                 float shadeOpacity)
Returns inner shade nine-patch icon.

Parameters:
shadeWidth - shade width
round - corners round
shadeOpacity - shade opacity
Returns:
inner shade nine-patch icon

parseIntervals

public static java.util.List<NinePatchInterval> parseIntervals(java.awt.image.BufferedImage image,
                                                               NinePatchIntervalType intervalType)
Returns a list of nine-patch data intervals from the specified image.

Parameters:
image - nin-patch image to process
intervalType - intervals type
Returns:
list of nine-patch data intervals from the specified image

parseStretchIntervals

public static java.util.List<NinePatchInterval> parseStretchIntervals(boolean[] filled)
Returns nine-patch stretch intervals.

Parameters:
filled - pixels fill data
Returns:
nine-patch stretch intervals

rotateIcon90CW

public static NinePatchIcon rotateIcon90CW(NinePatchIcon icon)
Returns rotated by 90 degrees clockwise NinePatchIcon. This method also modifies patches information properly.

Parameters:
icon - NinePatchIcon to rotate
Returns:
rotated by 90 degrees clockwise NinePatchIcon

rotateIcon90CCW

public static NinePatchIcon rotateIcon90CCW(NinePatchIcon icon)
Returns rotated by 90 degrees counter-clockwise NinePatchIcon. This method also modifies patches information properly.

Parameters:
icon - NinePatchIcon to rotate
Returns:
rotated by 90 degrees counter-clockwise NinePatchIcon

rotateIcon180

public static NinePatchIcon rotateIcon180(NinePatchIcon icon)
Returns rotated by 180 degrees NinePatchIcon. This method also modifies patches information properly.

Parameters:
icon - NinePatchIcon to rotate
Returns:
rotated by 180 degrees NinePatchIcon

loadNinePatchIcon

public static NinePatchIcon loadNinePatchIcon(java.lang.Object source)
Returns NinePatchIcon which is read from the source.

Parameters:
source - one of possible sources: URL, String, File, Reader, InputStream
Returns:
NinePatchIcon

loadNinePatchIcon

public static NinePatchIcon loadNinePatchIcon(ResourceFile resource)
Returns NinePatchIcon which is read from specified ResourceFile.

Parameters:
resource - file description
Returns:
NinePatchIcon

loadNinePatchStatePainter

public static NinePatchStatePainter loadNinePatchStatePainter(java.lang.Object source)
Returns NinePatchStatePainter which is read from the source.

Parameters:
source - one of possible sources: URL, String, File, Reader, InputStream
Returns:
NinePatchStatePainter

loadNinePatchStatePainter

public static NinePatchStatePainter loadNinePatchStatePainter(ResourceMap resourceMap)
Returns NinePatchStatePainter which is read from specified ResourceMap.

Parameters:
resourceMap - ResourceFile map
Returns:
NinePatchStatePainter

loadNinePatchIconPainter

public static NinePatchIconPainter loadNinePatchIconPainter(java.lang.Object source)
Returns NinePatchIconPainter which is read from the source.

Parameters:
source - one of possible sources: URL, String, File, Reader, InputStream
Returns:
NinePatchIconPainter

loadNinePatchIconPainter

public static NinePatchIconPainter loadNinePatchIconPainter(ResourceFile resource)
Returns NinePatchIconPainter which is read from specified ResourceFile.

Parameters:
resource - file description
Returns:
NinePatchIconPainter