package liquid;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import lombok.val;

/**
 * Control panel for a bottle and viewer.
 */
public final class Controls extends JPanel {

    private static final long serialVersionUID = 1L;

    private final Bottle bottle;
    private final Viewer viewer;

    /**
     * Create a new control panel for the given bottle and viewer.
     * @param bottle  the bottle to be controlled
     * @param viewer  the viewer to be controlled
     */
    public Controls(final Bottle bottle, final Viewer viewer) {
        this.bottle = bottle;
        this.viewer = viewer;

        val threshold = new JCheckBox("Threshold", true);
        threshold.addActionListener(new ActionListener() {
                public void actionPerformed(final ActionEvent e) {
                    viewer.setThreshold(threshold.isSelected());
                }
            });
        add(threshold);
        val blur = new JCheckBox("Blur", true);
        blur.addActionListener(new ActionListener() {
                public void actionPerformed(final ActionEvent e) {
                    viewer.setBlur(blur.isSelected());
                    threshold.setEnabled(blur.isSelected());
                }
            });
        add(blur);
    }
}

@@ -10,16 +10,44 @@
 iquid;%0A%0A
+import java.awt.GridLayout;%0A
 import j
@@ -111,16 +111,78 @@
 stener;%0A
+import javax.swing.BorderFactory;%0Aimport javax.swing.JButton;%0A
 import j
@@ -1082,16 +1082,17 @@
 shold);%0A
+%0A
         
@@ -1420,16 +1420,518 @@
 d(blur);
+%0A%0A        val pause = new JButton(%22Pause%22);%0A        pause.addActionListener(new ActionListener() %7B%0A                public void actionPerformed(final ActionEvent e) %7B%0A                    if (bottle.isRunning()) %7B%0A                        bottle.stop();%0A                        pause.setText(%22Play%22);%0A                    %7D else %7B%0A                        new Thread(bottle).start();%0A                        pause.setText(%22Pause%22);%0A                    %7D%0A                %7D%0A            %7D);%0A        add(pause);
 %0A    %7D%0A%7D

Add pause/unpause.