org.jvnet.substance
Class SubstanceImageCreator

java.lang.Object
  extended by org.jvnet.substance.SubstanceImageCreator

public final class SubstanceImageCreator
extends Object

Provides utility functions for creating various images for Substance look and feel.

Author:
Kirill Grouchnikov

Nested Class Summary
static class SubstanceImageCreator.Corner
          Corner enum (for creating rounded rectangles).
static class SubstanceImageCreator.Side
          Corner enum (for creating rounded rectangles).
static class SubstanceImageCreator.TreeIcon
          Enum for various tree node states.
 
Field Summary
static int ARROW_HEIGHT
          Combobox button arrow default height.
static int ARROW_WIDTH
          Combobox button arrow default width.
static int DRAG_BUMP_DIAMETER
          Drag bump diameter.
static int ICON_DIMENSION
          Default icon dimension.
 
Constructor Summary
SubstanceImageCreator()
           
 
Method Summary
static Icon getArrowIcon(int width, int height, int direction)
          Retrieves downward pointing arrow.
static BufferedImage getBlankImage(int width, int height)
          Retrieves transparent image of specified dimension.
static BufferedImage getBorder(int width, int height, ColorSchemeEnum borderSchemeEnum, Set<SubstanceImageCreator.Corner> roundedCorners, boolean hasDropShadow, int marginGap)
          Retrieves a border instance of specified dimensions and status.
static BufferedImage getCheckBox(int dimension, ComponentState componentState)
          Retrieves check box of the specified size that matches the specified component state.
static BufferedImage getCheckBox(int dimension, ComponentState componentState, ColorSchemeEnum mainColorSchemeEnum)
          Retrieves check box of the specified size that matches the specified component state.
static Icon getCloseIcon(ColorSchemeEnum colorSchemeEnum)
          Returns close icon.
static BufferedImage getCompositeRoundedBackground(int width, int height, int cornerRadius, ComponentState compDecrState, ComponentState compIncrState, boolean flipSides)
          Retrieves composite background for the specified parameters.
static BufferedImage getComputerIcon()
          Retrieves computer icon.
static Image getCrayonsImage()
           
static BufferedImage getDiskIcon()
          Retrieves disk icon.
static BufferedImage getDragImage(int width, int height)
          Returns drag bumps image.
static BufferedImage getFlipRoundedButton(int width, int height, int cornerRadius, ColorSchemeEnum colorSchemeEnum, int cyclePos, SubstanceImageCreator.Side side, boolean isSideOpen)
          Retrieves rounded background for the specified parameters which is rotated by 90 degrees counter clock wise.
static BufferedImage getFloppyIcon()
          Retrieves floppy icon.
static BufferedImage getGradientCubesImage(Component component, int width, int height, ColorSchemeEnum colorSchemeEnum, int leftTransitionStart, int leftTransitionEnd, int rightTransitionStart, int rightTransitionEnd)
          Creates an image with transition area between two colors.
static BufferedImage getHomeIcon()
          Retrieves home icon.
static BufferedImage getLonghornProgressBar(int width, int height, ColorSchemeEnum colorSchemeEnum)
          Returns Longhorn-inspired rectangular gradient background with gradient horizontal translucent stripe.
static Icon getMaximizeIcon(ColorSchemeEnum colorSchemeEnum)
          Returns maximize icon.
static Icon getMinimizeIcon(ColorSchemeEnum colorSchemeEnum)
          Returns minimize icon.
static BufferedImage getRadioButton(int dimension, ComponentState componentState)
          Retrieves radio button of the specified size that matches the specified component state.
static BufferedImage getRadioButton(int dimension, ComponentState componentState, int offsetX)
          Retrieves radio button of the specified size that matches the specified component state.
static BufferedImage getRadioButton(int dimension, ComponentState componentState, int offsetX, ColorSchemeEnum mainColorSchemeEnum)
           
static BufferedImage getRectangularBackground(int width, int height, ColorSchemeEnum colorSchemeEnum, boolean hasDarkBorder)
          Returns rectangular gradient background.
