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

📄 block.java

📁 emboss的linux版本的源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/**********************************************************************  This library is free software; you can redistribute it and/or*  modify it under the terms of the GNU Library General Public*  License as published by the Free Software Foundation; either*  version 2 of the License, or (at your option) any later version.**  This library is distributed in the hope that it will be useful,*  but WITHOUT ANY WARRANTY; without even the implied warranty of*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU*  Library General Public License for more details.**  You should have received a copy of the GNU Library General Public*  License along with this library; if not, write to the*  Free Software Foundation, Inc., 59 Temple Place - Suite 330,*  Boston, MA  02111-1307, USA.**  @author: Copyright (C) Tim Carver*********************************************************************/package org.emboss.jemboss.draw;import org.emboss.jemboss.gui.form.TextFieldInt;import javax.swing.*;import java.awt.geom.AffineTransform;import java.awt.*;import java.util.Vector;import java.awt.datatransfer.*;import java.io.*;import java.awt.event.*;import javax.swing.event.*;public class Block extends JPanel                   implements Transferable{  private DNADraw current_dna;  private Vector marker;  private double angStart;  private double angEnd;  private double fracRadii = 1.d;  private Rectangle rect = new Rectangle();  final public static DataFlavor BLOCK =         new DataFlavor(Block.class, "Block");  static DataFlavor blockFlavors[] = { BLOCK };    public Block(Vector marker)  {    super();    setOpaque(false);    this.marker = marker;  }  public Block(Vector marker,                DNADraw current_dna)  {    this(marker);    this.current_dna = current_dna;    setPreferredSize(current_dna.getPreferredSize());  }  public Vector getMarker()  {    return marker;  }  protected void paintComponent(Graphics g)  {    super.paintComponent(g);    Graphics2D g2  = (Graphics2D)g;    draw(g2);  }  protected void draw(Graphics2D g2)  {    if(current_dna.isCircular())      drawCircular(g2);    else      drawLinear(g2);     }    protected String getLabel()  {    return (String)marker.elementAt(0);  }  protected int getStart()  {    return ((Integer)marker.elementAt(1)).intValue();  }   protected int getEnd()  {    return ((Integer)marker.elementAt(2)).intValue();  }  protected void showProperties(final JFrame f, final DNADraw draw,                                JButton delete)  {//  final JFrame f = new JFrame("Properties");//set up menu bar    JMenuBar menuBar = new JMenuBar();    JMenu fileMenu = new JMenu("File");    fileMenu.setMnemonic(KeyEvent.VK_F);    menuBar.add(fileMenu);                                                                                 JMenuItem closeMenu = new JMenuItem("Close");    closeMenu.setAccelerator(KeyStroke.getKeyStroke(              KeyEvent.VK_E, ActionEvent.CTRL_MASK));                                                                                 closeMenu.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        f.dispose();      }    });    fileMenu.add(closeMenu);//set up window    f.setJMenuBar(menuBar);    JPanel pane = (JPanel)f.getContentPane();    String markerLabel = (String)marker.elementAt(0);    int bstart = ((Integer)marker.elementAt(1)).intValue();    int bend   = ((Integer)marker.elementAt(2)).intValue();    Color colour = (Color)marker.elementAt(3);    float strokeSize  = ((Float)marker.elementAt(4)).floatValue();    boolean arrowHead = ((Boolean)marker.elementAt(5)).booleanValue();    boolean arrowTail = ((Boolean)marker.elementAt(6)).booleanValue();             Box bdown = Box.createVerticalBox();    pane.add(bdown);         bdown.add(Box.createVerticalStrut(4));    Dimension d = new Dimension(200,30);     Box bacross = Box.createHorizontalBox();     final JTextField annotation = new JTextField();    annotation.setPreferredSize(d);    annotation.setMaximumSize(d);    annotation.setText(markerLabel);    annotation.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        marker.setElementAt(annotation.getText(),0);        if(draw != null)          draw.repaint();      }    });    bacross.add(annotation);    bacross.add(new JLabel(" Label"));    bacross.add(Box.createHorizontalGlue());    bdown.add(bacross);    d = new Dimension(65,30);    bacross = Box.createHorizontalBox();      final TextFieldInt start = new TextFieldInt();    start.setPreferredSize(d);    start.setMaximumSize(d);    start.setValue(bstart);    start.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        marker.setElementAt(new Integer(start.getValue()),1);         if(draw != null)          draw.repaint();      }    });    bacross.add(start);     bacross.add(new JLabel(" Start"));    bacross.add(Box.createHorizontalGlue());    bdown.add(bacross);    bacross = Box.createHorizontalBox();    final TextFieldInt end = new TextFieldInt();    end.setPreferredSize(d);    end.setMaximumSize(d);    end.setValue(bend);    end.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        marker.setElementAt(new Integer(end.getValue()),2);        if(draw != null)          draw.repaint();      }    });    bacross.add(end);    bacross.add(new JLabel(" End"));    bacross.add(Box.createHorizontalGlue());    bdown.add(bacross);//Set up the dialog that the button brings up.    final JButton button = new JButton("");    button.setBackground(colour);    final JColorChooser colorChooser = new JColorChooser();    ActionListener okListener = new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        marker.setElementAt(colorChooser.getColor(),3);        button.setBackground(colorChooser.getColor());        if(draw != null)          draw.repaint();      }    };    final JDialog dialog = JColorChooser.createDialog(button,                                "Pick a Color",true,                                colorChooser, okListener,                                null);     //Here's the code that brings up the dialog.    button.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        dialog.show();      }    });    bacross = Box.createHorizontalBox();    bacross.add(button);    bacross.add(Box.createHorizontalGlue());    bdown.add(bacross);    bacross = Box.createHorizontalBox();    final JSlider slider = new JSlider(1,25,(int)strokeSize);    bacross.add(slider);    bacross.add(new JLabel(" Line width"));    bacross.add(Box.createHorizontalGlue());    slider.addChangeListener(new ChangeListener()    {      public void stateChanged(ChangeEvent e)      {        marker.setElementAt(new Float((float)slider.getValue()),4);        if(draw != null)          draw.repaint();      }    });    bacross.add(Box.createHorizontalGlue());    bdown.add(bacross);    bacross = Box.createHorizontalBox();    bacross.add(new JLabel("Arrow :"));    bacross.add(Box.createHorizontalGlue());    bdown.add(bacross);    bacross = Box.createHorizontalBox();    final JRadioButton head = new JRadioButton("Head");    final JRadioButton tail = new JRadioButton("Tail");    final JRadioButton none = new JRadioButton("None");    head.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        if(head.isSelected())        {          marker.setElementAt(new Boolean(true),5);             marker.setElementAt(new Boolean(false),6);        }        else        {          marker.setElementAt(new Boolean(false),5);          marker.setElementAt(new Boolean(true),6);        }        if(draw != null)          draw.repaint();      }    });    bacross.add(head);    tail.addActionListener(new ActionListener()    {      public void actionPerformed(ActionEvent e)      {        if(tail.isSelected())        {          marker.setElementAt(new Boolean(true),6);          marker.setElementAt(new Boolean(false),5);        }        else        {          marker.setElementAt(new Boolean(false),6);          marker.setElementAt(new Boolean(true),5);        }

⌨️ 快捷键说明

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