X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FOverviewPanel.java;h=867ce56797cf768a81ca544e794b6a4ba6135a62;hb=8797ce6a98df4aa29eefecb25b10fed4f2ab9e86;hp=48f075e78df630a817470a7f5f7c244f9b4d6e6e;hpb=458b3c0783998e72caa6809dcb88df3907ed45cf;p=jalview.git diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index 48f075e..867ce56 100755 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.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 @@ -26,6 +26,7 @@ public class OverviewPanel extends Panel implements Runnable, MouseMotionListener, MouseListener { Image miniMe; + Image offscreen; AlignViewport av; AlignmentPanel ap; float scalew = 1f; @@ -56,10 +57,9 @@ public class OverviewPanel sr = new SequenceRenderer(av); sr.graphics = nullFrame.getGraphics(); - sr.renderGaps( false ); + sr.renderGaps = false; sr.forOverview = true; fr = new FeatureRenderer(av); - fr.drawText = false; fr.overview = true; @@ -68,7 +68,7 @@ public class OverviewPanel float initialScale = (float) av.alignment.getWidth() / (float) av.alignment.getHeight(); - if(av.vconsensus==null) + if(av.hconsensus==null) graphHeight = 0; if (av.alignment.getWidth() > av.alignment.getHeight()) @@ -125,9 +125,7 @@ public class OverviewPanel { boxX = evt.getX(); boxY = evt.getY(); - checkValid(); - repaint(); } public void mouseReleased(MouseEvent evt) @@ -135,8 +133,6 @@ public class OverviewPanel boxX = evt.getX(); boxY = evt.getY(); checkValid(); - ap.setScrollValues( (int) (boxX / scalew / av.getCharWidth()), - (int) (boxY / scaleh / av.getCharHeight())); } public void mouseDragged(MouseEvent evt) @@ -144,34 +140,56 @@ public class OverviewPanel boxX = evt.getX(); boxY = evt.getY(); checkValid(); - ap.setScrollValues( (int) (boxX / scalew / av.getCharWidth()), - (int) (boxY / scaleh / av.getCharHeight())); - - repaint(); - ap.repaint(); } void checkValid() { if (boxY < 0) { - boxY = 0; + boxY = 0; } - if (boxY > sequencesHeight - boxHeight) + if (boxY > (sequencesHeight - boxHeight)) { - boxY = sequencesHeight - boxHeight + 1; + boxY = sequencesHeight - boxHeight + 1; } if (boxX < 0) { - boxX = 0; + boxX = 0; } - if (boxX > width - boxWidth) + if (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 ); + ap.repaint(); } /** @@ -189,10 +207,8 @@ public class OverviewPanel { fr.featureGroups = ap.seqPanel.seqCanvas.getFeatureRenderer().featureGroups; fr.featureColours = ap.seqPanel.seqCanvas.getFeatureRenderer().featureColours; - fr.sequenceFeatures = ap.seqPanel.seqCanvas.getFeatureRenderer().sequenceFeatures; } - resizing = true; if ( (getSize().width > 0) && (getSize().height > 0)) @@ -201,11 +217,10 @@ public class OverviewPanel sequencesHeight = getSize().height - graphHeight; } setSize(new Dimension(width, sequencesHeight + graphHeight)); - setBoxPosition(); Thread thread = new Thread(this); thread.start(); - repaint(); + repaint(); } // This is set true if the user resizes whilst @@ -218,6 +233,11 @@ public class OverviewPanel int alwidth = av.alignment.getWidth(); int alheight = av.alignment.getHeight(); + if (av.showSequenceFeatures) + { + fr.transferSettings( ap.seqPanel.seqCanvas.getFeatureRenderer() ); + } + if (getSize().width > 0 && getSize().height > 0) { width = getSize().width; @@ -233,46 +253,86 @@ public class OverviewPanel scaleh = (float) sequencesHeight / (float) fullsizeHeight; miniMe = nullFrame.createImage(width, sequencesHeight + graphHeight); + offscreen = nullFrame.createImage(width, sequencesHeight + graphHeight); Graphics mg = miniMe.getGraphics(); float sampleCol = (float) alwidth / (float) width; float sampleRow = (float) alheight / (float) sequencesHeight; - int lastcol=-1, lastrow=0; + int lastcol=0, lastrow=0; + int xstart=0, ystart=0; Color color = Color.yellow; - int row, col; - jalview.datamodel.SequenceI sequence; - for (row = 0; row < sequencesHeight; row++) + int row, col, sameRow = 0, sameCol = 0; + jalview.datamodel.SequenceI seq; + boolean hiddenRow = false; + for (row = 0; row <= sequencesHeight; row++) { - sequence = av.getAlignment().getSequenceAt(lastrow); - for (col = 0; col < width; col++) + if((int)(row*sampleRow)==lastrow) { - if((int)(col*sampleCol) == lastcol && (int)(row*sampleRow)==lastrow) - { - mg.drawLine(col, row, col, row); - continue; - } - - lastrow = (int)(row*sampleRow); - lastcol = (int)(col*sampleCol); + sameRow ++; + continue; + } - if(av.alignment.getSequenceAt(lastrow).getLength()>lastcol) + hiddenRow = false; + if (av.hasHiddenRows) + { + seq = av.alignment.getHiddenSequences().getHiddenSequence(lastrow); + if (seq == null) { + int index = + av.alignment.getHiddenSequences().findIndexWithoutHiddenSeqs(lastrow); - color = sr.findSequenceColour(sequence, lastcol); - - if (av.showSequenceFeatures) - color = fr.findFeatureColour(color, - sequence, - lastcol); + seq = av.alignment.getSequenceAt(index); } else - color = color.white; - - mg.setColor(color); - mg.drawLine(col,row,col,row); + { + hiddenRow = true; + } + } + else + seq = av.alignment.getSequenceAt(lastrow); + for (col = 0; col < width; col++) + { + if ( (int) (col * sampleCol) == lastcol && (int) (row * sampleRow) == lastrow) + { + sameCol ++; + continue; + } + + lastcol = (int) (col * sampleCol); + + if (seq.getLength() > lastcol) + { + color = sr.getResidueBoxColour( + seq, lastcol); + + if (av.showSequenceFeatures) + color = fr.findFeatureColour(color, seq, lastcol); + } + else + { + color = Color.white; //White + } + + if (hiddenRow || + (av.hasHiddenColumns && !av.getColumnSelection().isVisible(lastcol))) + { + color = color.darker().darker(); + } + + mg.setColor(color); + if (sameCol == 1 && sameRow == 1) + mg.drawLine(xstart, ystart, xstart, ystart); + else + mg.fillRect(xstart, ystart, sameCol, sameRow); + + xstart = col; + sameCol = 1; } + lastrow = (int)(row*sampleRow); + ystart = row; + sameRow = 1; } if (av.conservation != null) @@ -291,9 +351,6 @@ public class OverviewPanel } } } - - - System.gc(); resizing = false; @@ -305,21 +362,50 @@ public class OverviewPanel resizeAgain = false; updateOverviewImage(); } - } +} 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(); } @@ -330,9 +416,14 @@ public class OverviewPanel public void paint(Graphics g) { + Graphics og = offscreen.getGraphics(); if (miniMe != null) { - g.drawImage(miniMe, 0, 0, this); + og.drawImage(miniMe, 0, 0, this); + og.setColor(Color.red); + og.drawRect(boxX, boxY, boxWidth, boxHeight); + og.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2); + g.drawImage(offscreen, 0,0, this); } else { @@ -343,10 +434,6 @@ public class OverviewPanel g.drawString("Recalculating", 5, sequencesHeight / 2); g.drawString("Overview.....", 5, (sequencesHeight / 2) + 20); } - - g.setColor(Color.red); - g.drawRect(boxX, boxY, boxWidth, boxHeight); - g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2); } }