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