Relation between figure bounds and display pixels [message #788013] |
Wed, 01 February 2012 03:44  |
Eclipse User |
|
|
|
Hi,
I have two rectangles
RectangleFigure figure = new RectangleFigure();
parent.add(figure);
parent.setConstraint(figure, new Rectangle(10, 10, 20, 20));
figure = new RectangleFigure();
parent.add(figure);
parent.setConstraint(figure, new Rectangle(30, 30, 20, 20));
Where the parent has set the XYLayout.
I would expect those rectangles touch each other with theirs corners, but there is one pixel gap between them. Why is that??
|
|
|
Re: Relation between figure bounds and display pixels [message #837975 is a reply to message #788013] |
Fri, 06 April 2012 07:25   |
Eclipse User |
|
|
|
What do you mean by one pixel gap?
When you draw a rectangle with size (10,10) starting from point (10,10) the Graphics will fill the pixels [(10,10),(10,11), ... , (10,19) ], so the line will take exactly 10 pixels space. So if you want another rectangle to overlap with each other then you have to start painting from (10,19).
Maybe attached picture (it is exactly what I got from your code) will explain this better
|
|
|
|
Powered by
FUDForum. Page generated in 0.13674 seconds