Android Open Source - wannabe Fixed Grid






From Project

Back to project page wannabe.

License

The source code is released under:

MIT License

If you think the Android project wannabe 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

// Copyright 2013 Patrick Forhan.
package wannabe.grid;
/*from w  ww . j a va  2s.  c  o m*/
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import wannabe.Position;
import wannabe.Voxel;

/** A grid optimized for subGrid usage.  It assumes that none of its voxels ever change. */
// Internal discussion follows:
//TODO make a Grid for a background or something, that's optimized for its voxels not changing.
//Could have a really efficient subGrid implementation. How to organize that, though?
//It'd have to be by x and y, then.
//The trick is that if there is a single Grid holding voxels, anything moving atop that will cause
//changes.  My need to come up with a way of having a background grid and a foreground grid,
//and making sure the stuff on foreground stays equal or higher z.

public class FixedGrid implements Grid {
  private final List<Voxel> voxels = new ArrayList<Voxel>();
  private final FixedGrid subGrid = new FixedGrid(null);

  public FixedGrid(Grid baseGrid) {
    // TODO try to finish this... optimizing for x and y is at odds with z-sorting
    // Ideally it ends up something like String.subString and can operate on the same base data structure
  }


  @Override public Iterator<Voxel> iterator() {
    return voxels.iterator();
  }

  @Override public Grid subGrid(int x, int y, int width, int height) {
    // TODO implement me!
    subGrid.voxels.clear();
    for (Voxel vox : voxels) {
      Position pos = vox.position;
      if (pos.x >= x && pos.x < x + width //
          && pos.y >= y && pos.y < y + height) {
        subGrid.voxels.add(vox);
      }
    }
    return subGrid;
  }

  @Override public boolean add(Voxel v) {
    return false;
  }

  @Override public boolean remove(Voxel v) {
    return false;
  }

  @Override public int size() {
    return voxels.size();
  }

  @Override public Grid unmodifyableGrid() {
    return this;
  }

  private static class Limits {
    int min, max;
  }

}




Java Source Code List

android.util.ArrayUtils.java
android.util.SparseArray.java
android.util.SparseIntArray.java
wannabe.Camera.java
wannabe.Position.java
wannabe.Rendered.java
wannabe.UI.java
wannabe.Voxel.java
wannabe.android.MainActivity.java
wannabe.grid.FixedGrid.java
wannabe.grid.Grid.java
wannabe.grid.SimpleGrid.java
wannabe.projection.Flat.java
wannabe.projection.Isometric.java
wannabe.projection.Projection.java
wannabe.projection.Projections.java
wannabe.projection.PseudoPerspective.java
wannabe.swing.SettingsPanel.java
wannabe.swing.SwingWannabe.java
wannabe.swing.WannabePanel.java
wannabe.util.SampleGrids.java
wannabe.util.UIs.java