Android Open Source - android-plotter Main Activity






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.app;
/*from ww  w  .  j a  v a2 s. co  m*/
import android.app.Activity;
import android.os.Bundle;
import android.os.Parcelable;
import android.view.View;
import org.solovyev.android.plotter.*;

import javax.annotation.Nonnull;

public class MainActivity extends Activity {

  @Nonnull
  private PlotView plotView;

  @Nonnull
  private final Plotter plotter = PlotterApplication.get().getPlotter();

  @Nonnull
  private final Runnable colorUpdater = new Runnable() {
    private int direction = -1;
    @Override
    public void run() {
      final PlotData plotData = plotter.getPlotData();
      final PlotFunction function = plotData.get(PlotterApplication.PARABOLOID);
      if(function == null) {
        return;
      }
      final Color color = Color.create(function.lineStyle.color);
      if (color.equals(Color.BLACK) || color.equals(Color.RED)) {
        direction = -direction;
      }
      function.lineStyle.color = color.add(direction * 0.01f, 0, 0).toInt();
      plotter.update(function);
      plotView.postDelayed(this, 100L);
    }
  };

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);
    plotView = (PlotView) findViewById(R.id.plotview);
    plotView.setPlotter(plotter);

    final View zoomOutButton = findViewById(R.id.zoom_out_button);
    zoomOutButton.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        plotView.zoom(false);
      }
    });
    final View zoom0Button = findViewById(R.id.zoom_0_button);
    zoom0Button.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        plotView.resetZoom();
      }
    });
    final View zoomInButton = findViewById(R.id.zoom_in_button);
    zoomInButton.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        plotView.zoom(true);
      }
    });
    final View plotModeButton = findViewById(R.id.plot_mode_button);
    plotModeButton.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        plotter.set3d(!plotter.is3d());
      }
    });


    plotView.post(colorUpdater);
  }

  @Override
  protected void onSaveInstanceState(@Nonnull Bundle out) {
    super.onSaveInstanceState(out);
    final Parcelable plotViewState = plotView.onSaveInstanceState();
    out.putParcelable("plotview", plotViewState);
  }

  @Override
  protected void onRestoreInstanceState(@Nonnull Bundle in) {
    super.onRestoreInstanceState(in);
    final Parcelable plotviewState = in.getParcelable("plotview");
    if (plotviewState != null) {
      plotView.onRestoreInstanceState(plotviewState);
    }
  }

  @Override
  protected void onPause() {
    plotView.onPause();
    super.onPause();
  }

  @Override
  protected void onResume() {
    super.onResume();
    plotView.onResume();
  }
}




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