00001
00002
00003
00004 package org.hfbk.vis.visnode;
00005
00006 import org.dronus.graph.Node;
00007 import org.lwjgl.util.vector.Vector3f;
00008
00016 public class VisKeycloud extends VisNode {
00017
00018 final float RADIUSFACTOR=15;
00019
00020 public VisKeycloud(Node node, Vector3f position) {
00021 super(node, position);
00022 }
00023
00024
00025 void renderSelf() {
00026 if (layoutLocked) return;
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 int n=children.size();
00040
00041
00042 double dist=Math.PI*2/(Math.floor(Math.sqrt(n*4))+1);
00043
00044
00045 radius=RADIUSFACTOR*(float)Math.sqrt(n/4/Math.PI);
00046
00047 int i=0;
00048 for (double lat=dist/2-Math.PI/2; lat<Math.PI/2 && i<n; lat+=dist)
00049 for (double lon=dist/2; lon<Math.PI*2 && i<n; lon+=dist/(1-Math.abs(lat/Math.PI*2))){
00050
00051 children.get(i).position=new Vector3f(
00052 (float)(radius*Math.cos(lat)*Math.cos(lon)),
00053 (float)(radius*-Math.sin(lat)),
00054 (float)(radius*Math.cos(lat)*-Math.sin(lon))
00055 );
00056 i++;
00057 }
00058
00059 layoutLocked=true;
00060 }
00061
00062 }