Good evening,

I have the need to learn how to make a picture jigsaw with java.
I have been looking for hours on the web for some kind of tutorial, source code example, something anything and I haven't been successfull in finding something I could work with.

Would somebody have a suggestion?
perhaps a site?
A java tutorial on how to do a picture jigsaw?

Thank you,

John

Good evening,

I have the need to learn how to make a picture jigsaw with java.
I have been looking for hours on the web for some kind of tutorial, source code example, something anything and I haven't been successfull in finding something I could work with.

Would somebody have a suggestion?
perhaps a site?
A java tutorial on how to do a picture jigsaw?

Thank you,

John

Like a jigsaw puzzle where you have a picture and then split it into smaller pictures and move the pieces around and put them together? I've never done one, never seen a tutorial for one, but I have though a lot about the subject and have been planning to write one for fun, though I have not yet.

My approach would be to split a large rectangle into smaller shapes from the Shape class. Easiest would be just smaller rectangles, but you can get much more elaborate. You have the contains and intersects methods from the Shape class. Use those methods to see whether a particular coordinate is contained inside the Shape. Have a MouseListener and drag the shapes around using mousePressed and mouseDragged. If two adjacent Shapes are next to each other in the overall picture and are "close enough" to each other when mouseReleased is called, fuse them into one Shape. When there's only one Shape left, the puzzle is solved.

The main functions are the functions that breaks an image into Shapes, breaks Shapes into smaller Shapes, and fuses Shapes together. How to do this depends on your Java experience. That's the approach I plan on taking when I get around to writing it, at least.

Thanks for reminding me of the javaFX tutorial.
I did stumble also upon it but I would have liked to stay within the regular java code.
I did find one source code example but it's not a tutorial, so I guess it will be a lot of figuring out on my own.
Just in case for reference the address is:
http://www.dreamincode.net/forums/index.php?showtopic=55247&hl=jigsaw

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.