Coverage Report - net.cscott.sdr.anim.MenuArrow
 
Classes in this File Line Coverage Branch Coverage Complexity
MenuArrow
0%
0/15
0%
0/8
2.333
 
 1  
 package net.cscott.sdr.anim;
 2  
 
 3  
 import com.jme.image.Texture;
 4  
 import com.jme.scene.state.TextureState;
 5  
 import com.jme.system.DisplaySystem;
 6  
 import com.jme.util.TextureManager;
 7  
 
 8  
 /**
 9  
  * {@link MenuArrow} is a {@link GradientTriangle} which is sized and textured
 10  
  * appropriately for use in the {@link MenuState}.
 11  
  * @author C. Scott Ananian
 12  
  * @version $Id: MenuArrow.java,v 1.2 2006-11-13 04:27:09 cananian Exp $
 13  
  */
 14  
 public class MenuArrow extends GradientTriangle {
 15  
     final TextureState textureState;
 16  
     public MenuArrow(String name, BaseState st, boolean isLeft) {
 17  0
         super(name, st.x(0), st.y(-22), st.x(isLeft?-24:24), st.y(0), st.x(0), st.y(22));
 18  0
         textureState = DisplaySystem.getDisplaySystem()
 19  
             .getRenderer().createTextureState();
 20  0
         textureState.setEnabled(true);
 21  0
         this.setRenderState(textureState);
 22  0
         this.setRenderState(BaseState.mkAlpha());
 23  0
         setSelected(false);
 24  0
     }
 25  
     public void setSelected(boolean isSelected) {
 26  0
         textureState.setTexture(getTexture(isSelected));
 27  0
         this.updateRenderState();
 28  0
     }
 29  
     
 30  0
     private static Texture[] texture = new Texture[2];
 31  
     private static Texture getTexture(boolean isSelected) {
 32  0
         int which = isSelected ? 1 : 0;
 33  0
         if (texture[which]==null) {
 34  0
             texture[which] = TextureManager.loadTexture(
 35  
                     MenuArrow.class.getClassLoader().getResource(
 36  
                     "net/cscott/sdr/anim/menu-arrow"+
 37  
                     (isSelected?"-sel":"")+
 38  
                     ".png"),
 39  
                     Texture.MM_NONE,
 40  
                     Texture.FM_LINEAR);
 41  
         }
 42  0
         return texture[which];
 43  
     }
 44  
 }