Esempio n. 1
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;
  }
  public void readFromCore(CMMCore core, String deviceName, String propertyName, boolean cached) {
    device = deviceName;
    name = propertyName;
    try {
      readOnly = core.isPropertyReadOnly(deviceName, propertyName);
      preInit = core.isPropertyPreInit(deviceName, propertyName);
      hasRange = core.hasPropertyLimits(deviceName, propertyName);
      lowerLimit = core.getPropertyLowerLimit(deviceName, propertyName);
      upperLimit = core.getPropertyUpperLimit(deviceName, propertyName);
      type = core.getPropertyType(deviceName, propertyName);
      StrVector values = core.getAllowedPropertyValues(deviceName, propertyName);
      allowed = new String[(int) values.size()];
      for (int k = 0; k < values.size(); k++) {
        allowed[k] = values.get(k);
      }

      sort();

      String coreVal;
      if (cached) coreVal = core.getPropertyFromCache(deviceName, propertyName);
      else coreVal = core.getProperty(deviceName, propertyName);
      setValueFromCoreString(coreVal);
    } catch (Exception e) {
      ReportingUtils.logError(e);
    }
  }
Esempio n. 3
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;
  }
Esempio n. 4
0
 public String[] getPropertyNames() {
   Vector<String> propNames = new Vector<String>();
   try {
     core_.setAutoFocusDevice(devName_);
     StrVector propNamesVect = core_.getDevicePropertyNames(devName_);
     for (int i = 0; i < propNamesVect.size(); i++)
       if (!core_.isPropertyReadOnly(devName_, propNamesVect.get(i))
           && !core_.isPropertyPreInit(devName_, propNamesVect.get(i)))
         propNames.add(propNamesVect.get(i));
   } catch (Exception e) {
     ReportingUtils.logError(e);
   }
   return (String[]) propNames.toArray();
 }
Esempio n. 5
0
  public PropertyItem[] getProperties() {
    StrVector propNamesVect;
    Vector<PropertyItem> props = new Vector<PropertyItem>();
    try {
      core_.setAutoFocusDevice(devName_);
      propNamesVect = core_.getDevicePropertyNames(devName_);
      for (int i = 0; i < propNamesVect.size(); i++) {
        PropertyItem p = new PropertyItem();
        p.device = devName_;
        p.name = propNamesVect.get(i);
        p.value = core_.getProperty(devName_, p.name);
        p.readOnly = core_.isPropertyReadOnly(devName_, p.name);
        if (core_.hasPropertyLimits(devName_, p.name)) {
          p.lowerLimit = core_.getPropertyLowerLimit(devName_, p.name);
          p.upperLimit = core_.getPropertyUpperLimit(devName_, p.name);
        }

        StrVector vals = core_.getAllowedPropertyValues(devName_, p.name);
        p.allowed = new String[(int) vals.size()];
        for (int j = 0; j < vals.size(); j++) p.allowed[j] = vals.get(j);

        props.add(p);
      }
    } catch (Exception e) {
      ReportingUtils.logError(e);
    }

    return props.toArray(new PropertyItem[0]);
  }
Esempio n. 6
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;
 }
Esempio n. 7
0
  public PropertyItem getProperty(String name) throws MMException {
    try {
      if (core_.hasProperty(devName_, name)) {
        PropertyItem p = new PropertyItem();
        p.device = devName_;
        p.name = name;
        p.value = core_.getProperty(devName_, p.name);
        p.readOnly = core_.isPropertyReadOnly(devName_, p.name);
        if (core_.hasPropertyLimits(devName_, p.name)) {
          p.lowerLimit = core_.getPropertyLowerLimit(devName_, p.name);
          p.upperLimit = core_.getPropertyUpperLimit(devName_, p.name);
        }

        StrVector vals = core_.getAllowedPropertyValues(devName_, p.name);
        p.allowed = new String[(int) vals.size()];
        for (int j = 0; j < vals.size(); j++) p.allowed[j] = vals.get(j);
        return p;
      } else {
        throw new MMException("Unknown property: " + name);
      }
    } catch (Exception e) {
      throw new MMException(e.getMessage());
    }
  }