File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Why Graphics.drawRoundRect() not have symmetrical corners? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Why Graphics.drawRoundRect() not have symmetrical corners?" Watch "Why Graphics.drawRoundRect() not have symmetrical corners?" New topic
Author

Why Graphics.drawRoundRect() not have symmetrical corners?

Dan Bizman
Ranch Hand

Joined: Feb 25, 2003
Posts: 387
Why are the corners not all the same when drawing a round rectangle in Java? When I do:

drawRoundRect( 0, 0, 100, 100, 10, 10 );

it draws the left side corners differently than the right. What's going on? how do i get them to be the same?
Dan Bizman
Ranch Hand

Joined: Feb 25, 2003
Posts: 387
anyone know?
C. Alan
Ranch Hand

Joined: Dec 17, 2004
Posts: 30
Without seeing exactly waht is going on, and not having your code in front of me, is there some other component that may somehow be interfering? I can't think of anything else right off hand, and I guess I can't think of ever having run into that particular problem before. I have had weird things happen with graphics when I tried to stuff them into a space where they wouldn't fit properly, and java resized them for me.

I know, not much help...sorry.


<a href="http://www.security-forums.com/forum/viewforum.php?f=48" target="_blank" rel="nofollow">Malware Removal</a> - Get your system running like new again.
Dan Bizman
Ranch Hand

Joined: Feb 25, 2003
Posts: 387
The curves will likely look fine to the naked eye, but if you scale the drawings (in MS Paint, or some other graphical program) you'll see the imperfection -- they are quite asymetrical. Varying the width and/or arcsize makes a little difference, but the result is still asymmetrical.

Dan Bizman
Ranch Hand

Joined: Feb 25, 2003
Posts: 387
Anyone try this or make it work?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Originally posted by Dan Bizman:
The curves will likely look fine to the naked eye


Well, there you go. Good enough is good enough, right? Besides, I ran your program and the rounded corners are defined by the placement of two or three pixels each -- how much more accurate could they be?

Scaling up bitmapped graphics always looks lousy -- that's why there are vector formats like SVG and PostScript.


[Jess in Action][AskingGoodQuestions]
Daniel Searson
Ranch Hand

Joined: Dec 03, 2000
Posts: 83
Well, if its absolutely mission-critical that it draws symmetrically you could write your own code to grab the image data of one corner, invert it, and then redraw it on the opposite side.


- Daniel
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Why Graphics.drawRoundRect() not have symmetrical corners?