<commit_before>///////////////////////////////////////////////////////////////////////////////
//FILE:          CameraSubPanel.java
//PROJECT:       Micro-Manager 
//SUBSYSTEM:     ASIdiSPIM plugin
//-----------------------------------------------------------------------------
//
// AUTHOR:       <NAME>, <NAME>
//
// COPYRIGHT:    University of California, San Francisco, & ASI, 2013
//
// LICENSE:      This file is distributed under the BSD license.
//               License text is included with the source distribution.
//
//               This file is distributed in the hope that it will be useful,
//               but WITHOUT ANY WARRANTY; without even the implied warranty
//               of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
//               IN NO EVENT SHALL THE COPYRIGHT OWNER OR
//               CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//               INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES.

package org.micromanager.asidispim;

import org.micromanager.asidispim.Data.Cameras;
import org.micromanager.asidispim.Data.Devices;
import org.micromanager.asidispim.Data.MyStrings;
import org.micromanager.asidispim.Data.Prefs;
import org.micromanager.asidispim.Utils.DevicesListenerInterface;
import org.micromanager.asidispim.Utils.ListeningJPanel;
import org.micromanager.asidispim.Utils.UpdateFromPropertyListenerInterface;

import java.awt.Dimension;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JToggleButton;

import org.micromanager.api.ScriptInterface;
import org.micromanager.MMStudio;
import org.micromanager.internalinterfaces.LiveModeListener;

import com.swtdesigner.SwingResourceManager;

import net.miginfocom.swing.MigLayout;


/**
 *
 * @author Jon
 */
@SuppressWarnings("serial")
public final class CameraSubPanel extends ListeningJPanel implements LiveModeListener {
   
   private final Devices devices_;
   private final Prefs prefs_;
   private final Cameras cameras_;
   private final ScriptInterface gui_;
   private final Devices.Sides side_;
   private final String instanceLabel_;
   private final JComboBox cameraBox_;
   private final JToggleButton camAButton_;
   private final JToggleButton camBButton_;
   private final JToggleButton camMultiButton_;
   private final JToggleButton camBotButton_;
//   private final JToggleButton testAcqButton_;
   private final JToggleButton toggleButtonLive_;
   private List<UpdateFromPropertyListenerInterface> privateListeners_;
   
