com.rapidminer.gui.tools
Class SwingTools

java.lang.Object
  extended by com.rapidminer.gui.tools.SwingTools

public class SwingTools
extends java.lang.Object

This helper class provides some static methods and properties which might be useful for several GUI classes. These methods include

Author:
Ingo Mierswa

Field Summary
static java.awt.Color BROWN_FONT_COLOR
          A brown font color.
static java.awt.Color DARK_BLUE
          Some color constants for Java Look and Feel.
static java.awt.Color DARK_YELLOW
          Some color constants for Java Look and Feel.
static java.awt.Color DARKEST_BLUE
          Some color constants for Java Look and Feel.
static java.awt.Color DARKEST_YELLOW
          Some color constants for Java Look and Feel.
static java.awt.Color LIGHT_BLUE
          Some color constants for Java Look and Feel.
static java.awt.Color LIGHT_BROWN_FONT_COLOR
          A brown font color.
static java.awt.Color LIGHT_YELLOW
          Some color constants for Java Look and Feel.
static java.awt.Color LIGHTEST_BLUE
          Some color constants for Java Look and Feel.
static java.awt.Color LIGHTEST_RED
          Some color constants for Java Look and Feel.
static java.awt.Color LIGHTEST_YELLOW
          Some color constants for Java Look and Feel.
static java.awt.Color RAPID_I_BROWN
          The Rapid-I brown color.
static java.awt.Color RAPID_I_ORANGE
          The Rapid-I orange color.
static int TABLE_ROW_EXTRA_HEIGHT
          Defines the extra height for each row in a table.
static int TABLE_WITH_COMPONENTS_ROW_EXTRA_HEIGHT
          Defines the extra height for rows in a table with components.
static java.awt.Color TRANSPARENT_YELLOW
          Some color constants for Java Look and Feel.
static java.awt.Color VERY_DARK_BLUE
          Some color constants for Java Look and Feel.
 
Constructor Summary
SwingTools()
           
 
Method Summary
static java.lang.String addLinebreaks(java.lang.String message)
          Adds linebreaks after TOOL_TIP_LINE_LENGTH letters.
static java.io.File chooseFile(java.awt.Component parent, java.io.File file, boolean open, boolean onlyDirs, java.lang.String extension, java.lang.String extensionDescription)
          Opens a file chooser with a reasonable start directory.
static java.io.File chooseFile(java.awt.Component parent, java.io.File file, boolean open, java.lang.String extension, java.lang.String extensionDescription)
          Opens a file chooser with a reasonable start directory.
static javax.swing.JFileChooser createFileChooser(java.io.File file, boolean onlyDirs, javax.swing.filechooser.FileFilter[] fileFilters)
          Creates file chooser with a reasonable start directory.
static javax.swing.ImageIcon createIcon(java.lang.String iconName)
          Tries to load the icon for the given resource.
static javax.swing.ImageIcon createImage(java.lang.String imageName)
          Tries to load the image for the given resource.
static javax.swing.JPanel createTextPanel(java.lang.String title, java.lang.String text)
          Creates a panel with title and text.
static java.util.List<java.awt.Image> getFrameIconList()
          Returns the list of all available program icon sizes.
static java.awt.Color getPointColor(double value)
          Returns a color equivalent to the value of value.
static java.awt.Color getPointColor(double value, double max, double min)
          Returns a color equivalent to the value of value.
static java.lang.String getStringFromClassArray(java.lang.Class[] classes)
          Transforms the given class name array into a comma separated string of the short class names.
static SyntaxStyle[] getSyntaxStyles()
          Returns adapted syntax color and font styles matching RapidMiner colors.
static TextAreaDefaults getTextAreaDefaults()
          Returns JEditTextArea defaults with adapted syntax color styles.
static java.lang.String html2RapidMinerText(java.lang.String html)
          Replaces simple html tags and quotes by RapidMiner specific text elements.
static java.awt.GradientPaint makeBluePaint(double width, double height)
          Creates a blue gradient paint.
static java.awt.GradientPaint makeRedPaint(double width, double height)
          Creates a red gradient paint.
static java.awt.GradientPaint makeYellowPaint(double width, double height)
          Creates a yellow gradient paint.
static void setDialogIcon(javax.swing.JDialog dialog)
          Returns the list of all possible frame icons.
static void setFrameIcon(javax.swing.JFrame frame)
          Returns the list of all possible frame icons.
static void setFrameIconProvider(FrameIconProvider _frameIconProvider)
           
static void setIconType(java.lang.String newIconType)
           
static void setupFrameIcons(java.lang.String frameIconBaseName)
           
static void showFinalErrorMessage(java.lang.String message, java.lang.Throwable e)
          Shows the final error message dialog.
