tags:

views:

223

answers:

1

I want to try display a relationship diagram.

I have the xml

<School>
     <Class>
          <Name>1st Grade</Name>
          <StudentName>A</StudentName>
          <StudentName>B</StudentName>
          <StudentName>C</StudentName>
          <StudentName>D</StudentName>
     </Class>
     <Class>
          <Name>2nd Grade</Name>
          <StudentName>E</StudentName>
          <StudentName>F</StudentName>
          <StudentName>G</StudentName>
          <StudentName>H</StudentName>
     <Class>
     <TeacherDetails>
          <Teacher>
               <Name>AAAA</Name>
               <Teaches>1st Grade</Teaches>
          <Teacher>
          <Teacher>
               <Name>BBBB</Name>
               <Teaches>1st Grade</Teaches>
               <Teaches>2nd Grade</Teaches>
          </Teacher>
     </TeacherDetails>
<School>
  1. How can I draw it, also, since there is a dependency for the teacher, there needs to be a connectivity between the Class & Teacher also.
  2. Is it possible to display them as icons and provide a tool tip which gives description, like the teacher icon would have teacher name and the grade she/he teaches?

Any help!!

A: 

Mark Shepherd's SpringGraph is a nice utility for drawing graphs. You'll have to write the layer between your XML representation and the nodes in the graph, but that is easy.

You can overload the itemRenderer for the nodes and show your custom images and hover tips on the appropriate Mouse event.

Simon
Thanks for the info Simon, but implementing that would make me change my XML format now :(. I'll keep trying!!
Panther24
Really? Why? Each teacher and class is a node and they are connected by the one-to-many "Teachs" relationship on the Teacher. You can iterate through your XML and create those nodes and relationships without any changes to your data structure...
Simon
Panther24
Can't you just use the contents of the name tag as the ID?
Simon
Gonna give it a shot tomorrow, lets hope it works fine, I have less than 72 hrs to deliver the functionality :)
Panther24