I am trying to draw an automata, but the problem is that I have several states, to position these states i generates two random numbers for x and y positions, but I got a drawing that is not pretty (nodes overlap) , here is my code , have u a much better idea

Random RandomNumber = new Random();
int number1 = RandomNumber.nextInt(200) ;
int number2 = RandomNumber.nextInt(200) ;
Object v1 = graph.insertVertex(parent, null, "blabla", number2, number1, 80,30,"shape=ellipse");
Object v2 = graph.insertVertex(parent, null, "blabla", number1, number2, 80,30,"shape=ellipse");
graph.insertEdge(parent, null, "blabla", v1, v2);

asked 04 May '12, 02:23

Wassim%20Sboui's gravatar image

Wassim Sboui
16
accept rate: 0%

edited 04 May '12, 02:29


The nodes are placed where you put them. Try using a layout to automatically arrange the nodes. See examples.

link

answered 04 May '12, 06:46

Gaudenz's gravatar image

Gaudenz
80.1k1310
accept rate: 39%

@Gaudenz can you give me a link for these examples

(04 May '12, 10:48) Wassim Sboui

Your download didn't contain the examples?

(04 May '12, 10:50) David
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×194
×100
×66
×45

Asked: 04 May '12, 02:23

Seen: 1,914 times

Last updated: 04 May '12, 10:50