From dea32f71ff7f8a80cc8494864b6605921d81fafa Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Wed, 16 Nov 2005 16:41:35 +0000 Subject: [PATCH] Highlight from alignment --- src/jalview/appletgui/CutAndPasteTransfer.java | 8 +- src/jalview/appletgui/SeqCanvas.java | 10 +-- src/jalview/appletgui/SeqPanel.java | 5 ++ src/jalview/appletgui/SequenceRenderer.java | 1 + src/jalview/gui/SeqCanvas.java | 17 ++-- src/jalview/gui/SeqPanel.java | 8 +- src/jalview/gui/SequenceRenderer.java | 100 ++++++++++-------------- 7 files changed, 72 insertions(+), 77 deletions(-) diff --git a/src/jalview/appletgui/CutAndPasteTransfer.java b/src/jalview/appletgui/CutAndPasteTransfer.java index c366409..0df34f2 100755 --- a/src/jalview/appletgui/CutAndPasteTransfer.java +++ b/src/jalview/appletgui/CutAndPasteTransfer.java @@ -84,7 +84,6 @@ public class CutAndPasteTransfer extends Panel +warning); textarea.setCaretPosition(text.length()); - return; } if(pdbImport) @@ -106,13 +105,14 @@ public class CutAndPasteTransfer extends Panel } } - setVisible(false); + ((Frame)this.getParent()).setVisible(false); } protected void cancel_actionPerformed(ActionEvent e) { - setVisible(false); + ((Frame)this.getParent()).setVisible(false); } + protected TextArea textarea = new TextArea(); Button ok = new Button(); Button cancel = new Button(); @@ -148,7 +148,7 @@ public class CutAndPasteTransfer extends Panel } void textarea_mousePressed(MouseEvent e) { - if (textarea.getText().equals("Paste your alignment file here")) { + if (textarea.getText().startsWith("Paste your")) { textarea.setText(""); } } diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index 33acb28..fc8bb5c 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -63,15 +63,15 @@ public class SeqCanvas return fr; } - MCview.AppletPDBCanvas pdbViewer; + MCview.AppletPDBCanvas pdbCanvas; public SequenceRenderer getSequenceRenderer() { return sr; } - public void setPDBViewer(MCview.AppletPDBCanvas pc) + public void setPDBCanvas(MCview.AppletPDBCanvas pc) { - pdbViewer = pc; + pdbCanvas = pc; } @@ -275,9 +275,9 @@ public class SeqCanvas g.drawImage(img, 0, 0, this); - if (pdbViewer != null) + if (pdbCanvas != null) { - pdbViewer.updateSeqColours(); + pdbCanvas.updateSeqColours(); } } diff --git a/src/jalview/appletgui/SeqPanel.java b/src/jalview/appletgui/SeqPanel.java index dec2b0a..7c524ad 100755 --- a/src/jalview/appletgui/SeqPanel.java +++ b/src/jalview/appletgui/SeqPanel.java @@ -290,6 +290,11 @@ public class SeqPanel } } + if(seqCanvas.pdbCanvas!=null && sequence==seqCanvas.pdbCanvas.sequence) + { + seqCanvas.pdbCanvas.highlightRes(sequence.findPosition(res)); + } + ap.alignFrame.statusBar.setText(text.toString()); // use aa to see if the mouse pointer is on a diff --git a/src/jalview/appletgui/SequenceRenderer.java b/src/jalview/appletgui/SequenceRenderer.java index d546634..b985cea 100755 --- a/src/jalview/appletgui/SequenceRenderer.java +++ b/src/jalview/appletgui/SequenceRenderer.java @@ -64,6 +64,7 @@ public class SequenceRenderer public Color findSequenceColour(SequenceI seq, int i) { + allGroups = av.alignment.findAllGroups(seq); drawBoxes(seq, i,i, 0, 0, 1,1); return resBoxColour; } diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index f86441a..97b9f08 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -65,7 +65,7 @@ public class SeqCanvas extends JComponent setBackground(Color.white); } - MCview.PDBCanvas pdbViewer; + MCview.PDBCanvas pdbCanvas; public SequenceRenderer getSequenceRenderer() { return sr; @@ -76,9 +76,9 @@ public class SeqCanvas extends JComponent return fr; } - public void setPDBViewer(MCview.PDBCanvas pc) + public void setPDBCanvas(MCview.PDBCanvas pc) { - pdbViewer = pc; + pdbCanvas = pc; } public AlignViewport getViewport() @@ -284,14 +284,16 @@ public class SeqCanvas extends JComponent sr.renderGaps(av.renderGaps); if ((img != null) && - (fastPaint || (getWidth() != g.getClipBounds().width) || - (getHeight() != g.getClipBounds().height))) + (fastPaint && getVisibleRect() != g.getClipBounds())) { g.drawImage(img, 0, 0, this); fastPaint = false; return; } + + + // this draws the whole of the alignment imgWidth = getWidth(); imgHeight = getHeight(); @@ -304,7 +306,6 @@ public class SeqCanvas extends JComponent return; } - img = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_INT_RGB); gg = (Graphics2D) img.getGraphics(); gg.setFont(av.getFont()); @@ -327,9 +328,9 @@ public class SeqCanvas extends JComponent g.drawImage(img, 0, 0, this); - if (pdbViewer != null) + if (pdbCanvas != null) { - pdbViewer.updateSeqColours(); + pdbCanvas.updateSeqColours(); } } diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 491b667..3209960 100755 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -357,6 +357,12 @@ public class SeqPanel extends JPanel return; } + if(seqCanvas.pdbCanvas!=null && sequence==seqCanvas.pdbCanvas.sequence) + { + seqCanvas.pdbCanvas.highlightRes(sequence.findPosition(res)); + } + + StringBuffer text = new StringBuffer("Sequence " + (seq + 1) + " ID: " + sequence.getName()); @@ -1003,7 +1009,7 @@ public class SeqPanel extends JPanel try { - Thread.sleep(75); + Thread.sleep(20); } catch (Exception ex) { diff --git a/src/jalview/gui/SequenceRenderer.java b/src/jalview/gui/SequenceRenderer.java index c431e7c..7070e5d 100755 --- a/src/jalview/gui/SequenceRenderer.java +++ b/src/jalview/gui/SequenceRenderer.java @@ -86,7 +86,7 @@ public class SequenceRenderer bi.getGraphics().setColor(initialCol); bi.getGraphics().fillRect(0, 0, 1, 1); - allGroups = null; + allGroups = av.alignment.findAllGroups(seq); graphics = bi.getGraphics(); drawBoxes(seq, i,i, 0, 0, 1,1); @@ -154,72 +154,59 @@ public class SequenceRenderer public void drawBoxes(SequenceI seq, int start, int end, int x1, int y1, int width, int height) { - int i = start; - int length = seq.getLength(); + int i = start; + int length = seq.getLength(); - int curStart = -1; - int curWidth = width; + int curStart = -1; + int curWidth = width; - Color tempColour = null; + Color tempColour = null; - while (i <= end) - { - resBoxColour = Color.white; + while (i <= end) + { + resBoxColour = Color.white; - if (i < length) + if (i < length) + { + if (inCurrentSequenceGroup(i)) { - if (inCurrentSequenceGroup(i)) + if (currentSequenceGroup.getDisplayBoxes()) { - if (currentSequenceGroup.getDisplayBoxes()) - { - getBoxColour(currentSequenceGroup.cs, seq, i); - } + getBoxColour(currentSequenceGroup.cs, seq, i); } - else if (av.getShowBoxes()) - { - getBoxColour(av.getGlobalColourScheme(), seq, i); - } - + } + else if (av.getShowBoxes()) + { + getBoxColour(av.getGlobalColourScheme(), seq, i); } - if (resBoxColour != tempColour) - { - if (tempColour != null) - { - int xxx = x1 + (int) (av.charWidth * (curStart - start)); - if (width != av.charWidth) - { - xxx = x1 + (int) (av.charWidth * (curStart - start)) / 3; - } - - - graphics.fillRect(xxx, y1, - curWidth, height); - } + } - graphics.setColor(resBoxColour); + if (resBoxColour != tempColour) + { + if (tempColour != null) + { + graphics.fillRect(x1 + (width * (curStart - start)), y1, + curWidth, height); + } - curStart = i; - curWidth = width; - tempColour = resBoxColour; - } - else - { - curWidth += width; - } + graphics.setColor(resBoxColour); - i++; - } + curStart = i; + curWidth = width; + tempColour = resBoxColour; + } + else + { + curWidth += width; + } - int xxx = x1 + (int) (av.charWidth * (curStart - start)); - if (width != av.charWidth) - { - xxx = x1 + (int) (av.charWidth * (curStart - start)) / 3; - } + i++; + } + graphics.fillRect(x1 + (width * (curStart - start)), y1, curWidth, + height); - graphics.fillRect(xxx, y1, curWidth, - height); } /** @@ -294,14 +281,9 @@ public class SequenceRenderer } charOffset = (width - fm.charWidth(s)) / 2; + graphics.drawString(String.valueOf(s), + charOffset + x1 + (int)(width * (i - start)), (y1 + height) - pady); - int xxx = charOffset + x1 + (int)(av.charWidth * (i - start)); - if(width != av.charWidth) - { - xxx = charOffset + x1 + (int)(av.charWidth * (i - start))/3; - } - - graphics.drawString(String.valueOf(s),xxx, (y1 + height) - pady); } } -- 1.7.10.2