Android Open Source - android-plotter Axis Grid






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  a 2 s. c om
import android.graphics.RectF;
import org.solovyev.android.plotter.Color;
import org.solovyev.android.plotter.Dimensions;

import javax.annotation.Nonnull;

public class AxisGrid extends BaseSurface {

  protected static enum Axes {
    XY,
    XZ,
    YZ;
  }

  @Nonnull
  private Axes axes;

  private AxisGrid(@Nonnull Dimensions dimensions, @Nonnull Axes axes) {
    super(dimensions);
    this.axes = axes;
    setColor(Color.create(0xFF222222));
  }

  @Nonnull
  public static AxisGrid yz(@Nonnull Dimensions dimensions) {
    return new AxisGrid(dimensions, Axes.YZ);
  }

  @Nonnull
  public static AxisGrid xz(@Nonnull Dimensions dimensions) {
    return new AxisGrid(dimensions, Axes.XZ);
  }

  @Nonnull
  public static AxisGrid xy(@Nonnull Dimensions dimensions) {
    return new AxisGrid(dimensions, Axes.XY);
  }

  @Nonnull
  @Override
  protected BaseMesh makeCopy() {
    return new AxisGrid(dimensions, axes);
  }

  @Nonnull
  public DoubleBufferMesh<AxisGrid> toDoubleBuffer() {
    return DoubleBufferMesh.wrap(this, DimensionsAwareSwapper.INSTANCE);
  }

  @Nonnull
  @Override
  protected SurfaceInitializer createInitializer() {
    final Scene.Axis xAxis = Scene.Axis.create(dimensions.scene, false);
    final Scene.Axis yAxis = Scene.Axis.create(dimensions.scene, true);
    final Scene.Ticks xTicks = Scene.Ticks.create(dimensions.graph, xAxis);
    final Scene.Ticks yTicks = Scene.Ticks.create(dimensions.graph, yAxis);
    final RectF bounds = new RectF();
    final Scene.Ticks widthTicks;
    final Scene.Ticks heightTicks;
    switch (axes) {
      case XZ:
        widthTicks = xTicks;
        heightTicks = yTicks;
        break;
      case YZ:
        widthTicks = yTicks;
        heightTicks = xTicks;
        break;
      case XY:
        widthTicks = xTicks;
        heightTicks = xTicks;
        break;
      default:
        throw new AssertionError();
    }
    bounds.left = -widthTicks.axisLength / 2;
    bounds.right = widthTicks.axisLength / 2;
    bounds.bottom = -heightTicks.axisLength / 2;
    bounds.top = heightTicks.axisLength / 2;
    return new SurfaceInitializer(this, SurfaceInitializer.Data.create(bounds, widthTicks.count, heightTicks.count)) {
      @Override
      protected void rotate(float[] point) {
        if (axes != Axes.XY) {
          final float x = point[0];
          final float y = point[1];
          final float z = point[2];
          switch (axes) {
            case XZ:
              point[0] = x;
              point[1] = z;
              point[2] = y;
              break;
            case YZ:
              point[0] = z;
              point[1] = y;
              point[2] = x;
              break;
          }
        }
      }
    };
  }

  @Override
  protected float z(float x, float y, int xi, int yi) {
    return 0;
  }

  @Override
  public String toString() {
    return "AxisGrid{" +
        "axes=" + axes +
        '}';
  }
}




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