Modifications for Applet PDB viewer
authoramwaterhouse <Andrew Waterhouse>
Mon, 14 Nov 2005 18:36:10 +0000 (18:36 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 14 Nov 2005 18:36:10 +0000 (18:36 +0000)
src/jalview/appletgui/APopupMenu.java
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/CutAndPasteTransfer.java
src/jalview/appletgui/MyGraphics.java
src/jalview/appletgui/SeqCanvas.java
src/jalview/appletgui/SequenceRenderer.java

index 0d1dad3..0435d25 100755 (executable)
@@ -54,7 +54,7 @@ public class APopupMenu
   CheckboxMenuItem showText = new CheckboxMenuItem();\r
   CheckboxMenuItem showColourText = new CheckboxMenuItem();\r
 \r
-  public APopupMenu(AlignmentPanel apanel, Sequence seq, Vector links)\r
+  public APopupMenu(AlignmentPanel apanel, final Sequence seq, Vector links)\r
   {\r
     ///////////////////////////////////////////////////////////\r
     // If this is activated from the sequence panel, the user may want to\r
@@ -111,9 +111,32 @@ public class APopupMenu
           linkMenu.add(item);\r
       }\r
       add(linkMenu);\r
+\r
+      item = new MenuItem("Show PDB Structure");\r
+      item.addActionListener(new java.awt.event.ActionListener()\r
+           {\r
+               public void actionPerformed(ActionEvent e)\r
+               {\r
+                  addPDB(seq);\r
+               }\r
+           });\r
+\r
+      add(item);\r
+\r
+\r
     }\r
   }\r
 \r
+  void addPDB(Sequence seq)\r
+  {\r
+    CutAndPasteTransfer cap = new CutAndPasteTransfer(true, ap.alignFrame.applet);\r
+    cap.setText("Paste your PDB file here.");\r
+    cap.setPDBImport(seq, ap.seqPanel.seqCanvas);\r
+    Frame frame = new Frame();\r
+    frame.add(cap);\r
+    jalview.bin.JalviewLite.addFrame(frame, "Paste PDB file ", 400, 300);\r
+  }\r
+\r
   private void jbInit()\r
       throws Exception\r
   {\r
@@ -467,26 +490,6 @@ public class APopupMenu
     refresh();\r
   }\r
 \r
