Exemple #1
0
 private void setProp(Ellipsoid e, int mode, Object value) {
   // "ax ce co de eq mo on op sc tr"
   //  0  1  2  3  4  5  6  7  8  9
   switch (mode) {
     case 0: // axes
       e.setTensor(
           ((Tensor) Interface.getUtil("Tensor", vwr, "script")).setFromAxes((V3[]) value));
       return;
     case 1: // center
       e.setCenter((P3) value);
       return;
     case 2: // color
       e.colix = C.getColixO(value);
       return;
     case 3: // delete
       simpleEllipsoids.remove(e.id);
       return;
     case 4: // equation
       e.setTensor(
           ((Tensor) Interface.getUtil("Tensor", vwr, "script"))
               .setFromThermalEquation((double[]) value, null));
       return;
     case 5: // modelindex
       e.tensor.modelIndex = ((Integer) value).intValue();
       return;
     case 6: // on
       e.isOn = ((Boolean) value).booleanValue();
       return;
     case 7: // options
       e.options = ((String) value).toLowerCase();
       return;
     case 8: // scale
       e.setScale(((Float) value).floatValue(), false);
       return;
     case 9: // translucency
       e.colix = C.getColixTranslucent3(e.colix, value.equals("translucent"), translucentLevel);
       return;
   }
   return;
 }
Exemple #2
0
  @Override
  public void setProperty(String propertyName, Object value, BS bs) {
    // System.out.println(propertyName + " " + value + " " + bs);
    if (propertyName == "thisID") {
      if (initEllipsoids(value) && ellipsoidSet.size() == 0) {
        String id = (String) value;
        Ellipsoid e = Ellipsoid.getEmptyEllipsoid(id, vwr.am.cmi);
        ellipsoidSet.addLast(e);
        simpleEllipsoids.put(id, e);
      }
      return;
    }

    if ("atoms" == propertyName) {
      selectedAtoms = (BS) value;
      return;
    }

    if (propertyName == "deleteModelAtoms") {
      int modelIndex = ((int[]) ((Object[]) value)[2])[0];
      Iterator<Ellipsoid> e = simpleEllipsoids.values().iterator();
      while (e.hasNext()) if (e.next().tensor.modelIndex == modelIndex) e.remove();
      e = atomEllipsoids.values().iterator();
      while (e.hasNext()) if (e.next().modelIndex == modelIndex) e.remove();
      ellipsoidSet.clear();
      return;
    }
    int mode = PROPERTY_MODES.indexOf((propertyName + "  ").substring(0, 2));
    if (ellipsoidSet.size() > 0) {
      if ("translucentLevel" == propertyName) {
        setPropS(propertyName, value, bs);
        return;
      }
      if (mode >= 0)
        for (int i = ellipsoidSet.size(); --i >= 0; ) setProp(ellipsoidSet.get(i), mode / 3, value);
      return;
    }

    if ("color" == propertyName) {
      short colix = C.getColixO(value);
      byte pid = PAL.pidOf(value);
      if (selectedAtoms != null) bs = selectedAtoms;
      for (Ellipsoid e : atomEllipsoids.values())
        if (e.tensor.type.equals(typeSelected) && e.tensor.isSelected(bs, -1)) {
          e.colix = getColixI(colix, pid, e.tensor.atomIndex1);
          e.pid = pid;
        }
      return;
    }

    if ("on" == propertyName) {
      boolean isOn = ((Boolean) value).booleanValue();
      if (selectedAtoms != null) bs = selectedAtoms;
      if (isOn) setSize(Integer.MAX_VALUE, bs);
      for (Ellipsoid e : atomEllipsoids.values()) {
        Tensor t = e.tensor;
        if ((t.type.equals(typeSelected) || typeSelected.equals(t.altType))
            && t.isSelected(bs, -1)) {
          e.isOn = isOn;
        }
      }
      return;
    }

    if ("options" == propertyName) {
      String options = ((String) value).toLowerCase().trim();
      if (options.length() == 0) options = null;
      if (selectedAtoms != null) bs = selectedAtoms;
      if (options != null) setSize(Integer.MAX_VALUE, bs);
      for (Ellipsoid e : atomEllipsoids.values())
        if (e.tensor.type.equals(typeSelected) && e.tensor.isSelected(bs, -1)) e.options = options;
      return;
    }

    if ("params" == propertyName) {
      Object[] data = (Object[]) value;
      data[2] = null; // Jmol does not allow setting sizes this way from PyMOL yet
      typeSelected = "0";
      setSize(50, bs);
      // onward...
    }

    if ("points" == propertyName) {
      // Object[] o = (Object[]) value;
      // setPoints((P3[]) o[1], (BS) o[2]);
      return;
    }

    if ("scale" == propertyName) {
      setSize((int) (((Float) value).floatValue() * 100), bs);
      return;
    }

    if ("select" == propertyName) {
      typeSelected = ((String) value).toLowerCase();
      return;
    }

    if ("translucency" == propertyName) {
      boolean isTranslucent = (value.equals("translucent"));
      for (Ellipsoid e : atomEllipsoids.values())
        if (e.tensor.type.equals(typeSelected) && e.tensor.isSelected(bs, -1))
          e.colix = C.getColixTranslucent3(e.colix, isTranslucent, translucentLevel);
      return;
    }
    setPropS(propertyName, value, bs);
  }