<commit_before>package etomica.graphics;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;

import javax.swing.JPanel;

import etomica.Controller;
import etomica.Simulation;
import etomica.action.ResetAccumulators;
import etomica.action.SimulationRestart;
import etomica.simulations.HSMD2D;

/**
 * Device comprising three buttons: (1) attaches to a controller to toggle its pause/resume state; 
 * (2)causes a reset (restart) action of simulation to be performed; (3) causes reset of meter averages
 * only.
 *
 * @author <NAME>
 */
 
 /* History of changes.
  * 07/03/02 Created
  */
public class DeviceTrioControllerButton extends Device {
    
    private JPanel jp;
    private DeviceControllerButton button1;
    private Simulation simulation;
    private DeviceButton button2;
    private DeviceButton button3; 
    private SimulationRestart simReset;
    private ResetAccumulators resetAccumulators;
	private double width;
	private boolean firstResized = true;
	private String shape;

    /**
     * Contructs device with buttons that affect the given simulation.
     */
    public DeviceTrioControllerButton(Simulation simulation) {
        this();
        setSimulation(simulation);
    }
    
    /**
     * No-argument contructor gives device that performs no action until
     * setSimulation is used to specify the target simulation.
     */
    public DeviceTrioControllerButton() {
        super();
        jp = new JPanel(new java.awt.GridLayout(1,0)); //default shape of panel
        jp.setBorder(new javax.swing.border.TitledBorder("Control"));
        jp.setOpaque(false);
//        jp.setBackground(DefaultGraphic.BORDER_COLOR);
/*        jp.setBorder(new javax.swing.border.TitledBorder(
                         new javax.swing.border.EtchedBorder(
                             javax.swing.border.EtchedBorder.RAISED, java.awt.Color.red, java.awt.Color.blue) 
                             ,"Control"
                             ,javax.swing.border.TitledBorder.LEFT
                             ,javax.swing.border.TitledBorder.TOP
                             ,new java.awt.Font(null,java.awt.Font.BOLD,15)
                             ,java.awt.Color.black));
                             */

        button1 = new DeviceControllerButton(null);
        button2 = new DeviceButton(null);
        button3 = new DeviceButton(null);
        button2.setLabel("Restart");
        button3.setLabel("Reset averages");
        
        jp.add(button1.graphic()); 
        jp.add(button2.graphic());  
        jp.add(button3.graphic());
                       
        setShape("VERTICAL");
    }
        
    /**
     * Sets the controller that is toggled by this device.
     */
    public void setSimulation(Simulation sim) {
        simulation = sim;
        Controller c = sim.getController();
        setController(c);
        button1.setController(c);
        button2.setController(c);
        button3.setController(c);
        button2.setAction(new SimulationRestart(sim));
        button3.setAction(new ResetAccumulators(sim.getDataManagerList()));
    }<commit_msg>fix for change to data handlers<commit_after>package etomica.graphics;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;

import javax.swing.JPanel;

import etomica.Controller;
import etomica.Simulation;
import etomica.action.ResetAccumulators;
import etomica.action.SimulationRestart;
import etomica.simulations.HSMD2D;

/**
 * Device comprising three buttons: (1) attaches to a controller to toggle its pause/resume state; 
 * (2)causes a reset (restart) action of simulation to be performed; (3) causes reset of meter averages
 * only.
 *
 * @author <NAME>
 */
 
 /* History of changes.
  * 07/03/02 Created
  */
public class DeviceTrioControllerButton extends Device {
    
    private JPanel jp;
    private DeviceControllerButton button1;
    private Simulation simulation;
    private DeviceButton button2;
    private DeviceButton button3; 
    private SimulationRestart simReset;
    private ResetAccumulators resetAccumulators;
	private double width;
	private boolean firstResized = true;
	private String shape;

    /**
     * Contructs device with buttons that affect the given simulation.
     */
    public DeviceTrioControllerButton(Simulation simulation) {
        this();
        setSimulation(simulation);
    }
    
    /**
     * No-argument contructor gives device that performs no action until
     * setSimulation is used to specify the target simulation.
     */
    public DeviceTrioControllerButton() {
        super();
        jp = new JPanel(new java.awt.GridLayout(1,0)); //default shape of panel
        jp.setBorder(new javax.swing.border.TitledBorder("Control"));
        jp.setOpaque(false);
//        jp.setBackground(DefaultGraphic.BORDER_COLOR);
/*        jp.setBorder(new javax.swing.border.TitledBorder(
                         new javax.swing.border.EtchedBorder(
                             javax.swing.border.EtchedBorder.RAISED, java.awt.Color.red, java.awt.Color.blue) 
                             ,"Control"
                             ,javax.swing.border.TitledBorder.LEFT
                             ,javax.swing.border.TitledBorder.TOP
                             ,new java.awt.Font(null,java.awt.Font.BOLD,15)
                             ,java.awt.Color.black));
                             */

        button1 = new DeviceControllerButton(null);
        button2 = new DeviceButton(null);
        button3 = new DeviceButton(null);
        button2.setLabel("Restart");
        button3.setLabel("Reset averages");
        
        jp.add(button1.graphic()); 
        jp.add(button2.graphic());  
        jp.add(button3.graphic());
                       
        setShape("VERTICAL");
    }
        
    /**
     * Sets the controller that is toggled by this device.
     */
    public void setSimulation(Simulation sim) {
        simulation = sim;
        Controller c = sim.getController();
        setController(c);
        button1.setController(c);
        button2.setController(c);
        button3.setController(c);
        button2.setAction(new SimulationRestart(sim));
        button3.setAction(new ResetAccumulators(sim.getDataAccumulatorList()));
    }
{'fraction_non_alphanumeric': 0.0944781359719119, 'fraction_numerical': 0.009575486753909991, 'mean_word_length': 2.351336898395722, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3306745', 'n_tokens_mistral': 1757, 'n_tokens_neox': 1704, 'n_words': 391}