-  protected void analyze_actionPerformed(ActionEvent e)\r
-  {\r
-    CutAndPasteTransfer cap = new CutAndPasteTransfer(false, ap.alignFrame.applet);\r
-    Frame frame = new Frame();\r
-    frame.add(cap);\r
-    jalview.bin.JalviewLite.addFrame(frame, "Analyze this - ", 400, 300);\r
-    SequenceGroup sg = getGroup();\r
-    StringBuffer sb = new StringBuffer();\r
-\r
-    for (int i = 0; i < sg.sequences.size(); i++)\r
-    {\r
-      Sequence tmp = (Sequence) sg.sequences.elementAt(i);\r
-      sb.append(tmp.getSequence(sg.getStartRes(), sg.getEndRes() + 1));\r
-      sb.append("\n");\r
-    }\r
-\r
-    sb.append("Something amazing will happen soon");\r
-    cap.setText(sb.toString());\r
-\r
-  }\r
 \r
   SequenceGroup getGroup()\r
   {\r
index 7c3ab49..692c2fd 100755 (executable)
@@ -35,7 +35,7 @@ public class AlignFrame
     extends GAlignFrame\r
 {\r
   final AlignmentPanel alignPanel;\r
-  final AlignViewport viewport;\r
+  public final AlignViewport viewport;\r
   int NEW_WINDOW_WIDTH = 700;\r
   int NEW_WINDOW_HEIGHT = 500;\r
   jalview.bin.JalviewLite applet;\r
@@ -249,7 +249,6 @@ public class AlignFrame
   public void closeMenuItem_actionPerformed(ActionEvent e)\r
   {\r
     PaintRefresher.components.remove(viewport.alignment);\r
-    dispose();\r
     if(PaintRefresher.components.size()==0 && applet==null)\r
       System.exit(0);\r
   }\r
index 6627e88..43ec65e 100755 (executable)
@@ -30,6 +30,11 @@ public class CutAndPasteTransfer
     extends GCutAndPasteTransfer\r
 {\r
   jalview.bin.JalviewLite applet;\r
+\r
+  boolean pdbImport = false;\r
+  Sequence seq;\r
+  SeqCanvas seqcanvas;\r
+\r
   public CutAndPasteTransfer(boolean forImport, jalview.bin.JalviewLite mainApplet)\r
   {\r
     super();\r
@@ -41,6 +46,14 @@ public class CutAndPasteTransfer
     }\r
   }\r
 \r
+  public void setPDBImport(Sequence seq, SeqCanvas seqcanvas)\r
+  {\r
+    this.seq = seq;\r
+    this.seqcanvas = seqcanvas;\r
+    pdbImport = true;\r
+  }\r
+\r
+\r
   public String getText()\r
   {\r
     return textarea.getText();\r
@@ -71,18 +84,24 @@ public class CutAndPasteTransfer
       return;\r
     }\r
 \r
-    SequenceI[] sequences = null;\r
-\r
-    String format = IdentifyFile.Identify(text, "Paste");\r
-    sequences = new AppletFormatAdapter().readFile(text, "Paste", format);\r
-\r
-    if (sequences != null)\r
+    if(pdbImport)\r
     {\r
-      AlignFrame af = new AlignFrame(new Alignment(sequences), applet,\r
-                                     "Cut & Paste input - " + format);\r
-      af.statusBar.setText("Successfully pasted alignment file");\r
+      new MCview.AppletPDBViewer(text, seq, seqcanvas);\r
     }\r
+    else\r
+    {\r
+      SequenceI[] sequences = null;\r
 \r
+      String format = IdentifyFile.Identify(text, "Paste");\r
+      sequences = new AppletFormatAdapter().readFile(text, "Paste", format);\r
+\r
+      if (sequences != null)\r
+      {\r
+        AlignFrame af = new AlignFrame(new Alignment(sequences), applet,\r
+                                       "Cut & Paste input - " + format);\r
+        af.statusBar.setText("Successfully pasted alignment file");\r
+      }\r
+    }\r
     Frame frame = (Frame)this.getParent();\r
     frame.setVisible(false);\r
   }\r
index 835aff2..bcad0fb 100755 (executable)
@@ -5,17 +5,17 @@ public class MyGraphics
 {\r
   public static void AntiAlias(Graphics g)\r
   {\r
-    Graphics2D g2 = (Graphics2D)g;\r
-    g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING,\r
-            RenderingHints.VALUE_ANTIALIAS_ON);\r
+  //  Graphics2D g2 = (Graphics2D)g;\r
+   // g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING,\r
+   //         RenderingHints.VALUE_ANTIALIAS_ON);\r
   }\r
 \r
 \r
   public static void SetTransparency(Graphics g, float transparency)\r
     {\r
-      Graphics2D g2 = (Graphics2D) g;\r
-      g2.setComposite(\r
-          AlphaComposite.getInstance(\r
-              AlphaComposite.SRC_OVER, transparency));\r
+    //  Graphics2D g2 = (Graphics2D) g;\r
+     // g2.setComposite(\r
+      //    AlphaComposite.getInstance(\r
+      //        AlphaComposite.SRC_OVER, transparency));\r
     }\r
 }\r
index ddc32e8..8984d62 100755 (executable)
@@ -51,7 +51,11 @@ public class SeqCanvas
     fr = new FeatureRenderer(av);\r
     sr = new SequenceRenderer(av);\r
     PaintRefresher.Register(this, av.alignment);\r
+  }\r
 \r
+  public AlignViewport getViewport()\r
+  {\r
+    return av;\r
   }\r
 \r
   public FeatureRenderer getFeatureRenderer()\r
@@ -59,6 +63,18 @@ public class SeqCanvas
     return fr;\r
   }\r
 \r
+  MCview.AppletPDBCanvas pdbViewer;\r
+  public SequenceRenderer getSequenceRenderer()\r
+  {\r
+    return sr;\r
+  }\r
+\r
+  public void setPDBViewer(MCview.AppletPDBCanvas pc)\r
+  {\r
+    pdbViewer = pc;\r
+  }\r
+\r
+\r
   void drawNorthScale(Graphics g, int startx, int endx, int ypos)\r
   {\r
     int scalestartx = startx - startx % 10 + 10;\r
@@ -263,6 +279,10 @@ public class SeqCanvas
 \r
     g.drawImage(img, 0, 0, this);\r
 \r
+    if (pdbViewer != null)\r
+    {\r
+      pdbViewer.updateSeqColours();\r
+    }\r
   }\r
 \r
   int LABEL_WEST, LABEL_EAST;\r
index c413588..d546634 100755 (executable)
@@ -62,6 +62,12 @@ public class SequenceRenderer
     }\r
   }\r
 \r
+  public Color findSequenceColour(SequenceI seq, int i)\r
+  {\r
+    drawBoxes(seq, i,i, 0, 0, 1,1);\r
+    return resBoxColour;\r
+  }\r
+\r
   public void drawSequence(Graphics g, SequenceI seq, SequenceGroup[] sg,\r
                            int start, int end, int x1, int y1, int width,\r
                            int height)\r