com.melloware.jukes.file.image
Class ImageFactory

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

public final class ImageFactory
extends 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 ImageIcon ICO_TRAYICON
           
static ImageIcon ICO_TRAYPAUSE
           
static ImageIcon ICO_TRAYPLAY
           
static ImageIcon ICO_TRAYSTOP
           
static ImageIcon IMAGE_NOCOVER
           
static Settings settings
          EAL
 
Method Summary
static ImageIcon getDiscImage(String aFileName)
          Gets the disc and returns it the correct size.
static ImageIcon getIconFromFile(String aFileName)
          Method to create a new ImageIcon and return the reference
static Image getImageFromUrl(String aUrl)
          Gets an Image from the URL specified.
static ImageIcon getScaledImage(String aFileName, int height, int width)
          Gets an ImageIcon and scales it to the size requested.
static File saveImage(Image image, String filename)
          Saves an image file to disk in the location specified.
static String saveImageToUserDefinedDirectory(File imageFile, String aArtist, String aDisc, String aYear)
          AZ
static String saveImageWithFileFormat(Image image, String aFormat, String aDirectory, String aArtist, String aDisc, String aYear)
          Saves this image file based on a format from prefs.
static void setSettings(Settings aSettings)
          EAL
static String standardImageFileName(String aArtist, String aDisc, String aYear)
          AZ
 
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 ImageIcon ICO_TRAYICON

ICO_TRAYPLAY

public static final ImageIcon ICO_TRAYPLAY

ICO_TRAYPAUSE

public static final ImageIcon ICO_TRAYPAUSE

ICO_TRAYSTOP

public static final ImageIcon ICO_TRAYSTOP

IMAGE_NOCOVER

public static final ImageIcon IMAGE_NOCOVER

settings

public static Settings settings
EAL

Method Detail

setSettings

public static void setSettings(Settings aSettings)
EAL


getDiscImage

public static ImageIcon getDiscImage(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 ImageIcon getIconFromFile(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 Image getImageFromUrl(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 ImageIcon getScaledImage(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 File saveImage(Image image,
                             String filename)
                      throws 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:
IOException - if any error occurs writing the file.

saveImageWithFileFormat

public static String saveImageWithFileFormat(Image image,
                                             String aFormat,
                                             String aDirectory,
                                             String aArtist,
                                             String aDisc,
                                             String aYear)
                                      throws IOException
Saves this image file based on a format from prefs. The format is in aFormat and can have values %y for year, %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:
IOException - if any error occurs writing the file out

saveImageToUserDefinedDirectory

public static String saveImageToUserDefinedDirectory(File imageFile,
                                                     String aArtist,
                                                     String aDisc,
                                                     String aYear)
                                              throws IOException
AZ

Throws:
IOException

standardImageFileName

public static String standardImageFileName(String aArtist,
                                           String aDisc,
                                           String aYear)
AZ



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