Package org.jppf.ui.utils
Class GuiUtils
java.lang.Object
org.jppf.ui.utils.GuiUtils
Collection of GUI utility methods.
- Author:
- Laurent Cohen
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault thickness for adjusted scrollbars.static final StringPath to the JPPF icon used in the GUI. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidadjustScrollbarsThickness(JScrollPane scrollPane) Change the thickness of the horizontal and vertical scrollbars in the specified scroll pane to thedefault value.static voidadjustScrollbarsThickness(JScrollPane scrollPane, int thickness) Change the thickness of the horizontal and vertical scrollbars in the specified scroll pane.static voidPut the specified icon in the cache wiht the specified path.static StringcomputeNodeIconKey(org.jppf.client.monitoring.topology.TopologyNode node) Compute the cache key for the specified node, to determine which icon to dispaly.static JPanelcreateBoxPanel(int orientation) Create a chartPanel with a box layout with the specified orientation.static CursorcreateCursor(String name, String imagePath, Point hotspot) Create or get a custom mouse cursor.static JComponentcreateFiller(int width, int height) Create a filler component with the specified fixed size.static StringformatToolTipText(String tooltip) Format a possibly multi-line text into a a string that can be properly displayed as a tooltip.static CursorGet a custom mouse cursor.static ComponentgetTabComponent(OptionElement option) Get the component used in the tab to which the specified option belongs.static FramegetTopFrame(Component comp) Retrieve the top frame ro which a component belongs.static voidInitialize the possible icons for the nodes.static voidinvokeOnAWTThread(Runnable action) Perform the specified action on the AWT event dispatch thread.static ImageIconLoad and cache an icon from the file system or classpath.static ImageIconLoad and cache an icon from the file system or classpath.static ImageIconmergeIcons(String source, String... toMerge) Merge the specified images into one.All images are assumed to be of the same size.static voidExecute the specified runnable in a new thread.static StringshortenLabel(String key) Replace pre-determined keywords in a string, with shorter ones.
-
Field Details
-
JPPF_ICON
Path to the JPPF icon used in the GUI.- See Also:
-
DEFAULT_SCROLLBAR_THICKNESS
public static final int DEFAULT_SCROLLBAR_THICKNESSDefault thickness for adjusted scrollbars.
-
-
Constructor Details
-
GuiUtils
public GuiUtils()
-
-
Method Details
-
createBoxPanel
Create a chartPanel with a box layout with the specified orientation.- Parameters:
orientation- the box orientation, one ofBoxLayout.Y_AXISorBoxLayout.X_AXIS.- Returns:
- a
JPanelinstance.
-
loadIcon
Load and cache an icon from the file system or classpath.- Parameters:
path- the path to the icon.- Returns:
- the loaded icon as an
ImageIconinstance, or null if the icon could not be loaded.
-
loadIcon
Load and cache an icon from the file system or classpath.- Parameters:
path- the path to the icon.useCache- specifies whether the icon should be retrieved from and/or put in the icon cache.- Returns:
- the loaded icon as an
ImageIconinstance, or null if the icon could not be loaded.
-
cacheIcon
Put the specified icon in the cache wiht the specified path.- Parameters:
path- the cache key for the icon.icon- the icon to cache.
-
createCursor
Create or get a custom mouse cursor.- Parameters:
name- the name given to the cursor.imagePath- the path to the image.hotspot- the cursor's hotspot.- Returns:
- the create cursor, or
nullif it couldn't be created.
-
getCursor
Get a custom mouse cursor.- Parameters:
name- the name given to the cursor.- Returns:
- a
Cursorobject, ornullif it couldn't be retrieved.
-
mergeIcons
Merge the specified images into one.All images are assumed to be of the same size.- Parameters:
source- the source image, upon which all others will overwrite.toMerge- the images that overwrite the source, int he specified order.- Returns:
- a new ImageIcon whose image is the result of merging all specified images.
-
initNodeIcons
public static void initNodeIcons()Initialize the possible icons for the nodes. -
computeNodeIconKey
Compute the cache key for the specified node, to determine which icon to dispaly.- Parameters:
node- the node for which to compute the key.- Returns:
- the icon cache key as a string.
-
createFiller
Create a filler component with the specified fixed size. The resulting component can be used as a separator for layout purposes.- Parameters:
width- the component's width.height- the component's height.- Returns:
- a
JComponentinstance.
-
formatToolTipText
Format a possibly multi-line text into a a string that can be properly displayed as a tooltip.- Parameters:
tooltip- the non-formatted text of the tooltip.- Returns:
- the input text if it does not contain any line break, otherwise the input text wrapped in <html> ... </html> tags, with the line breaks transformed into <br> tags.
-
getTopFrame
Retrieve the top frame ro which a component belongs.- Parameters:
comp- the component whose frame to retrieve.- Returns:
- a
Frameinstance if it can be found, null otherwise.
-
shortenLabel
Replace pre-determined keywords in a string, with shorter ones.- Parameters:
key- the string to shorten.- Returns:
- the string with its keywords replaced.
-
runAction
Execute the specified runnable in a new thread.- Parameters:
r- theRunnableto execute.name- the thread name.
-
getTabComponent
Get the component used in the tab to which the specified option belongs.- Parameters:
option- the option for which to find the tab component.- Returns:
- the tab component, or
nullif the option is not in a tab.
-
adjustScrollbarsThickness
Change the thickness of the horizontal and vertical scrollbars in the specified scroll pane to thedefault value.- Parameters:
scrollPane- the scroll pane to change.
-
adjustScrollbarsThickness
Change the thickness of the horizontal and vertical scrollbars in the specified scroll pane.- Parameters:
scrollPane- the scroll pane to change.thickness- the desried scrollbar thickness.
-
invokeOnAWTThread
Perform the specified action on the AWT event dispatch thread.- Parameters:
action- the action to perform.
-