diff options
Diffstat (limited to 'Week15 Mandelbrot/src/com/camilstaps/mandelbrot/Textfields.java')
-rw-r--r-- | Week15 Mandelbrot/src/com/camilstaps/mandelbrot/Textfields.java | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/Week15 Mandelbrot/src/com/camilstaps/mandelbrot/Textfields.java b/Week15 Mandelbrot/src/com/camilstaps/mandelbrot/Textfields.java index 78098d1..b4eb6a7 100644 --- a/Week15 Mandelbrot/src/com/camilstaps/mandelbrot/Textfields.java +++ b/Week15 Mandelbrot/src/com/camilstaps/mandelbrot/Textfields.java @@ -1,5 +1,25 @@ /* - * Copyright (c) 2015 Camil Staps + * The MIT License (MIT) + * + * Copyright (c) 2015 Camil Staps <info@camilstaps.nl> + * + * 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; @@ -24,13 +44,11 @@ public class Textfields extends JPanel implements Observer { private final String INITIAL_CENTER_X = "0", INITIAL_CENTER_Y = "0", - INITIAL_SCALE = "0.5", - INITIAL_REPETITIONS = "100"; + INITIAL_SCALE = "0.5"; private final JTextField field_centerX = new JTextField(INITIAL_CENTER_X, 6); private final JTextField field_centerY = new JTextField(INITIAL_CENTER_Y, 6); private final JTextField field_scale = new JTextField(INITIAL_SCALE, 6); - private final JTextField field_repetitions = new JTextField(INITIAL_REPETITIONS, 6); private final JButton button_redraw = new JButton("Redraw"); private final JButton button_reset = new JButton("Reset"); @@ -41,6 +59,8 @@ public class Textfields extends JPanel implements Observer { fractalModel.addObserver(this); setupControls(); + + update(fractalModel, null); } private void setupControls() { @@ -55,9 +75,6 @@ public class Textfields extends JPanel implements Observer { panel.add(new JLabel("Scale:")); panel.add(field_scale); - panel.add(new JLabel("Repetitions:")); - panel.add(field_repetitions); - button_redraw.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { @@ -74,7 +91,6 @@ public class Textfields extends JPanel implements Observer { field_centerX.setText(INITIAL_CENTER_X); field_centerY.setText(INITIAL_CENTER_Y); field_scale.setText(INITIAL_SCALE); - field_repetitions.setText(INITIAL_REPETITIONS); button_redraw.doClick(); } @@ -115,7 +131,7 @@ public class Textfields extends JPanel implements Observer { } @Override - public void update(Observable o, Object o1) { + public final void update(Observable o, Object o1) { field_centerX.setText(Float.toString((float) ((fractalModel.getEndX() - fractalModel.getStartX()) / 2 + fractalModel.getStartX()))); field_centerY.setText(Float.toString((float) |