X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FOverviewPanel.java;h=fd3c334ccb62b91e5a2e6004e275b3f6d05a5f58;hb=7cf75b5b379dd71b3480726419c7dc55d8e01f0e;hp=baec46b0cfe36d9b1ea4685dccda59adda460962;hpb=d8cdb85d0e0006bc5c3381423ec7be2dd8815755;p=jalview.git diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index baec46b..fd3c334 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/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 @@ -64,10 +64,10 @@ public class OverviewPanel extends JPanel implements Runnable setLayout(null); sr = new SequenceRenderer(av); - sr.renderGaps( false ); + 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(); @@ -111,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(); + } } }); @@ -121,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! @@ -201,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 ); + } /** @@ -225,7 +210,6 @@ public class OverviewPanel extends JPanel implements Runnable } setPreferredSize(new Dimension(width, sequencesHeight + graphHeight)); - setBoxPosition(); Thread thread = new Thread(this); thread.start(); @@ -245,15 +229,12 @@ public class OverviewPanel extends JPanel implements Runnable if (av.showSequenceFeatures) { - fr.featuresDisplayed = ap.seqPanel.seqCanvas.getFeatureRenderer(). - featuresDisplayed; - //fr.featureGroups = ap.seqPanel.seqCanvas.getFeatureRenderer().featureGroups; - fr.featureColours = ap.seqPanel.seqCanvas.getFeatureRenderer().featureColours; - fr.transparency = ap.seqPanel.seqCanvas.getFeatureRenderer().transparency; + 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)); @@ -275,34 +256,92 @@ public class OverviewPanel extends JPanel implements Runnable float sampleRow = (float) alheight / (float) sequencesHeight; int lastcol=-1, lastrow=-1; - Color color = Color.white; - for (int col = 0; col < width; col++) + 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) { + //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.getRGB()); + miniMe.setRGB(col,row,color); continue; } - lastrow = (int)(row*sampleRow); + lastcol = (int)(col*sampleCol); - if(av.alignment.getSequenceAt(lastrow).getLength()>lastcol) + if (seq.getLength() > lastcol) { - color = sr.getResidueBoxColour( - av.alignment.getSequenceAt(lastrow), lastcol); + color = sr.getResidueBoxColour( + seq, lastcol).getRGB(); - if(av.showSequenceFeatures) - color = fr.findFeatureColour(color, av.alignment.getSequenceAt(lastrow), - lastcol); + if (av.showSequenceFeatures) + color = fr.findFeatureColour(color, seq, 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.getRGB()); - if (av.conservation != null) + 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, @@ -310,11 +349,10 @@ public class OverviewPanel extends JPanel implements Runnable graphHeight, (int) (col * sampleCol), (int) (col * sampleCol) + 1); - mg.translate(-col, -sequencesHeight); + mg.translate( -col, -sequencesHeight); } } } - System.gc(); resizing = false; @@ -334,16 +372,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(); }