X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FOverviewPanel.java;h=54e1ac2b68b2b85aa6773e83d2ce22cba11ac95d;hb=b169b1a49c078d123feb729db6acb9779f50e7d6;hp=c5789fe0ba3eb555cd9b318a920c3597e376baf1;hpb=de468b0bf50850a89c6a8a7acfa4ff5b689ffed1;p=jalview.git diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index c5789fe..54e1ac2 100755 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.java @@ -26,6 +26,7 @@ public class OverviewPanel extends Panel implements Runnable, MouseMotionListener, MouseListener { Image miniMe; + Image offscreen; AlignViewport av; AlignmentPanel ap; float scalew = 1f; @@ -40,7 +41,7 @@ public class OverviewPanel // Can set different properties in this seqCanvas than // main visible SeqCanvas SequenceRenderer sr; - //FeatureRenderer fr; + FeatureRenderer fr; Frame nullFrame; @@ -56,10 +57,10 @@ public class OverviewPanel sr = new SequenceRenderer(av); sr.graphics = nullFrame.getGraphics(); - sr.renderGaps( false ); - //fr = new FeatureRenderer(av); - //fr.transparency = ap.seqPanel.seqCanvas.getFeatureRenderer().transparency; - //fr.featuresDisplayed = ap.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed; + sr.renderGaps = false; + sr.forOverview = true; + fr = new FeatureRenderer(av); + fr.overview = true; @@ -124,9 +125,7 @@ public class OverviewPanel { boxX = evt.getX(); boxY = evt.getY(); - checkValid(); - repaint(); } public void mouseReleased(MouseEvent evt) @@ -134,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) @@ -143,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(); } /** @@ -184,6 +203,12 @@ public class OverviewPanel return; } + if (av.showSequenceFeatures) + { + fr.featureGroups = ap.seqPanel.seqCanvas.getFeatureRenderer().featureGroups; + fr.featureColours = ap.seqPanel.seqCanvas.getFeatureRenderer().featureColours; + } + resizing = true; if ( (getSize().width > 0) && (getSize().height > 0)) @@ -192,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 @@ -209,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; @@ -224,33 +253,93 @@ 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=-1; - Color color = Color.white; - for (int col = 0; col < width; col++) + int lastcol=0, lastrow=0; + int xstart=0, ystart=0; + Color color = Color.yellow; + int row, col, sameRow = 0, sameCol = 0; + 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) + { + sameRow ++; + continue; + } + + hiddenRow = false; + if (av.hasHiddenRows) { - if((int)(col*sampleCol) == lastcol && (int)(row*sampleRow)==lastrow) + seq = av.alignment.getHiddenSequences().getHiddenSequence(lastrow); + if (seq == null) { - mg.setColor(color); - mg.fillRect(col,row,1,1); - continue; + int index = + av.alignment.getHiddenSequences().findIndexWithoutHiddenSeqs(lastrow); + + seq = av.alignment.getSequenceAt(index); + } + else + { + hiddenRow = true; } + } + else + seq = av.alignment.getSequenceAt(lastrow); - lastrow = (int)(row*sampleRow); - lastcol = (int)(col*sampleCol); + 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(); + } - color = sr.findSequenceColour(av.alignment.getSequenceAt(lastrow), lastcol); + mg.setColor(color); + if (sameCol == 1 && sameRow == 1) + mg.drawLine(xstart, ystart, xstart, ystart); + else + mg.fillRect(xstart, ystart, sameCol, sameRow); - mg.setColor(color); - mg.fillRect(col,row,1,1); + xstart = col; + sameCol = 1; + } + lastrow = (int)(row*sampleRow); + ystart = row; + sameRow = 1; + } - if (av.conservation != null) + if (av.conservation != null) + { + for (col = 0; col < width; col++) + { + lastcol = (int) (col * sampleCol); { mg.translate(col, sequencesHeight); ap.annotationPanel.drawGraph(mg, av.conservation, @@ -258,11 +347,10 @@ public class OverviewPanel graphHeight, (int) (col * sampleCol), (int) (col * sampleCol) + 1); - mg.translate(-col, -sequencesHeight); + mg.translate( -col, -sequencesHeight); } } } - System.gc(); resizing = false; @@ -274,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(); } @@ -299,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 { @@ -312,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); } }