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