File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Making a genealogy tree Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Making a genealogy tree" Watch "Making a genealogy tree" New topic
Author

Making a genealogy tree

Eric Juneau
Greenhorn

Joined: Jul 13, 2009
Posts: 28
I am trying to make a sort of geneology type program in swing. The basics of the program are this: user chooses 2 or more elements. Each element combines with another to make a unique child element. A recursive algorithm tries all different permutations of combinations to find the one that results in the best final element.

But that part's done. My problem is that I'm trying to find a way to represent this graphically. In all the JTree interfaces, children have one parent. In my case, every element has, and must have, two parents. I was thinking about having a JDialog with a html table, with descendants represented by merged cells (i.e. P1 and P2 would be two cells in the first row, and C1 would be one cell colspan=2 in the second row).

When the algorithm is done, I get back a set of 3-size arrays (parent, parent, child) that lead into each other. So one permutation might look like this:

Starting elements: A1, A2, A3, A4, A5

[A1, A2, B1], [B1, A3, C1], [A4, A5, B2], [C1, B2, D1] (with D1 representing the final result)

As a table, it would look like this:


Two problems:
-What's the best way to represent this type of structure in java GUI
-How do I get this kind of data into a tree structure I can use to make into something graphical? I'm having trouble figuring out how to loop through my results when the results may not always follow a logical structure for building breadth-first, since the algorithm is depth first.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16479
    
    2

I think you're not on the right track. A genealogy "tree", as you call it, is not a tree in the computer science world. In that kind of tree, each node except the root has a single parent. As you observe, genealogy doesn't follow that rule.

But HTML does follow that rule. So it isn't really going to be helpful.

Sorry, I don't have a good idea of how to make a genealogy GUI. You could look at some other genealogy programs and steal borrow ideas from them.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Making a genealogy tree
 
Similar Threads
Operator precedence and associativity confusion........
the algrithm in my homework
Tree Stored Procedure
Single table two column dependency query
Combinations Algorithm