Android Open Source - HexNanoController_Android Indicator






From Project

Back to project page HexNanoController_Android.

License

The source code is released under:

Code license GNU GPL v2 http://www.gnu.org/licenses/gpl.html Content license CC BY-NC-SA 4.0 http://creativecommons.org/licenses/by-nc-sa/4.0/

If you think the Android project HexNanoController_Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.hexairbot.hexmini.ui;
//from   ww  w.j  ava2  s  . c  o  m
import javax.microedition.khronos.opengles.GL10;

import android.content.res.Resources;
import android.graphics.Canvas;
import android.view.MotionEvent;
import android.view.View;

import com.hexairbot.hexmini.ui.gl.GLSprite;

public class Indicator extends Sprite 
{
  private GLSprite[] indicatorStates;
  private int value;
  private boolean initialized;
  
  public Indicator(Resources resources, int[] drawableIds, Align alignment) 
  {
    super(alignment);
  
    indicatorStates = new GLSprite[drawableIds.length];
    
    for (int i=0; i<drawableIds.length; ++i) {
      GLSprite sprite = new GLSprite(resources, drawableIds[i]);
      indicatorStates[i] = sprite;
    }
  }

  @Override
  public void init(GL10 gl, int program) {
      
    for (int i=0; i<indicatorStates.length; ++i) {
      GLSprite sprite = indicatorStates[i];
      sprite.init(gl, program);
    }
    
    initialized = true;
  }

  
  @Override
  public void draw(GL10 gl) 
  {
    GLSprite sprite = indicatorStates[value];
    sprite.onDraw(gl,  bounds.left, surfaceHeight - bounds.top - sprite.height);
  }

  
  @Override
  public void draw(Canvas canvas) 
  {
    GLSprite sprite = indicatorStates[value];
    sprite.onDraw(canvas,  bounds.left, surfaceHeight - bounds.top - sprite.height);
  }

  
  @Override
  public boolean onTouchEvent(View v, MotionEvent event) 
  {
    return false;
  }

  
  @Override
  public boolean isInitialized() 
  {
    return initialized;
  }

  
  @Override
  public void setViewAndProjectionMatrices(float[] vMatrix, float[] projMatrix) 
  {
    for (int i=0; i<indicatorStates.length; ++i) {
      indicatorStates[i].setViewAndProjectionMatrices(vMatrix, projMatrix);
    }
  }

  
  @Override
  public int getWidth() 
  {
    return indicatorStates[value].width;
  }

  
  @Override
  public int getHeight() 
  {  
    return indicatorStates[value].height;
  }
  
  
  public void setValue(int value)
  {
    if (value < 0 || value >= indicatorStates.length) {
      throw new IllegalArgumentException("Value " + value + " is out of bounds");
    }
    
    this.value = value;
  }

    
  @Override
    public void freeResources()
    {
        for (int i=0; i<indicatorStates.length; ++i) {
            indicatorStates[i].freeResources();
        }
    }

  @Override
  public void setNeedsUpdate() {
    initialized = false;
  }
}




Java Source Code List

.FileHelper.java
.Input.java
.Output.java
.Serializable.java
com.hexairbot.hexmini.HelpActivity.java
com.hexairbot.hexmini.HexMiniApplication.java
com.hexairbot.hexmini.HudActivity.java
com.hexairbot.hexmini.HudViewControllerDelegate.java
com.hexairbot.hexmini.HudViewController.java
com.hexairbot.hexmini.SettingsDialogDelegate.java
com.hexairbot.hexmini.SettingsDialog.java
com.hexairbot.hexmini.SettingsViewControllerDelegate.java
com.hexairbot.hexmini.SettingsViewController.java
com.hexairbot.hexmini.ViewController.java
com.hexairbot.hexmini.adapter.SettingsViewAdapter.java
com.hexairbot.hexmini.ble.BleConnectinManagerDelegate.java
com.hexairbot.hexmini.ble.BleConnectinManager.java
com.hexairbot.hexmini.ble.BluetoothLeService.java
com.hexairbot.hexmini.gestures.EnhancedGestureDetector.java
com.hexairbot.hexmini.modal.ApplicationSettings.java
com.hexairbot.hexmini.modal.Channel.java
com.hexairbot.hexmini.modal.OSDCommon.java
com.hexairbot.hexmini.modal.Transmitter.java
com.hexairbot.hexmini.sensors.DeviceOrientationChangeDelegate.java
com.hexairbot.hexmini.sensors.DeviceOrientationManager.java
com.hexairbot.hexmini.sensors.DeviceSensorManagerWrapper.java
com.hexairbot.hexmini.sensors.SensorManagerWrapper.java
com.hexairbot.hexmini.services.ConnectStateManager.java
com.hexairbot.hexmini.services.IpcControlService.java
com.hexairbot.hexmini.services.IpcProxy.java
com.hexairbot.hexmini.services.NavData.java
com.hexairbot.hexmini.services.OnIpcConnectChangedListener.java
com.hexairbot.hexmini.services.VIConfig.java
com.hexairbot.hexmini.ui.Button.java
com.hexairbot.hexmini.ui.Image.java
com.hexairbot.hexmini.ui.Indicator.java
com.hexairbot.hexmini.ui.Sprite.java
com.hexairbot.hexmini.ui.Text.java
com.hexairbot.hexmini.ui.ToggleButton.java
com.hexairbot.hexmini.ui.UIRenderer.java
com.hexairbot.hexmini.ui.control.CustomSeekBar.java
com.hexairbot.hexmini.ui.control.ViewPagerIndicator.java
com.hexairbot.hexmini.ui.gl.GLSprite.java
com.hexairbot.hexmini.ui.joystick.AcceleratorJoystick.java
com.hexairbot.hexmini.ui.joystick.AnalogueJoystick.java
com.hexairbot.hexmini.ui.joystick.JoystickBase.java
com.hexairbot.hexmini.ui.joystick.JoystickFactory.java
com.hexairbot.hexmini.ui.joystick.JoystickListener.java
com.hexairbot.hexmini.util.DebugHandler.java
com.hexairbot.hexmini.util.FontUtils.java
com.hexairbot.hexmini.util.SystemUiHiderBase.java
com.hexairbot.hexmini.util.SystemUiHiderHoneycomb.java
com.hexairbot.hexmini.util.SystemUiHider.java
com.hexairbot.hexmini.util.SystemUtil.java
com.hexairbot.hexmini.util.TextureUtils.java
fix.android.opengl.GLES20.java