1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
/*
* Copyright (c) 2015 Camil Staps
*/
package com.camilstaps.mandelbrot;
import java.util.Observable;
/**
*
* @author camilstaps
*/
public class FractalModel extends Observable {
private double start_x, start_y, end_x, end_y;
public FractalModel() {
start_x = -1;
start_y = -1;
end_x = 1;
end_y = 1;
}
public int getMandelNumber(MandelbrotFractal.Point p, int repetitions) {
return MandelbrotFractal.mandelNumber(p, repetitions);
}
public int getMandelNumber(double x, double y, int repetitions) {
return MandelbrotFractal.mandelNumber(x, y, repetitions);
}
public double getStartX() {
return start_x;
}
public double getStartY() {
return start_y;
}
public double getEndX() {
return end_x;
}
public double getEndY() {
return end_y;
}
public synchronized void setBorders(double start_x, double end_x, double start_y, double end_y) {
if (start_x == this.start_x && end_x == this.end_x && start_y == this.start_y && end_y == this.end_y)
return;
this.start_x = start_x;
this.end_x = end_x;
this.start_y = start_y;
this.end_y = end_y;
setChanged();
notifyObservers();
}
public synchronized void setStartX(double x) {
if (start_x == x)
return;
start_x = x;
setChanged();
notifyObservers();
}
public synchronized void setStartY(double y) {
if (start_y == y)
return;
start_y = y;
setChanged();
notifyObservers();
}
public synchronized void setEndX(double x) {
if (end_x == x)
return;
end_x = x;
setChanged();
notifyObservers();
}
public synchronized void setEndY(double y) {
if (end_y == y)
return;
end_y = y;
setChanged();
notifyObservers();
}
}
|