flatscape.util
Class ImageUtils

java.lang.Object
  |
  +--flatscape.util.ImageUtils

public class ImageUtils
extends java.lang.Object

The ImageUtils class contains static utility methods related to loading and resizing images, icons, and cursors.

Copyright (c) 2001 Rutgers, The State University of New Jersey

Since:
flatscape %Version%
Version:
%Version%, %Time%

Method Summary
static java.awt.Cursor getCrosshairCursor(java.lang.String subImageSource, java.lang.String cursorName)
          Returns a crosshair cursor with the specified image in the lower right corner.
static java.awt.Cursor getCursor(java.lang.String source, java.awt.Point hotSpot, java.lang.String cursorName)
          Returns a cursor constructed from the specified source.
static java.awt.Image getImage(java.lang.String source)
          Returns an Image that has been fully loaded.
static java.awt.Image getImage(java.lang.String source, java.awt.Dimension size, boolean allowExpand)
          Returns an Image that has been resized using verifyAspectAndSize().
static javax.swing.ImageIcon getImageIcon(java.lang.String source)
          Returns an ImageIcon that has been fully loaded.
static javax.swing.ImageIcon getImageIcon(java.lang.String source, java.awt.Dimension size, boolean allowExpand)
          Returns an ImageIcon that has been resized using verifyAspectAndSize().
static java.awt.image.RenderedImage getRenderedImage(java.lang.String source)
          Returns a RenderedImage loaded using Java Advanced Imaging.
static java.awt.Dimension verifyAspectAndSize(java.awt.Dimension original, java.awt.Dimension desiredMax)
          Returns a new Dimension that as large as possible with the same aspect ratio as the original, but is smaller or equal to in width and height as the desired maximum.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getImageIcon

public static javax.swing.ImageIcon getImageIcon(java.lang.String source)
Returns an ImageIcon that has been fully loaded.

Parameters:
source - A relative or absolute path or URL

getImage

public static java.awt.Image getImage(java.lang.String source)
Returns an Image that has been fully loaded.

Parameters:
source - A relative or absolute path or URL

getRenderedImage

public static java.awt.image.RenderedImage getRenderedImage(java.lang.String source)
Returns a RenderedImage loaded using Java Advanced Imaging.

Parameters:
source - A relative or absolute path or URL

verifyAspectAndSize

public static java.awt.Dimension verifyAspectAndSize(java.awt.Dimension original,
                                                     java.awt.Dimension desiredMax)
Returns a new Dimension that as large as possible with the same aspect ratio as the original, but is smaller or equal to in width and height as the desired maximum. The result may be an expansion or contraction of the original Dimension as required.


getImage

public static java.awt.Image getImage(java.lang.String source,
                                      java.awt.Dimension size,
                                      boolean allowExpand)
Returns an Image that has been resized using verifyAspectAndSize().

Parameters:
source - A relative or absolute path or URL
size - The desired maximum size
allowExpand - If false, image will only be contracted if necessary, never expanded

getImageIcon

public static javax.swing.ImageIcon getImageIcon(java.lang.String source,
                                                 java.awt.Dimension size,
                                                 boolean allowExpand)
Returns an ImageIcon that has been resized using verifyAspectAndSize().

Parameters:
source - A relative or absolute path or URL
size - The desired maximum size
allowExpand - If false, image will only be contracted if necessary, never expanded

getCursor

public static java.awt.Cursor getCursor(java.lang.String source,
                                        java.awt.Point hotSpot,
                                        java.lang.String cursorName)
Returns a cursor constructed from the specified source.

Parameters:
source - A relative or absolute path or URL
hotSpot - The click location of the image

getCrosshairCursor

public static java.awt.Cursor getCrosshairCursor(java.lang.String subImageSource,
                                                 java.lang.String cursorName)
Returns a crosshair cursor with the specified image in the lower right corner.

Parameters:
subImageSource - A relative or absolute path or URL


Copyright (c) 2003 Rutgers, The State University of New Jersey