November 2002
Intermediate to advanced
848 pages
19h 59m
English
If you wanted to rotate or otherwise transform a graphics object and then redraw it, there would be two obvious ways to go. One way, which is generally impractical, is to transform each point of the graphics object and then render the transformed object. Any reasonably complicated shape would require many hundreds of transforms. The preferred way is to transform the user space, draw on it, and then render the user space to the output device.
class myCustomCanvas extends Canvas { public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setColor(Color.red); //setting context Rectangle2D sq1 = new Rectangle2D.Float(0.f,0.f,175.0f,175.0f); //translate user space to center g2d.translate(this.getSize().width/2, ...Read now
Unlock full access