static BufferedImage getRectangularSpottedBackground(int width, int height, ColorSchemeEnum colorSchemeEnum, boolean hasSpots, BufferedImage stripeImage, int stripeOffset)
          Returns rectangular gradient background with spots and optional replicated stripe image.
static Icon getRestoreIcon(ColorSchemeEnum colorSchemeEnum)
          Returns restore icon.
static BufferedImage getRotated(BufferedImage bi, int quadrantClockwise)
          Returns rotated image.
static BufferedImage getRoundedBackground(int width, int height, int cornerRadius, ColorSchemeEnum borderSchemeEnum, ColorSchemeEnum fillSchemeEnum, int cyclePos, SubstanceImageCreator.Side side, boolean isSideOpen, boolean hasShine)
          Retrieves rounded background for the specified parameters.
static BufferedImage getRoundedBackground(int width, int height, int cornerRadius, ColorSchemeEnum colorSchemeEnum, int cyclePos, SubstanceImageCreator.Side side)
          Retrieves rounded background for the specified parameters.
static BufferedImage getRoundedBackground(int width, int height, int cornerRadius, ColorSchemeEnum colorSchemeEnum, int cyclePos, SubstanceImageCreator.Side side, boolean isSideOpen)
          Retrieves rounded background for the specified parameters.
static BufferedImage getRoundedTriangleBackground(int width, int height, int cornerRadius, ComponentState componentState, ColorSchemeEnum mainColorSchemeEnum)
          Retrieves rounded background with triangular bottom half for the specified parameters.
static BufferedImage getSingleCrayon(Color mainColor, int width, int height)
           
static BufferedImage getStripe(int baseSize)
          Returns diagonal stripe image.
static BufferedImage getTreeIcon(boolean isCollapsed)
          Retrieves tree icon.
static BufferedImage getTreeLeafIcon()
          Retrieves tree leaf icon.
static BufferedImage getTreeNodeIcon(SubstanceImageCreator.TreeIcon treeIconKind)
          Retrieves tree node icon.
static Icon makeTransparent(Icon icon, double alpha)
          Makes the specified icon transparent.
static Icon toGreyscale(Icon icon)
          Translated the specified icon to grey scale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ICON_DIMENSION

public static final int ICON_DIMENSION
Default icon dimension.

See Also:
Constant Field Values

ARROW_WIDTH

public static final int ARROW_WIDTH
Combobox button arrow default width.

See Also:
Constant Field Values

ARROW_HEIGHT

public static final int ARROW_HEIGHT
Combobox button arrow default height.

See Also:
Constant Field Values

DRAG_BUMP_DIAMETER

public static final int DRAG_BUMP_DIAMETER
Drag bump diameter.

See Also:
Constant Field Values
Constructor Detail

SubstanceImageCreator

public SubstanceImageCreator()
Method Detail

getBlankImage

public static BufferedImage getBlankImage(int width,
                                          int height)
Retrieves transparent image of specified dimension.

Parameters:
width - Image width.
height - Image height.
Returns:
Transparent image of specified dimension.

getBorder

public static BufferedImage getBorder(int width,
                                      int height,
                                      ColorSchemeEnum borderSchemeEnum,
                                      Set<SubstanceImageCreator.Corner> roundedCorners,
                                      boolean hasDropShadow,
                                      int marginGap)
Retrieves a border instance of specified dimensions and status.

Parameters:
width - Border width.
height - Border height.
borderSchemeEnum - Border color scheme enum.
roundedCorners - A set of corners that will be rounded.
hasDropShadow - If true, drop shadow will be drawn.
marginGap - The margin gap around the border
Returns:
Border instance of specified dimensions and status.

getArrowIcon

public static Icon getArrowIcon(int width,
                                int height,
                                int direction)
Retrieves downward pointing arrow.

