• Post Reply Bookmark Topic Watch Topic
  • New Topic

creating lines in Java  RSS feed

 
Miina Ise
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I`m completely new to Java and in big trouble with the following exercise.
Using JTS Topology Suite and Eclipse, I`m supposed to run a certain program to create 3 lines (LineString; a, b, c) with the coordinates (x,y) and as a result to find out which lines intersect the first line a.

This is what have:

I don`t know how I could create three separate lines, each line a, b and c has 3 pairs of x,y coordinates. I think here I am creating just one big line with all the coordinates.
If understand correctly this is the command that is actually taking x,y coordinates from above and joining it for a line, right?
Since I`m supposed to have 3 lines, should I amend it or copy 3x somehow?


Any help much appreciated!!!
 
Campbell Ritchie
Marshal
Posts: 56534
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I have moved the questions out of the code tags. Your code looks all confused and will not compile in its current state. For example, you are using x and y before you declare them.
I am not familiar with JTS. You can find out how to draw lines in Swing/AWT with Graphics2D here.

I suggest you are making life dofficult for yourself by trying too much all at once. I suggest you hard‑code a few figures, and see what happens with one line.Now you should have a line. I do not know what the code to display this line or anything is.
Try that one line. Forget about command‑line input or intersection. Get that one line working. Then add more coordinates to your array and see what happens. I do not know what the code to display that line is, nor how to work out whether two lines intersect.
 
Campbell Ritchie
Marshal
Posts: 56534
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Earlier, I wrote: . . . . . .
I have looked up the JTS documentation and that should read (as you had it)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!