X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2FMCview%2FPDBCanvas.java;h=9805c357990bd8958128db09c423aa1d98c73a72;hb=c95df1d1e8746c6fa31b94c2bf8505f25a30c168;hp=6014455efd09eedd0a1e4345318ffb7506a415e7;hpb=c44b1974aea543db46790f6cb88f5ac0aae10a94;p=jalview.git diff --git a/src/MCview/PDBCanvas.java b/src/MCview/PDBCanvas.java index 6014455..9805c35 100755 --- a/src/MCview/PDBCanvas.java +++ b/src/MCview/PDBCanvas.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer -* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle +* Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -73,6 +73,8 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe Vector highlightRes; boolean pdbAction = false; boolean seqColoursReady = false; + jalview.gui.FeatureRenderer fr; + Color backgroundColour = Color.black; public PDBCanvas(jalview.gui.SeqCanvas seqcanvas, Sequence seq) { @@ -416,7 +418,7 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe public void drawAll(Graphics g, int width, int height) { - g.setColor(Color.black); + g.setColor(backgroundColour); g.fillRect(0, 0, width, height); drawScene(g); drawLabels(g); @@ -477,11 +479,20 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe void colourBySequence(PDBChain chain) { // System.out.println("colour by seq"); + boolean showFeatures = false; + if(seqcanvas.getViewport().getShowSequenceFeatures()) + { + showFeatures = true; + if (fr == null) + fr = new jalview.gui.FeatureRenderer(seqcanvas.getViewport()); + + fr.transferSettings( seqcanvas.getFeatureRenderer() ); + } + + Bond tmp; for (int i = 0; i < chain.bonds.size(); i++) { - Bond tmp = (Bond) chain.bonds.elementAt(i); - tmp.startCol = Color.lightGray; - tmp.endCol = Color.lightGray; + tmp = (Bond) chain.bonds.elementAt(i); if(chain!=mainchain) continue; @@ -495,11 +506,12 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe { tmp.startCol = seqcanvas.getSequenceRenderer(). getResidueBoxColour( sequence, index); + + if(showFeatures) + tmp.startCol = fr.findFeatureColour(tmp.startCol, sequence, index); + if(tmp.startCol==null) tmp.startCol = Color.white; - - tmp.startCol = seqcanvas.getFeatureRenderer(). - findFeatureColour(tmp.startCol, sequence, index); } } @@ -513,95 +525,118 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe { tmp.endCol = seqcanvas.getSequenceRenderer(). getResidueBoxColour( sequence, index); + + if(showFeatures) + tmp.endCol = fr.findFeatureColour(tmp.endCol, sequence, index); + if(tmp.endCol==null) tmp.endCol = Color.white; - tmp.endCol = seqcanvas.getFeatureRenderer(). - findFeatureColour(tmp.endCol, sequence, index); } } } } + Zsort zsort; public void drawScene(Graphics g) { - if (zbuffer) - { - Zsort.Zsort(visiblebonds); - } + if (zbuffer) + { + if (zsort == null) + zsort = new Zsort(); - Bond tmpBond=null; - for (int i = 0; i < visiblebonds.size(); i++) - { - tmpBond = (Bond) visiblebonds.elementAt(i); + zsort.Zsort(visiblebonds); + } - xstart = (int) (((tmpBond.start[0] - centre[0]) * scale) + - (getWidth() / 2)); - ystart = (int) (((tmpBond.start[1] - centre[1]) * scale) + - (getHeight() / 2)); + Bond tmpBond = null; + for (int i = 0; i < visiblebonds.size(); i++) + { + tmpBond = (Bond) visiblebonds.elementAt(i); - xend = (int) (((tmpBond.end[0] - centre[0]) * scale) + - (getWidth() / 2)); - yend = (int) (((tmpBond.end[1] - centre[1]) * scale) + - (getHeight() / 2)); + xstart = (int) ( ( (tmpBond.start[0] - centre[0]) * scale) + + (getWidth() / 2)); + ystart = (int) ( ( (tmpBond.start[1] - centre[1]) * scale) + + (getHeight() / 2)); - xmid = (xend + xstart) / 2; - ymid = (yend + ystart) / 2; + xend = (int) ( ( (tmpBond.end[0] - centre[0]) * scale) + + (getWidth() / 2)); + yend = (int) ( ( (tmpBond.end[1] - centre[1]) * scale) + + (getHeight() / 2)); - if (depthcue && !bymolecule) - { - if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) { - g.setColor(tmpBond.startCol.darker().darker()); - drawLine(g, xstart, ystart, xmid, ymid); - g.setColor(tmpBond.endCol.darker().darker()); - drawLine(g, xmid, ymid, xend, yend); - } else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) { - g.setColor(tmpBond.startCol.darker()); - drawLine(g, xstart, ystart, xmid, ymid); - - g.setColor(tmpBond.endCol.darker()); - drawLine(g, xmid, ymid, xend, yend); - } else { - g.setColor(tmpBond.startCol); - drawLine(g, xstart, ystart, xmid, ymid); + xmid = (xend + xstart) / 2; + ymid = (yend + ystart) / 2; + if (depthcue && !bymolecule) + { + if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) + { - g.setColor(tmpBond.endCol); - drawLine(g, xmid, ymid, xend, yend); - } - } else if (depthcue && bymolecule) { - if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) { - g.setColor(Color.green.darker().darker()); - drawLine(g, xstart, ystart, xend, yend); - } else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) { - g.setColor(Color.green.darker()); - drawLine(g, xstart, ystart, xend, yend); - } else { - g.setColor(Color.green); - drawLine(g, xstart, ystart, xend, yend); - } - } else if (!depthcue && !bymolecule) { - g.setColor(tmpBond.startCol); - drawLine(g, xstart, ystart, xmid, ymid); - g.setColor(tmpBond.endCol); - drawLine(g, xmid, ymid, xend, yend); - } else { - drawLine(g, xstart, ystart, xend, yend); - } + g.setColor(tmpBond.startCol.darker().darker()); + drawLine(g, xstart, ystart, xmid, ymid); + g.setColor(tmpBond.endCol.darker().darker()); + drawLine(g, xmid, ymid, xend, yend); - if(highlightBond1!=null && highlightBond1==tmpBond) - { - g.setColor(tmpBond.endCol.brighter().brighter().brighter().brighter()); - drawLine(g, xmid, ymid, xend, yend); - } + } + else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) + { + g.setColor(tmpBond.startCol.darker()); + drawLine(g, xstart, ystart, xmid, ymid); - if(highlightBond2!=null && highlightBond2==tmpBond) - { - g.setColor(tmpBond.startCol.brighter().brighter().brighter().brighter()); - drawLine(g, xstart, ystart, xmid, ymid); - } + g.setColor(tmpBond.endCol.darker()); + drawLine(g, xmid, ymid, xend, yend); + } + else + { + g.setColor(tmpBond.startCol); + drawLine(g, xstart, ystart, xmid, ymid); + + g.setColor(tmpBond.endCol); + drawLine(g, xmid, ymid, xend, yend); + } + } + else if (depthcue && bymolecule) + { + if (tmpBond.start[2] < (centre[2] - (maxwidth / 6))) + { + g.setColor(Color.green.darker().darker()); + drawLine(g, xstart, ystart, xend, yend); + } + else if (tmpBond.start[2] < (centre[2] + (maxwidth / 6))) + { + g.setColor(Color.green.darker()); + drawLine(g, xstart, ystart, xend, yend); + } + else + { + g.setColor(Color.green); + drawLine(g, xstart, ystart, xend, yend); + } + } + else if (!depthcue && !bymolecule) + { + g.setColor(tmpBond.startCol); + drawLine(g, xstart, ystart, xmid, ymid); + g.setColor(tmpBond.endCol); + drawLine(g, xmid, ymid, xend, yend); + } + else + { + drawLine(g, xstart, ystart, xend, yend); + } + if (highlightBond1 != null && highlightBond1 == tmpBond) + { + g.setColor(tmpBond.endCol.brighter().brighter().brighter().brighter()); + drawLine(g, xmid, ymid, xend, yend); } + if (highlightBond2 != null && highlightBond2 == tmpBond) + { + g.setColor(tmpBond.startCol.brighter().brighter().brighter().brighter()); + drawLine(g, xstart, ystart, xmid, ymid); + } + + } + } @@ -666,7 +701,7 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe if (highlightRes == null) highlightRes = new Vector(); - if (highlightRes.contains(fatom.alignmentMapping+"" + "")) + if (highlightRes.contains(fatom.alignmentMapping+"")) highlightRes.remove(fatom.alignmentMapping + ""); else highlightRes.add(fatom.alignmentMapping + ""); @@ -718,35 +753,24 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe void highlightSeqcanvas(int pos) { - int index = seqcanvas.getViewport().getAlignment().findIndex(sequence); - - int size = pos==-1?0:3; - - if(highlightRes!=null) - size += highlightRes.size()*3; - - int [] array = new int[size]; - int i=0; + SearchResults searchResults = new SearchResults(); if(highlightRes!=null) { - for (i = 0; i < highlightRes.size(); i++) + for (int i = 0; i < highlightRes.size(); i++) { int a = Integer.parseInt(highlightRes.elementAt( i).toString())+1; - array[i * 3] = index; - array[ (i * 3) + 1] = a; - array[ (i * 3) + 2] = a; + + searchResults.addResult(sequence, a, a); } } if(pos!=-1) { - array[i * 3] = index; - array[i * 3 + 1] = pos+1; - array[i * 3 + 2] = pos+1; + searchResults.addResult(sequence, pos+1, pos+1); } - seqcanvas.highlightSearchResults(array); + seqcanvas.highlightSearchResults(searchResults); }