programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering OS Languages Paradigms IDEs Build Tools Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

how to calculate X Y cooridinates for GeneralPath?

Bobby Sharma
Ranch Hand
Posts: 598
3
I have never done good graphic work before but I want to play with Graphics for fun.The question is how to
calculate x and y coordinates for GernerPath's functions?

In below code I put some random arguments but actually I have no idea how to calculate those values to draw a stunning object.
Please enlighten me how to do math or how to plan for creating an graphic object.

best regards,
Omi

Campbell Ritchie
Marshal
Posts: 56541
172
Wikipedia article. Finding a decent reference on the internet which shows the difference between computer screen locations and ordinary locations is difficult. This is the best I could find.
Suggest you
• copy your Graphics object with its create method
• Cast it to Graphics2D
• Perform a scale transform of x = 1.0, y = -1.0 on it.
• Preform a translate transform x = width / 2, y = height / 2 on it.
• Then you can use the same sort of Cartesian coordinates you are used to.

David Newton
Author
Rancher
Posts: 12617
I've always thought spirographs were neat; maybe this link will give you some ideas.

Bobby Sharma
Ranch Hand
Posts: 598
3

BTW I wonder if Adobe Flash can get vertices from a drawing object.

I mean we draw polygons in Adobe flash and get their vertices by someway and use them
as an argument in Java's drawing functions. :P

Campbell Ritchie
Marshal
Posts: 56541
172
Try drawing on squared paper.
Try tracing lines on a JPanel, add a MouseListener, and get the X Y coordinates from the MouseEvent whenever the mouse is clicked.

Bobby Sharma
Ranch Hand
Posts: 598
3
I tried squared paper coordinates but it did not work boss.

Java code

Am I missing any functions for 'start' and 'stop'.? What's the functions for 'start' and 'stop'

Flash and Java both have same coordinates system.When I get coordinates from any drawing in flash and put into Java, I get different shapes surprisingly.

Why is that ? I thought Flash could save me the trouble so I tried
it but it made me more frustrated.

How to translate flash coordinates to Java coordinates ?

Campbell Ritchie
Marshal
Posts: 56541
172
Don't know. It helps little to say did not work. What went wrong? Did you get lots of lines from one corner of the display to another corner?

Bobby Sharma
Ranch Hand
Posts: 598
3
Below is what I got from Java but expected a flower.

In Flash I drew a polygon , noted its coordinates and put them into Java but got a unexpected result.

Coordinates for the polygon