Package testing

Source Code of testing.Grid

package testing;

import java.util.ArrayList;

import framework.component.Component;
import framework.component.ParentComponent;

public class Grid extends Component{
 
  private final int width;
  private final int height;
  private final float gridSpacing;
 
  private final ArrayList<ArrayList<Dot>> dots = new ArrayList<ArrayList<Dot>>();
 
  public Grid(int width, int height, float gridSpacing) {
    super();
    this.width = width;
    this.height = height;
    this.gridSpacing = gridSpacing;
  }
 
  public Dot getDot(int x, int y){
    return dots.get(x).get(y);
  }

  @Override
  public boolean allowSameTypedSiblings() {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  protected byte getDataFormatVersion() {
    // TODO Auto-generated method stub
    return 0;
  }
 
  @Override
  protected void onAddedToParent(ParentComponent parent) {
    super.onAddedToParent(parent);
    if(parent != null){
      for(int i = 0; i < width; i++){
        dots.add(new ArrayList<Dot>());
        for(int j = 0; j < height; j++){
          ParentComponent p = SquaresGen.generateDot(getParent(), i, j, gridSpacing);
          dots.get(i).add((Dot)p.getChildByType(Dot.class.getName()));
        }
      }
    }
  }
}
TOP

Related Classes of testing.Grid

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.