Пример #1
0
 private boolean optionRNADisplay() {
   // les options d'affichages generales
   if (_type.equals("gaspin")) {
     _vp.getVARNAUI().UIToggleGaspinMode();
   } else if (_type.equals("backbone")) {
     _vp.getVARNAUI().UISetBackboneColor();
   } else if (_type.equals("bonds")) {
     Color c = JColorChooser.showDialog(_vp, "Choose new bonds color", _vp.getBackground());
     if (c != null) {
       _vp.setDefaultBPColor(c);
       _vp.repaint();
     }
   } else if (_type.equals("basecolorforBP")) {
     if (_source != null) {
       if (_source instanceof JCheckBoxMenuItem) {
         JCheckBoxMenuItem check = (JCheckBoxMenuItem) _source;
         _vp.setUseBaseColorsForBPs(check.getState());
         _vp.repaint();
       }
     }
   } else if (_type.equals("bpstyle")) {
     _vp.getVARNAUI().UISetBPStyle();
   } else if (_type.equals("specialbasecolored")) {
     _vp.getVARNAUI().UIToggleColorSpecialBases();
   } else if (_type.equals("showwarnings")) {
     _vp.getVARNAUI().UIToggleShowWarnings();
   } else if (_type.equals("dashbasecolored")) {
     _vp.getVARNAUI().UIToggleColorGapsBases();
   } else if (_type.equals("numPeriod")) {
     _vp.getVARNAUI().UISetNumPeriod();
   } else if (_type.equals("eachKind")) {
     if (_vp.getRNA().get_listeBases() != null) {
       _vp.getVARNAUI().UIBaseTypeColor();
     } else {
       _vp.emitWarning("No base");
     }
   } else if (_type.equals("eachCouple")) {
     if (_vp.getRNA().get_listeBases() != null && _vp.getRNA().get_listeBases().size() != 0) {
       _vp.getVARNAUI().UIBasePairTypeColor();
     } else {
       _vp.emitWarning("No base");
     }
   } else if (_type.equals("eachBase")) {
     if (_vp.getRNA().get_listeBases() != null && _vp.getRNA().get_listeBases().size() != 0) {
       _vp.getVARNAUI().UIBaseAllColor();
     } else {
       _vp.emitWarning("No base");
     }
   } else if (_type.equals("specialBasesColor")) {
     _vp.getVARNAUI().UIPickSpecialBasesColor();
   } else if (_type.equals("dashBasesColor")) {
     _vp.getVARNAUI().UIPickGapsBasesColor();
   } else return colorBases();
   return true;
 }
Пример #2
0
 private ArrayList<Integer> listSwitchType(String _type) {
   if (_type.equals("helix")) return _vp.getRNA().findHelix(_vp.getNearestBase());
   if (_type.equals("current")) {
     return _vp.getSelectionIndices();
   }
   if (_type.equals("allBases")) {
     return _vp.getRNA().findAll();
   }
   if (_type.equals("loop1")) {
     return _vp.getRNA().findLoopForward(_vp.getNearestBase());
   }
   if (_type.equals("loop2")) {
     return _vp.getRNA().findLoopBackward(_vp.getNearestBase());
   }
   if (_type.equals("stem")) return _vp.getRNA().findStem(_vp.getNearestBase());
   if (_type.equals("base")) {
     ArrayList<Integer> list = new ArrayList<Integer>();
     list.add(_vp.getNearestBase());
     return list;
   }
   if (_type.equals("basepair") || _type.equals("bpcolor") || _type.equals("bp")) {
     ArrayList<Integer> list = new ArrayList<Integer>();
     int i = _vp.getNearestBase();
     list.add(i);
     ModeleBase mb = _vp.getRNA().get_listeBases().get(i);
     int j = mb.getElementStructure();
     if (mb.getElementStructure() != -1) {
       list.add(i);
       list.add(j);
     }
     return list;
   }
   if (_type.equals("5'")) return _vp.getRNA().findNonPairedBaseGroup(_vp.getNearestBase());
   if (_type.equals("3'")) return _vp.getRNA().findNonPairedBaseGroup(_vp.getNearestBase());
   if (_type.equals("bulge")) return _vp.getRNA().findNonPairedBaseGroup(_vp.getNearestBase());
   if (_type.equals("all")) return _vp.getRNA().findAll();
   return new ArrayList<Integer>();
 }
