public void drawImageCentred(Graphics g, Image image) { if (element != null) { Graphics2D g2 = (Graphics2D) g; Rectangle r = element.jGetBounds(); int mitteX = r.width / 2; int mitteY = r.height / 2; int imageMitteX = image.getWidth(null) / 2; int imageMitteY = image.getHeight(null) / 2; g2.drawImage(image, r.x + mitteX - imageMitteX, r.y + mitteY - imageMitteY, null); } }
public void onDispose() { if (image != null) { image.flush(); image = null; } }