Some small tidying.

This commit is contained in:
Michael Bayne
2007-10-22 06:39:26 +00:00
parent a22d5c3707
commit 3b18e77805
2 changed files with 39 additions and 41 deletions
@@ -453,6 +453,37 @@ public abstract class Getdown extends Thread
setStatus(message, -1, -1L, true); setStatus(message, -1, -1L, true);
} }
/**
* Load the image at the path. Before trying the exact path/file specified we will look to see
* if we can find a localized version by sticking a _<language> in front of the "." in the
* filename.
*/
public BufferedImage loadImage (String path)
{
if (StringUtil.isBlank(path)) {
return null;
}
File imgpath = null;
try {
// First try for a localized image.
String localeStr = Locale.getDefault().getLanguage();
imgpath = _app.getLocalPath(StringUtil.replace(path, ".", "_" + localeStr + "."));
return ImageIO.read(imgpath);
} catch (IOException ioe) {
// No biggie, we'll try the generic one.
}
// If that didn't work, try a generic one.
try {
imgpath = _app.getLocalPath(path);
return ImageIO.read(imgpath);
} catch (IOException ioe2) {
Log.warning("Failed to load image [path=" + imgpath + ", error=" + ioe2 + "].");
return null;
}
}
/** /**
* Downloads and installs an Java VM bundled with the application. This is called if we are not * Downloads and installs an Java VM bundled with the application. This is called if we are not
* running with the necessary Java version. * running with the necessary Java version.
@@ -717,7 +748,6 @@ public abstract class Getdown extends Thread
} }
EventQueue.invokeLater(new Runnable() { EventQueue.invokeLater(new Runnable() {
public void run () { public void run () {
if (_status == null) { if (_status == null) {
_container = createContainer(); _container = createContainer();
@@ -735,8 +765,8 @@ public abstract class Getdown extends Thread
{ {
if (_ifc.rotatingBackgrounds != null) { if (_ifc.rotatingBackgrounds != null) {
if (_ifc.backgroundImage != null) { if (_ifc.backgroundImage != null) {
Log.warning("ui.background_image and ui.rotating_background were " Log.warning("ui.background_image and ui.rotating_background were both specified. " +
+ " both specified. The rotating images are being used."); "The rotating images are being used.");
} }
return new RotatingBackgrounds(_ifc.rotatingBackgrounds, Getdown.this); return new RotatingBackgrounds(_ifc.rotatingBackgrounds, Getdown.this);
} else if (_ifc.backgroundImage != null) { } else if (_ifc.backgroundImage != null) {
@@ -812,38 +842,6 @@ public abstract class Getdown extends Thread
} }
} }
/**
* Load the image at the path. Before trying the exact path/file specified
* we will look to see if we can find a localized version by sticking a
* _<language> in front of the "." in the filename.
*/
public BufferedImage loadImage (String path)
{
String localeStr = Locale.getDefault().getLanguage();
if (StringUtil.isBlank(path)) {
return null;
}
File imgpath = null;
try {
// First try for a localized image.
imgpath = _app.getLocalPath(StringUtil.replace(path, ".", "_" + localeStr + "."));
return ImageIO.read(imgpath);
} catch (IOException ioe) {
// No biggie, we'll try the generic one.
}
// If that didn't work, try a generic one.
try {
imgpath = _app.getLocalPath(path);
return ImageIO.read(imgpath);
} catch (IOException ioe2) {
Log.warning("Failed to load image [path=" + imgpath + ", error=" + ioe2 + "].");
return null;
}
}
/** /**
* Creates the container in which our user interface will be displayed. * Creates the container in which our user interface will be displayed.
*/ */
@@ -57,16 +57,16 @@ public class GetdownApplet extends JApplet
if (appname == null) { if (appname == null) {
appname = ""; appname = "";
} }
final RotatingBackgrounds bgimages; final RotatingBackgrounds bgimages;
if(imgpath == null) { if (imgpath == null) {
bgimages = new RotatingBackgrounds(); bgimages = new RotatingBackgrounds();
} else if(imgpath.contains(",")) { } else if (imgpath.contains(",")) {
bgimages = new RotatingBackgrounds(imgpath.split(","), this); bgimages = new RotatingBackgrounds(imgpath.split(","), this);
} else { } else {
bgimages = new RotatingBackgrounds(loadImage(imgpath)); bgimages = new RotatingBackgrounds(loadImage(imgpath));
} }
Log.info("App Base: " + appbase); Log.info("App Base: " + appbase);
Log.info("App Name: " + appname); Log.info("App Name: " + appname);