Class UITools

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

public class UITools
extends java.lang.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 class  UITools.Defaults  
    static class  UITools.InsertEolAction  
  • Field Summary

    Fields
    Modifier and Type Field Description
    static float FONT_SCALE_FACTOR  
    static java.lang.String MAIN_FREEPLANE_FRAME  
    static java.awt.Dimension MAX_BUTTON_DIMENSION  
    static java.lang.String SCROLLBAR_INCREMENT  
  • Constructor Summary

    Constructors
    Constructor Description
    UITools()  
  • Method Summary

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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAIN_FREEPLANE_FRAME

      public static final java.lang.String MAIN_FREEPLANE_FRAME
      See Also:
      Constant Field Values
    • SCROLLBAR_INCREMENT

      public static final java.lang.String SCROLLBAR_INCREMENT
      See Also:
      Constant Field Values
    • MAX_BUTTON_DIMENSION

      public static final java.awt.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​(javax.swing.JDialog dialog)
    • addEscapeActionToDialog

      public static void addEscapeActionToDialog​(javax.swing.JDialog dialog, javax.swing.Action action)
    • addKeyActionToDialog

      public static void addKeyActionToDialog​(javax.swing.JDialog dialog, javax.swing.Action action, java.lang.String keyStroke, java.lang.String actionId)
    • convertPointFromAncestor

      public static void convertPointFromAncestor​(java.awt.Component ancestor, java.awt.Point p, java.awt.Component c)
    • convertPointToAncestor

      public static void convertPointToAncestor​(java.awt.Component source, java.awt.Point point, java.lang.Class<?> ancestorClass)
    • convertRectangleToAncestor

      public static void convertRectangleToAncestor​(java.awt.Component from, java.awt.Rectangle r, java.awt.Component destination)
    • convertPointToAncestor

      public static void convertPointToAncestor​(java.awt.Component from, java.awt.Point p, java.awt.Component destination)
    • errorMessage

      public static void errorMessage​(java.lang.Object message)
    • getCurrentRootComponent

      public static java.awt.Component getCurrentRootComponent()
    • getCurrentFrame

      public static java.awt.Frame getCurrentFrame()
    • getFrame

      public static java.awt.Frame getFrame()
    • getMenuComponent

      public static java.awt.Component getMenuComponent()
    • getKeyStroke

      public static javax.swing.KeyStroke getKeyStroke​(java.lang.String keyStrokeDescription)
      returns a KeyStroke if possible and null otherwise.
    • keyStrokeToString

      public static java.lang.String keyStrokeToString​(javax.swing.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​(java.lang.String message)
    • informationMessage

      public static void informationMessage​(java.awt.Component frame, java.lang.String message)
    • informationMessage

      public static void informationMessage​(java.awt.Component frame, java.lang.String message, java.lang.String title)
    • informationMessage

      public static void informationMessage​(java.awt.Component frame, java.lang.String text, java.lang.String title, int type)
    • setBounds

      public static void setBounds​(java.awt.Component frame, int win_x, int win_y, int win_width, int win_height)
    • getValidFrameBounds

      public static java.awt.Rectangle getValidFrameBounds​(java.awt.Component frame, int win_x, int win_y, int win_width, int win_height)
    • getAvailableScreenBounds

      public static java.awt.Rectangle getAvailableScreenBounds​(java.awt.Component frame)
    • getScreenBounds

      public static java.awt.Rectangle getScreenBounds​(java.awt.GraphicsConfiguration graphicsConfiguration)
    • setDialogLocationRelativeTo

      public static void setDialogLocationRelativeTo​(javax.swing.JDialog dialog, java.awt.Component c)
    • findBestLocation

      public static java.awt.Point findBestLocation​(java.awt.Component placedComponent, java.awt.Component displayedComponent)
    • setDialogLocationRelativeTo

      public static void setDialogLocationRelativeTo​(javax.swing.JDialog dialog, org.freeplane.features.map.NodeModel node)
    • setDialogLocationUnder

      public static void setDialogLocationUnder​(javax.swing.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​(java.lang.String message, int messageType)
    • showConfirmDialog

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

      public static int showConfirmDialog​(org.freeplane.features.map.NodeModel node, java.lang.Object message, java.lang.String title, int optionType)
    • showInputDialog

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

      public static java.lang.String showInputDialog​(org.freeplane.features.map.NodeModel node, java.lang.String text, java.lang.String title, int type)
    • setScrollbarIncrement

      public static void setScrollbarIncrement​(javax.swing.JScrollPane scrollPane)
    • addScrollbarIncrementPropertyListener

      public static void addScrollbarIncrementPropertyListener​(javax.swing.JScrollPane scrollPane)
    • getTextColorForBackground

      public static java.awt.Color getTextColorForBackground​(java.awt.Color color)
    • isLight

      public static boolean isLight​(java.awt.Color color)
    • isLighter

      public static boolean isLighter​(java.awt.Color color, int minimum)
    • focusOn

      public static void focusOn​(javax.swing.JComponent component)
    • createStroke

      public static java.awt.BasicStroke createStroke​(float width, int[] dash, int join)
    • repaintAll

      public static void repaintAll​(java.awt.Container root)
    • createCancelDialog

      public static javax.swing.JDialog createCancelDialog​(java.awt.Component component, java.lang.String titel, java.lang.String text)
    • addTitledBorder

      public static javax.swing.border.TitledBorder addTitledBorder​(javax.swing.JComponent c, java.lang.String title, float size)
    • backOtherWindows

      public static void backOtherWindows()
    • createHtmlLinkStyleButton

      public static javax.swing.JButton createHtmlLinkStyleButton​(java.net.URI uri, java.lang.String title)
    • getComponentIndex

      public static final int getComponentIndex​(java.awt.Component component)
    • scale

      public static java.awt.Font scale​(java.awt.Font font)
    • scaleUI

      public static java.awt.Font scaleUI​(java.awt.Font font)
    • scaleFontInt

      public static java.awt.Font scaleFontInt​(java.awt.Font font, double additionalFactor)
    • invertScale

      public static java.awt.Font invertScale​(java.awt.Font font)
    • showFrame

      public static void showFrame()
    • isEditingText

      public static boolean isEditingText()
    • executeWhenNodeHasFocus

      public static void executeWhenNodeHasFocus​(java.lang.Runnable runnable)
    • getUIFontSize

      public static int getUIFontSize​(double scalingFactor)
    • getUIFontSize

      public static int getUIFontSize​(float scalingFactor)
    • getUIFont

      public static java.awt.Font getUIFont​(float scalingFactor)
    • getUIFont

      public static java.awt.Font getUIFont()
    • getDefaultLabelFont

      public static java.awt.Font getDefaultLabelFont()
    • newFileChooser

      public static javax.swing.JFileChooser newFileChooser()
    • newFileChooser

      public static javax.swing.JFileChooser newFileChooser​(java.io.File directory)
    • getFreeplaneTabbedPanel

      public static javax.swing.JTabbedPane getFreeplaneTabbedPanel()
    • isLightLookAndFeelInstalled

      public static boolean isLightLookAndFeelInstalled()