X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2FMCview%2FPDBCanvas.java;h=10b0659573efeace10c7ac52e77c29c8120e4c53;hb=ab0f35021e8e5dbbe1da52ad0e1991099525d269;hp=17db1a0b26059f5fce1386a0c44c5609f84ba94b;hpb=8893c2ac9824d4c566ae69c73d34889c5316b058;p=jalview.git diff --git a/src/MCview/PDBCanvas.java b/src/MCview/PDBCanvas.java index 17db1a0..10b0659 100755 --- a/src/MCview/PDBCanvas.java +++ b/src/MCview/PDBCanvas.java @@ -72,6 +72,9 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe PDBChain mainchain; Vector highlightRes; boolean pdbAction = false; + boolean seqColoursReady = false; + jalview.gui.FeatureRenderer fr; + Color backgroundColour = Color.black; public PDBCanvas(jalview.gui.SeqCanvas seqcanvas, Sequence seq) { @@ -198,6 +201,7 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe Vector visiblebonds; void setupBonds() { + seqColoursReady = false; // Sort the bonds by z coord visiblebonds = new Vector(); @@ -215,6 +219,7 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe } updateSeqColours(); + seqColoursReady = true; redrawneeded = true; repaint(); } @@ -369,7 +374,7 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe { super.paintComponent(g); - if(visiblebonds==null) + if(!seqColoursReady) { g.setColor(Color.black); g.setFont(new Font("Verdana", Font.BOLD, 14)); @@ -413,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); @@ -474,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; @@ -492,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); } } @@ -510,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); + } + + } + } @@ -663,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 + ""); @@ -715,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); } @@ -929,6 +956,8 @@ public class PDBCanvas extends JPanel implements MouseListener, MouseMotionListe Bond highlightBond1, highlightBond2; public void highlightRes(int ii) { + if( !seqColoursReady ) + return; if (highlightRes != null && highlightRes.contains((ii-1) + ""))