   /**
    * 
    * @param gui Micro-Manager script interface
    * @param cameras instance of Camera class
    * @param devices the (single) instance of the Devices class
    * @param instanceLabel name of the panel calling this class
    * @param side A, B, or none
    * @param prefs
    * @param showLiveButton if false then the live button is omitted
    */
   public CameraSubPanel(ScriptInterface gui, 
           Cameras cameras, 
           Devices devices, 
           String instanceLabel,
           Devices.Sides side, 
           Prefs prefs) {    
      super (MyStrings.PanelNames.CAMERA_SUBPANEL.toString() + instanceLabel,
            new MigLayout(
              "", 
              "[right]8[center]",
              "[]8[]"));
      setBorder(BorderFactory.createLineBorder(ASIdiSPIM.borderColor));

      final int columnWidth = 105;
      
      cameras_ = cameras;
      devices_ = devices;
      side_ = side;
      prefs_ = prefs;
      instanceLabel_ = instanceLabel;
      gui_ = gui;
      
      privateListeners_ = new ArrayList<UpdateFromPropertyListenerInterface>();

      JPanel camButtonPanel = new JPanel(new MigLayout(
            "",
            "0[center]4[center]4[center]4[center]0",
            "0[]0"));
      
      switch (side_) {
      case A:
         camAButton_ = makeCameraButton("Imaging", Devices.Keys.CAMERAA);
         camBButton_ = makeCameraButton("  Epi  ", Devices.Keys.CAMERAB);
         break;
      case B:
         camAButton_ = makeCameraButton("Imaging", Devices.Keys.CAMERAB);
         camBButton_ = makeCameraButton("  Epi  ", Devices.Keys.CAMERAA);
         break;
      case NONE:
      default:
         camAButton_ = makeCameraButton("Path A", Devices.Keys.CAMERAA);
         camBButton_ = makeCameraButton("Path B", Devices.Keys.CAMERAB);
         break;
      }

      camMultiButton_ = makeCameraButton("Multi", Devices.Keys.MULTICAMERA); 
      camBotButton_ = makeCameraButton("Bottom", Devices.Keys.CAMERALOWER);

      camButtonPanel.add(camAButton_);
      camButtonPanel.add(camMultiButton_);
      camButtonPanel.add(camBButton_);
      camButtonPanel.add(camBotButton_);
      
      // make sure only one can be selected at a time
      ButtonGroup group = new ButtonGroup();
      group.add(camAButton_);
      group.add(camBButton_);
      group.add(camMultiButton_);
      group.add(camBotButton_);

      add(camButtonPanel, "span 2, wrap");
      
      add(new JLabel("On tab activate:"));
      cameraBox_ = makeCameraSelectionBox(columnWidth);
      add(cameraBox_, "wrap");
      
      JPanel liveButtonPanel = new JPanel(new MigLayout(
            "",
            "[left]8[right]",
            "0[]0"));
      
//      testAcqButton_ = new JToggleButton("Test Acq.");
            
      toggleButtonLive_ = new JToggleButton();
      toggleButtonLive_.setMargin(new Insets(2, 15, 2, 15));
      toggleButtonLive_.setIconTextGap(6);
      toggleButtonLive_.setToolTipText("Continuous live view");
      setLiveButtonAppearance(gui_.isLiveModeOn());
      toggleButtonLive_.addActionListener(new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
            setLiveButtonAppearance(!gui_.isLiveModeOn());
            cameras_.enableLiveMode(!gui_.isLiveModeOn());
         }
      });
      <commit_msg>ASIdiSPIM: GUI spacing tweak to shrink plugin window<commit_after>///////////////////////////////////////////////////////////////////////////////
//FILE:          CameraSubPanel.java
//PROJECT:       Micro-Manager 
//SUBSYSTEM:     ASIdiSPIM plugin
//-----------------------------------------------------------------------------
//
// AUTHOR:       <NAME>, <NAME>
//
// COPYRIGHT:    University of California, San Francisco, & ASI, 2013
//
// LICENSE:      This file is distributed under the BSD license.
//               License text is included with the source distribution.
//
//               This file is distributed in the hope that it will be useful,
//               but WITHOUT ANY WARRANTY; without even the implied warranty
//               of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
//               IN NO EVENT SHALL THE COPYRIGHT OWNER OR
//               CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//               INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES.

package org.micromanager.asidispim;

import org.micromanager.asidispim.Data.Cameras;
import org.micromanager.asidispim.Data.Devices;
import org.micromanager.asidispim.Data.MyStrings;
import org.micromanager.asidispim.Data.Prefs;
import org.micromanager.asidispim.Utils.DevicesListenerInterface;
import org.micromanager.asidispim.Utils.ListeningJPanel;
import org.micromanager.asidispim.Utils.UpdateFromPropertyListenerInterface;

import java.awt.Dimension;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JToggleButton;

import org.micromanager.api.ScriptInterface;
import org.micromanager.MMStudio;
import org.micromanager.internalinterfaces.LiveModeListener;

import com.swtdesigner.SwingResourceManager;

import net.miginfocom.swing.MigLayout;


/**
 *
 * @author Jon
 */
@SuppressWarnings("serial")
public final class CameraSubPanel extends ListeningJPanel implements LiveModeListener {
   
   private final Devices devices_;
   private final Prefs prefs_;
   private final Cameras cameras_;
   private final ScriptInterface gui_;
   private final Devices.Sides side_;
   private final String instanceLabel_;
   private final JComboBox cameraBox_;
   private final JToggleButton camAButton_;
   private final JToggleButton camBButton_;
   private final JToggleButton camMultiButton_;
   private final JToggleButton camBotButton_;
//   private final JToggleButton testAcqButton_;
   private final JToggleButton toggleButtonLive_;
   private List<UpdateFromPropertyListenerInterface> privateListeners_;
   
