2
* The contents of this file are subject to the terms of the Common Development
3
* and Distribution License (the License). You may not use this file except in
4
* compliance with the License.
6
* You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7
* or http://www.netbeans.org/cddl.txt.
9
* When distributing Covered Code, include this CDDL Header Notice in each file
10
* and include the License file at http://www.netbeans.org/cddl.txt.
11
* If applicable, add the following below the CDDL Header, with the fields
12
* enclosed by brackets [] replaced by your own identifying information:
13
* "Portions Copyrighted [year] [name of copyright owner]"
15
* The Original Software is NetBeans. The Initial Developer of the Original
16
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17
* Microsystems, Inc. All Rights Reserved.
19
package javaone.demo5;
21
import test.SceneSupport;
26
* @author David Kaspar
28
public class ManyObjectsDemo {
30
public static void main (String[] args) {
31
RadialGraphScene scene = new RadialGraphScene ();
33
createStructure (scene, 1, 10, 200, 400, 450);
34
createStructure (scene, 2, 100, 1100, 1000, 1000);
35
createStructure (scene, 3, 1000, 5000, 7500, 9500);
37
SceneSupport.show (scene.createView ());
40
private static void createStructure (RadialGraphScene scene, int setID, int count, int centerX, int centerY, float maxRadius) {
41
String rootNode = "Root of Set no. " + setID;
42
scene.addNode (rootNode).setPreferredLocation (new Point (centerX, centerY));
44
for (int index = 1; index <= count; index ++) {
45
double radius = maxRadius * index / count;
46
double angle = 2 * Math.PI * index / count;
47
int x = (int) (centerX + radius * Math.cos (angle));
48
int y = (int) (centerY + radius * Math.sin (angle));
50
String node = "Set no. " + setID + " - Child " + index;
51
scene.addNode (node).setPreferredLocation (new Point (x, y));
53
String edge = "Set no. " + setID + " - Edge " + index;
55
scene.setEdgeSource (edge, rootNode);
56
scene.setEdgeTarget (edge, node);