Painting with AffineTransform

Jump to navigation Jump to search
Revision as of 2 November 2011 at 03:44.
This is the thread's initial revision.

Painting with AffineTransform

Anyone played around with trying to use an AffineTransform when painting on the battle field? If I so much as make an exact clone of the existing AffineTransform associated with the Graphics2D object and set the clone as the transform, nothing gets painted to the battlefield. Not sure what is going on there. Maybe something weird Robocode is doing. Example:

public void onPaint(Graphics2D g) {
	AffineTransform clone = new AffineTransform(g.getTransform());
	g.setTransform(clone);
	// paint something here
}

This will result in nothing being painted. Remove setting the transform, and it paints fine.

I'm trying to figure out how to shift the paint position for a paint framework I am trying to write. The general idea in play here is developing a means for moving informational displays around on the screen. I can't get the AffineTransform to work. I also tried to cheat and use graphics from a BufferedImage, then draw the image onto the battle field, but Robocode doesn't allow the use of the drawImage methods.

I would appreciate any information anyone has on using AffineTransform in Robocode, or any other ideas on how I might accomplish what I am trying to do.

    Skotty05:44, 2 November 2011