Android Open Source - Visu Draw Buffer






From Project

Back to project page Visu.

License

The source code is released under:

Apache License

If you think the Android project Visu 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.ufavaloro.android.visu.draw.channel;
//w  w w .j  a v  a 2s.  com
import java.util.ArrayList;

import com.ufavaloro.android.visu.storage.datatypes.AcquisitionData;
import com.ufavaloro.android.visu.storage.datatypes.StudyData;

public class DrawBuffer {
  
  // Buffer
  private short[] mBuffer;
  
  // Largo total del Buffer
  private int mSize;
  
  // Cantidad de "p?ginas" del buffer
  private int mTotalPages;
  
  // Puntero de almacenamiento
  private int mStoringIndex;
  
  // Puntero de graficaci?n
  private int mGraphingIndex;
  
  private float mHorizontalZoom;
  private float mVerticalZoom;
  
  private int mBits;
  
/*****************************************************************************************
* M?todos principales                                           *
*****************************************************************************************/  

  // Constructor para Online Draw Buffer
  public DrawBuffer(int channelNumber, int samplesPerPage, int totalPages, int bits) {
    mSize = samplesPerPage*totalPages;
    mTotalPages = totalPages;
    mBuffer = new short[mSize];
    mBits = bits;
    setZero();
    mHorizontalZoom = 1;
    mVerticalZoom = 1;
  }

  // Constructor para Offline Draw Buffer
  public DrawBuffer(int mAdcChannelNumber, StudyData studyData, int totalPages) {
    mSize = studyData.getSamplesBuffer().getSize();
    mTotalPages = totalPages;
    mBuffer = new short[mSize];
    mBits = studyData.getAcquisitionData().getBits();
    mBuffer = studyData.getSamplesBuffer().getBuffer();  
    mHorizontalZoom = 1;
    mVerticalZoom = 1;
  }

  // M?todo para almacenar muestras
  public void storeSamples(short[] x) {
    
    // Almaceno
    for(int i=0; i<x.length; i++) {
      
      this.mBuffer[mStoringIndex] = x[i];
      
      // Incremento ?ndices
      mStoringIndex++;
      mGraphingIndex++;
      
      // Si llego al m?ximo, pongo ?ndices en cero
      if(mStoringIndex == mSize) mStoringIndex = 0;
      if(mGraphingIndex == mSize) mGraphingIndex = 0;
    
    }
  
  }
  
  // M?todo para recibir muestras
  public int getSample(int index) {
    
    // Resto offset de muestras
    index = index + (mGraphingIndex - mSize/mTotalPages);
    
    // Inicializo un ?ndice dummy
    int newIndex = 0;
    
    // Si el ?ndice es negativo
    if(index < 0) {
      // Le sumo el largo del Buffer
      newIndex = index + mSize;
    }
    
    // Si el ?ndice est? en el rango permitido
    if(index <= mSize - 1 && index >= 0) { 
      // No hago nada
      newIndex = index;
    }
    
    // Si el ?ndice es mayor al largo total
    if(index > mSize - 1) { 
      // Le resto el ?ndice al largo total
      newIndex = index - mSize;
    }
    
    // Devuelvo muestra
    return mBuffer[newIndex];
  }
  
  // M?todo para incrementar el ?ndice de graficaci?n
  public void increaseGraphingIndex(int inc) {
    
    // Incremento
    mGraphingIndex = mGraphingIndex + inc;
    
    // Si me pas? del largo total
    if(mGraphingIndex > mSize - 1) { 
      
      // Le resto el largo total al ?ndice
      mGraphingIndex = mGraphingIndex - mSize;
    
    }
  
  }
  
  // M?todo para decrementar el ?ndice de graficaci?n
  public void decreaseGraphingIndex(int dec) {
    
    // Incremento
    mGraphingIndex = mGraphingIndex - dec;
    
    // Si el ?ndice es negativo
    if(mGraphingIndex < 0) { 
      
      // Le resto el ?ndice al largo total
      mGraphingIndex = mGraphingIndex + mSize;
    
    }
  
  }

  // Seteo el valor nulo
  public void setZero() {
    short zero = (short) (Math.pow(2, mBits) / 2);
    for(int i=0; i<mSize; i++) { 
      mBuffer[i] = zero;
    }
    
  }

  // Setter de graphing index, para resetear
  public void setGraphingIndex(int graphingIndex) {
    mGraphingIndex = graphingIndex;
  }

