| | |
How to get or calculate coordinates?
Thread Solved |
•
•
Join Date: Sep 2008
Posts: 8
Reputation:
Solved Threads: 0
Below is what I got from Java but expected a flower. 
http://img18.imageshack.us/i/flowera.jpg/
As to Flash ,Since Java and Flash both have same coordinates
system , I should have no problem in creating the shape but
I am getting the messed up result.
If you were me , what would be your strategy to draw shapes in
Java?

http://img18.imageshack.us/i/flowera.jpg/
As to Flash ,Since Java and Flash both have same coordinates
system , I should have no problem in creating the shape but
I am getting the messed up result.

If you were me , what would be your strategy to draw shapes in
Java?
Last edited by JChakra; Jul 7th, 2009 at 10:45 am. Reason: my wish
•
•
Join Date: Apr 2008
Posts: 972
Reputation:
Solved Threads: 146
Looks 60-70% right to me. Presumably just a few messed-up coordinates.
I would store the coordinates as data, rather than embed them into the code - I'd use a Vector of Points. I'd hold those in a simple text file, and just read it into the Vector, so it would be easy to edit the data. Then I'd have a simple loop that looped thru the Points drawing 1 segment at a time. For testing I'd put a bit extra in the loop so it sent the coodinates to System.out, then waited for a CR before plotting that point. Like that I could step thru the drawing 1 point at a time and see exactly which coords were wrong.
If I wanted to get clever I'd write a little JPanel that I could click on, and the Mouse handler would add the points where I clicked to the Vector of points, then write it all to the text file.
I would store the coordinates as data, rather than embed them into the code - I'd use a Vector of Points. I'd hold those in a simple text file, and just read it into the Vector, so it would be easy to edit the data. Then I'd have a simple loop that looped thru the Points drawing 1 segment at a time. For testing I'd put a bit extra in the loop so it sent the coodinates to System.out, then waited for a CR before plotting that point. Like that I could step thru the drawing 1 point at a time and see exactly which coords were wrong.
If I wanted to get clever I'd write a little JPanel that I could click on, and the Mouse handler would add the points where I clicked to the Vector of points, then write it all to the text file.
•
•
Join Date: Sep 2008
Posts: 8
Reputation:
Solved Threads: 0
thanks for your time and programming tricks James. 
The problem was the lineTo function which is , I believe , is not
suitable for creating polygons as we have the functions such
as drawline(..) and drawpolygon(..) for that.
Regarding Flash , It's true that both Java and Flash have
same coordinates system but the way Flash show the
coordinates in the property box is unclear to me.Using Flash
for this kinda job is not a good idea.
Well , the problem has been solved.
thanks again for your precious time.

The problem was the lineTo function which is , I believe , is not
suitable for creating polygons as we have the functions such
as drawline(..) and drawpolygon(..) for that.

Regarding Flash , It's true that both Java and Flash have
same coordinates system but the way Flash show the
coordinates in the property box is unclear to me.Using Flash
for this kinda job is not a good idea.
Well , the problem has been solved.

thanks again for your precious time.
Last edited by JChakra; Jul 7th, 2009 at 1:55 pm. Reason: forgot to add smiles
![]() |
Similar Threads
- More of a math problem (Java)
- object for an array (Java)
- Java Maze Problem (Java)
- Displaying Image and Text in Java 2D (Java)
- xy-rotation problem (Game Development)
- how to calculate the distence ? (Visual Basic 4 / 5 / 6)
- Frames of Pictures (C++)
Other Threads in the Java Forum
- Previous Thread: consuming a webservice
- Next Thread: Trouble with area
| Thread Tools | Search this Thread |
911 actionlistener addball addressbook android api append applet application array arrays automation binary bluetooth button character chat class client code component consumer css csv database desktop eclipse ee error fractal ftp game givemetehcodez graphics gui html ide image integer j2me japplet java javaarraylist javac javaee javaprojects jni jpanel julia jvm linked linux list loan mac map method methods mobile netbeans newbie objects online oriented output panel phone printf problem program programming project projects properties recursion replaydirector reporting researchinmotion rotatetext rsa scanner se server service set sms software sort sql string swing test threads time transfer tree ubuntu update windows working





