talx x1.0.5

talx.util
Class DrawUtils

java.lang.Object
  extended bytalx.util.DrawUtils

public class DrawUtils
extends java.lang.Object

Provides static methods to assist in drawing components.


Method Summary
static java.awt.Font bestFitFont(java.lang.String text, java.awt.Component c)
          Returns the font that best fits the given string to the given component.
static javax.swing.ImageIcon getScaledIcon(java.lang.String name, int width, int height, boolean isFile)
          Returns a scaled ImageIcon from the given filename.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getScaledIcon

public static javax.swing.ImageIcon getScaledIcon(java.lang.String name,
                                                  int width,
                                                  int height,
                                                  boolean isFile)
Returns a scaled ImageIcon from the given filename.

Parameters:
name - the name of the file or resource that holds the image.
width - the width in pixels of the returned image
height - the height in pixels of the returned image
isFile - if true, this method will try to load the image from the file system. If false, this method will use the system class loader to find the image resource in the classpath.
Returns:
the Icon or null if the file can't be parsed.

bestFitFont

public static java.awt.Font bestFitFont(java.lang.String text,
                                        java.awt.Component c)
Returns the font that best fits the given string to the given component. This method assumes the text should all be on a single line. The font name and style are taken from the current values for the component's font. This method never returns a font bigger than 144 point (2 inches tall).

Throws:
java.lang.IllegalStateException - if the component is not currently showing, or its font has not been set.

talx x1.0.5

© 2001-2005 University of Oregon.
Eugene OR 97403, U.S.A. All Rights Reserved.