Package jadx.gui.utils
Class UiUtils
- java.lang.Object
-
- jadx.gui.utils.UiUtils
-
public class UiUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static intCTRL_BNT_KEYstatic java.lang.RunnableEMPTY_RUNNABLEstatic booleanJADX_GUI_DEBUGstatic longMIN_FREE_MEMORYThe minimum about of memory in bytes we are trying to keep free, otherwise the application may run out of heap which ends up in a Java garbage collector running "amok" (CPU utilization 100% for each core and the UI is not responsive).
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends java.awt.Window & javax.swing.RootPaneContainer>
voidaddEscapeShortCutToDispose(T window)static voidaddKeyBinding(javax.swing.JComponent comp, javax.swing.KeyStroke key, java.lang.String id, java.lang.Runnable action)static voidaddKeyBinding(javax.swing.JComponent comp, javax.swing.KeyStroke key, java.lang.String id, javax.swing.Action action)static java.awt.ColoradjustBrightness(java.awt.Color color, float factor)Adjusts the brightness of a givenColorobject without altering its hue or saturation.static voidbgRun(java.lang.Runnable runnable)Run task in background thread.static intcalcProgress(long done, long total)static intcalcProgress(ITaskProgress taskProgress)static longcalculateMinFreeMemory()static voidcopyToClipboard(java.lang.String text)static intctrlButton()static voiddebugTimer(int periodInSeconds, java.lang.Runnable action)static voiderrorMessage(java.awt.Component parent, java.lang.String message)static java.lang.StringescapeHtml(java.lang.String str)static java.lang.StringfadeHtml(java.lang.String htmlStr)static java.awt.PointgetMousePosition(java.awt.Component comp)static intgetOffsetAtMousePosition(AbstractCodeArea codeArea)Get closest offset at mouse positionstatic javax.swing.tree.TreeNodegetTreeNodeUnderMouse(javax.swing.JTree tree, java.awt.event.MouseEvent mouseEvent)static voidhighlightAsErrorField(javax.swing.JTextField field, boolean isError)static booleanisCtrlDown(java.awt.event.KeyEvent keyEvent)static booleanisDarkTheme(java.awt.Color background)static booleanisFreeMemoryAvailable()static OverlayIconmakeIcon(jadx.core.dex.info.AccessInfo af, javax.swing.Icon pub, javax.swing.Icon pri, javax.swing.Icon pro, javax.swing.Icon def)static java.lang.StringmemoryInfo()static voidnotUiThreadGuard()static javax.swing.ImageIconopenIcon(java.lang.String name)static java.awt.ImageopenImage(java.lang.String path)static com.formdev.flatlaf.extras.FlatSVGIconopenSvgIcon(java.lang.String name)static voidprintStackTrace(java.lang.String label)static voidremoveKeyBinding(javax.swing.JComponent comp, javax.swing.KeyStroke key, java.lang.String id)static voidresetClipboardOwner()Owner field in Clipboard class can store reference to CodeArea.static voidsetClipboardString(java.lang.String text)static voidsetWindowIcons(java.awt.Window window)static voidshowMessageBox(java.awt.Component parent, java.lang.String msg)static voidsleep(int ms)static java.lang.StringtypeFormat(java.lang.String name, jadx.core.dex.instructions.args.ArgType type)static java.lang.StringtypeFormatHtml(java.lang.String name, jadx.core.dex.instructions.args.ArgType type)static java.lang.StringtypeStr(jadx.core.dex.instructions.args.ArgType type)static voiduiRun(java.lang.Runnable runnable)static voiduiRunAndWait(java.lang.Runnable runnable)static voiduiThreadGuard()static java.lang.StringwrapHtml(java.lang.String htmlStr)
-
-
-
Field Detail
-
JADX_GUI_DEBUG
public static final boolean JADX_GUI_DEBUG
-
MIN_FREE_MEMORY
public static final long MIN_FREE_MEMORY
The minimum about of memory in bytes we are trying to keep free, otherwise the application may run out of heap which ends up in a Java garbage collector running "amok" (CPU utilization 100% for each core and the UI is not responsive).We can calculate and store this value here as the maximum heap is fixed for each JVM instance and can't be changed at runtime.
-
EMPTY_RUNNABLE
public static final java.lang.Runnable EMPTY_RUNNABLE
-
CTRL_BNT_KEY
public static final int CTRL_BNT_KEY
-
-
Method Detail
-
openSvgIcon
public static com.formdev.flatlaf.extras.FlatSVGIcon openSvgIcon(java.lang.String name)
-
openIcon
public static javax.swing.ImageIcon openIcon(java.lang.String name)
-
openImage
public static java.awt.Image openImage(java.lang.String path)
-
addKeyBinding
public static void addKeyBinding(javax.swing.JComponent comp, javax.swing.KeyStroke key, java.lang.String id, java.lang.Runnable action)
-
addKeyBinding
public static void addKeyBinding(javax.swing.JComponent comp, javax.swing.KeyStroke key, java.lang.String id, javax.swing.Action action)
-
removeKeyBinding
public static void removeKeyBinding(javax.swing.JComponent comp, javax.swing.KeyStroke key, java.lang.String id)
-
typeFormat
public static java.lang.String typeFormat(java.lang.String name, jadx.core.dex.instructions.args.ArgType type)
-
typeFormatHtml
public static java.lang.String typeFormatHtml(java.lang.String name, jadx.core.dex.instructions.args.ArgType type)
-
fadeHtml
public static java.lang.String fadeHtml(java.lang.String htmlStr)
-
wrapHtml
public static java.lang.String wrapHtml(java.lang.String htmlStr)
-
escapeHtml
public static java.lang.String escapeHtml(java.lang.String str)
-
typeStr
public static java.lang.String typeStr(jadx.core.dex.instructions.args.ArgType type)
-
makeIcon
public static OverlayIcon makeIcon(jadx.core.dex.info.AccessInfo af, javax.swing.Icon pub, javax.swing.Icon pri, javax.swing.Icon pro, javax.swing.Icon def)
-
calculateMinFreeMemory
public static long calculateMinFreeMemory()
- Returns:
- 20% of the maximum heap size limited to 512 MB (bytes)
-
isFreeMemoryAvailable
public static boolean isFreeMemoryAvailable()
-
memoryInfo
public static java.lang.String memoryInfo()
-
setClipboardString
public static void setClipboardString(java.lang.String text)
-
setWindowIcons
public static void setWindowIcons(java.awt.Window window)
-
ctrlButton
@MagicConstant(flagsFromClass=java.awt.event.InputEvent.class) public static int ctrlButton()
-
isCtrlDown
public static boolean isCtrlDown(java.awt.event.KeyEvent keyEvent)
-
addEscapeShortCutToDispose
public static <T extends java.awt.Window & javax.swing.RootPaneContainer> void addEscapeShortCutToDispose(T window)
-
getOffsetAtMousePosition
public static int getOffsetAtMousePosition(AbstractCodeArea codeArea)
Get closest offset at mouse position- Returns:
- -1 on error
-
getMousePosition
public static java.awt.Point getMousePosition(java.awt.Component comp)
-
getTreeNodeUnderMouse
public static javax.swing.tree.TreeNode getTreeNodeUnderMouse(javax.swing.JTree tree, java.awt.event.MouseEvent mouseEvent)
-
showMessageBox
public static void showMessageBox(java.awt.Component parent, java.lang.String msg)
-
errorMessage
public static void errorMessage(java.awt.Component parent, java.lang.String message)
-
copyToClipboard
public static void copyToClipboard(java.lang.String text)
-
resetClipboardOwner
public static void resetClipboardOwner()
Owner field in Clipboard class can store reference to CodeArea. This prevents from garbage collection whole jadx object tree and cause memory leak. Trying to lost ownership by new empty selection.
-
calcProgress
public static int calcProgress(ITaskProgress taskProgress)
-
calcProgress
public static int calcProgress(long done, long total)
-
sleep
public static void sleep(int ms)
-
uiRun
public static void uiRun(java.lang.Runnable runnable)
-
uiRunAndWait
public static void uiRunAndWait(java.lang.Runnable runnable)
-
bgRun
public static void bgRun(java.lang.Runnable runnable)
Run task in background thread. Uses single thread, so all tasks are ordered.
-
uiThreadGuard
public static void uiThreadGuard()
-
notUiThreadGuard
public static void notUiThreadGuard()
-
debugTimer
@TestOnly public static void debugTimer(int periodInSeconds, java.lang.Runnable action)
-
printStackTrace
@TestOnly public static void printStackTrace(java.lang.String label)
-
isDarkTheme
public static boolean isDarkTheme(java.awt.Color background)
-
adjustBrightness
public static java.awt.Color adjustBrightness(java.awt.Color color, float factor)Adjusts the brightness of a givenColorobject without altering its hue or saturation.This method converts the input RGB color to the HSB (Hue, Saturation, Brightness) color model, multiplies its brightness component by the specified
factor, and then converts it back to a new RGBColorobject.The new brightness value is capped at
How to use:1.0f(maximum HSB brightness) to prevent colors from becoming invalid or exceeding full brightness.- To make a color **brighter**: Use a
factorgreater than1.0f(e.g.,1.2f,1.5f). - To make a color **darker**: Use a
factorless than1.0f(e.g.,0.8f,0.5f). - To keep the brightness **unchanged**: Use a
factorof1.0f.
// Example usage: Color originalColor = Color.BLUE; // Make the blue color 50% brighter (factor 1.5) Color brighterBlue = adjustBrightness(originalColor, 1.5f); // Make the blue color 30% darker (factor 0.7) Color darkerBlue = adjustBrightness(originalColor, 0.7f); // Get the brightest possible version of the color (will cap at 1.0 brightness) Color maxBrightnessBlue = adjustBrightness(originalColor, 10.0f); // Get a very dark, almost black version Color veryDarkBlue = adjustBrightness(originalColor, 0.1f);- Parameters:
color- The originalColorobject whose brightness needs to be adjusted.factor- The multiplier for the brightness.- Returns:
- A new
Colorobject with the adjusted brightness. - See Also:
Color.RGBtoHSB(int, int, int, float[]),Color.getHSBColor(float, float, float)
- To make a color **brighter**: Use a
-
highlightAsErrorField
public static void highlightAsErrorField(javax.swing.JTextField field, boolean isError)
-
-