Parameters:
width - Arrow width.
height - Arrow height.
direction - Arrow direction.
Returns:
Arrow image.
See Also:
SwingConstants.NORTH, SwingConstants.WEST, SwingConstants.SOUTH, SwingConstants.EAST

getRotated

public static BufferedImage getRotated(BufferedImage bi,
                                       int quadrantClockwise)
Returns rotated image.

Parameters:
bi - Image to rotate.
quadrantClockwise - Amount of quadrants to rotate in clockwise directio. The rotation angle is 90 times this value.
Returns:
Rotated image.

toGreyscale

public static Icon toGreyscale(Icon icon)
Translated the specified icon to grey scale.

Parameters:
icon - Icon.
Returns:
Greyscale version of the specified icon.

makeTransparent

public static Icon makeTransparent(Icon icon,
                                   double alpha)
Makes the specified icon transparent.

Parameters:
icon - Icon.
alpha - The opaqueness of the resulting image. The closer this value is to 0.0, the more transparent resulting image will be.
Returns:
Transparent version of the specified icon.

getRoundedBackground

public static BufferedImage getRoundedBackground(int width,
                                                 int height,
                                                 int cornerRadius,
                                                 ColorSchemeEnum colorSchemeEnum,
                                                 int cyclePos,
                                                 SubstanceImageCreator.Side side)
Retrieves rounded background for the specified parameters.

Parameters:
width - Image width.
height - Image height.
cornerRadius - Corner radius.
colorSchemeEnum - Color scheme for the border and the filling
cyclePos - Cycle position index.
side - Straight side (if not null).
Returns:
Rounded background for the specified parameters.

getRadioButton

public static BufferedImage getRadioButton(int dimension,
                                           ComponentState componentState)
Retrieves radio button of the specified size that matches the specified component state.

Parameters:
dimension - Radio button size.
componentState - Component state.
Returns:
Radio button of the specified size that matches the specified component state.

getRadioButton

public static BufferedImage getRadioButton(int dimension,
                                           ComponentState componentState,
                                           int offsetX)
Retrieves radio button of the specified size that matches the specified component state.

Parameters:
dimension - Radio button size.
componentState - Component state.
offsetX - Offset on X axis - should be positive in order to see the entire radio button.
Returns:
Radio button of the specified size that matches the specified component state.

getRadioButton

public static BufferedImage getRadioButton(int dimension,
                                           ComponentState componentState,
                                           int offsetX,
                                           ColorSchemeEnum mainColorSchemeEnum)

getCheckBox

public static BufferedImage getCheckBox(int dimension,
                                        ComponentState componentState)
Retrieves check box of the specified size that matches the specified component state.

Parameters:
dimension - Check box size.
componentState - Component state.
Returns:
Check box of the specified size that matches the specified component state.

getCheckBox

public static BufferedImage getCheckBox(int dimension,
                                        ComponentState componentState,
                                        ColorSchemeEnum mainColorSchemeEnum)
Retrieves check box of the specified size that matches the specified component state.

Parameters:
dimension - Check box size.
componentState - Component state.
Returns:
Check box of the specified size that matches the specified component state.

getRoundedBackground

public static BufferedImage getRoundedBackground(int width,
                                                 int height,
                                                 int cornerRadius,
                                                 ColorSchemeEnum colorSchemeEnum,
                                                 int cyclePos,
                                                 SubstanceImageCreator.Side side,
                                                 boolean isSideOpen)
Retrieves rounded background for the specified parameters.

Parameters:
width - Image width.
height - Image height.
cornerRadius - Corner radius.
colorSchemeEnum - Color scheme for the border and the filling
cyclePos - Cycle position index.
side - Straight side (if not null).
isSideOpen - If true, the above side will not have border.

getFlipRoundedButton

public static BufferedImage getFlipRoundedButton(int width,
                                                 int height,
                                                 int cornerRadius,
                                                 ColorSchemeEnum colorSchemeEnum,
                                                 int cyclePos,
                                                 SubstanceImageCreator.Side side,
                                                 boolean isSideOpen)
