/* * The MIT License (MIT) * * Copyright (c) 2015 Camil Staps * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ package com.camilstaps.mandelbrot; import java.util.Observable; /** * The FractalModel holds the bounds of the shown fractal * @author Camil Staps */ public class FractalModel extends Observable { private double start_x = -1, end_x = 1, start_y = -1, end_y = 1; /** * Get the Mandelbrot number for a specific point up to some maximum * @param x the x coordinate of the point * @param y the y coordinate of the point * @param repetitions the maximum * @return the mandelbrot number */ public int getMandelNumber(double x, double y, int repetitions) { return MandelbrotFractal.mandelNumber(x, y, repetitions); } /** * Get the Mandelbrot number for a specific point up to some maximum * @param p the point * @param repetitions the maximum * @return the mandelbrot number */ public int getMandelNumber(MandelbrotFractal.Point p, int repetitions) { return MandelbrotFractal.mandelNumber(p, 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; } /** * Set all bounds together * @param start_x * @param end_x * @param start_y * @param end_y */ public synchronized void setBounds(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(); } }