Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

X and Y coordinates for drawing lines on applet

 
Anam Zahra
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an applet. I am drawing lines on it. The code of my applet is as follows:

I want to make the ending X and Y coordinates of each line as starting X and Y coordinates of the next line. In this way I would be able to draw a continuous line on applet. I am stuck on this issue. Somebody can help me to resolve it. Thanks
 
Tony Docherty
Bartender
Posts: 3054
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are many ways of doing this, probably the easiest and certainly the least elegant is to just set the start coordinates of each line to the appropriate value ie:

A better way would to have an array of single X,Y co-ordinates ie
Then iterate over the array the array length - 1 times using the current index as the start X, Y coordinate and the current index + 1 as the end X, Y coordinate.
 
Anam Zahra
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried a lot but unable to find a way to get the solution.
 
Tony Docherty
Bartender
Posts: 3054
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry but I've no idea what that code is supposed to do or how it relates to your original question. Has your question changed?

I've noticed in both your posts your code has a nested for loop with the inner for loop iterating exactly once. You can remove the inner for loop as it isn't doing anything other than adding confusion.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic