Package org.freeplane.core.ui.components

# Class UITools

java.lang.Object
org.freeplane.core.ui.components.UITools

public class UITools extends Object
Utilities for accessing the GUI, creating dialogs etc.: In scripts available as "global variable" `ui`.

In scripts this would be a simple way of opening a info popup:

     ui.informationMessage("Hello World!")
     ui.informationMessage(ui.frame, "Hello World!") // longer version, equivalent

Since:
  29.12.2008

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static final class`
`UITools.InsertEolAction`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final float`
`FONT_SCALE_FACTOR`
`static final String`
`MAIN_FREEPLANE_FRAME`
`static final Dimension`
`MAX_BUTTON_DIMENSION`
`static final String`
`MENU_ITEM_FONT_SIZE_PROPERTY`
`static final String`
`SCROLLBAR_INCREMENT`

## Constructor Summary

Constructors
Constructor
Description
`UITools()`

## Method Summary

Modifier and Type
Method
Description
`static void`
`addEscapeActionToDialog(JDialog dialog)`
`static void`
`addEscapeActionToDialog(JDialog dialog, Action action)`
`static void`
`addKeyActionToDialog(JDialog dialog, Action action, String keyStroke, String actionId)`
`static void`
`addScrollbarIncrementPropertyListener(JScrollPane scrollPane)`
`static void`
`addTitledBorder(JComponent c, String title, float size)`
`static void`
`backOtherWindows()`
`static void`
`convertPointFromAncestor(Component ancestor, Point p, Component c)`
`static void`
`convertPointToAncestor(Component from, Point p, Component destination)`
`static void`
`convertPointToAncestor(Component source, Point point, Class<?> ancestorClass)`
`static void`
`convertRectangleToAncestor(Component from, Rectangle r, Component destination)`
`static JDialog`
`createCancelDialog(Component component, String titel, String text)`
`static JButton`
`createHtmlLinkStyleButton(URI uri, String title)`
`static BasicStroke`
`createStroke(float width, int[] dash, int join)`
`static void`
`errorMessage(Object message)`
`static void`
`executeWhenNodeHasFocus(Runnable runnable)`
`static Point`
`findBestLocation(Component placedComponent, Component displayedComponent)`
`static void`
`focusOn(JComponent component)`
`static Rectangle`
`getAvailableScreenBounds(Component frame)`
`static final int`
`getComponentIndex(Component component)`
`static Frame`
`getCurrentFrame()`
`static Component`
`getCurrentRootComponent()`
`static Font`
`getDefaultLabelFont()`
`static Frame`
`getFrame()`
`static KeyStroke`
`getKeyStroke(String keyStrokeDescription)`
returns a KeyStroke if possible and null otherwise.
`static Component`
`getMenuComponent()`
`static Rectangle`
`getScreenBounds(GraphicsConfiguration graphicsConfiguration)`
`static Color`
`getTextColorForBackground(Color color)`
`static float`
`getUIFontSize(double scalingFactor)`
`static Rectangle`
`getValidFrameBounds(Component frame, int win_x, int win_y, int win_width, int win_height)`
`static void`
`informationMessage(Component frame, String message)`
`static void`
`informationMessage(Component frame, String message, String title)`
`static void`
`informationMessage(Component frame, String text, String string, int type)`
`static void`
`informationMessage(String message)`
`static Font`
`invertScale(Font font)`
`static boolean`
`isEditingText()`
`static String`
`keyStrokeToString(KeyStroke keyStroke)`
formats a KeyStroke in a ledgible way, e.g.
`static void`
`repaintAll(Container root)`
`static Font`
`scale(Font font)`
`static Font`
`scaleFontInt(Font font, double additionalFactor)`
`static Font`
`scaleUI(Font font)`
`static void`
`setBounds(Component frame, int win_x, int win_y, int win_width, int win_height)`
`static void`
`setDialogLocationRelativeTo(JDialog dialog, Component c)`
`static void`
`setDialogLocationRelativeTo(JDialog dialog, org.freeplane.features.map.NodeModel node)`
`static void`
`setDialogLocationUnder(JDialog dialog, org.freeplane.features.map.NodeModel node)`
`static void`
`setScrollbarIncrement(JScrollPane scrollPane)`
`static boolean`
`shouldScaleUIFonts()`
`static void`
`showAttributeEmptyStringErrorMessage()`
Shows the error message "attributes_adding_empty_attribute_error"
`static int`
`showConfirmDialog(org.freeplane.features.map.NodeModel node, Object message, String title, int optionType)`
`static int`
`showConfirmDialog(org.freeplane.features.map.NodeModel node, Object message, String title, int optionType, int messageType)`
`static void`
`showFrame()`
`static String`
`showInputDialog(org.freeplane.features.map.NodeModel node, String message, String initialValue)`
`static String`
`showInputDialog(org.freeplane.features.map.NodeModel node, String text, String title, int type)`
`static void`
`showMessage(String message, int messageType)`
`static float[]`
`toFloats(int[] dash)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### MENU_ITEM_FONT_SIZE_PROPERTY

public static final String MENU_ITEM_FONT_SIZE_PROPERTY

See Also:
  - Constant Field Values

### MAIN_FREEPLANE_FRAME

public static final String MAIN_FREEPLANE_FRAME

See Also:
  - Constant Field Values

### SCROLLBAR_INCREMENT

public static final String SCROLLBAR_INCREMENT

See Also:
  - Constant Field Values

### MAX_BUTTON_DIMENSION

public static final Dimension MAX_BUTTON_DIMENSION

### FONT_SCALE_FACTOR

public static final float FONT_SCALE_FACTOR

## Constructor Details

### UITools

public UITools()

## Method Details

### addEscapeActionToDialog

public static void addEscapeActionToDialog(JDialog dialog)

### addEscapeActionToDialog

public static void addEscapeActionToDialog(JDialog dialog, Action action)

### addKeyActionToDialog

public static void addKeyActionToDialog(JDialog dialog, Action action, String keyStroke, String actionId)

### convertPointFromAncestor

public static void convertPointFromAncestor(Component ancestor, Point p, Component c)

### convertPointToAncestor

public static void convertPointToAncestor(Component source, Point point, Class<?> ancestorClass)

### convertRectangleToAncestor

public static void convertRectangleToAncestor(Component from, Rectangle r, Component destination)

### convertPointToAncestor

public static void convertPointToAncestor(Component from, Point p, Component destination)

### errorMessage

public static void errorMessage(Object message)

### getCurrentRootComponent

public static Component getCurrentRootComponent()

### getCurrentFrame

public static Frame getCurrentFrame()

### getFrame

public static Frame getFrame()

### getMenuComponent

public static Component getMenuComponent()

### getKeyStroke

public static KeyStroke getKeyStroke(String keyStrokeDescription)
returns a KeyStroke if possible and null otherwise.

### keyStrokeToString

public static String keyStrokeToString(KeyStroke keyStroke)
formats a KeyStroke in a ledgible way, e.g. Control+V. Null is converted to "". Taken from MotifGraphicsUtils.paintMenuItem().

### informationMessage

public static void informationMessage(String message)

### informationMessage

public static void informationMessage(Component frame, String message)

### informationMessage

public static void informationMessage(Component frame, String message, String title)

### informationMessage

public static void informationMessage(Component frame, String text, String string, int type)

### setBounds

public static void setBounds(Component frame, int win_x, int win_y, int win_width, int win_height)

### getValidFrameBounds

public static Rectangle getValidFrameBounds(Component frame, int win_x, int win_y, int win_width, int win_height)

### getAvailableScreenBounds

public static Rectangle getAvailableScreenBounds(Component frame)

### getScreenBounds

public static Rectangle getScreenBounds(GraphicsConfiguration graphicsConfiguration)

### setDialogLocationRelativeTo

public static void setDialogLocationRelativeTo(JDialog dialog, Component c)

### findBestLocation

public static Point findBestLocation(Component placedComponent, Component displayedComponent)

### setDialogLocationRelativeTo

public static void setDialogLocationRelativeTo(JDialog dialog, org.freeplane.features.map.NodeModel node)

### setDialogLocationUnder

public static void setDialogLocationUnder(JDialog dialog, org.freeplane.features.map.NodeModel node)

### showAttributeEmptyStringErrorMessage

public static void showAttributeEmptyStringErrorMessage()
Shows the error message "attributes_adding_empty_attribute_error"

### showMessage

public static void showMessage(String message, int messageType)

### showConfirmDialog

public static int showConfirmDialog(org.freeplane.features.map.NodeModel node, Object message, String title, int optionType, int messageType)

### showConfirmDialog

public static int showConfirmDialog(org.freeplane.features.map.NodeModel node, Object message, String title, int optionType)

### showInputDialog

public static String showInputDialog(org.freeplane.features.map.NodeModel node, String message, String initialValue)

### showInputDialog

public static String showInputDialog(org.freeplane.features.map.NodeModel node, String text, String title, int type)

### setScrollbarIncrement

public static void setScrollbarIncrement(JScrollPane scrollPane)

### addScrollbarIncrementPropertyListener

public static void addScrollbarIncrementPropertyListener(JScrollPane scrollPane)

### getTextColorForBackground

public static Color getTextColorForBackground(Color color)

### focusOn

public static void focusOn(JComponent component)

### createStroke

public static BasicStroke createStroke(float width, int[] dash, int join)

### toFloats

public static float[] toFloats(int[] dash)

### repaintAll

public static void repaintAll(Container root)

### createCancelDialog

public static JDialog createCancelDialog(Component component, String titel, String text)

### addTitledBorder

public static void addTitledBorder(JComponent c, String title, float size)

### backOtherWindows

public static void backOtherWindows()

### createHtmlLinkStyleButton

public static JButton createHtmlLinkStyleButton(URI uri, String title)

### getComponentIndex

public static final int getComponentIndex(Component component)

### scale

public static Font scale(Font font)

### scaleUI

public static Font scaleUI(Font font)

### scaleFontInt

public static Font scaleFontInt(Font font, double additionalFactor)

### invertScale

public static Font invertScale(Font font)

### showFrame

public static void showFrame()

### isEditingText

public static boolean isEditingText()

### executeWhenNodeHasFocus

public static void executeWhenNodeHasFocus(Runnable runnable)

### getUIFontSize

public static float getUIFontSize(double scalingFactor)

### getDefaultLabelFont

public static Font getDefaultLabelFont()

### shouldScaleUIFonts

public static boolean shouldScaleUIFonts()