Retrieves rounded background for the specified parameters which is rotated by 90 degrees counter clock wise.

Parameters:
width - Image width.
height - Image height.
cornerRadius - Corner radius.
colorSchemeEnum - Color scheme for the border and the filling
cyclePos - Cycle position index.
side - Straight side (if not null).
isSideOpen - If true, the above side will not have border.
Returns:
Rounded background for the specified parameters.

getCompositeRoundedBackground

public static BufferedImage getCompositeRoundedBackground(int width,
                                                          int height,
                                                          int cornerRadius,
                                                          ComponentState compDecrState,
                                                          ComponentState compIncrState,
                                                          boolean flipSides)
Retrieves composite background for the specified parameters. The composite background consists of three layers:
  1. Layer that matches the increased state.
  2. Layer that matches the decreased state.
  3. Regular layer with rounded background.
The layers are drawn in the following order:
  1. The left half of the first layer
  2. The right half of the second layer
  3. The third layer
Combined together, the layers create the image for scrollbar track with continuation of the arrow increase and decrease buttons.

Parameters:
width - Image width.
height - Image height.
cornerRadius - Corner radius.
compDecrState - The decreased state.
compIncrState - The increased state.
flipSides - If true, the drawn halves of the first and the second layers above will be swapped.
Returns:
Composite background for the specified parameters.

getRoundedBackground

public static BufferedImage getRoundedBackground(int width,
                                                 int height,
                                                 int cornerRadius,
                                                 ColorSchemeEnum borderSchemeEnum,
                                                 ColorSchemeEnum fillSchemeEnum,
                                                 int cyclePos,
                                                 SubstanceImageCreator.Side side,
                                                 boolean isSideOpen,
                                                 boolean hasShine)
Retrieves rounded background for the specified parameters.

Parameters:
width - Image width.
height - Image height.
cornerRadius - Corner radius.
borderSchemeEnum - Color scheme for the border.
fillSchemeEnum - Color scheme for the filling.
cyclePos - Cycle position index.
side - Straight side (if not null).
isSideOpen - If true, the above side will not have border.
hasShine - If true, shine-spot will be added.
Returns:
Rounded background for the specified parameters.

getRoundedTriangleBackground

public static BufferedImage getRoundedTriangleBackground(int width,
                                                         int height,
                                                         int cornerRadius,
                                                         ComponentState componentState,
                                                         ColorSchemeEnum mainColorSchemeEnum)
Retrieves rounded background with triangular bottom half for the specified parameters.

Parameters:
width - Image width.
height - Image height.
cornerRadius - Corner radius.
componentState - Component state.
Returns:
Rounded background with triangular bottom half for the specified parameters.

getGradientCubesImage

public static BufferedImage getGradientCubesImage(Component component,
                                                  int width,
                                                  int height,
                                                  ColorSchemeEnum colorSchemeEnum,
                                                  int leftTransitionStart,
                                                  int leftTransitionEnd,
                                                  int rightTransitionStart,
                                                  int rightTransitionEnd)
Creates an image with transition area between two colors. The transition area is specified by the starting and ending columns (in pixel units). The transition area is randomly covered by semi-randomly colored squares.

Parameters:
width - The width of the resilting image.
height - The height of the resilting image.
colorSchemeEnum - Color scheme.
leftTransitionStart - The starting column of the left transition area. All the pixels lying to the left of this column will be colored uniformly by the left-side color.
leftTransitionEnd - The ending column of the left transition area. All the pixels lying to the right of this column will be colored uniformly by the right-side color.
rightTransitionStart - The starting column of the right transition area. All the pixels lying to the left of this column will be colored uniformly by the left-side color.
rightTransitionEnd - The ending column of the right transition area. All the pixels lying to the right of this column will be colored uniformly by the right-side color.
Returns:
The resulting image.

getMinimizeIcon

public static Icon getMinimizeIcon(ColorSchemeEnum colorSchemeEnum)
Returns minimize icon.

Parameters:
colorSchemeEnum - Color scheme for the icon.
Returns:
Minimize icon.

getRestoreIcon

public static Icon getRestoreIcon(ColorSchemeEnum colorSchemeEnum)
Returns restore icon.

Parameters:
colorSchemeEnum - Color scheme for the icon.
Returns:
Restore icon.

getMaximizeIcon

public static Icon getMaximizeIcon(ColorSchemeEnum colorSchemeEnum)
Returns maximize icon.

Parameters:
colorSchemeEnum - Color scheme for the icon.
Returns:
Maximize icon.

getCloseIcon

public static Icon getCloseIcon(ColorSchemeEnum colorSchemeEnum)
Returns close icon.

Parameters:
colorSchemeEnum - Color scheme for the icon.
Returns:
Close icon.

getRectangularBackground

public static BufferedImage getRectangularBackground(int width,
                                                     int height,
                                                     ColorSchemeEnum colorSchemeEnum,
                                                     boolean hasDarkBorder)
Returns rectangular gradient background.

Parameters:
width - Background width.
height - Background height.
colorSchemeEnum - Color scheme for the background.
hasDarkBorder - If true, the resulting image will have dark border.
Returns:
Background matching the parameters.

getRectangularSpottedBackground

public static BufferedImage getRectangularSpottedBackground(int width,
                                                            int height,
                                                            ColorSchemeEnum colorSchemeEnum,
                                                            boolean hasSpots,
                                                            BufferedImage stripeImage,
                                                            int stripeOffset)
Returns rectangular gradient background with spots and optional replicated stripe image.

Parameters:
width - Background width.
height - Background height.
colorSchemeEnum - Color scheme for the background.
hasSpots - If true, the resulting image will have spots.
stripeImage - Stripe image to replicate.
stripeOffset - Offset of the first stripe replication.
Returns:
Background matching the parameters.

getStripe

public static BufferedImage getStripe(int baseSize)
Returns diagonal stripe image.

Parameters:
baseSize - Stripe base in pixels.
Returns:
Diagonal stripe image.

getDragImage

public static BufferedImage getDragImage(int width,
                                         int height)
Returns drag bumps image.

Parameters:
width - Drag bumps width.
height - Drag bumps height.
Returns:
Drag bumps image.

getTreeIcon

public static BufferedImage getTreeIcon(boolean isCollapsed)
Retrieves tree icon.

Parameters:
isCollapsed - Collapsed state.
Returns:
Tree icon.

getTreeNodeIcon

public static BufferedImage getTreeNodeIcon(SubstanceImageCreator.TreeIcon treeIconKind)
Retrieves tree node icon.

Parameters:
treeIconKind - Tree node icon kind.
Returns:
Tree node icon.

getTreeLeafIcon

public static BufferedImage getTreeLeafIcon()
Retrieves tree leaf icon.

Returns:
Tree leaf icon.

getHomeIcon

public static BufferedImage getHomeIcon()
Retrieves home icon.

Returns:
Home icon.

getComputerIcon

public static BufferedImage getComputerIcon()
Retrieves computer icon.

Returns:
Computer icon.

getDiskIcon

public static BufferedImage getDiskIcon()
Retrieves disk icon.

Returns:
Disk icon.

getFloppyIcon

public static BufferedImage getFloppyIcon()
Retrieves floppy icon.

Returns:
Floppy icon.

getLonghornProgressBar

public static BufferedImage getLonghornProgressBar(int width,
                                                   int height,
                                                   ColorSchemeEnum colorSchemeEnum)
Returns Longhorn-inspired rectangular gradient background with gradient horizontal translucent stripe.

Parameters:
width - Background width.
height - Background height.
colorSchemeEnum - Color scheme for the background.
Returns:
Background matching the parameters.

getSingleCrayon

public static BufferedImage getSingleCrayon(Color mainColor,
                                            int width,
                                            int height)

getCrayonsImage

public static Image getCrayonsImage()