ExamVerticesArrayGenerator.java :  » UnTagged » mob-dictionary » com » caini » iDictionary » BarChartDisplay » Android Open Source

Android Open Source » UnTagged » mob dictionary 
mob dictionary » com » caini » iDictionary » BarChartDisplay » ExamVerticesArrayGenerator.java
package com.caini.iDictionary.BarChartDisplay;

public class ExamVerticesArrayGenerator {
  
  public static final int NUMOFDAYS = 7;
  
  private float[][] verticesArrays;
  private float[] offsets;
  
  public ExamVerticesArrayGenerator(int[] numOfWords) {
    verticesArrays = new float[NUMOFDAYS][12];
    offsets = this.calculateOffsets(numOfWords);
    initialization();
  }
  
  public float[] getOffsets() {
    return offsets;
  }
  
  private float[] calculateOffsets(int[] numOfWords) {
    float[] offsets = new float[NUMOFDAYS];
    for (int i = 0; i < NUMOFDAYS; i++)
      if (numOfWords[i] == 0)
        offsets[i] = 0;
      else
        offsets[i] = numOfWords[i]/(float)5;      // !!!!!!! A MAGIC NUMBER HERE, it depends on the numbers of question in an exam
    return offsets;
  }
  
  private void initialization() {
    verticesArrays[0] = new float[] {
        -0.7f, -0.5f, 0f,
        -0.6f, -0.5f, 0f,
        -0.6f, -0.5f+offsets[0], 0f,
        -0.7f, -0.5f+offsets[0], 0f
    };
    verticesArrays[1] = new float[] {
        -0.5f, -0.5f, 0.0f,
        -0.4f, -0.5f, 0.0f,
        -0.4f, -0.5f+offsets[1], 0.0f,
        -0.5f, -0.5f+offsets[1], 0.0f
    };
    verticesArrays[2] = new float[] {
        -0.3f, -0.5f, 0f,
        -0.2f, -0.5f, 0f,
        -0.2f, -0.5f+offsets[2], 0f,
        -0.3f, -0.5f+offsets[2], 0f
    };
    verticesArrays[3] = new float[] {
        -0.1f, -0.5f, 0f,
        0.0f, -0.5f, 0f,
        0.0f, -0.5f+offsets[3], 0f,
        -0.1f, -0.5f+offsets[3], 0f
    };
    verticesArrays[4] = new float[] {
        0.1f, -0.5f, 0f,
        0.2f, -0.5f, 0f,
        0.2f, -0.5f+offsets[4], 0f,
        0.1f, -0.5f+offsets[4], 0f
    };
    verticesArrays[5] = new float[] {
        0.3f, -0.5f, 0f,
        0.4f, -0.5f, 0f,
        0.4f, -0.5f+offsets[5], 0f,
        0.3f, -0.5f+offsets[5], 0f
    };
    verticesArrays[6] = new float[] {
        0.5f, -0.5f, 0f,
        0.6f, -0.5f, 0f,
        0.6f, -0.5f+offsets[6], 0f,
        0.5f, -0.5f+offsets[6], 0f
    };
  }
  
  public float[][] getVertexArrays() {
    return verticesArrays;
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.