1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
private void drawCompositeBg(Graphics pG) {
Graphics2D g2d = (Graphics2D)pG;
Paint oldPaint = g2d.getPaint();
// coin suppérieur gauche
g2d.drawImage(leftUpBg, x, y, leftUpBg.getWidth(null), leftUpBg.getHeight(null), game);
// partie suppérieur
g2d.setPaint(upBgTexture);
int lDrawWidth = getWidth()-leftUpBg.getWidth(null)-rightUpBg.getWidth(null);
int lDrawX = x+leftUpBg.getWidth(null);
g2d.fillRect(lDrawX, y, lDrawWidth, upBg.getHeight(null));
// coin suppérieur droit
lDrawX += lDrawWidth;
g2d.drawImage(rightUpBg, lDrawX, y, rightUpBg.getWidth(null), rightUpBg.getHeight(null), game);
// partie gauche
g2d.setPaint(leftBgTexture);
int lDrawY = y+leftUpBg.getHeight(null);
int lDrawHeight = getHeight()-leftUpBg.getHeight(null)-leftDownBg.getHeight(null);
g2d.fillRect(x, lDrawY, leftBg.getWidth(null), lDrawHeight);
// partie central
g2d.setPaint(middleBgTexture);
lDrawX = x+leftBg.getWidth(null);
lDrawWidth = getWidth()-leftBg.getWidth(null)-rightBg.getWidth(null);
g2d.fillRect(lDrawX, lDrawY, lDrawWidth, lDrawHeight);
// partie droite
g2d.setPaint(rightBgTexture);
lDrawX += lDrawWidth;
g2d.fillRect(lDrawX, lDrawY, rightBg.getWidth(null), lDrawHeight);
// coin inférieur gauche
lDrawY += lDrawHeight;
g2d.drawImage(leftDownBg, x, lDrawY, leftDownBg.getWidth(null), leftDownBg.getHeight(null), game);
// partie inférieur
g2d.setPaint(downBgTexture);
lDrawX = x+leftDownBg.getWidth(null);
lDrawWidth = getWidth()-leftDownBg.getWidth(null)-rightDownBg.getWidth(null);
g2d.fillRect(lDrawX, lDrawY, lDrawWidth, downBg.getHeight(null));
// coin inférieur droit
lDrawX += lDrawWidth;
g2d.drawImage(rightDownBg, lDrawX, lDrawY, rightDownBg.getWidth(null), rightDownBg.getHeight(null), game);
g2d.setPaint(oldPaint);
} |
Partager