org.pushingpixels.flamingo.internal.utils
Class FlamingoUtilities

java.lang.Object
  extended by org.pushingpixels.flamingo.internal.utils.FlamingoUtilities

public class FlamingoUtilities
extends Object

Helper utilities for Flamingo project. This class is for internal use only.


Constructor Summary
FlamingoUtilities()
           
 
Method Summary
static void checkResizePoliciesConsistency(AbstractRibbonBand ribbonBand)
           
static void checkResizePoliciesConsistencyBase(AbstractRibbonBand ribbonBand)
           
static String clipString(FontMetrics metrics, int availableWidth, String fullText)
          Clips string based on specified font metrics and available width (in pixels).
static BufferedImage createThumbnail(BufferedImage image, int requestedThumbWidth)
          Creates a thumbnail of the specified width.
static Color getAlphaColor(Color color, int alpha)
          Returns the alpha version of the specified color.
static JRibbonApplicationMenuButton getApplicationMenuButton(Component comp)
           
static BufferedImage getBlankImage(int width, int height)
          Retrieves transparent image of specified dimension.
static Color getBorderColor()
           
static Color getColor(Color defaultColor, String... keys)
          Gets the color based on the specified UIManager keys.
static ResizableIcon getCommandButtonPopupActionIcon(JCommandButton commandButton)
          Returns a popup action icon for the specific command button.
static FontUIResource getFont(Component comp, String... keys)
          Gets the component font.
static int getHLayoutGap(AbstractCommandButton commandButton)
           
static Color getLighterColor(Color color, double diff)
          Returns lighter version of the specified color.
static ResizableIcon getRibbonBandExpandIcon(AbstractRibbonBand ribbonBand)
          Returns a ribbon band expand icon.
static GeneralPath getRibbonBorderOutline(int startX, int endX, int startSelectedX, int endSelectedX, int topY, int bandTopY, int bottomY, float radius)
          Returns the outline of the ribbon border.
static GeneralPath getRibbonGalleryOutline(int startX, int endX, int topY, int bottomY, float radius)
          Returns the outline of in-ribbon gallery.
static GeneralPath getRibbonTaskToggleButtonOutline(int width, int height, float radius)
          Returns the clip area of a task toggle button in ribbon component.
static int getVLayoutGap(AbstractCommandButton commandButton)
           
static boolean hasPopupAction(AbstractCommandButton commandButton)
           
static boolean isShowingMinimizedRibbonInPopup(JRibbon ribbon)
           
static boolean isShowingMinimizedRibbonInPopup(JRibbonTaskToggleButton taskToggleButton)
           
static void renderSurface(Graphics g, Container c, Rectangle rect, boolean toSimulateRollover, boolean hasTopBorder, boolean hasBottomBorder)
           
static void updateRibbonFrameIconImages(JRibbonFrame ribbonFrame)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FlamingoUtilities

public FlamingoUtilities()
Method Detail

getFont

public static FontUIResource getFont(Component comp,
                                     String... keys)
Gets the component font.

Parameters:
comp - Component.
keys - UIManager keys.
Returns:
If the component is not null, its font is returned. Otherwise the first entry in UIManager which is a Font is returned.

getColor

public static Color getColor(Color defaultColor,
                             String... keys)
Gets the color based on the specified UIManager keys.

Parameters:
defaultColor - Default color to return if none of the UIManager keys are present.
keys - UIManager keys.
Returns:
The first entry in UIManager which is a color. If none, then the default color is returned.

getRibbonBandExpandIcon

public static ResizableIcon getRibbonBandExpandIcon(AbstractRibbonBand ribbonBand)
Returns a ribbon band expand icon.

Returns:
Ribbon band expand icon.

getCommandButtonPopupActionIcon

public static ResizableIcon getCommandButtonPopupActionIcon(JCommandButton commandButton)
Returns a popup action icon for the specific command button.


createThumbnail

public static BufferedImage createThumbnail(BufferedImage image,
                                            int requestedThumbWidth)
Creates a thumbnail of the specified width.

Parameters:
image - The original image.
requestedThumbWidth - The width of the resulting thumbnail.
Returns:
Thumbnail of the specified width.

