I have a little problem where on a panel, i am trying to flip an image.. but it seems to flip all images on the screen. I can't seem to get it working.. anybody able to spot the problem?
It loops thru all images, and only if 'rotated' it should rotate image, draw them all to buffered image and draw it to screen
<code follows.. >
public void update(Graphics g){ Graphics2D g2 = (Graphics2D)g;
if(firstTime){ Dimension dim = this.getSize();
Random randomvalue = new Random();
int w = dim.width*2; int h = dim.height;
setSize(w,h); area = new Rectangle(dim); bi = (BufferedImage)createImage(w, h); big = bi.createGraphics();
firstTime = false;
}
int thecenterx,thecentery; int thex, they;
big.clearRect(0, 0, area.width*2, area.height); Dimension d = getSize();
AffineTransform oldat = big.getTransform();//get the at to restore later.
if (flippedarray[currentimage]) { // System.out.println("Flipping.."); thecenterx=rectarray[currentimage].x+(imagearray[currentimage].getWidth(this)/ 2); thecentery=rectarray[currentimage].y+(imagearray[currentimage].getHeight(this) /2);//Centre co-ords of rectangle needed
AffineTransform fliptransform = AffineTransform.getTranslateInstance(thecenterx,thecentery);//The last transform is translation from origin back to original location
fliptransform.translate(-thecenterx, -thecentery);//The first transform is from original location back to origin
at.concatenate(fliptransform);
big.setTransform(fliptransform); shape=at.createTransformedShape(rectarray[currentimage]);//Returns a new Shape object defined by the geometry of //the specified Shape after it has been transformed by this transform