1 package org.woehlke.computer.kurzweil.dla.model.dendrite;
2
3
4 import java.io.Serializable;
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 public class Dendrite implements Serializable {
20
21 static final long serialVersionUID = 242L;
22
23 private int worldMap[][];
24 private Point dimensions;
25 private int age=1;
26
27 public Dendrite(Point dimensions) {
28 this.dimensions = dimensions;
29 worldMap = new int[dimensions.getX()][dimensions.getY()];
30 int x = dimensions.getX() / 2;
31 int y = dimensions.getY() / 2;
32 worldMap[x][y]=age;
33 age++;
34 }
35
36 public boolean hasDendriteNeighbour(Point pixel){
37 if(worldMap[pixel.getX()][pixel.getY()]==0){
38 Point[] neighbours=pixel.getNeighbourhood(dimensions);
39 for(Point neighbour:neighbours){
40 if(worldMap[neighbour.getX()][neighbour.getY()]>0){
41 worldMap[pixel.getX()][pixel.getY()]=age;
42 age++;
43 return true;
44 }
45 }
46 return false;
47 } else {
48 return true;
49 }
50 }
51
52 public int getAgeForPixel(int x,int y){
53 return worldMap[x][y];
54 }
55 }