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()));
}
}
}
}
}