org.knime.core.node.util
Class ViewUtils

java.lang.Object
  extended by org.knime.core.node.util.ViewUtils

public final class ViewUtils
extends Object

Provides helper methods mostly useful when implementing NodeViews.

Author:
ohl, University of Konstanz

Method Summary
static JPanel getInFlowLayout(int alignment, int hgap, int vgap, JComponent... components)
          Constructs a new FlowLayout panel and adds the argument component(s) to it.
static JPanel getInFlowLayout(int alignment, JComponent... components)
          Constructs a new FlowLayout panel and adds the argument component(s) to it.
static JPanel getInFlowLayout(JComponent... components)
          Constructs a new FlowLayout panel and adds the argument component(s) to it.
static void invokeAndWaitInEDT(Runnable runMe)
          Executes the specified runnable in the Swing Event Dispatch Thread.
static Icon loadIcon(Class<?> className, String path)
          Convenience method to load an icon from package relative path.
static void runOrInvokeLaterInEDT(Runnable runMe)
          Executes the specified runnable some time in the Swing Event Dispatch Thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

invokeAndWaitInEDT

public static void invokeAndWaitInEDT(Runnable runMe)
                               throws InvocationTargetRuntimeException
Executes the specified runnable in the Swing Event Dispatch Thread. If the caller is already running in the EDT, it just executes the run method of the runnable, otherwise it passes the runnable to the EDT and waits until its run method returns.

Parameters:
runMe - the run method of this will be executed.
Throws:
InvocationTargetRuntimeException - if the executed code throws an exception (the cause of it is set to the exception thrown by the executed code then), or if the execution was interrupted in the EDT.
See Also:
SwingUtilities.invokeAndWait(Runnable)

runOrInvokeLaterInEDT

public static void runOrInvokeLaterInEDT(Runnable runMe)
Executes the specified runnable some time in the Swing Event Dispatch Thread. If the caller is already running in the EDT, it immediately executes the run method and does not return until it finishes. Otherwise it queues the argument for execution in the EDT and returns (not waiting for the run method to finish).

Parameters:
runMe - the run method of this will be executed.
See Also:
SwingUtilities.invokeLater(Runnable)

getInFlowLayout

public static JPanel getInFlowLayout(JComponent... components)
Constructs a new FlowLayout panel and adds the argument component(s) to it. The layout has a centered alignment and a default 5-unit horizontal and vertical gap.

Parameters:
components - The components to add
Returns:
The panel /w flow layout and the components added to it.

getInFlowLayout

public static JPanel getInFlowLayout(int alignment,
                                     JComponent... components)
Constructs a new FlowLayout panel and adds the argument component(s) to it. The layout has the specified alignment and a default 5-unit horizontal and vertical gap. The value of the alignment argument must be one of FlowLayout.LEFT, FlowLayout.RIGHT, FlowLayout.CENTER, FlowLayout.LEADING, or FlowLayout.TRAILING.

Parameters:
alignment - The flow panel alignment
components - The components to add
Returns:
The panel /w flow layout and the components added to it.

getInFlowLayout

public static JPanel getInFlowLayout(int alignment,
                                     int hgap,
                                     int vgap,
                                     JComponent... components)
Constructs a new FlowLayout panel and adds the argument component(s) to it. The layout has the specified alignment and horizontal and vertical gap. The value of the alignment argument must be one of FlowLayout.LEFT, FlowLayout.RIGHT, FlowLayout.CENTER, FlowLayout.LEADING, or FlowLayout.TRAILING.

Parameters:
alignment - The flow panel alignment
hgap - the horizontal gap between components and between the components and the borders of the Container
vgap - the vertical gap between components and between the components and the borders of the Container
components - The components to add
Returns:
The panel /w flow layout and the components added to it.

loadIcon

public static Icon loadIcon(Class<?> className,
                            String path)
Convenience method to load an icon from package relative path. The icon is supposed to be located relative to the package associated with the argument class under the path path. This method will not throw an exception when the loading fails but instead return a null icon.

Parameters:
className - The class object, from which to retrieve the package, e.g. FooValue.class.
path - The icon path relative to package associated with the class argument.
Returns:
the icon loaded from that path or null if it loading fails


Copyright, 2003 - 2012. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.