  public void setHorizontalZoom(float horizontalZoom) {
    mHorizontalZoom = horizontalZoom;
  }

  public void setVerticalZoom(float verticalZoom) {
    mVerticalZoom = verticalZoom;
  }
  
/*****************************************************************************************
* Getters                                                 *
*****************************************************************************************/
  public int getStoringIndex() {
    return mStoringIndex;
  }
  
  public int getGraphingIndex() {
    return mGraphingIndex;
  }
  
  public short[] getBuffer() {
    return mBuffer;
  }
  
  public float getHorizontalZoom() {
    return mHorizontalZoom;
  }
  
  public float getVerticalZoom() {
    return mVerticalZoom;
  }

}// DrawBuffer





Java Source Code List

com.samsung.sprc.fileselector.FileData.java
com.samsung.sprc.fileselector.FileListAdapter.java
com.samsung.sprc.fileselector.FileOperation.java
com.samsung.sprc.fileselector.FileSelector.java
com.samsung.sprc.fileselector.FileUtils.java
com.samsung.sprc.fileselector.OnHandleFileListener.java
com.samsung.sprc.fileselector.SaveLoadClickListener.java
com.samsung.sprc.fileselector.TextViewWithImage.java
com.ufavaloro.android.visu.UI.ChannelOptionsDialog.java
com.ufavaloro.android.visu.UI.LoadFileFromGoogleDriveDialog.java
com.ufavaloro.android.visu.UI.LoadFileFromLocalStorageDialog.java
com.ufavaloro.android.visu.UI.MainActivity.java
com.ufavaloro.android.visu.UI.MainMenuDialog.java
com.ufavaloro.android.visu.UI.NewStudyDialog.java
com.ufavaloro.android.visu.UI.OfflineChannelPropertiesDialog.java
com.ufavaloro.android.visu.UI.OnlineChannelPropertiesDialog.java
com.ufavaloro.android.visu.UI.StopStudyDialog.java
com.ufavaloro.android.visu.bluetooth.BluetoothProtocolMessage.java
com.ufavaloro.android.visu.bluetooth.BluetoothProtocol.java
com.ufavaloro.android.visu.bluetooth.BluetoothServiceMessage.java
com.ufavaloro.android.visu.bluetooth.BluetoothService.java
com.ufavaloro.android.visu.draw.BitmapManager.java
com.ufavaloro.android.visu.draw.DrawHelper.java
com.ufavaloro.android.visu.draw.RGB.java
com.ufavaloro.android.visu.draw.ReferenceMatrix.java
com.ufavaloro.android.visu.draw.TouchPointer.java
com.ufavaloro.android.visu.draw.channel.ChannelList.java
com.ufavaloro.android.visu.draw.channel.Channel.java
com.ufavaloro.android.visu.draw.channel.DrawBuffer.java
com.ufavaloro.android.visu.draw.channel.InfoBox.java
com.ufavaloro.android.visu.draw.channel.Label.java
com.ufavaloro.android.visu.draw.channel.ScreenElement.java
com.ufavaloro.android.visu.draw.channel.SignalBox.java
com.ufavaloro.android.visu.storage.DataConversion.java
com.ufavaloro.android.visu.storage.SamplesBuffer.java
com.ufavaloro.android.visu.storage.StorageHelperMessage.java
com.ufavaloro.android.visu.storage.StorageHelper.java
com.ufavaloro.android.visu.storage.StudyDataParser.java
com.ufavaloro.android.visu.storage.datatypes.AcquisitionData.java
com.ufavaloro.android.visu.storage.datatypes.AdcData.java
com.ufavaloro.android.visu.storage.datatypes.PatientData.java
com.ufavaloro.android.visu.storage.datatypes.StorageData.java
com.ufavaloro.android.visu.storage.datatypes.StudyData.java
com.ufavaloro.android.visu.storage.googledrive.GoogleDriveClientMessage.java
com.ufavaloro.android.visu.storage.googledrive.GoogleDriveClient.java
com.ufavaloro.android.visu.storage.googledrive.GoogleDriveManagerMessage.java
com.ufavaloro.android.visu.storage.googledrive.GoogleDriveManager.java
com.ufavaloro.android.visu.storage.local.LocalStorageManager.java
com.ufavaloro.android.visu.study.StudyMessage.java
com.ufavaloro.android.visu.study.StudyType.java
com.ufavaloro.android.visu.study.Study.java