Здравствуйте! Я навичок в JavaFX столкнулась с такой проблемой.. после создания n-ных деревьев рандомно или вводя данные с клавиатуры необходимо изобразить их. Т.е. нарисовать, но к сожалению после поиска в интернете и просмотра многих форумов не смогла найти никаких конкретных примеров или даже просто функций. Заранее спасибо за помощь! Часть кода создания деревьев: Код | public void readData() throws IOException { cin = new BufferedReader(new InputStreamReader(System.in)); cout = new PrintWriter(System.out); int i = 0; tree = new Tree(); Node parent = tree.getNode(i); String tmp = cin.readLine(); while (!tmp.equals("")) { input = tmp.split("-"); while (Integer.parseInt(input[0]) != parent.getValue()) { i++; parent = tree.getNode(i); } tree.addChild(parent, Integer.parseInt(input[1])); tmp = cin.readLine(); } cin.close(); cout.close(); return; }
private Node randomTree(int livelli) { int n = ++values; Node a = new Node(n, "Non visitato"); if(Math.random()<0.2) return a; if(livelli < 1) return a;
int f = (int) (Math.random()*5); for(int i = 0; i < f; i++) a.addChild(randomTree(livelli-1)); return a; }
|
|