   /**
    * 
    * @param gui Micro-Manager script interface
    * @param cameras instance of Camera class
    * @param devices the (single) instance of the Devices class
    * @param instanceLabel name of the panel calling this class
    * @param side A, B, or none
    * @param prefs
    * @param showLiveButton if false then the live button is omitted
    */
   public CameraSubPanel(ScriptInterface gui, 
           Cameras cameras, 
           Devices devices, 
           String instanceLabel,
           Devices.Sides side, 
           Prefs prefs) {    
      super (MyStrings.PanelNames.CAMERA_SUBPANEL.toString() + instanceLabel,
            new MigLayout(
              "", 
              "[right]8[center]",
              "[]8[]"));
      setBorder(BorderFactory.createLineBorder(ASIdiSPIM.borderColor));

      final int columnWidth = 105;
      
      cameras_ = cameras;
      devices_ = devices;
      side_ = side;
      prefs_ = prefs;
      instanceLabel_ = instanceLabel;
      gui_ = gui;
      
      privateListeners_ = new ArrayList<UpdateFromPropertyListenerInterface>();

      JPanel camButtonPanel = new JPanel(new MigLayout(
            "",
            "0[center]4[center]4[center]4[center]0",
            "0[]0"));
      
      switch (side_) {
      case A:
         camAButton_ = makeCameraButton("Imaging", Devices.Keys.CAMERAA);
         camBButton_ = makeCameraButton("  Epi  ", Devices.Keys.CAMERAB);
         break;
      case B:
         camAButton_ = makeCameraButton("Imaging", Devices.Keys.CAMERAB);
         camBButton_ = makeCameraButton("  Epi  ", Devices.Keys.CAMERAA);
         break;
      case NONE:
      default:
         camAButton_ = makeCameraButton("Path A", Devices.Keys.CAMERAA);
         camBButton_ = makeCameraButton("Path B", Devices.Keys.CAMERAB);
         break;
      }

      camMultiButton_ = makeCameraButton("Multi", Devices.Keys.MULTICAMERA); 
      camBotButton_ = makeCameraButton("Bottom", Devices.Keys.CAMERALOWER);

      camButtonPanel.add(camAButton_);
      camButtonPanel.add(camMultiButton_);
      camButtonPanel.add(camBButton_);
      camButtonPanel.add(camBotButton_);
      
      // make sure only one can be selected at a time
      ButtonGroup group = new ButtonGroup();
      group.add(camAButton_);
      group.add(camBButton_);
      group.add(camMultiButton_);
      group.add(camBotButton_);

      add(camButtonPanel, "span 2, center, wrap");
      
      add(new JLabel("On tab activate:"));
      cameraBox_ = makeCameraSelectionBox(columnWidth);
      add(cameraBox_, "wrap");
      
      JPanel liveButtonPanel = new JPanel(new MigLayout(
            "",
            "0[left]8[right]0",
            "0[]0"));
      
//      testAcqButton_ = new JToggleButton("Test Acq.");
            
      toggleButtonLive_ = new JToggleButton();
      toggleButtonLive_.setMargin(new Insets(2, 15, 2, 15));
      toggleButtonLive_.setIconTextGap(6);
      toggleButtonLive_.setToolTipText("Continuous live view");
      setLiveButtonAppearance(gui_.isLiveModeOn());
      toggleButtonLive_.addActionListener(new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
            setLiveButtonAppearance(!gui_.isLiveModeOn());
            cameras_.enableLiveMode(!gui_.isLiveModeOn());
         }
      });
      
{'fraction_non_alphanumeric': 0.11443963758060567, 'fraction_numerical': 0.004571055424047016, 'mean_word_length': 2.6280722534794196, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '6541821', 'n_tokens_mistral': 3443, 'n_tokens_neox': 3344, 'n_words': 818}