* Create the background image
* @return
*/
private BufferedImage createBackground(DisplayImageDIResolver resolver) {
BufferedImage background = new BufferedImage(rect.width, rect.height, BufferedImage.TYPE_4BYTE_ABGR);
IOpenPatricianPainter opPainter = resolver.getOpenPatricianPainter();
Graphics gScr = background.getGraphics();
// Render the frame
BufferedImage img = loader.getImage("FrameLayout");
int width = img.getWidth();
gScr.drawImage(img, rect.x, rect.y, null);
// Compute the top fringe
int remWidth = rect.width-width;
img = loader.getImage("topDeco");
int decoWidth = img.getWidth();
int countComplete = remWidth/decoWidth; // number the deco can be drawn complete
int partialWidth = remWidth-(countComplete*decoWidth);
for (int i=0;i<countComplete;i++){
int startX = rect.x+width+(i*decoWidth);
gScr.drawImage(img, startX, rect.y, null);
}
int startX = rect.x+width+(countComplete*decoWidth);
gScr.drawImage(img, startX, rect.y, partialWidth, img.getHeight(), null);
// draw right border
final int cornerDim = 10;
final int mortarDim = 12;
final int defaultPlateding = 200;
countComplete = (int)Math.round((rect.height-TOP_STATUS_HEIGHT-1.5*cornerDim)/(mortarDim+defaultPlateding));
// compute the scale in y direction
int constantBuffer = cornerDim+cornerDim/2+mortarDim*countComplete-mortarDim;
int platingDestDim = rect.height-TOP_STATUS_HEIGHT-constantBuffer;
img = loader.getImage("reightBorderMiddle");
int platingOrigDim = countComplete*img.getHeight();
double scale = platingDestDim*1.0/platingOrigDim;
BufferedImage plate = opPainter.scaleY(img, (int)Math.rint(img.getHeight()*scale));
startX = rect.x+rect.width-img.getWidth();
int startY = rect.y+TOP_STATUS_HEIGHT;
// draw top right corner
img = loader.getImage("rightTopBorderCorner");
img = img.getSubimage(0, img.getHeight()/2, img.getWidth(), img.getHeight()/2);
gScr.drawImage(img, startX, startY, null);
startY += img.getHeight();
img = loader.getImage("reightBorderMortar");
for (int h=0;h<countComplete;h++){
if (h<countComplete-1){
gScr.drawImage(plate, startX, startY, null);
startY += plate.getHeight();
gScr.drawImage(img, startX, startY, null);
startY += img.getHeight();
} else {
// fill all the excessive space
int height = rect.height-cornerDim-startY;
img = loader.getImage("reightBorderMiddle"); // overriding since there is no more mortar to be drawn
plate = opPainter.scaleY(img, height);
gScr.drawImage(plate, startX, startY, null);
startY += height;
}
}
img = loader.getImage("rightBottomBorderCorner");
gScr.drawImage(img, startX, startY, null);
// Draw the bottom border
countComplete = (int)Math.round((rect.width-LEFT_PANEL_WIDTH-1.5*cornerDim)/(mortarDim+defaultPlateding));
// compute the scale in x direction
platingDestDim = rect.width-LEFT_PANEL_WIDTH-constantBuffer;
img = loader.getImage("bottomBorderMiddle");
platingOrigDim = countComplete*img.getWidth();
scale = platingDestDim*1.0/platingOrigDim;
plate = opPainter.scaleX(img, (int)Math.rint(img.getWidth()*scale));
startX = rect.x+LEFT_PANEL_WIDTH;
// startY must not be adjusted is correct from above
// draw top right corner
img = loader.getImage("leftBottomBorderCorner");
img = img.getSubimage(img.getWidth()/2, 0, img.getWidth()/2, img.getHeight());
gScr.drawImage(img, startX, startY, null);
startX += img.getWidth();
img = loader.getImage("bottomBorderMortar");
for (int w=0;w<countComplete;w++){
if (w<countComplete-1){
gScr.drawImage(plate, startX, startY, null);
startX += plate.getWidth();
gScr.drawImage(img, startX, startY, null);
startX += img.getWidth();
} else {
// fill all the excessive space
width = rect.width-cornerDim-startX;
img = loader.getImage("bottomBorderMiddle"); // overriding since there is no more mortar to be drawn
plate = opPainter.scaleX(img, width);
gScr.drawImage(plate, startX, startY, null);
startX += width;
}
}
// render deco under left side panel
int height = rect.height-MINMIMAL_DISPLAY_HEIGHT-rect.y;
String ornamentName="Ornament310x310";
if (height<125){
ornamentName="Ornament310x94";
} else if (height<158){
ornamentName="Ornament310x155";
} else if (height<173){
ornamentName="Ornament310x162";
} else if (height<298){
ornamentName="Ornament310x185";
}
img = loader.getImage(ornamentName);
img = opPainter.scaleY(img, height);
gScr.drawImage(img, rect.x, rect.y+MINMIMAL_DISPLAY_HEIGHT, null);
return background;
}