File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Game Development and the fly likes Frustrated with drawing shapes programmtically? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "Frustrated with drawing shapes programmtically? " Watch "Frustrated with drawing shapes programmtically? " New topic
Author

Frustrated with drawing shapes programmtically?

Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 574
    
    1

From last three days I have been trying hard to have fun with drawing shapes by coding but rather
than having fun I been getting frustrated.

For drawing shapes programmatically first thing we do is to get coordinates of the particular shape ,and then use
the coordinates in Java's API.For getting coordinates , I go to photoshop , draw some shapes ,note coordinates by the
help selection tool ,and put them into Java's API.Sometimes I get perfect shape ,sometimes I get annoying results.
Annoying outputs and wrong coordinates are making me frustrated and sulked.The one more bad thing about this is it
requires lots of time and energy.

Is there any better way do this? I mean there would be any problem if I just draw something in any graphic softwares and import
that crap into Java as an image?

I am not from math background

best regards,
omi


Back to Java , again.
Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 679
I have struggled with the same thing. Drawing effective shapes requires a certain artistic or geometric flair that I don't have.

Are you using draw and fill commands from the Graphics class and using them in a paint or paintComponent method of a JPanel?

Consider writing a generic little utility program that builds upon these draw commands. in the GUI you will have a text fields for the points, and once you have filled these fields, then you can have a JButton to repaint your JPanel. This idea would allow you to create shapes quicker and easier by saving you the trouble of changing the source code and recompiling each time. That will maybe make it quicker and more enjoyable for you to get a feel for shapes.

Hopefully that will help. Maybe someone else has a different idea.



Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 574
    
    1

Fred Hamilton wrote:
Are you using draw and fill commands from the Graphics class and using them in a paint or paintComponent method of a JPanel?


yea , this is what I am doing.

thanks your tips.

best regards,
Omi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Frustrated with drawing shapes programmtically?
 
Similar Threads
How interfaces are used for code reusability
Wanted: How to use Strategy Pattern with Shapes?
Drawing non-standard shapes in MIDP 2.0
Swing GUI
Adding a custom component to a layout?