getRibbonBorderOutline

public static GeneralPath getRibbonBorderOutline(int startX,
                                                 int endX,
                                                 int startSelectedX,
                                                 int endSelectedX,
                                                 int topY,
                                                 int bandTopY,
                                                 int bottomY,
                                                 float radius)
Returns the outline of the ribbon border.

Parameters:
startX - The starting X of the ribbon area.
endX - The ending X of the ribbon area.
startSelectedX - The starting X of the toggle tab button of the selected task.
endSelectedX - The ending X of the toggle tab button of the selected task.
topY - The top Y of the ribbon area.
bandTopY - The top Y of the ribbon band area.
bottomY - The bottom Y of the ribbon area.
radius - Corner radius.
Returns:
The outline of the ribbon border.

getRibbonTaskToggleButtonOutline

public static GeneralPath getRibbonTaskToggleButtonOutline(int width,
                                                           int height,
                                                           float radius)
Returns the clip area of a task toggle button in ribbon component.

Parameters:
width - Toggle tab button width.
height - Toggle tab button height.
radius - Toggle tab button corner radius.
Returns:
Clip area of a toggle tab button in ribbon component.

getRibbonGalleryOutline

public static GeneralPath getRibbonGalleryOutline(int startX,
                                                  int endX,
                                                  int topY,
                                                  int bottomY,
                                                  float radius)
Returns the outline of in-ribbon gallery.

Parameters:
startX - Start X of the in-ribbon gallery.
endX - End X of the in-ribbon gallery.
topY - Top Y of the in-ribbon gallery.
bottomY - Bottom Y of the in-ribbon gallery.
radius - Corner radius.
Returns:
The outline of in-ribbon gallery.

clipString

public static String clipString(FontMetrics metrics,
                                int availableWidth,
                                String fullText)
Clips string based on specified font metrics and available width (in pixels). Returns the clipped string, which contains the beginning and the end of the input string separated by ellipses (...) in case the string is too long to fit into the specified width, and the origianl string otherwise.

Parameters:
metrics - Font metrics.
availableWidth - Available width in pixels.
fullText - String to clip.
Returns:
The clipped string, which contains the beginning and the end of the input string separated by ellipses (...) in case the string is too long to fit into the specified width, and the origianl string otherwise.

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.

getAlphaColor

public static Color getAlphaColor(Color color,
                                  int alpha)
Returns the alpha version of the specified color.

Parameters:
color - Original color.
alpha - Alpha channel value.
Returns:
Alpha version of the specified color.

getHLayoutGap

public static int getHLayoutGap(AbstractCommandButton commandButton)

getVLayoutGap

public static int getVLayoutGap(AbstractCommandButton commandButton)

hasPopupAction

public static boolean hasPopupAction(AbstractCommandButton commandButton)

updateRibbonFrameIconImages

public static void updateRibbonFrameIconImages(JRibbonFrame ribbonFrame)

getApplicationMenuButton

public static JRibbonApplicationMenuButton getApplicationMenuButton(Component comp)

renderSurface

public static void renderSurface(Graphics g,
                                 Container c,
                                 Rectangle rect,
                                 boolean toSimulateRollover,
                                 boolean hasTopBorder,
                                 boolean hasBottomBorder)

getLighterColor

public static Color getLighterColor(Color color,
                                    double diff)
Returns lighter version of the specified color.

Parameters:
color - Color.
diff - Difference factor (values closer to 1.0 will produce results closer to white color).
Returns:
Lighter version of the specified color.

getBorderColor

public static Color getBorderColor()

isShowingMinimizedRibbonInPopup

public static boolean isShowingMinimizedRibbonInPopup(JRibbon ribbon)

isShowingMinimizedRibbonInPopup

public static boolean isShowingMinimizedRibbonInPopup(JRibbonTaskToggleButton taskToggleButton)

checkResizePoliciesConsistency

public static void checkResizePoliciesConsistency(AbstractRibbonBand ribbonBand)

checkResizePoliciesConsistencyBase

public static void checkResizePoliciesConsistencyBase(AbstractRibbonBand ribbonBand)