• Post Reply Bookmark Topic Watch Topic
  • New Topic

Could use some help with my program  RSS feed

 
Timothy Hoogen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am now busy with making the GUI for a traveling salesment problem, but i don't know how to do some things.

Here is the code i have so far.





So what it does is the program draws 'packages' on a random place in a magazine grid.
Now i want to draw lines between the packages so there is a kind of path and i want like an oval shape that follows the path to begin with.

Can you help me with that?



 
Stephan van Hulst
Saloon Keeper
Posts: 7973
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Graphics has a method drawArc that you can use to draw segments of an ellipse. You can also cast the Graphics object to a Graphics2D and have it draw() a Arc2D, a QuadCurve2D or a CubicCurve2D.
 
Timothy Hoogen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know how I draw these lines between the packages and I want something that can follow the line (as an animation). I'm just going to use a drawOval() for that.
 
Stephan van Hulst
Saloon Keeper
Posts: 7973
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean like a marker that moves along the paths? In this case you need to set up an animation loop that will repeatedly draw your marker in the correct location. I suggest making an Animation class that takes a path Shape, a drawing delay, and a drawing operation, which when it is started, runs a javax.swing.Timer to perform the drawing operation on a Graphics object. The drawing operation is passed the current point in the path shape, which is calculated using a FlatteningPathIterator.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hope it isn't too late to welcome you to the Ranch
 
Timothy Hoogen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No it is not, thank you
But I posted this topic in java beginner and java general so I could get an answer as quick as possible.
But I think I'm going back to the beginners forum
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you appear to be in the GUIs forum.

Please don't post twice for faster answers.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!