Пример #3
0
 /**
  * Creates the menu listener
  *
  * @param _varnaPanel The VARNAPanel
  */
 public ControleurMenu(VARNAPanel _varnaPanel, VueMenu _vueMenu) {
   _vp = _varnaPanel;
   _vm = _vueMenu;
   _vp.getRNA().addVARNAListener(this);
 }
Пример #4
0
 private boolean colorBases() {
   // System.out.println(_type);
   ArrayList<Integer> listBase = new ArrayList<Integer>();
   String phrase = "Choose new " + _type;
   if (_color.equals("InnerColor")) {
     phrase += " inner color";
     Color c = JColorChooser.showDialog(_vp, phrase, VARNAConfig.BASE_INNER_COLOR_DEFAULT);
     if (c != null) {
       listBase = listSwitchType(_type);
       for (int i = 0; i < listBase.size(); i++) {
         _vp.getRNA().get_listeBases().get(listBase.get(i)).getStyleBase().setBaseInnerColor(c);
       }
       _vp.repaint();
     }
   } else if (_color.equals("OutlineColor")) {
     phrase += " outline color";
     Color c = JColorChooser.showDialog(_vp, phrase, VARNAConfig.BASE_OUTLINE_COLOR_DEFAULT);
     if (c != null) {
       listBase = listSwitchType(_type);
       for (int i = 0; i < listBase.size(); i++) {
         _vp.getRNA().get_listeBases().get(listBase.get(i)).getStyleBase().setBaseOutlineColor(c);
       }
       _vp.repaint();
     }
   } else if (_color.equals("NameColor")) {
     phrase += " name color";
     Color c = JColorChooser.showDialog(_vp, phrase, VARNAConfig.BASE_NAME_COLOR_DEFAULT);
     if (c != null) {
       listBase = listSwitchType(_type);
       for (int i = 0; i < listBase.size(); i++) {
         _vp.getRNA().get_listeBases().get(listBase.get(i)).getStyleBase().setBaseNameColor(c);
       }
       _vp.repaint();
     }
   } else if (_color.equals("NumberColor")) {
     phrase += " number color";
     Color c = JColorChooser.showDialog(_vp, phrase, VARNAConfig.BASE_NUMBER_COLOR_DEFAULT);
     if (c != null) {
       listBase = listSwitchType(_type);
       for (int i = 0; i < listBase.size(); i++) {
         _vp.getRNA().get_listeBases().get(listBase.get(i)).getStyleBase().setBaseNumberColor(c);
       }
       _vp.repaint();
     }
   } else if (_color.equals("BPColor")) {
     phrase += " base-pair color";
     Color c = JColorChooser.showDialog(_vp, phrase, VARNAConfig.BASE_NUMBER_COLOR_DEFAULT);
     if (c != null) {
       listBase = listSwitchType(_type);
       for (int i = 0; i < listBase.size(); i++) {
         for (ModeleBP msbp : _vp.getRNA().getBPsAt(listBase.get(i))) {
           if (msbp != null) {
             msbp.getStyle().setCustomColor(c);
           }
         }
       }
       _vp.repaint();
     }
   } else if (_color.equals("BPColor")) {
     phrase += " base-pair color";
     Color c = JColorChooser.showDialog(_vp, phrase, VARNAConfig.BASE_NUMBER_COLOR_DEFAULT);
     if (c != null) {
       listBase = listSwitchType(_type);
       for (int i = 0; i < listBase.size(); i++) {
         ModeleBase mb = _vp.getRNA().get_listeBases().get(listBase.get(i));
         if (mb.getElementStructure() != -1) {
           mb.getStyleBP().getStyle().setCustomColor(c);
         }
       }
       _vp.repaint();
     }
   } else if (_color.equals("BPThickness")) {
     listBase = listSwitchType(_type);
     // System.out.println(listBase.size());
     ArrayList<ModeleBP> styleBPs = new ArrayList<ModeleBP>();
     for (int i = 0; i < listBase.size(); i++) {
       ModeleBase mb = _vp.getRNA().get_listeBases().get(listBase.get(i));
       if (mb.getElementStructure() != -1) {
         styleBPs.add(mb.getStyleBP());
       }
     }
     VueBPThickness vbpt = new VueBPThickness(_vp, styleBPs);
     if (JOptionPane.showConfirmDialog(
             _vp, vbpt.getPanel(), "Set base pair(s) thickness", JOptionPane.OK_CANCEL_OPTION)
         != JOptionPane.OK_OPTION) {
       vbpt.restoreThicknesses();
       _vp.repaint();
     }
   } else return false;
   return true;
 }