static void showSimpleErrorMessage(java.lang.String message, java.lang.Throwable e)
          This is the normal method which could be used by GUI classes for errors caused by some exception (e.g.
static void showVerySimpleErrorMessage(java.lang.String message)
          Shows a very simple error message without any Java exception hints.
static java.lang.String text2DisplayHtml(java.lang.String text)
          Replaces the RapidMiner specific tag elements by normal html tags.
static java.lang.String text2SimpleHtml(java.lang.String htmlText)
          Replaces the RapidMiner specific tag elements by normal html tags.
static java.lang.String transformToolTipText(java.lang.String description)
          This method transforms the given tool tip text into HTML.
static java.lang.String transformToolTipText(java.lang.String description, boolean addHTMLTags, int lineLength)
          This method transforms the given tool tip text into HTML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TABLE_ROW_EXTRA_HEIGHT

public static final int TABLE_ROW_EXTRA_HEIGHT
Defines the extra height for each row in a table.

See Also:
Constant Field Values

TABLE_WITH_COMPONENTS_ROW_EXTRA_HEIGHT

public static final int TABLE_WITH_COMPONENTS_ROW_EXTRA_HEIGHT
Defines the extra height for rows in a table with components. If an ExtendedJTable is used, this amount can be added additionally to the amount of TABLE_ROW_EXTRA_HEIGHT which is already added in the constructor.

See Also:
Constant Field Values

DARKEST_YELLOW

public static final java.awt.Color DARKEST_YELLOW
Some color constants for Java Look and Feel.


DARK_YELLOW

public static final java.awt.Color DARK_YELLOW
Some color constants for Java Look and Feel.


LIGHT_YELLOW

public static final java.awt.Color LIGHT_YELLOW
Some color constants for Java Look and Feel.


LIGHTEST_YELLOW

public static final java.awt.Color LIGHTEST_YELLOW
Some color constants for Java Look and Feel.


TRANSPARENT_YELLOW

public static final java.awt.Color TRANSPARENT_YELLOW
Some color constants for Java Look and Feel.


VERY_DARK_BLUE

public static final java.awt.Color VERY_DARK_BLUE
Some color constants for Java Look and Feel.


DARKEST_BLUE

public static final java.awt.Color DARKEST_BLUE
Some color constants for Java Look and Feel.


DARK_BLUE

public static final java.awt.Color DARK_BLUE
Some color constants for Java Look and Feel.


LIGHT_BLUE

public static final java.awt.Color LIGHT_BLUE
Some color constants for Java Look and Feel.


LIGHTEST_BLUE

public static final java.awt.Color LIGHTEST_BLUE
Some color constants for Java Look and Feel.


RAPID_I_ORANGE

public static final java.awt.Color RAPID_I_ORANGE
The Rapid-I orange color.


RAPID_I_BROWN

public static final java.awt.Color RAPID_I_BROWN
The Rapid-I brown color.


LIGHTEST_RED

public static final java.awt.Color LIGHTEST_RED
Some color constants for Java Look and Feel.


BROWN_FONT_COLOR

public static final java.awt.Color BROWN_FONT_COLOR
A brown font color.


LIGHT_BROWN_FONT_COLOR

public static final java.awt.Color LIGHT_BROWN_FONT_COLOR
A brown font color.

Constructor Detail

SwingTools

public SwingTools()
Method Detail

setFrameIconProvider

public static void setFrameIconProvider(FrameIconProvider _frameIconProvider)

setupFrameIcons

public static void setupFrameIcons(java.lang.String frameIconBaseName)

getFrameIconList

public static java.util.List<java.awt.Image> getFrameIconList()
Returns the list of all available program icon sizes.


setFrameIcon

public static void setFrameIcon(javax.swing.JFrame frame)
Returns the list of all possible frame icons.


setDialogIcon

public static void setDialogIcon(javax.swing.JDialog dialog)
Returns the list of all possible frame icons.


makeRedPaint

public static java.awt.GradientPaint makeRedPaint(double width,
                                                  double height)
Creates a red gradient paint.


makeBluePaint

public static java.awt.GradientPaint makeBluePaint(double width,
                                                   double height)
Creates a blue gradient paint.


makeYellowPaint

public static java.awt.GradientPaint makeYellowPaint(double width,
                                                     double height)
Creates a yellow gradient paint.


setIconType

public static void setIconType(java.lang.String newIconType)

createIcon

public static javax.swing.ImageIcon createIcon(java.lang.String iconName)
Tries to load the icon for the given resource. Returns null (and writes a warning) if the resource file cannot be loaded. This method automatically adds the icon path and the correct icon type (modern or classic). The given names must contain '/' instead of backslashes!


createImage

public static javax.swing.ImageIcon createImage(java.lang.String imageName)
Tries to load the image for the given resource. Returns null (and writes a warning) if the resource file cannot be loaded.


transformToolTipText

public static java.lang.String transformToolTipText(java.lang.String description)
This method transforms the given tool tip text into HTML. Lines are splitted at linebreaks and additional line breaks are added after ca. TOOL_TIP_LINE_LENGTH characters.


transformToolTipText

public static java.lang.String transformToolTipText(java.lang.String description,
                                                    boolean addHTMLTags,
                                                    int lineLength)
This method transforms the given tool tip text into HTML. Lines are splitted at linebreaks and additional line breaks are added after ca. TOOL_TIP_LINE_LENGTH characters.


getStringFromClassArray

public static java.lang.String getStringFromClassArray(java.lang.Class[] classes)
Transforms the given class name array into a comma separated string of the short class names.


addLinebreaks

public static java.lang.String addLinebreaks(java.lang.String message)
Adds linebreaks after TOOL_TIP_LINE_LENGTH letters.


showVerySimpleErrorMessage

public static void showVerySimpleErrorMessage(java.lang.String message)
Shows a very simple error message without any Java exception hints.


showSimpleErrorMessage

public static void showSimpleErrorMessage(java.lang.String message,
                                          java.lang.Throwable e)
This is the normal method which could be used by GUI classes for errors caused by some exception (e.g. IO issues). Of course these erro message methods should never be invoked by operators or similar.


showFinalErrorMessage

public static void showFinalErrorMessage(java.lang.String message,
                                         java.lang.Throwable e)
Shows the final error message dialog. This dialog also allows to send a bugreport if the error was not (definitely) a user error.


chooseFile

public static java.io.File chooseFile(java.awt.Component parent,
                                      java.io.File file,
                                      boolean open,
                                      java.lang.String extension,
                                      java.lang.String extensionDescription)
Opens a file chooser with a reasonable start directory. If the extension is null, no file filters will be used.


chooseFile

public static java.io.File chooseFile(java.awt.Component parent,
                                      java.io.File file,
                                      boolean open,
                                      boolean onlyDirs,
                                      java.lang.String extension,
                                      java.lang.String extensionDescription)
Opens a file chooser with a reasonable start directory. If the extension is null, no file filters will be used. This method allows choosing directories.


createFileChooser

public static javax.swing.JFileChooser createFileChooser(java.io.File file,
                                                         boolean onlyDirs,
                                                         javax.swing.filechooser.FileFilter[] fileFilters)
Creates file chooser with a reasonable start directory. You may use the following code snippet in order to retrieve the file:
        if (fileChooser.showOpenDialog(parent) == JFileChooser.APPROVE_OPTION)
            File selectedFile = fileChooser.getSelectedFile();
 
Usually, the method chooseFile(Component, File, boolean, boolean, FileFilter[]) or one of the convenience wrapper methods can be used to do this. This method is only useful if one is interested, e.g., in the selected file filter.

Parameters:
file - The initially selected value of the file chooser dialog
onlyDirs - Only allow directories to be selected
fileFilters - List of FileFilters to use

createTextPanel

public static javax.swing.JPanel createTextPanel(java.lang.String title,
                                                 java.lang.String text)
Creates a panel with title and text. The panel has a border layout and the text is placed into the NORTH section.


html2RapidMinerText

public static java.lang.String html2RapidMinerText(java.lang.String html)
Replaces simple html tags and quotes by RapidMiner specific text elements. These can be used in XML files without confusing an XML parser.


text2DisplayHtml

public static java.lang.String text2DisplayHtml(java.lang.String text)
Replaces the RapidMiner specific tag elements by normal html tags. The given text is also embedded in an html and body tag with an appropriated style sheet definition.


text2SimpleHtml

public static java.lang.String text2SimpleHtml(java.lang.String htmlText)
Replaces the RapidMiner specific tag elements by normal html tags. This method does not embed the given text in a html tag.


getPointColor

public static java.awt.Color getPointColor(double value)
Returns a color equivalent to the value of value. The value has to be normalized between 0 and 1.


getPointColor

public static java.awt.Color getPointColor(double value,
                                           double max,
                                           double min)
Returns a color equivalent to the value of value. The value will be normalized between 0 and 1 using the parameters max and min. Which are the minimum and maximum of the complete dataset.


getTextAreaDefaults

public static TextAreaDefaults getTextAreaDefaults()
Returns JEditTextArea defaults with adapted syntax color styles.


getSyntaxStyles

public static SyntaxStyle[] getSyntaxStyles()
Returns adapted syntax color and font styles matching RapidMiner colors.



Copyright © 2001-2009 by Rapid-I