Exemplo n.º 1
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>();
 }
Exemplo n.º 2
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;
 }