Drawing a graph with Swing: a general approach

Suppose I have a graph consisting of nodes and edges, and I want to draw it in a Swing application. I'm not a Swing programmer, but as far as I know, I see two approaches:

  • draw the entire graph as a component
  • draw each node and edge as one component

I saw an application running the first. To drag a node drawn as a circle, the application checks that it is the closest node to the clicked point. It seems to me that this is not so effective. Is there a second approach? And what should be followed and why?

+5
source share
2 answers

JGraph, 10 , . . , , .

, .

+7

, . GraphPanel - , JGraph , .

+2

All Articles