X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FOverviewPanel.java;h=714eec688ce9f2a27463b8b4ee7a25c071c7e934;hb=3bff9f93376444b36ca6b69d30193e10ea3c07ab;hp=635e4550591766e076fb979312246ccb701981fe;hpb=2ffe2deedb1527c067060646055bddd18d41d367;p=jalview.git diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index 635e455..714eec6 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -49,7 +49,8 @@ public class OverviewPanel extends JPanel implements Runnable // Can set different properties in this seqCanvas than // main visible SeqCanvas - SeqCanvas overviewSeq; + SequenceRenderer sr; + FeatureRenderer fr; /** * Creates a new OverviewPanel object. @@ -62,14 +63,15 @@ public class OverviewPanel extends JPanel implements Runnable this.ap = ap; setLayout(null); - overviewSeq = new SeqCanvas(av); - overviewSeq.isOverview = true; - overviewSeq.sr.renderGaps = false; + sr = new SequenceRenderer(av); + sr.renderGaps = false; + sr.forOverview = true; + fr = new FeatureRenderer(av); // scale the initial size of overviewpanel to shape of alignment float initialScale = (float) av.alignment.getWidth() / (float) av.alignment.getHeight(); - if(av.vconsensus==null) + if(av.conservation==null) graphHeight = 0; @@ -109,8 +111,12 @@ public class OverviewPanel extends JPanel implements Runnable { public void mouseDragged(MouseEvent evt) { - if(!av.wrapAlignment) - doMouseDragged(evt); + if (!av.wrapAlignment) + { + boxX = evt.getX(); + boxY = evt.getY(); + checkValid(); + } } }); @@ -119,63 +125,17 @@ public class OverviewPanel extends JPanel implements Runnable public void mousePressed(MouseEvent evt) { if(!av.wrapAlignment) - doMousePressed(evt); - } - - public void mouseReleased(MouseEvent evt) - { - if(!av.wrapAlignment) - doMouseReleased(evt); + { + boxX = evt.getX(); + boxY = evt.getY(); + checkValid(); + } } }); updateOverviewImage(); } - /** - * DOCUMENT ME! - * - * @param evt DOCUMENT ME! - */ - public void doMousePressed(MouseEvent evt) - { - boxX = evt.getX(); - boxY = evt.getY(); - - checkValid(); - repaint(); - } - - /** - * DOCUMENT ME! - * - * @param evt DOCUMENT ME! - */ - public void doMouseReleased(MouseEvent evt) - { - boxX = evt.getX(); - boxY = evt.getY(); - checkValid(); - - ap.setScrollValues((int) (boxX / scalew / av.getCharWidth()), - (int) (boxY / scaleh / av.getCharHeight())); - } - - /** - * DOCUMENT ME! - * - * @param evt DOCUMENT ME! - */ - public void doMouseDragged(MouseEvent evt) - { - boxX = evt.getX(); - boxY = evt.getY(); - checkValid(); - - ap.setScrollValues( (int) (boxX / scalew / av.getCharWidth()), - (int) (boxY / scaleh / av.getCharHeight())); - repaint(); - } /** * DOCUMENT ME! @@ -199,8 +159,35 @@ public class OverviewPanel extends JPanel implements Runnable if (boxX > (width - boxWidth)) { - boxX = width - boxWidth; + if(av.hasHiddenColumns) + { + //Try smallest possible box + boxWidth = (int) ( (av.endRes - av.startRes + 1) * + av.getCharWidth() * scalew); + } + boxX = width - boxWidth; + } + + int col = (int) (boxX / scalew / av.getCharWidth()); + int row = (int) (boxY / scaleh / av.getCharHeight()); + + if (av.hasHiddenColumns) + { + if (!av.getColumnSelection().isVisible(col)) + { + return; + } + + col = av.getColumnSelection().findColumnPosition(col); } + + if( av.hasHiddenRows ) + { + row = av.alignment.getHiddenSequences().findIndexWithoutHiddenSeqs(row); + } + + ap.setScrollValues( col, row ); + } /** @@ -223,7 +210,6 @@ public class OverviewPanel extends JPanel implements Runnable } setPreferredSize(new Dimension(width, sequencesHeight + graphHeight)); - setBoxPosition(); Thread thread = new Thread(this); thread.start(); @@ -241,8 +227,14 @@ public class OverviewPanel extends JPanel implements Runnable { miniMe = null; + if (av.showSequenceFeatures) + { + fr.transferSettings( ap.seqPanel.seqCanvas.getFeatureRenderer() ); + } + int alwidth = av.alignment.getWidth(); - int alheight = av.alignment.getHeight(); + int alheight = av.alignment.getHeight() + +av.alignment.getHiddenSequences().getSize(); setPreferredSize(new Dimension(width, sequencesHeight + graphHeight)); @@ -257,36 +249,112 @@ public class OverviewPanel extends JPanel implements Runnable Graphics mg = miniMe.getGraphics(); + mg.setColor(Color.orange); + mg.fillRect(0,0,width, miniMe.getHeight()); float sampleCol = (float) alwidth / (float) width; float sampleRow = (float) alheight / (float) sequencesHeight; - for (int col = 0; col < width; col++) + int lastcol=-1, lastrow=-1; + int color = Color.white.getRGB(); + int row, col; + jalview.datamodel.SequenceI seq; + boolean hiddenRow = false; + for (row = 0; row < sequencesHeight; row++) { - for (int row = 0; row < sequencesHeight; row++) + if((int)(row*sampleRow)==lastrow) { - overviewSeq.drawPanel(mg, - (int) (col * sampleCol), - (int) (col * sampleCol), - (int) (row * sampleRow), - (int) (row * sampleRow) + 1, - (int) (col * sampleCol), - (int) (row * sampleRow), 0); - mg.translate(0, 1); - - if (av.conservation != null) + //No need to recalculate the colours, + //Just copy from the row above + for (col = 0; col < width; col++) + { + miniMe.setRGB(col, row, miniMe.getRGB(col, row-1)); + } + continue; + } + + lastrow = (int)(row*sampleRow); + + hiddenRow = false; + if (av.hasHiddenRows) + { + seq = av.alignment.getHiddenSequences().getHiddenSequence(lastrow); + if (seq == null) + { + + int index = + av.alignment.getHiddenSequences().findIndexWithoutHiddenSeqs(lastrow); + + + seq = av.alignment.getSequenceAt(index); + } + else + { + hiddenRow = true; + } + } + else + seq = av.alignment.getSequenceAt(lastrow); + + if(seq==null) + { + System.out.println(lastrow+" null"); + continue; + } + + for (col = 0; col < width; col++) + { + if((int)(col*sampleCol) == lastcol && (int)(row*sampleRow)==lastrow) + { + miniMe.setRGB(col,row,color); + continue; + } + + + lastcol = (int)(col*sampleCol); + + if (seq.getLength() > lastcol) + { + color = sr.getResidueBoxColour( + seq, lastcol).getRGB(); + + if (av.showSequenceFeatures) + color = fr.findFeatureColour(color, lastrow, lastcol); + } + else + { + color = -1; //White + } + + if(hiddenRow || + (av.hasHiddenColumns && !av.getColumnSelection().isVisible(lastcol))) + { + color = new Color(color).darker().darker().getRGB(); + } + + + miniMe.setRGB(col,row,color); + + + } + } + + if (av.conservation != null) + { + for (col = 0; col < width; col++) + { + lastcol = (int) (col * sampleCol); + { + mg.translate(col, sequencesHeight); ap.annotationPanel.drawGraph(mg, av.conservation, (int) (sampleCol) + 1, graphHeight, (int) (col * sampleCol), (int) (col * sampleCol) + 1); - + mg.translate( -col, -sequencesHeight); + } } - mg.translate(0, -sequencesHeight); - mg.translate(1, 0); - } - System.gc(); resizing = false; @@ -306,16 +374,49 @@ public class OverviewPanel extends JPanel implements Runnable public void setBoxPosition() { int fullsizeWidth = av.alignment.getWidth() * av.getCharWidth(); - int fullsizeHeight = av.alignment.getHeight() * av.getCharHeight(); + int fullsizeHeight = (av.alignment.getHeight() + +av.alignment.getHiddenSequences().getSize()) * av.getCharHeight(); + + int startRes = av.getStartRes(); + int endRes = av.getEndRes(); + + if(av.hasHiddenColumns) + { + startRes = av.getColumnSelection().adjustForHiddenColumns(startRes); + endRes = av.getColumnSelection().adjustForHiddenColumns(endRes); + } + + int startSeq = av.startSeq; + int endSeq = av.endSeq; + + if (av.hasHiddenRows) + { + startSeq = + av.alignment.getHiddenSequences().adjustForHiddenSeqs(startSeq); + + endSeq = + av.alignment.getHiddenSequences().adjustForHiddenSeqs(endSeq); + + } + scalew = (float) width / (float) fullsizeWidth; scaleh = (float) sequencesHeight / (float) fullsizeHeight; - boxX = (int) (av.getStartRes() * av.getCharWidth() * scalew); - boxY = (int) (av.getStartSeq() * av.getCharHeight() * scaleh); - boxWidth = (int) ((av.getEndRes() - av.getStartRes() + 1) * av.getCharWidth() * scalew); - boxHeight = (int) (av.getEndSeq() * av.getCharHeight() * scaleh) - - boxY; + boxX = (int) (startRes * av.getCharWidth() * scalew); + boxY = (int) (startSeq * av.getCharHeight() * scaleh); + + + + if(av.hasHiddenColumns) + boxWidth = (int) ((endRes - startRes + 1) * av.getCharWidth() * scalew); + else + boxWidth = (int) ((endRes - startRes + 1) * av.getCharWidth() * scalew); + + + boxHeight = (int) ((endSeq - startSeq) * av.getCharHeight() * scaleh); + + repaint(); }