allows deletion of chars, font chooser added
authoramwaterhouse <Andrew Waterhouse>
Wed, 9 Mar 2005 18:36:17 +0000 (18:36 +0000)
committeramwaterhouse <Andrew Waterhouse>
Wed, 9 Mar 2005 18:36:17 +0000 (18:36 +0000)
src/jalview/gui/AlignFrame.java

index 22c48bc..9566bb5 100755 (executable)
@@ -36,8 +36,6 @@ public class AlignFrame extends GAlignFrame
     viewport = new AlignViewport(al,true,true,true,false);\r
     alignPanel = new AlignmentPanel(this, viewport);\r
     getContentPane().add(alignPanel, java.awt.BorderLayout.CENTER);\r
-    fontNameMenuItem.setText(viewport.getFont().getName());\r
-    fontSizeMenuItem.setText(viewport.getFont().getSize()+"");\r
 \r
     addInternalFrameListener(new InternalFrameAdapter()\r
    {\r
@@ -350,8 +348,18 @@ public class AlignFrame extends GAlignFrame
 \r
      SequenceGroup sg = viewport.getRubberbandGroup();\r
      for (int i=0;i < sg.sequences.size(); i++)\r
-             viewport.getAlignment().deleteSequence(sg.getSequenceAt(i));\r
+     {\r
+       SequenceI seq = sg.getSequenceAt(i);\r
+       int index = viewport.getAlignment().findIndex(seq);\r
+       seq.deleteChars(sg.getStartRes(), sg.getEndRes()+1);\r
+\r
+       if(seq.getSequence().length()<1)\r
+          viewport.getAlignment().deleteSequence(seq);\r
+      else\r
+          viewport.getAlignment().getSequences().setElementAt(seq, index);\r
+     }\r
 \r
+     viewport.setRubberbandGroup(null);\r
      viewport.alignment.deleteGroup(sg);\r
      viewport.resetSeqLimits( alignPanel.seqPanel.seqCanvas.getHeight());\r
      if(viewport.getAlignment().getHeight()<1)\r
@@ -511,55 +519,15 @@ public class AlignFrame extends GAlignFrame
   }\r
 \r
 \r
-\r
-  public void fontNameMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    String fonts[] = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();\r
-\r
-\r
-    String selection = JOptionPane.showInternalInputDialog(this,\r
-                                "Select font",\r
-                                "Font selection",\r
-                                JOptionPane.QUESTION_MESSAGE,\r
-                                null,fonts\r
-                                ,fontNameMenuItem.getText()).toString();\r
-    if(selection!=null)\r
-    {\r
-       fontNameMenuItem.setText(selection);\r
-       SetFont();\r
-     }\r
-\r
-  }\r
-\r
-  public void fontSizeMenuItem_actionPerformed(ActionEvent e)\r
-  {\r
-    String selection = JOptionPane.showInternalInputDialog(this,\r
-                                "Select font size",\r
-                                "Font size",\r
-                                JOptionPane.QUESTION_MESSAGE,\r
-                                null, new String[]{"1","2","4","6","8","10","12","14","16","18","20"}\r
-                                ,fontSizeMenuItem.getText()).toString();\r
-    if(selection!=null)\r
-     {\r
-       fontSizeMenuItem.setText(selection);\r
-       SetFont();\r
-     }\r
-  }\r
-\r
-  public void fontStyleMenuItem_actionPerformed(ActionEvent e)\r
+  public void font_actionPerformed(ActionEvent e)\r
   {\r
-    String selection = JOptionPane.showInternalInputDialog(this,\r
-                                "Select font style",\r
-                                "Font style",\r
-                                JOptionPane.QUESTION_MESSAGE,\r
-                                null, new String[]{"plain", "bold", "italic"}\r
-                                ,fontStyleMenuItem.getText()).toString();\r
-    if(selection!=null)\r
-    {\r
-      fontStyleMenuItem.setText(selection);\r
-      SetFont();\r
-    }\r
-\r
+    JOptionPane op = new JOptionPane();\r
+    JInternalFrame frame = op.createInternalFrame(this, "Change Font");\r
+    FontChooser fc = new FontChooser( alignPanel );\r
+    frame.setClosable(true);\r
+    frame.setContentPane(fc);\r
+    frame.setSize(480, 100);\r
+    frame.setVisible(true);\r
   }\r
 \r
   protected void colourTextMenuItem_actionPerformed(ActionEvent e)\r
@@ -568,21 +536,6 @@ public class AlignFrame extends GAlignFrame
       alignPanel.RefreshPanels();\r
   }\r
 \r
-  void SetFont()\r
-  {\r
-      int style = java.awt.Font.PLAIN;\r
-      if(fontStyleMenuItem.getText().equals("bold"))\r
-        style = java.awt.Font.BOLD;\r
-      else if(fontStyleMenuItem.getText().equals("italic"))\r
-        style = java.awt.Font.ITALIC;\r
-\r
-      viewport.setFont(new java.awt.Font(fontNameMenuItem.getText(),\r
-                                           style,\r
-                                           Integer.parseInt(fontSizeMenuItem.getText())));\r
-      alignPanel.RefreshPanels();\r
-\r
-  }\r
-\r
   protected void wrapMenuItem_actionPerformed(ActionEvent e)\r
   {\r
     viewport.setWrapAlignment( wrapMenuItem.isSelected() );\r