Example #1
0
  /**
   * Constructs a special JComboBox with all cameras that have more than 1 channel, which we expect
   * to just be a single Multicamera device
   *
   * @param deviceName
   * @return
   */
  public JComboBox makeMultiCameraDeviceBox(Devices.Keys deviceName, int maximumWidth) {
    List<String> multiCameras = new ArrayList<String>();
    multiCameras.add(0, "");
    try {
      StrVector strvDevices = core_.getLoadedDevicesOfType(mmcorej.DeviceType.CameraDevice);
      for (int i = 0; i < strvDevices.size(); i++) {
        // find all Multi-camera devices (usually just one)
        String test = strvDevices.get(i);
        if (core_.getDeviceLibrary(test).equals(Devices.Libraries.UTILITIES.toString())
            && core_
                .getDeviceDescription(test)
                .equals("Combine multiple physical cameras into a single logical camera")) {
          multiCameras.add(strvDevices.get(i));
        }
      }
    } catch (Exception ex) {
      MyDialogUtils.showError("Error detecting multi camera devices");
    }

    JComboBox deviceBox = new JComboBox(multiCameras.toArray());
    deviceBox.addActionListener(new DeviceBoxListener(deviceName, deviceBox));
    // if we have one and only one multi-camera then set box to it
    if (multiCameras.size() == 2) { // recall we added empty string as the first entry
      deviceBox.setSelectedIndex(1);
    } else {
      deviceBox.setSelectedItem(
          devices_.getMMDevice(deviceName)); // selects whatever device was read in by prefs
    }
    deviceBox.setMaximumSize(new Dimension(maximumWidth, 30));
    return deviceBox;
  }
Example #2
0
  /**
   * Constructs a special JComboBox with all cameras that have only 1 channel
   *
   * @param deviceName
   * @return
   */
  public JComboBox makeSingleCameraDeviceBox(Devices.Keys deviceName, int maximumWidth) {
    List<String> singleCameras = new ArrayList<String>();
    singleCameras.add(0, "");
    String originalCamera = core_.getCameraDevice();
    try {
      StrVector strvDevices = core_.getLoadedDevicesOfType(mmcorej.DeviceType.CameraDevice);
      for (int i = 0; i < strvDevices.size(); i++) {
        String test = strvDevices.get(i);
        core_.setCameraDevice(test);
        if (core_.getNumberOfCameraChannels() == 1) {
          singleCameras.add(test);
        }
      }
    } catch (Exception ex) {
      MyDialogUtils.showError("Error detecting single camera devices");
    } finally {
      try {
        core_.setCameraDevice(originalCamera);
      } catch (Exception e) {
        MyDialogUtils.showError(e);
      }
    }

    JComboBox deviceBox = new JComboBox(singleCameras.toArray());
    deviceBox.addActionListener(new DeviceBoxListener(deviceName, deviceBox));
    deviceBox.setSelectedItem(
        devices_.getMMDevice(deviceName)); // selects whatever device was read in by prefs
    deviceBox.setMaximumSize(new Dimension(maximumWidth, 30));
    return deviceBox;
  }
Example #3
0
 /**
  * Constructs a JComboBox populated with devices of specified Micro-Manager type Attaches a
  * listener and sets selected item to what is specified in the Devices class.
  *
  * @param deviceType - Micro-Manager device type (mmcorej.DeviceType)
  * @param deviceKey - ASi diSPIM device key (see Devices class)
  * @param maximumWidth -
  * @return final JComboBox
  */
 public JComboBox makeDeviceSelectionBox(
     mmcorej.DeviceType deviceType, Devices.Keys deviceKey, int maximumWidth) {
   // when editing this method do the same to the one with array argument too
   JComboBox deviceBox = new JComboBox();
   ArrayList<String> devices = new ArrayList<String>();
   StrVector strvDevices = core_.getLoadedDevicesOfType(deviceType);
   devices.addAll(Arrays.asList(strvDevices.toArray()));
   devices.add(0, "");
   deviceBox.removeAllItems();
   for (String device : devices) {
     deviceBox.addItem(device);
   }
   deviceBox.addActionListener(new DeviceBoxListener(deviceKey, deviceBox));
   deviceBox.setSelectedItem(
       devices_.getMMDevice(deviceKey)); // selects whatever device was read in by prefs
   deviceBox.setMaximumSize(new Dimension(maximumWidth, 30));
   return deviceBox;
 }