From cb5acd3e551c2f9e67f8db366a93828f110c15fa Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Thu, 16 Mar 2006 15:28:41 +0000 Subject: [PATCH] Faster --- src/jalview/gui/OverviewPanel.java | 138 +++++++++++++++++++++++++++++++----- 1 file changed, 119 insertions(+), 19 deletions(-) diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index 7ffac1e..a4127bd 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -161,8 +161,22 @@ public class OverviewPanel extends JPanel implements Runnable boxY = evt.getY(); checkValid(); - ap.setScrollValues((int) (boxX / scalew / av.getCharWidth()), + if(av.hasHiddenColumns) + { + int col = (int) ( boxX / scalew / av.getCharWidth()); + + if(av.getColumnSelection().isVisible(col)) + { + ap.setScrollValues( + av.getColumnSelection().findColumnPosition(col), (int) (boxY / scaleh / av.getCharHeight())); + } + else + System.out.println(col +" not visible"); + } + else + ap.setScrollValues( (int) (boxX / scalew / av.getCharWidth()), + (int) (boxY / scaleh / av.getCharHeight())); } /** @@ -176,8 +190,22 @@ public class OverviewPanel extends JPanel implements Runnable boxY = evt.getY(); checkValid(); + if(av.hasHiddenColumns) + { + int col = (int) ( boxX / scalew / av.getCharWidth()); + + if(!av.getColumnSelection().isVisible(col)) + { + return; + } + + ap.setScrollValues( + av.getColumnSelection().findColumnPosition( col ), + (int) (boxY / scaleh / av.getCharHeight())); + } + else ap.setScrollValues( (int) (boxX / scalew / av.getCharWidth()), - (int) (boxY / scaleh / av.getCharHeight())); + (int) (boxY / scaleh / av.getCharHeight())); repaint(); } @@ -203,7 +231,14 @@ 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; } } @@ -227,7 +262,7 @@ public class OverviewPanel extends JPanel implements Runnable } setPreferredSize(new Dimension(width, sequencesHeight + graphHeight)); - setBoxPosition(); + // setBoxPosition(); Thread thread = new Thread(this); thread.start(); @@ -254,7 +289,8 @@ public class OverviewPanel extends JPanel implements Runnable } 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)); @@ -278,8 +314,50 @@ public class OverviewPanel extends JPanel implements Runnable 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++) { + 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) @@ -288,22 +366,28 @@ public class OverviewPanel extends JPanel implements Runnable 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).getRGB(); + color = sr.getResidueBoxColour( + seq, lastcol).getRGB(); - if(av.showSequenceFeatures) - color = fr.findFeatureColour(color, lastrow, lastcol); + 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(); + } - } - else - { - color = -1; //White - } miniMe.setRGB(col,row,color); @@ -346,14 +430,30 @@ 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); + } + scalew = (float) width / (float) fullsizeWidth; scaleh = (float) sequencesHeight / (float) fullsizeHeight; - boxX = (int) (av.getStartRes() * av.getCharWidth() * scalew); + boxX = (int) (startRes * av.getCharWidth() * scalew); boxY = (int) (av.getStartSeq() * av.getCharHeight() * scaleh); - boxWidth = (int) ((av.getEndRes() - av.getStartRes() + 1) * av.getCharWidth() * scalew); + + if(av.hasHiddenColumns) + boxWidth = (int) ((endRes - startRes + 1) * av.getCharWidth() * scalew); + else + boxWidth = (int) ((endRes - startRes + 1) * av.getCharWidth() * scalew); + boxHeight = (int) (av.getEndSeq() * av.getCharHeight() * scaleh) - boxY; repaint(); -- 1.7.10.2