_rightEnd = winApp.loadImage(_skin + "/end_right.png");
_thumb = winApp.loadImage(_skin +"/handle.png");
_thumb_mouseover = winApp.loadImage(_skin +"/handle_mouseover.png");
//load the centre image up temporarily as we will generate the final stretched
//image to use shortly
PImage cTemp = winApp.loadImage(_skin + "/centre.png");
String files = "";
//generate a list of files that aren't there
if(_leftEnd == null)
files += "end_left.png\n";
if(_rightEnd == null)
files += "end_right.png\n";
if(_thumb == null)
files += "handle.png\n";
if(_thumb_mouseover == null)
files += "handle_mouseover.png\n";
if(cTemp == null)
files += "centre.png\n";
// See if we have problems with the skin files
if(files != ""){
PApplet.println("The following files could not be found for the skin " + _skin + ": \n" + files
+ "\nCheck that these files are correctly placed in the data directory under a folder with"
+ " the same name as the skin used.\n");
}
if(cTemp.width != 1){
PApplet.println("The supplied centre image for this skin is not of width 1px.");
}
if(cTemp.height != _leftEnd.height || cTemp.height != _rightEnd.height){
PApplet.println("The image components of the slider are not all the same height.");
}
this.height = cTemp.height;
int cWidth = length - _leftEnd.width - _rightEnd.width;
if(cWidth < 0){cWidth = 1;}
_centre = new PImage(cWidth,cTemp.height);
//now copy over the data from cTemp to main centre image
//the standard PImage stretch method is no good in this case
//appears better to do it manually.
cTemp.loadPixels();
_centre.loadPixels();
for (int i = 0; i < _centre.height; i++) {
for (int j = 0; j < _centre.width; j++) {
_centre.pixels[i*_centre.width +j] = cTemp.pixels[i];
}
}
_centre.updatePixels();
cTemp.updatePixels();
//the thumb only moves along the centre section
thumbMin = _leftEnd.width;
thumbMax = _leftEnd.width + _centre.width;
this.setLimits(50.0f, 0.0f, 100.0f);