Пример #5
0
  private boolean optionAnnotation() {
    if (!_type.contains("annotation")) return false;
    // a partir du menu principale (gestion des annotations)
    if (_type.equals("annotationsaddPosition")) {
      _vp.getVARNAUI()
          .UIAnnotationsAddPosition(
              _vp.getPopup().getSpawnPoint().x, _vp.getPopup().getSpawnPoint().y);
    } else if (_type.equals("annotationsaddBase")) {
      _vp.getVARNAUI()
          .UIAnnotationsAddBase(_vp.getPopup().getSpawnPoint().x, _vp.getPopup().getSpawnPoint().y);
    } else if (_type.equals("annotationsaddLoop")) {
      _vp.getVARNAUI()
          .UIAnnotationsAddLoop(_vp.getPopup().getSpawnPoint().x, _vp.getPopup().getSpawnPoint().y);
    } else if (_type.equals("annotationsaddChemProb")) {
      _vp.getVARNAUI()
          .UIAnnotationsAddChemProb(
              _vp.getPopup().getSpawnPoint().x, _vp.getPopup().getSpawnPoint().y);
    } else if (_type.equals("annotationsaddRegion")) {
      _vp.getVARNAUI()
          .UIAnnotationsAddRegion(
              _vp.getPopup().getSpawnPoint().x, _vp.getPopup().getSpawnPoint().y);
    } else if (_type.equals("annotationsaddHelix")) {
      _vp.getVARNAUI()
          .UIAnnotationsAddHelix(
              _vp.getPopup().getSpawnPoint().x, _vp.getPopup().getSpawnPoint().y);
    } else if (_type.equals("annotationsautohelices")) {
      _vp.getVARNAUI().UIAutoAnnotateHelices();
    } else if (_type.equals("annotationsautointerior")) {
      _vp.getVARNAUI().UIAutoAnnotateInteriorLoops();
    } else if (_type.equals("annotationsautoterminal")) {
      _vp.getVARNAUI().UIAutoAnnotateTerminalLoops();
    } else if (_type.equals("annotationsautohelices")) {
      _vp.getVARNAUI().UIAutoAnnotateHelices();
    } else if (_type.equals("annotationsremove")) {
      _vp.getVARNAUI().UIAnnotationsRemove();
    } else if (_type.equals("annotationsautoextremites")) {
      _vp.getVARNAUI().UIAutoAnnotateStrandEnds();
    } else if (_type.equals("annotationsedit")) {
      _vp.getVARNAUI().UIAnnotationsEdit();
      // a partir du menu selection (annotation la plus proche)
    } else if (_type.equals("Selectionannotationremove")) {
      _vp.getVARNAUI().UIAnnotationRemoveFromAnnotation(_vp.get_selectedAnnotation());
    } else if (_type.equals("Selectionannotationedit")) {
      _vp.getVARNAUI().UIAnnotationEditFromAnnotation(_vp.get_selectedAnnotation());

      // a partir d'une structure(base, loop, helix) dans l'arn
      // (annotation li� a la structure)
    } else if (_type.endsWith("annotationadd")
        || _type.contains("annotationremove")
        || _type.contains("annotationedit")) {
      try {
        TextAnnotation.AnchorType type = trouverAncrage();
        ArrayList<Integer> listeIndex = new ArrayList<Integer>();
        switch (type) {
          case BASE:
            listeIndex.add(_vp.getNearestBase());
          case LOOP:
            if (_type.startsWith("loop1"))
              listeIndex = _vp.getRNA().findLoopForward(_vp.getNearestBase());
            else if (_type.startsWith("loop2"))
              listeIndex = _vp.getRNA().findLoopBackward(_vp.getNearestBase());
            else listeIndex = _vp.getRNA().findLoop(_vp.getNearestBase());
            break;
          case HELIX:
            listeIndex = _vp.getRNA().findHelix(_vp.getNearestBase());
            break;
        }
        if (_type.endsWith("annotationadd")) {
          _vp.getVARNAUI().UIAnnotationAddFromStructure(type, listeIndex);
        } else if (_type.contains("annotationremove")) {
          _vp.getVARNAUI().UIAnnotationRemoveFromStructure(trouverAncrage(), listeIndex);
        } else if (_type.contains("annotationedit")) {
          _vp.getVARNAUI().UIAnnotationEditFromStructure(trouverAncrage(), listeIndex);
        }

      } catch (Exception e2) {
        e2.printStackTrace();
      }
    } else return false;
    return true;
  }