Example #1
0
  public VueBPType(VARNAPanel vp, ModeleBP msbp) {
    _vp = vp;
    _msbp = msbp;

    ModeleBP.Edge[] edges = ModeleBP.Edge.values();
    ModeleBP.Edge bck = msbp.getEdgePartner5();
    _edge5 = new JComboBox(edges);
    for (int i = 0; i < edges.length; i++) {
      if (edges[i] == bck) _edge5.setSelectedIndex(i);
    }

    bck = msbp.getEdgePartner3();
    _edge3 = new JComboBox(edges);
    for (int i = 0; i < edges.length; i++) {
      if (edges[i] == bck) _edge3.setSelectedIndex(i);
    }

    ModeleBP.Stericity[] sters = ModeleBP.Stericity.values();
    ModeleBP.Stericity bcks = msbp.getStericity();
    _stericity = new JComboBox(sters);
    for (int i = 0; i < sters.length; i++) {
      if (sters[i] == bcks) _stericity.setSelectedIndex(i);
    }

    _edge5.addActionListener(this);
    _edge3.addActionListener(this);
    _stericity.addActionListener(this);

    panel = new JPanel();
    panel.setLayout(new FlowLayout(FlowLayout.LEFT));

    JLabel label5 = new JLabel("5' edge: ");
    JLabel label3 = new JLabel("3' edge: ");
    JLabel labelS = new JLabel("Stericity: ");

    panel.add(label5);
    panel.add(_edge5);
    panel.add(label3);
    panel.add(_edge3);
    panel.add(labelS);
    panel.add(_stericity);
  }
Example #2
0
 public void actionPerformed(ActionEvent e) {
   _msbp.setEdge5(getEdge5());
   _msbp.setEdge3(getEdge3());
   _msbp.setStericity(getStericity());
   _vp.repaint();
 }
 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;
 }