Thread history
Viewing a history listing
Time | User | Activity | Comment |
---|---|---|---|
04:44, 2 November 2011 | Skotty (talk | contribs) | New thread created | |
07:35, 5 November 2011 | Skotty (talk | contribs) | New reply created | (Reply to 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.
FYI: I worked around this problem by creating a proxy class for the Robocode Graphics2D object called WindowGraphics2D. The proxy class uses a subset of delegate methods to support many of the Graphics2D paint methods; in those methods, it manually shifts the text or shapes to the appropriate screen positions. To use a window, you extend the abstract WindowPainter class, which in turn allows painting through an abstract method with signature paintWindowComponent(WindowGraphics2D graphics, T paintable).