com.melloware.jukes.file.image
Class ImageFactory

java.lang.Object
  extended by com.melloware.jukes.file.image.ImageFactory

public final class ImageFactory
extends java.lang.Object

Class to represent and storage area for all icon references. This will reduce overhead and memory usage throughout the application. Also contains some static helper methods for loading and scaling images.

Copyright: Copyright (c) 2006

Company: Melloware, Inc.

Version:
4.0
Author:
Emil A. Lefkof III

Field Summary
static javax.swing.ImageIcon ICO_TRAYICON
           
static javax.swing.ImageIcon ICO_TRAYPAUSE
           
static javax.swing.ImageIcon ICO_TRAYPLAY
           
static javax.swing.ImageIcon ICO_TRAYSTOP
           
static javax.swing.ImageIcon IMAGE_NOCOVER
           
 
Method Summary
static javax.swing.ImageIcon getDiscImage(java.lang.String aFileName)
          Gets the disc and returns it the correct size.
static javax.swing.ImageIcon getIconFromFile(java.lang.String aFileName)
          Method to create a new ImageIcon and return the reference
static java.awt.Image getImageFromUrl(java.lang.String aUrl)
          Gets an Image from the URL specified.
static javax.swing.ImageIcon getScaledImage(java.lang.String aFileName, int height, int width)
          Gets an ImageIcon and scales it to the size requested.
static java.io.File saveImage(java.awt.Image image, java.lang.String filename)
          Saves an image file to disk in the location specified.
static java.lang.String saveImageWithFileFormat(java.awt.Image image, java.lang.String aFormat, java.lang.String aDirectory, java.lang.String aArtist, java.lang.String aDisc)
          Saves this image file based on a format from prefs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ICO_TRAYICON

public static final javax.swing.ImageIcon ICO_TRAYICON

ICO_TRAYPLAY

public static final javax.swing.ImageIcon ICO_TRAYPLAY

ICO_TRAYPAUSE

public static final javax.swing.ImageIcon ICO_TRAYPAUSE

ICO_TRAYSTOP

public static final javax.swing.ImageIcon ICO_TRAYSTOP

IMAGE_NOCOVER

public static final javax.swing.ImageIcon IMAGE_NOCOVER
Method Detail

getDiscImage

public static javax.swing.ImageIcon getDiscImage(java.lang.String aFileName)
Gets the disc and returns it the correct size.

Parameters:
aFileName - the file location of the disc
Returns:
the ImageIcon

getIconFromFile

public static javax.swing.ImageIcon getIconFromFile(java.lang.String aFileName)
Method to create a new ImageIcon and return the reference

Parameters:
aFileName - filename of icon to load
Returns:
ImageIcon reference of fileName

getImageFromUrl

public static java.awt.Image getImageFromUrl(java.lang.String aUrl)
Gets an Image from the URL specified. Safe so we return NULL if anything goes wrong and the image can not be loaded.

Parameters:
aUrl - the URL to look for the image
Returns:
the Image if found, NULL if nothing found

getScaledImage

public static javax.swing.ImageIcon getScaledImage(java.lang.String aFileName,
                                                   int height,
                                                   int width)
Gets an ImageIcon and scales it to the size requested.

Parameters:
aFileName - the filename to get
height - the desired height of the image
width - the desired width of the image
Returns:
the ImageIcon

saveImage

public static java.io.File saveImage(java.awt.Image image,
                                     java.lang.String filename)
                              throws java.io.IOException
Saves an image file to disk in the location specified.

Parameters:
image - the image to save
filename - the file to save it as
Throws:
java.io.IOException - if any error occurs writing the file.

saveImageWithFileFormat

public static java.lang.String saveImageWithFileFormat(java.awt.Image image,
                                                       java.lang.String aFormat,
                                                       java.lang.String aDirectory,
                                                       java.lang.String aArtist,
                                                       java.lang.String aDisc)
                                                throws java.io.IOException
Saves this image file based on a format from prefs. The format is in aFormat and can have values %a for artist, and %d for disc. Replaces any invalid characters (\\, /, :, , *, ?, ", <, >, or |) with underscores _ to prevent any errors on file systems. Examples: %a - %d = Black Crowes - Amorica.jpg

Parameters:
image - the image to save
aFormat - the string format like %a - %d = Black Crowes - Amorica.jpg
aDirectory - the directory to save the file in.
aArtist - the name of the artist
aDisc - the name of the disc
Returns:
true if renamed, false if failure
Throws:
java.io.IOException - if any error occurs writing the file out


Copyright © 1999-2008 Melloware Inc. All Rights Reserved.