From: amwaterhouse Date: Thu, 17 Nov 2005 15:16:48 +0000 (+0000) Subject: Optimized Overview X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=63e023b9b4aedc87fe7f69e2b3887d70aa6a02c1;p=jalview.git Optimized Overview --- diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index 7910f2d..6164468 100755 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.java @@ -39,7 +39,8 @@ public class OverviewPanel // Can set different properties in this seqCanvas than // main visible SeqCanvas - SeqCanvas overviewSeq; + SequenceRenderer sr; + //FeatureRenderer fr; Frame nullFrame; @@ -52,9 +53,13 @@ public class OverviewPanel nullFrame = new Frame(); nullFrame.addNotify(); - overviewSeq = new SeqCanvas(av); - overviewSeq.isOverview = true; - overviewSeq.sr.renderGaps = false; + + sr = new SequenceRenderer(av); + sr.renderGaps( false ); + //fr = new FeatureRenderer(av); + //fr.transparency = ap.seqPanel.seqCanvas.getFeatureRenderer().transparency; + //fr.featuresDisplayed = ap.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed; + // scale the initial size of overviewpanel to shape of alignment @@ -231,31 +236,40 @@ public class OverviewPanel 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++) { for (int row = 0; row < sequencesHeight; row++) { - 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((int)(col*sampleCol) == lastcol && (int)(row*sampleRow)==lastrow) + { + mg.setColor(color); + mg.fillRect(col,row,1,1); + continue; + } + + lastrow = (int)(row*sampleRow); + lastcol = (int)(col*sampleCol); + + color = sr.findSequenceColour(av.alignment.getSequenceAt(lastrow), lastcol); + + mg.setColor(color); + mg.fillRect(col,row,1,1); if (av.conservation != null) + { + 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; diff --git a/src/jalview/appletgui/SeqCanvas.java b/src/jalview/appletgui/SeqCanvas.java index fc8bb5c..5d02825 100755 --- a/src/jalview/appletgui/SeqCanvas.java +++ b/src/jalview/appletgui/SeqCanvas.java @@ -43,7 +43,6 @@ public class SeqCanvas boolean fastPaint = false; - boolean isOverview = false; public SeqCanvas(AlignViewport av) { @@ -472,7 +471,7 @@ public class SeqCanvas group = (SequenceGroup) groups.elementAt(0); groupIndex = 0; } - if (group != null && !isOverview) + if (group != null) { do { diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index 534f68f..5391e78 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,9 +63,11 @@ 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 ); + fr = new FeatureRenderer(av); + fr.transparency = ap.seqPanel.seqCanvas.getFeatureRenderer().transparency; + fr.featuresDisplayed = ap.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed; // scale the initial size of overviewpanel to shape of alignment float initialScale = (float) av.alignment.getWidth() / (float) av.alignment.getHeight(); @@ -257,34 +260,50 @@ 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; + int lastcol=-1, lastrow=-1; + Color color = Color.white; for (int col = 0; col < width; col++) { for (int row = 0; row < sequencesHeight; row++) { - 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((int)(col*sampleCol) == lastcol && (int)(row*sampleRow)==lastrow) + { + miniMe.setRGB(col,row,color.getRGB()); + continue; + } + + lastrow = (int)(row*sampleRow); + lastcol = (int)(col*sampleCol); + + color = sr.findSequenceColour(Color.white, + av.alignment.getSequenceAt(lastrow), lastcol); + + if(av.showSequenceFeatures) + { + color = fr.findFeatureColour(color, + av.alignment.getSequenceAt(lastrow), + lastcol); + } + + miniMe.setRGB(col,row,color.getRGB()); if (av.conservation != null) + { + 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();