This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Draw a cylinder

 
Rob Hunter
Ranch Hand
Posts: 832
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the easiest way to draw a cylinder within a JPanel? Is there a method similar to drawOval for the Graphics object? Any help would be appreciated. Thanks.
 
Paul Clapham
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Break down the cylinder into its component parts. You already know about drawOval so that's half of the job. I expect you also know about the method required to draw a straight line. Besides that there's just some arithmetic required to figure out where to draw each of the parts.
 
Rob Hunter
Ranch Hand
Posts: 832
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,
So no shortcut? :-) I didn't want to go ahead and re-invent the wheel if something already existed. Thanks for the feedback.
RH
 
Paul Clapham
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't checked. You could look at the Graphics documentation for yourself to see if there's drawCylinder or whatever. I just know from experience that people who write APIs don't typically write a ton of convenience methods like that, especially when they just involve simple extensions which anybody could do in a few minutes. You might find that somebody else has written a fancy graphics package which has that ton of convenience methods, though.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, there are no methods to draw 2D representations of 3D objects in the core API. There's Java3D, but that's a whole different animal.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic