Class FlamingoUtilities
- java.lang.Object
-
- 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
Constructors Constructor Description FlamingoUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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)
Recursively searches thecomp
child components for aJRibbonApplicationMenuButton
and returns it.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 specifiedUIManager
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)
Handles updating the application menu button icon image.
-
-
-
Method Detail
-
getFont
public static FontUIResource getFont(Component comp, String... keys)
Gets the component font.
-
getColor
public static Color getColor(Color defaultColor, String... keys)
Gets the color based on the specifiedUIManager
keys.
-
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)
Handles updating the application menu button icon image. IfribbonFrame
does not have an application menu button nothing is performed.- Parameters:
ribbonFrame
- the ribbon frame containing the application icon
-
getApplicationMenuButton
public static JRibbonApplicationMenuButton getApplicationMenuButton(Component comp)
Recursively searches thecomp
child components for aJRibbonApplicationMenuButton
and returns it. If nothing is foundnull
is returned.- Parameters:
comp
- the component to recursively search- Returns:
- the
JRibbonApplicationMenuButton
, ornull
if not found
-
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)
-
-