This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

visualize a Tree and tree traversal

 
Yi Meng
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I have to visualize an xml file as a tree and to show tree traversal by hightlighting the edges.
can anyone suggest where can i strat or is there any open source project for java tree implementation and visualization?
thanks
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The easiest thing to do would probably be to use JDOM... it uses DefaultMutableTreeNodes to represent XML elements, and these can be pulled directly into your TreeModel. As far as visualization, you'll need to do that yourself, but it sounds like all you need to do is highlight nodes, and a JTree already does that. If you need to do anything extra, you just need to extend DefaultTreeCellRenderer and provide the custom rendering in the getTreeCellRendererComponent() method.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic