AppletLoader: addded ability to use appletloader with no images, just the logo, just the progressbar or both. To set no image for either image you must set the parameter value to "". Both images are now centred independently allowing variable size logo and progressbar images. Resized appletprogress.gif to match appletlogo.png size.
This commit is contained in:
parent
12a37c264e
commit
c05cc0b695
Binary file not shown.
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 7.3 KiB |
|
@ -283,13 +283,12 @@ public class AppletLoader extends Applet implements Runnable, AppletStub {
|
||||||
setBackground(bgColor);
|
setBackground(bgColor);
|
||||||
fgColor = getColor("boxfgcolor", Color.black);
|
fgColor = getColor("boxfgcolor", Color.black);
|
||||||
|
|
||||||
// load logos
|
// load logos, if value is "" then skip
|
||||||
logo = getImage(getParameter("al_logo"));
|
if (!getParameter("al_logo").equals("")) {
|
||||||
progressbar = getImage(getParameter("al_progressbar"));
|
logo = getImage(getParameter("al_logo"));
|
||||||
|
}
|
||||||
//sanity check
|
if (!getParameter("al_progressbar").equals("")) {
|
||||||
if(logo == null || progressbar == null) {
|
progressbar = getImage(getParameter("al_progressbar"));
|
||||||
fatalErrorOccured("Unable to load logo and progressbar images", null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for lzma support
|
// check for lzma support
|
||||||
|
@ -460,21 +459,26 @@ public class AppletLoader extends Applet implements Runnable, AppletStub {
|
||||||
|
|
||||||
painting = true;
|
painting = true;
|
||||||
|
|
||||||
// get logo position so its in the middle of applet
|
// get position at the middle of the offscreen buffer
|
||||||
int x = 0, y = 0;
|
int x = offscreen.getWidth(null)/2;
|
||||||
|
int y = offscreen.getHeight(null)/2;
|
||||||
|
|
||||||
if(logo != null) {
|
/*if(logo != null) {
|
||||||
x = (offscreen.getWidth(null) - logo.getWidth(null)) / 2;
|
x = (offscreen.getWidth(null) - logo.getWidth(null)) / 2;
|
||||||
y = (offscreen.getHeight(null) - logo.getHeight(null)) / 2;
|
y = (offscreen.getHeight(null) - logo.getHeight(null)) / 2;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// draw logo
|
// draw logo
|
||||||
if (logo != null) og.drawImage(logoBuffer, x, y, this);
|
if (logo != null) {
|
||||||
|
og.drawImage(logoBuffer, x-logo.getWidth(null)/2, y-logo.getHeight(null)/2, this);
|
||||||
|
}
|
||||||
|
|
||||||
// draw message
|
// draw message
|
||||||
int messageX = (offscreen.getWidth(null) - fm.stringWidth(message)) / 2;
|
int messageX = (offscreen.getWidth(null) - fm.stringWidth(message)) / 2;
|
||||||
int messageY = y + 20;
|
int messageY = y + 20;
|
||||||
if (logo != null) messageY += logoBuffer.getHeight(null);
|
|
||||||
|
if (logo != null) messageY += logo.getHeight(null)/2;
|
||||||
|
else if (progressbar != null) messageY += progressbar.getHeight(null)/2;
|
||||||
|
|
||||||
og.drawString(message, messageX, messageY);
|
og.drawString(message, messageX, messageY);
|
||||||
|
|
||||||
|
@ -486,9 +490,9 @@ public class AppletLoader extends Applet implements Runnable, AppletStub {
|
||||||
|
|
||||||
// draw loading bar, clipping it depending on percentage done
|
// draw loading bar, clipping it depending on percentage done
|
||||||
if (progressbar != null) {
|
if (progressbar != null) {
|
||||||
int barSize = (progressbarBuffer.getWidth(null) * percentage) / 100;
|
int barSize = (progressbar.getWidth(null) * percentage) / 100;
|
||||||
og.clipRect(0, 0, x + barSize, offscreen.getHeight(null));
|
og.clipRect(x-progressbar.getWidth(null)/2, 0, barSize, offscreen.getHeight(null));
|
||||||
og.drawImage(progressbarBuffer, x, y, this);
|
og.drawImage(progressbarBuffer, x-progressbar.getWidth(null)/2, y-progressbar.getHeight(null)/2, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
painting = false;
|
painting = false;
|
||||||
|
@ -527,7 +531,10 @@ public class AppletLoader extends Applet implements Runnable, AppletStub {
|
||||||
g.fillRect(0, 0, buffer.getWidth(null), buffer.getHeight(null));
|
g.fillRect(0, 0, buffer.getWidth(null), buffer.getHeight(null));
|
||||||
|
|
||||||
// buffer background is cleared, so draw logo under progressbar
|
// buffer background is cleared, so draw logo under progressbar
|
||||||
if (img == progressbar && logo != null) g.drawImage(logoBuffer, 0, 0, null);
|
if (img == progressbar && logo != null) {
|
||||||
|
g.drawImage(logoBuffer, progressbar.getWidth(null)/2-logo.getWidth(null)/2,
|
||||||
|
progressbar.getHeight(null)/2-logo.getHeight(null)/2, null);
|
||||||
|
}
|
||||||
|
|
||||||
g.drawImage(img, 0, 0, this);
|
g.drawImage(img, 0, 0, this);
|
||||||
g.dispose();
|
g.dispose();
|
||||||
|
@ -1453,6 +1460,9 @@ public class AppletLoader extends Applet implements Runnable, AppletStub {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
/* */
|
/* */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// show error as image could not be loaded
|
||||||
|
fatalErrorOccured("Unable to load logo and progressbar images", null);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue