00001 package org.hfbk.vis.visnode;
00002
00003 import java.util.HashMap;
00004 import java.util.Map;
00005
00006 import org.dronus.gl.GLUtil;
00007 import org.lwjgl.opengl.GL11;
00008 import org.lwjgl.util.vector.Vector3f;
00009
00010
00035 public class VisEdges extends VisNode {
00036
00037 VisEdges() {
00038 super(null, new Vector3f());
00039 radius=Float.POSITIVE_INFINITY;
00040 }
00041
00042
00043 VisRoot root;
00044
00045 HashMap<VisNode,Vector3f> positions=new HashMap<VisNode, Vector3f>();
00046
00053 void renderSelf() {
00054 if (root==null)
00055 root=getRoot();
00056
00057
00058 recurse(root, new Vector3f());
00059
00060
00061 GL11.glDisable(GL11.GL_TEXTURE_2D);
00062 GL11.glColor4f(1,1,1,.4f);
00063
00064
00065
00066 for (Map.Entry<VisNode, Vector3f> entry: positions.entrySet()){
00067 if (entry.getKey() instanceof VisUI) continue;
00068 VisNode parent=entry.getKey().parent;
00069 if (parent!=null && parent!=root)
00070 GLUtil.drawLine(entry.getValue(), positions.get(parent));
00071 }
00072
00073
00074
00075
00076 GL11.glLineWidth(3);
00077 GL11.glColor3f(1,0,0);
00078
00079 for (Map.Entry<String, VisNode> entry: root.sourceNodesBySource.entrySet()){
00080 VisNode n=entry.getValue();
00081
00082 VisNode sn=root.nodesBySource.get(entry.getKey());
00083 if (sn!=null){
00084 Vector3f from=positions.get(n), to=positions.get(sn);
00085 if (from!=null && to!=null) GLUtil.drawLine(from, to);
00086 }
00087
00088 }
00089
00090
00091
00092
00093
00094
00095 GL11.glColor4f(1f,0,0,.4f);
00096
00097 for(Map.Entry<String, VisNode> entry: root.sourceNodesBySource.entrySet()){
00098 VisNode n=entry.getValue();
00099 if (n==null) continue;
00100
00101
00102
00103
00104 VisNode pathEnd=n.parent;
00105 while (pathEnd!=root && !root.nodesBySource.containsKey(pathEnd.url)){
00106 pathEnd=pathEnd.parent;
00107 }
00108
00109
00110
00111
00112 if (pathEnd!=root)
00113 while (n!=pathEnd) {
00114 GLUtil.drawLine(positions.get(n), positions.get(n.parent));
00115 n=n.parent;
00116 }
00117 }
00118 GL11.glLineWidth(2);
00119 }
00120
00129 void recurse(VisNode node, Vector3f pos){
00130
00131 Vector3f abspos=new Vector3f();
00132
00133 Vector3f.add(pos,node.position,abspos);
00134 positions.put(node, abspos);
00135
00136 for (VisNode child: node.children) recurse(child,abspos);
00137 }
00138 }