What I'm saying is that one or more of the lines that make up the rectangle 
will disappear at certain scale levels.  Try the following and you'll see that 
at smaller sizes some lines of the rectangle disappear.

[code]
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class ClippingBug extends JFrame {

        private class MyPanel extends JPanel {

                @Override
                public void paintComponent(final Graphics g) {
                        final Graphics2D g2d = (Graphics2D)g;
                        final double scaleFactorX = this.getWidth() / 100.0;
                        final double scaleFactorY = this.getHeight() / 100.0;
                        final AffineTransform at =
                            new 
AffineTransform(AffineTransform.getScaleInstance(scaleFactorX, scaleFactorY));
                        final int width = this.getWidth();
                        final int height = this.getHeight();
                        final int tx = 10 + (int)((width - 100.0 * 
scaleFactorX) / 2.0 / scaleFactorX);
                        final int ty = 10 + (int)((height - 100.0 * 
scaleFactorY) / 2.0 / scaleFactorY);
                        g2d.transform(at);
                        g2d.translate(tx, ty);
                        this.render(g2d);
                }

                public void render(final Graphics2D g2d) {
                        g2d.setColor(Color.RED);
                        final Rectangle r = new Rectangle(0, 0, 80, 80);
                        g2d.setClip(r);
                        g2d.draw(r);
                }
        }

        public ClippingBug() {
                this.setLayout(new BorderLayout());
                final MyPanel panel = new MyPanel();
                this.add(panel, BorderLayout.CENTER);
                panel.setBackground(Color.WHITE);
                this.pack();
                this.setSize(500, 520);
                this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                this.setLocationRelativeTo(null);
        }

        public static void main(final String[] args) {
                EventQueue.invokeLater(new Runnable() {

                        public void run() {
                                new ClippingBug().setVisible(true);
                        }
                });
        }
}
[/code]
[Message sent by forum member 'qu0ll' (qu0ll)]

http://forums.java.net/jive/thread.jspa?messageID=326921

===========================================================================
To unsubscribe, send email to lists...@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
lists...@java.sun.com and include in the body of the message "help".

Reply via email to