1 package org.woehlke.simulation.dla.model;
2
3 import org.woehlke.simulation.dla.DiffusionLimitedAggregation;
4
5
6
7
8
9
10
11
12
13
14
15 public class Point implements DiffusionLimitedAggregation {
16
17 static final long serialVersionUID = mySerialVersionUID;
18
19
20 private int x = 0;
21 private int y = 0;
22
23 public Pointint" href="../../../../../org/woehlke/simulation/dla/model/Point.html#Point">Point(Point p) {
24 this.x = p.getX();
25 this.y = p.getY();
26 }
27
28 public Point(int x, int y) {
29 this.x = x;
30 this.y = y;
31 }
32
33 public int getX() {
34 return x;
35 }
36
37 public void setX(int x) {
38 this.x = x;
39 }
40
41 public int getY() {
42 return y;
43 }
44
45 public void setY(int y) {
46 this.y = y;
47 }
48
49 public void killNagative() {
50 if (y < 0) {
51 y *= -1;
52 }
53 if (x < 0) {
54 x *= -1;
55 }
56 }
57
58 public void add(Point p) {
59 this.x += p.getX();
60 this.y += p.getY();
61 }
62
63 public void normalize(Point p) {
64 this.x %= p.getX();
65 this.y %= p.getY();
66 }
67
68 public Point/../../org/woehlke/simulation/dla/model/Point.html#Point">Point[] getNeighbourhood(Point max){
69 PointPoint.html#Point">Point neighbourhood[] = new Point[9];
70 int maxX = max.getX();
71 int maxY = max.getY();
72 neighbourhood[0]= new Point((this.x+maxX-1) % maxX,(this.y+maxY-1) % maxY);
73 neighbourhood[1]= new Point((this.x+maxX-1) % maxX,this.y);
74 neighbourhood[2]= new Point((this.x+maxX-1) % maxX,(this.y+maxY+1) % maxY);
75 neighbourhood[3]= new Point(this.x,(this.y+maxY-1) % maxY);
76 neighbourhood[4]= new Point(this.x,this.y);
77 neighbourhood[5]= new Point(this.x,(this.y+maxY+1) % maxY);
78 neighbourhood[6]= new Point((this.x+maxX+1) % maxX,(this.y+maxY-1) % maxY);
79 neighbourhood[7]= new Point((this.x+maxX+1) % maxX,this.y);
80 neighbourhood[8]= new Point((this.x+maxX+1) % maxX,(this.y+maxY+1) % maxY);
81 return neighbourhood;
82 }
83 }