This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes Displaying a graph Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Displaying a graph" Watch "Displaying a graph" New topic
Author

Displaying a graph

Vibha Verma
Ranch Hand

Joined: Jan 15, 2002
Posts: 107
I have an input file that stores nodes and edges, I want to show the graph using the input file and don't want edges to intersect each other. Edges don't have to be straight lines. To represent an edge between two distant nodes (without crossing other edges) an arc can be used.
Anyidea, how this can be done?
Thanks.
Vibha.
Greg Brouelette
Ranch Hand

Joined: Jan 23, 2002
Posts: 144
Vibha:
I don't know of a standard Java Class that would do this. What I would suggest is to build a class that can hold the data from your input file as a data structure of some type. Then build a new class that extends JPanel. You would overwrite the paint method of that class to paint (using 2D Graphics) your graph based on the data structure that is passed to it. Then display that new class in the ContentPane of a JFrame (or wherever you need to put it).
It's going to be a lot of "do it by hand" work to get it up and running though. Good luck.


For a good Prime, call:<br />29819592777931214269172453467810429868925511217482600306406141434158089
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Displaying a graph