VisClient/org/hfbk/vis/visnode/VisScale.java

Go to the documentation of this file.
00001 package org.hfbk.vis.visnode;
00002 
00003 import java.util.HashMap;
00004 
00005 import org.dronus.gl.GLSphereRenderer;
00006 import org.dronus.gl.GLTextPanel;
00007 import org.dronus.graph.Node;
00008 import org.lwjgl.opengl.GL11;
00009 import org.lwjgl.util.vector.Vector3f;
00010 
00011 
00025 public class VisScale extends VisNode {
00026 
00027         static final float LENGTH=50;
00028         
00029         //count of used scales
00030         static int scales=0;
00031         
00032         int id;
00033         String name;
00034         
00035         float value=.5f;
00036         float scale=1;
00037         
00038         VisMarker marker;
00039         
00040         VisScale(String name, float scale) {
00041                 super(new Node(name), new Vector3f());
00042                 radius=Float.POSITIVE_INFINITY;
00043                 this.name=name;
00044                 this.scale=scale;
00045                 id=(scales++);
00046         }
00047 
00048         static HashMap<String,VisScale> defaultScales=new HashMap<String, VisScale>();
00057         public static void scaleIt(String name, float value, float scale, VisRoot root){
00058                 VisScale s=defaultScales.get(name);
00059                 if(s==null){
00060                         s=new VisScale(name,scale);
00061                         defaultScales.put(name, s);
00062                         root.add(s);
00063                 }
00064                 s.value=value;
00065         }
00066         
00071         void transform() {
00072                 GL11.glRotatef(30,0,0,1);
00073                 GL11.glRotatef(id*30,0,1,0);
00074                 GL11.glRotatef(-30,0,0,1);
00075                 //GL11.glRotatef(id*30,0,1,0);
00076         }
00077         
00081         void renderSelf() {
00082                 if (marker==null)
00083                         add(marker=new VisMarker(name));
00084                 
00085                 value+=((float)Math.random()-.5)/1000;
00086                 marker.position.y=value*scale*LENGTH;
00087                 
00088                 GL11.glDisable(GL11.GL_TEXTURE_2D);
00089                 GL11.glColor3f(1,1,1);
00090                 
00091                 GL11.glBegin(GL11.GL_LINES);
00092                 GL11.glVertex3f(0,0,0);
00093                 GL11.glVertex3f(0,LENGTH,0);
00094                 GL11.glEnd();
00095                 GL11.glTranslatef(0,LENGTH,0);
00096                 GL11.glScalef(1,.2f,1);
00097                 GLSphereRenderer.renderSphere(2);               
00098         }
00099 
00108         class VisMarker extends VisButton{
00109                 VisMarker(String name) {
00110                         super(name, new Vector3f());
00111                         radius=w=h=2;
00112                 }
00113 
00114                 float oldvalue;
00115                 
00119                 void renderSelf() {
00120                         GL11.glDisable(GL11.GL_TEXTURE_2D);                     
00121                         if (isHoovered){
00122                                 if (helpPanel==null || value!=oldvalue){ //if value changed, 
00123                                         helpPanel=new GLTextPanel(help+": "+value,0,0); //build new text 
00124                                         oldvalue=value;
00125                                 }
00126                                 GL11.glEnable(GL11.GL_TEXTURE_2D);
00127                                 GL11.glPushMatrix();
00128                                 GL11.glTranslatef(2f,0,0);
00129                                 GL11.glScalef(1,2,2);
00130                                 helpPanel.render();
00131                                 GL11.glPopMatrix();
00132                                 GL11.glDisable(GL11.GL_TEXTURE_2D);
00133                                 
00134                                 GL11.glColor3f(1,.2f,.2f);
00135                         }else
00136                                 GL11.glColor3f(1,1,1);
00137                         GL11.glScalef(1,.2f,1);
00138                         GLSphereRenderer.renderSphere(2);
00139                 }
00140                 
00144                 public void handleClick() {}
00145         }
00146 }

Generated on Tue Apr 7 17:57:22 2009 for visclient by  doxygen 1.5.1