public class HierarchyInspector extends Object
Modifier and Type | Method and Description |
---|---|
static int |
countInstances(Widget root,
Class<? extends Widget> clazz)
Counts instances of a
Widget type in a widget hierarchy. |
static int |
countMaxDepth(Widget root)
Counts the maximum depth of a widget hierarchy.
|
static int |
countNumberOfContainers(Widget root)
Counts containers in a given widget hierarchy.
|
static int |
countNumberOfWidgets(Widget root)
Counts widgets in a widget hierarchy.
|
static String |
hierarchyStyleToString(Widget root)
Prints the widget hierarchy of a desktop.
|
static String |
hierarchyToString(Widget root)
Prints a widget hierarchy.
|
static String |
pathToWidgetToString(Widget widget)
Prints the path to the given widget with
> separator. |
static String |
pathToWidgetToString(Widget widget,
char separator)
Prints the path to the given widget.
|
static void |
printHierarchy(Widget root)
Prints the widget hierarchy of a desktop on the "standard" output stream.
|
static void |
printHierarchyStyle(Widget root)
Prints the widget hierarchy of a desktop on the "standard" output stream.
|
static void |
visitHierarchy(Widget widget,
WidgetVisitor visitor)
Visits a widget hierarchy.
|
public static int countInstances(Widget root, Class<? extends Widget> clazz)
Widget
type in a widget hierarchy.
The method is recursive: if the given widget is a container, it browses its children.
root
- the root of the widget hierarchy.clazz
- the widget class.public static int countMaxDepth(Widget root)
The method is recursive: if the given widget is a container, it browses its children.
root
- the root of the widget hierarchy.public static int countNumberOfContainers(Widget root)
The method is recursive: if the given widget is a container, it browses its children.
root
- the root of the widget hierarchy.public static int countNumberOfWidgets(Widget root)
The method is recursive: if the given widget is a container, it browses its children.
root
- the root of the widget hierarchy.public static String hierarchyStyleToString(Widget root)
For each widget and its children recursively in a tree format, prints its class name and current style.
root
- the root of the widget hierarchy.IllegalArgumentException
- if root
is null
or is not attached.Widget.isAttached()
public static String hierarchyToString(Widget root)
Prints the root widget and its children recursively in a tree format.
root
- the root of the widget hierarchy.public static String pathToWidgetToString(Widget widget)
>
separator.widget
- the widget to inspect.pathToWidgetToString(Widget, char)
public static String pathToWidgetToString(Widget widget, char separator)
Prints the containers from the root (including the desktop) to the widget, separated with the given separator.
Example: Desktop > Scroll > ScrollableList > Label
widget
- the widget to inspect.separator
- the separator between the items.public static void printHierarchy(Widget root)
For each widget and its children recursively in a tree format, prints its class name.
This method writes on the "standard" output stream, for use during time-sensitive operations, prefer
hierarchyStyleToString(Widget)
.
root
- the root of the widget hierarchy.IllegalArgumentException
- if root
is null
or is not attached.standard output stream
,
Widget.isAttached()
public static void printHierarchyStyle(Widget root)
For each widget and its children recursively in a tree format, prints its class name and current style.
This method writes on the "standard" output stream, for use during time-sensitive operations, prefer
hierarchyStyleToString(Widget)
.
root
- the root of the widget hierarchy.IllegalArgumentException
- if root
is null
or is not attached.standard output stream
,
Widget.isAttached()
public static void visitHierarchy(Widget widget, WidgetVisitor visitor)
If the root widget is a Container
, this method calls:
visitWidget(root); beginContainer(); for (Widget child: getChildren(root)) { visitHierarchy(child, visitor); } endContainer()Otherwise, it simply calls `visitWidget(root)`.
widget
- the root of the widget hierarchy.visitor
- the visitor.