Android Open Source - android-plotter Arrays






From Project

Back to project page android-plotter.

License

The source code is released under:

Apache License

If you think the Android project android-plotter 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 org.solovyev.android.plotter.meshes;
/* w w w . j  a  v  a2  s.c  om*/
import org.solovyev.android.plotter.Check;

import javax.annotation.Nonnull;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;

final class Arrays {

  // create on the background thread and accessed from GL thread
  private volatile FloatBuffer verticesBuffer;
  private volatile ShortBuffer indicesBuffer;

  float[] vertices;
  short[] indices;

  int vertex = 0;
  int index = 0;

  public Arrays() {
  }

  public Arrays(int verticesCount, int indicesCount) {
    this.vertices = new float[verticesCount];
    this.indices = new short[indicesCount];
  }

  public boolean isCreated() {
    return vertices != null && indices != null;
  }

  public void add(int i, float x, float y, float z) {
    add((short) i, x, y, z);
  }

  public void add(short i, float x, float y, float z) {
    Check.isTrue(vertex < vertices.length, "Vertices must be allocated properly");
    Check.isTrue(index < indices.length, "Indices must be allocated properly");

    indices[index++] = i;
    vertices[vertex++] = x;
    vertices[vertex++] = y;
    vertices[vertex++] = z;
  }

  public void init() {
    vertex = 0;
    index = 0;
    verticesBuffer = null;
    indicesBuffer = null;
  }

  public void init(int verticesCount, int indicesCount) {
    if (vertices == null || vertices.length != verticesCount) {
      vertices = new float[verticesCount];
    }

    if (indices == null || indices.length != indicesCount) {
      indices = new short[indicesCount];
    }

    init();
  }

  public void createBuffers() {
    Check.isTrue(isCreated(), "Arrays should be initialized");
    verticesBuffer = Meshes.allocateOrPutBuffer(vertices, verticesBuffer);
    indicesBuffer = Meshes.allocateOrPutBuffer(indices, indicesBuffer);
  }

  @Nonnull
  public FloatBuffer getVerticesBuffer() {
    Check.isTrue(isCreated(), "Arrays should be initialized");
    Check.isNotNull(verticesBuffer);
    return verticesBuffer;
  }

  @Nonnull
  public ShortBuffer getIndicesBuffer() {
    Check.isTrue(isCreated(), "Arrays should be initialized");
    Check.isNotNull(indicesBuffer);
    return indicesBuffer;
  }
}




Java Source Code List

com.android.texample.GLText.java
com.android.texample.SpriteBatch.java
com.android.texample.TexampleRenderer.java
com.android.texample.TextureRegion.java
com.android.texample.Vertices.java
org.solovyev.android.plotter.Angle.java
org.solovyev.android.plotter.AxisStyle.java
org.solovyev.android.plotter.Check.java
org.solovyev.android.plotter.Color.java
org.solovyev.android.plotter.DefaultPlotter.java
org.solovyev.android.plotter.Dimensions.java
org.solovyev.android.plotter.Frustum.java
org.solovyev.android.plotter.Function0.java
org.solovyev.android.plotter.Function1.java
org.solovyev.android.plotter.Function2.java
org.solovyev.android.plotter.Function.java
org.solovyev.android.plotter.LineStyle.java
org.solovyev.android.plotter.MeshConfig.java
org.solovyev.android.plotter.MultisampleConfigChooser.java
org.solovyev.android.plotter.PinchZoomTracker.java
org.solovyev.android.plotter.PlotData.java
org.solovyev.android.plotter.PlotFunction.java
org.solovyev.android.plotter.PlotRenderer.java
org.solovyev.android.plotter.PlotView.java
org.solovyev.android.plotter.Plot.java
org.solovyev.android.plotter.Plotter.java
org.solovyev.android.plotter.PlottingView.java
org.solovyev.android.plotter.Spf.java
org.solovyev.android.plotter.SuperFunction.java
org.solovyev.android.plotter.TouchHandler.java
org.solovyev.android.plotter.ZoomLevels.java
org.solovyev.android.plotter.Zoomer.java
org.solovyev.android.plotter.app.MainActivity.java
org.solovyev.android.plotter.app.PlotterApplication.java
org.solovyev.android.plotter.meshes.Arrays.java
org.solovyev.android.plotter.meshes.AxisGrid.java
org.solovyev.android.plotter.meshes.Axis.java
org.solovyev.android.plotter.meshes.BaseCube.java
org.solovyev.android.plotter.meshes.BaseCurve.java
org.solovyev.android.plotter.meshes.BaseMesh.java
org.solovyev.android.plotter.meshes.BaseSurface.java
org.solovyev.android.plotter.meshes.DimensionsAwareSwapper.java
org.solovyev.android.plotter.meshes.DimensionsAware.java
org.solovyev.android.plotter.meshes.DoubleBufferGroup.java
org.solovyev.android.plotter.meshes.DoubleBufferMesh.java
org.solovyev.android.plotter.meshes.FunctionGraph2d.java
org.solovyev.android.plotter.meshes.FunctionGraph3d.java
org.solovyev.android.plotter.meshes.FunctionGraphSwapper.java
org.solovyev.android.plotter.meshes.FunctionGraph.java
org.solovyev.android.plotter.meshes.Graph.java
org.solovyev.android.plotter.meshes.Group.java
org.solovyev.android.plotter.meshes.IndicesOrder.java
org.solovyev.android.plotter.meshes.ListGroup.java
org.solovyev.android.plotter.meshes.ListPool.java
org.solovyev.android.plotter.meshes.Mesh.java
org.solovyev.android.plotter.meshes.Meshes.java
org.solovyev.android.plotter.meshes.Pool.java
org.solovyev.android.plotter.meshes.Scene.java
org.solovyev.android.plotter.meshes.SolidCube.java
org.solovyev.android.plotter.meshes.SurfaceInitializer.java
org.solovyev.android.plotter.meshes.WireFrameCube.java