Search code examples
javaswingdiagram

compiler automata , how do I make this diagram so the lines wouldn't intersect?


I am writing a Java app that helps transform a non deterministic automata to a deterministic one ( im translating from french ) . Well the algorithm that does that isnt the problem , since there are rules to follow .

But i'm having trouble figuring out how the GUI would work ... i figured out how to draw the circles and arrows and all ( its not complete yet but im not asking about that ). What i'm asking here is how would i be able to write a program that figures out which circle should be drawn where , so the diagram would look well drawn with no intersections :

So what i want is for it to come out like the one on the left .Intersection isnt the main problem , just how the program would firgure out the layout in the first place.

now i know usually i should post some codes and show effort and all but the part that i have coded already i dont have any problems with as ive said... the auto drawing part is the first time i come onto something where i don't even know what to try and code :/ I brainstormed about this for quite some time to no avail . thought about layouts , recursive algorithms , AI algorithms ... i just don't know what im looking for here.

Is there some kind of trick to it ? cuz ive seen this in other programs before. Is there any information i seem to be missing ? anything i could read to help with this would be much appretiated .


Solution

  • You should use existing libs. For example, yFiles.