⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dnadraw.java

📁 emboss的linux版本的源代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
           current_dna = new DNADraw(block,restrictionEnzyme,                                  lineAttr,0,100,100);        jsp.setViewportView(current_dna);      }    });    fileMenu.add(openMenu);    fileMenu.add(new JSeparator()); // print    JMenu printMenu = new JMenu("Print");    fileMenu.add(printMenu);    JMenuItem print = new JMenuItem("Print postscript");    print.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        doPrintActions();      }    });    printMenu.add(print);    JMenuItem printImage = new JMenuItem("Print png/jpeg Image...");    printImage.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        PrintDNAImage pdnai = new PrintDNAImage(current_dna);        pdnai.print();      }    });    printMenu.add(printImage);// print preview    JMenuItem printPreview = new JMenuItem("Print Preview...");    printPreview.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        PrintDNAImage pdnai = new PrintDNAImage(current_dna);        pdnai.printPreview();      }    });    fileMenu.add(printPreview);    fileMenu.add(new JSeparator());    JMenuItem fileMenuExit = new JMenuItem("Exit");    fileMenuExit.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        if(!close)          System.exit(0);        else        {          mainFrame.setVisible(false);          mainFrame.dispose();        }      }    });    fileMenu.add(fileMenuExit);// view menu    JMenu viewMenu = new JMenu("View");    menuBar.add(viewMenu);      JMenuItem zoomIn = new JMenuItem("Zoom In");    zoomIn.setAccelerator(KeyStroke.getKeyStroke(                    KeyEvent.VK_I, ActionEvent.CTRL_MASK));    zoomIn.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        zoomIn();      }    });    viewMenu.add(zoomIn);    JMenuItem zoomOut = new JMenuItem("Zoom Out");    zoomOut.setAccelerator(KeyStroke.getKeyStroke(                    KeyEvent.VK_O, ActionEvent.CTRL_MASK));    zoomOut.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        zoomOut();      }    });    viewMenu.add(zoomOut);// options menu    JMenu optionMenu = new JMenu("Options");    menuBar.add(optionMenu);    JMenuItem wizard = new JMenuItem("DNA Wizard");    wizard.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {           Wizard wiz = new Wizard(current_dna);        current_dna = wiz.getDNADraw();        jsp.setViewportView(current_dna);      }    });    optionMenu.add(wizard);    optionMenu.add(new JSeparator());    JMenuItem line = new JMenuItem("DNA attributes");    line.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        JFrame f = new JFrame("DNA Attributes");        LineAttribute la = new LineAttribute(current_dna);        JScrollPane laScroll = new JScrollPane(la);        JPanel laPane = (JPanel)f.getContentPane();        laPane.add(laScroll,BorderLayout.CENTER);        f.setJMenuBar(la.createMenuBar(f));        f.pack();        f.setVisible(true);      }    });    optionMenu.add(line);        JMenuItem tickMarks = new JMenuItem("Tick marks");    tickMarks.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        JFrame f = new JFrame("Tick Marks");        Ticks tk = new Ticks(current_dna,true);        JScrollPane tkScroll = new JScrollPane(tk);        JPanel tkPane = (JPanel)f.getContentPane();        tkPane.add(tkScroll,BorderLayout.CENTER);        f.setJMenuBar(tk.createMenuBar(f));        f.pack();        f.setVisible(true);      }    });    optionMenu.add(tickMarks);    JMenuItem gmarker = new JMenuItem("Genetic Features");    gmarker.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        JFrame f = new JFrame("Genetic Features");        GeneticMarker gm = new GeneticMarker(current_dna,                                             block);        JScrollPane gmScroll = new JScrollPane(gm);        JPanel gmPane = (JPanel)f.getContentPane();        gmPane.add(gmScroll,BorderLayout.CENTER);        f.setJMenuBar(gm.createMenuBar(f));        f.pack();        f.setVisible(true);      }    });    optionMenu.add(gmarker);    JMenuItem reSites = new JMenuItem("Restriction Enzyme");    reSites.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        JFrame f = new JFrame("Restriction Enzyme");        RestrictionEnzyme re = new RestrictionEnzyme(current_dna,                                              restrictionEnzyme);        JScrollPane reScroll = new JScrollPane(re);        JPanel rePane = (JPanel)f.getContentPane();        rePane.add(reScroll,BorderLayout.CENTER);        f.setJMenuBar(re.createMenuBar(f));        f.pack();        f.setVisible(true);      }    });    optionMenu.add(reSites);// help manu    JMenu helpMenu = new JMenu("Help");    menuBar.add(helpMenu);       JMenuItem aboutMenu = new JMenuItem("About");    helpMenu.add(aboutMenu);    aboutMenu.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        ClassLoader cl = this.getClass().getClassLoader();        try        {          URL inURL = cl.getResource("resources/readmeDNADraw.html");          new Browser(inURL,"resources/readmeAlign.html");        }        catch (Exception ex)        {          JOptionPane.showMessageDialog(null,                              "Jemboss Alignment Viewer Guide not found!",                              "Error", JOptionPane.ERROR_MESSAGE);        }      }    });    return menuBar;  }    public void setCloseAndDispose(boolean close, JFrame mainFrame)  {    this.mainFrame = mainFrame;    this.close = close;  }  protected Vector getGeneticMarker()  {    return block;  }  protected Vector getRestrictionEnzyme()  {    return restrictionEnzyme;  }  protected int getStart()  {    return ((Integer)lineAttr.get("start")).intValue();  }   protected int getEnd()  {    return ((Integer)lineAttr.get("end")).intValue();  }    protected void setStart(int start)  {    lineAttr.put("start",new Integer(start));    calculateTickPosistions();  }  protected void setEnd(int end)  {    lineAttr.put("end",new Integer(end));    calculateTickPosistions();  }////////////////////// DRAG AND DROP////////////////////// drag source  public void dragGestureRecognized(DragGestureEvent e)  {    // ignore if mouse popup trigger    InputEvent ie = e.getTriggerEvent();    if(ie instanceof MouseEvent)      if(((MouseEvent)ie).isPopupTrigger())        return;    Point loc = e.getDragOrigin();    Component c = getComponentAt(loc);     if(c instanceof Block)    {//    System.out.println("BLOCK DRAG GESTURE");          for(int i=0; i<getComponentCount(); i++)      {        if(getComponent(i) instanceof Block)        {          Block drawBlock = (Block)getComponent(i);          if(drawBlock.isOverMe(loc.x,loc.y))             e.startDrag(DragSource.DefaultCopyDrop,  // cursor                   (Transferable)drawBlock,           // transferable data                   this);                             // drag source listener        }      }    }  }  public void dragDropEnd(DragSourceDropEvent e) {}  public void dragEnter(DragSourceDragEvent e) {}  public void dragExit(DragSourceEvent e) {}  public void dragOver(DragSourceDragEvent e) {}  public void dropActionChanged(DragSourceDragEvent e) {}// drop sink  public void dragEnter(DropTargetDragEvent e)  {    if(e.isDataFlavorSupported(Block.BLOCK))      e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);  }  public void drop(DropTargetDropEvent e)  {    Transferable t = e.getTransferable();    if(t.isDataFlavorSupported(Block.BLOCK))    {      try      {        Point loc = e.getLocation();        Block drawBlock = (Block)t.getTransferData(Block.BLOCK);                for(int i=0; i<getComponentCount(); i++)          if(getComponent(i) instanceof Block)          {            Block c = (Block)getComponent(i);            if( c.getLabel().equals(drawBlock.getLabel()) &&                c.getStart() == drawBlock.getStart() &&                c.getEnd() == drawBlock.getEnd() )              c.setBlockLocation(loc.x,loc.y);          }      }      catch(Exception ufe){}     }  }  public void dragOver(DropTargetDragEvent e)  {  }  public void dropActionChanged(DropTargetDragEvent e) {}  public void dragExit(DropTargetEvent e){}  public static void main(String arg[])  {    Wizard wiz = new Wizard(null);    DNADraw dna = wiz.getDNADraw();    JFrame f = new JFrame("DNA Viewer");    Dimension d = f.getToolkit().getScreenSize();    Vector minTicks = new Vector();    minTicks.add(new Integer(1200));    minTicks.add(new Integer(1600));    minTicks.add(new Integer(2000));    minTicks.add(new Integer(2500));    minTicks.add(new Integer(3000));    minTicks.add(new Integer(3500));    minTicks.add(new Integer(4070));    minTicks.add(new Integer(4500));    minTicks.add(new Integer(5070));    Vector majTicks = new Vector();    Vector marker = new Vector();    Vector block = new Vector();    marker.add(new String("CDS"));    marker.add(new Integer(1200));    marker.add(new Integer(1600));    marker.add(Color.red);    marker.add(new Float(10.0f));    marker.add(new Boolean(false));    marker.add(new Boolean(true));    block.add(marker);    Vector restrictionEnzyme = new Vector();     Vector re = new Vector();    re.add(new String("EcoR1"));    re.add(new Integer(2555));    re.add(Color.blue);    restrictionEnzyme.add(re);    re = new Vector();    re.add(new String("EcoR1"));    re.add(new Integer(3444));    re.add(Color.blue);    restrictionEnzyme.add(re);      if(dna == null)      dna = new DNADraw(minTicks,majTicks,block,restrictionEnzyme);    jsp = new JScrollPane(dna);    jsp.getViewport().setBackground(Color.white);    f.getContentPane().add(jsp);    f.setJMenuBar(dna.createMenuBar());        f.pack();    f.setLocation(((int)d.getWidth()-f.getWidth())/4,                  ((int)d.getHeight()-f.getHeight())/2);    f.setVisible(true);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -