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

Go to the documentation of this file.
00001 /*
00002  * Created on 27.04.2008
00003  */
00004 package org.hfbk.vis.visnode;
00005 
00006 import java.awt.event.MouseEvent;
00007 
00008 import org.dronus.gl.GLBoxRenderer;
00009 import org.dronus.gl.GLTextPanel;
00010 import org.lwjgl.opengl.GL11;
00011 import org.lwjgl.util.vector.Vector3f;
00012 
00020 public abstract class VisButton extends VisNodeMousable implements VisUI {
00021 
00022         
00023         public String help;
00024         GLTextPanel helpPanel;
00025         boolean toggled=false;
00026         
00030         VisButton(String help, Vector3f position) {
00031                 super(null, position);
00032                 this.help=help;
00033                 w=2; h=1; radius=2;
00034         }
00035         
00036         public abstract void handleClick();
00037         
00038         void handleEvent(VisMouseEvent evt) {
00039                 if (evt.getID()==MouseEvent.MOUSE_RELEASED){
00040                         handleClick();
00041                 }
00042         }
00043 
00044         void renderHelp(){
00045                 if (helpPanel==null)
00046                         helpPanel=new GLTextPanel(help,0,0);                    
00047                 GL11.glEnable(GL11.GL_TEXTURE_2D);
00048                 GL11.glPushMatrix();
00049                 GL11.glTranslatef(1f,-.5f,0);
00050                 
00051                 Vector3f scaler=new Vector3f(.5f,1,1);
00052                 scaler.scale(h);
00053                 GL11.glScalef(scaler.x,scaler.y,scaler.z);
00054                 helpPanel.render();
00055                 GL11.glPopMatrix();
00056                 GL11.glDisable(GL11.GL_TEXTURE_2D);
00057         }
00058         
00059         void renderSelf() {
00060                 GL11.glDisable(GL11.GL_TEXTURE_2D);
00061                 //push back the surface in z buffer to allow overrendering by edges
00062                 GL11.glPolygonOffset(1,1);
00063                 if(isHoovered){
00064                         renderHelp();
00065                         GL11.glColor4f(1,1,1,.5f);                      
00066                 }else if (toggled)
00067                         GL11.glColor4f(1f,1f,.5f,.5f);
00068                 else
00069                         GL11.glColor4f(.5f,.5f,.5f,.3f);
00070                 GLBoxRenderer.renderBox(w,h,w);
00071                 
00072                 //render edges
00073                 GL11.glPolygonOffset(0,0);
00074                 GL11.glColor4f(1,1,1,1);
00075                 GLBoxRenderer.renderFrame(w,h,w);
00076         }
00077 }

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