/* BeanShell init file. Run every time an album is generated with this skin */

import se.datadosen.jalbum.JAFilter;
import javax.swing.*;

// This skin requires at least Java 1.4, check and report if not.
if (System.getProperty("java.specification.version").compareTo("1.4") < 0) {
	JOptionPane.showMessageDialog(window, "This skin requires at least Java 1.4.\nPlease update from http://www.java.com and reinstall JAlbum", "Java version problem", JOptionPane.ERROR_MESSAGE);
	throw new OperationAbortedException();
}

// Load variables specific to the current style
String stylebase = style.substring(0, style.lastIndexOf('.'));
File f = new File(skinDirectory, "styles/" + stylebase + ".bsh");
if (f.exists()) engine.processBeanShellFile(f);

// Set filters
if (grayThumbnails)
	engine.addFilter(new GrayscaleFilter(), JAFilter.THUMBNAILS_POSTSCALE_STAGE);

if (grayCloseups)
	engine.addFilter(new GrayscaleFilter(), JAFilter.CLOSEUPS_POSTSCALE_STAGE);


FixedShapeFilter fsf = new FixedShapeFilter();
engine.addFilter(fsf, JAFilter.THUMBNAILS_PRESCALE_STAGE);

if (topLeftOrnament) {
	LogoFilter lf = new LogoFilter();
	lf.setSrc(new File(skinDirectory, "png/ornamentBigTopLeft.png").toURL().toString());
	lf.setOffset(-1);
	lf.setVoffset(-1);
	engine.addFilter(lf, JAFilter.THUMBNAILS_PRESCALE_STAGE);
	engine.addFilter(lf, JAFilter.ALL_POSTSCALE_STAGE);
}

if (topRightOrnament) {
	LogoFilter lf = new LogoFilter();
	lf.setSrc(new File(skinDirectory, "png/ornamentBigTopRight.png").toURL().toString());
	lf.setOffset(1);
	lf.setVoffset(-1);
	lf.setAlign("right");
	engine.addFilter(lf, JAFilter.THUMBNAILS_PRESCALE_STAGE);
	engine.addFilter(lf, JAFilter.CLOSEUPS_POSTSCALE_STAGE);
}

if (bottomLeftOrnament) {
	LogoFilter lf = new LogoFilter();
	lf.setSrc(new File(skinDirectory, "png/ornamentBigBottomLeft.png").toURL().toString());
	lf.setValign("bottom");
	lf.setOffset(-1);
	engine.addFilter(lf, JAFilter.THUMBNAILS_PRESCALE_STAGE);
	engine.addFilter(lf, JAFilter.CLOSEUPS_POSTSCALE_STAGE);
}

if (bottomRightOrnament) {
	LogoFilter lf = new LogoFilter();
	lf.setSrc(new File(skinDirectory, "png/ornamentBigBottomRight.png").toURL().toString());
	lf.setValign("bottom");
	lf.setAlign("right");
	lf.setOffset(1);
	engine.addFilter(lf, JAFilter.THUMBNAILS_PRESCALE_STAGE);
	engine.addFilter(lf, JAFilter.CLOSEUPS_POSTSCALE_STAGE);
}


XBorderFilter xb = new XBorderFilter();
if (thumbnailFrames) {
	xb.setFrWidth("" + 4);
	xb.setFrCol(frameColor);
}

if (thumbnailShadows) {
	xb.setShWidth(8);
	xb.setShCol(shcolor);
	xb.setShDrop("soft");
	xb.setBgFile(new File(skinDirectory, "styles/" + stylebase + "/background.jpg").getAbsolutePath());
//	xb.setBgFile(new File(skinDirectory, "res/rutor.gif").getAbsolutePath());
}
engine.addFilter(new PropertySettingFilterWrapper(xb), JAFilter.THUMBNAILS_POSTSCALE_STAGE);

XBorderFilter xb2 = new XBorderFilter();
if (closeupFrames) {
	xb2.setFrWidth("" + 8);
	xb2.setFrCol(frameColor);
}
if (closeupShadows) {
	xb2.setShWidth(8);
	xb2.setShCol(shcolor);
	xb2.setShDrop("soft");
	xb2.setBgFile(new File(skinDirectory, "styles/" + stylebase + "/background.jpg").getAbsolutePath());
//	xb2.setBgFile(new File(skinDirectory, "res/rutor.gif").getAbsolutePath());
	xb2.setBgOffX(228);
	xb2.setBgOffY(136);
}
engine.addFilter(xb2, JAFilter.CLOSEUPS_POSTSCALE_STAGE);
