From: amwaterhouse Date: Fri, 10 Feb 2006 16:03:03 +0000 (+0000) Subject: Overview displays features X-Git-Tag: Root_VamJalview_2_07b+~152 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=d355ad106f73e0de0abc3fb3f375af4eaf352591;p=jalview.git Overview displays features --- diff --git a/src/jalview/appletgui/AlignFrame.java b/src/jalview/appletgui/AlignFrame.java index fbe21b5..01bea4d 100755 --- a/src/jalview/appletgui/AlignFrame.java +++ b/src/jalview/appletgui/AlignFrame.java @@ -213,6 +213,7 @@ public class AlignFrame extends Frame implements ActionListener, } catch (Exception ex) { + ex.printStackTrace(); System.out.println("Error parsing groups file: " + ex); } } diff --git a/src/jalview/appletgui/FeatureRenderer.java b/src/jalview/appletgui/FeatureRenderer.java index 048df28..091a127 100755 --- a/src/jalview/appletgui/FeatureRenderer.java +++ b/src/jalview/appletgui/FeatureRenderer.java @@ -36,7 +36,6 @@ public class FeatureRenderer SequenceGroup currentSequenceGroup = null; SequenceGroup[] allGroups = null; Graphics graphics; - float transparency = .4f; // The following vector holds the features which are // to be added, in the correct order or rendering @@ -44,6 +43,10 @@ public class FeatureRenderer Color currentColour = null; + boolean drawText = true; + FontMetrics fm; + int charOffset; + /** * Creates a new FeatureRenderer object. * @@ -53,13 +56,9 @@ public class FeatureRenderer { this.av = av; initColours(); - String version = System.getProperty("java.version"); - if (version.indexOf("1.1") == 0) - highlightTransparent = false; - } - boolean highlightTransparent = true; + //boolean highlightTransparent = true; /** * DOCUMENT ME! * @@ -76,6 +75,7 @@ public class FeatureRenderer public void drawSequence(Graphics g, SequenceI seq, int start, int end, int x1, int y1, int width, int height) { + fm = g.getFontMetrics(); if(seq.getSequenceFeatures()==null) return; @@ -87,11 +87,6 @@ public class FeatureRenderer else e = seq.getSequenceFeatures().elements(); - if(highlightTransparent) - { - // MyGraphics.SetTransparency(g, transparency); - } - while (e.hasMoreElements()) { @@ -124,72 +119,70 @@ public class FeatureRenderer continue; } - int fstart = seq.findIndex(sf.getBegin()) - 1; - int fend = seq.findIndex(sf.getEnd()) - 1; - - if (((fstart <= end) && (fend >= start))) + if (type.equals("disulfide bond")) { - if (fstart < start) - { // fix for if the feature we have starts before the sequence start, - fstart = start; // but the feature end is still valid!! - } - - if (fend >= end) - { - fend = end; - } - - if (fstart == fend) - { - currentColour = getColour(type); - g.setColor(currentColour); - g.fillRoundRect((fstart - start) * width, y1, width, - height, 4, 4); - g.setColor(Color.white); - - char s = seq.getSequence().charAt(fstart); - FontMetrics fm = g.getFontMetrics(); - int charOffset = (width - fm.charWidth(s)) / 2; - int pady = height / 5; - g.drawString(String.valueOf(s), - charOffset + x1 + (width * (fstart - start)), - (y1 + height) - pady); - } - else - { - for (int i = fstart; i <= fend; i++) - { - char s = seq.getSequence().charAt(i); - - if (jalview.util.Comparison.isGap(s)) - { - continue; - } - currentColour = getColour(type); - g.setColor(currentColour); - - g.fillRect((i - start) * width, y1, width, height); - - g.setColor(Color.white); - - FontMetrics fm = g.getFontMetrics(); - int charOffset = (width - fm.charWidth(s)) / 2; - int pady = height / 5; - g.drawString(String.valueOf(s), - charOffset + x1 + (width * (i - start)), - (y1 + height) - pady); - } - } + + renderFeature(g, seq, + seq.findIndex(sf.getBegin()) - 1, + seq.findIndex(sf.getBegin()) - 1, + type, start, end, x1, y1, width, height); + renderFeature(g, seq, + seq.findIndex(sf.getEnd()) - 1, + seq.findIndex(sf.getEnd()) - 1, + type, start, end, x1, y1, width, height); + } + else + renderFeature(g, seq, + seq.findIndex(sf.getBegin()) - 1, + seq.findIndex(sf.getEnd()) - 1, + type, start, end, x1, y1, width, height); + + } + } + + void renderFeature(Graphics g, SequenceI seq, + int fstart, int fend, String type, int start, int end, + int x1, int y1, int width, int height) + { + if ( ( (fstart <= end) && (fend >= start))) + { + if (fstart < start) + { // fix for if the feature we have starts before the sequence start, + fstart = start; // but the feature end is still valid!! + } + + if (fend >= end) + { + fend = end; + } + for (int i = fstart; i <= fend; i++) + { + char s = seq.getSequence().charAt(i); + + if (jalview.util.Comparison.isGap(s)) + { + continue; } - if (highlightTransparent) + currentColour = getColour(type); + + g.setColor(currentColour); + + g.fillRect( (i - start) * width, y1, width, height); + + if (drawText) { - // MyGraphics.SetTransparency(g, 1.0f); + g.setColor(Color.white); + charOffset = (width - fm.charWidth(s)) / 2; + g.drawString(String.valueOf(s), + charOffset + x1 + (width * (i - start)), + (y1 + height) - height / 5); } + } + } } - Image offscreen; Frame nullframe; public Color findFeatureColour(Color initialCol, SequenceI seq, int i) @@ -218,7 +211,7 @@ public class FeatureRenderer featureColours.put(featureType, col); } - public void setTransparency(float value) + /* public void setTransparency(float value) { transparency = value; } @@ -226,14 +219,18 @@ public class FeatureRenderer public float getTransparency() { return transparency; - } + }*/ public void setFeaturePriority(Object [][] data) { // The feature table will display high priority // features at the top, but theses are the ones // we need to render last, so invert the data - featuresDisplayed = new Vector(); + if(featuresDisplayed!=null) + featuresDisplayed.removeAllElements(); + else + featuresDisplayed = new Vector(); + for(int i=data.length-1; i>-1; i--) { String type = data[i][0].toString(); diff --git a/src/jalview/appletgui/FeatureSettings.java b/src/jalview/appletgui/FeatureSettings.java index e01615a..4d0f25e 100755 --- a/src/jalview/appletgui/FeatureSettings.java +++ b/src/jalview/appletgui/FeatureSettings.java @@ -114,6 +114,8 @@ public class FeatureSettings extends Panel implements ItemListener, fr.setFeaturePriority(data); ap.seqPanel.seqCanvas.repaint(); + if(ap.overviewPanel!=null) + ap.overviewPanel.updateOverviewImage(); } Checkbox selectedCheck; @@ -167,6 +169,7 @@ public class FeatureSettings extends Panel implements ItemListener, this.remove(selectedCheck); this.add(selectedCheck, targetIndex); validate(); + itemStateChanged(null); } } diff --git a/src/jalview/appletgui/OverviewPanel.java b/src/jalview/appletgui/OverviewPanel.java index 9c3e908..57150c3 100755 --- a/src/jalview/appletgui/OverviewPanel.java +++ b/src/jalview/appletgui/OverviewPanel.java @@ -58,8 +58,8 @@ public class OverviewPanel 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; + fr.drawText = false; + // scale the initial size of overviewpanel to shape of alignment @@ -183,6 +183,10 @@ public class OverviewPanel return; } + if (av.showSequenceFeatures) + fr.featuresDisplayed = ap.seqPanel.seqCanvas.getFeatureRenderer().featuresDisplayed; + + resizing = true; if ( (getSize().width > 0) && (getSize().height > 0)) @@ -229,18 +233,29 @@ public class OverviewPanel float sampleRow = (float) alheight / (float) sequencesHeight; int lastcol=-1, lastrow=-1; - Color color = Color.white; - for (int col = 0; col < width; col++) + Color color = Color.yellow; + int row, col; + for (col = 0; col < width; col++) { - for (int row = 0; row < sequencesHeight; row++) + for (row = 0; row < sequencesHeight; row++) { if((int)(col*sampleCol) == lastcol && (int)(row*sampleRow)==lastrow) { - mg.setColor(color); - mg.fillRect(col,row,1,1); + mg.drawLine(col, row, col, row); continue; } + 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); + } + lastrow = (int)(row*sampleRow); lastcol = (int)(col*sampleCol); @@ -248,29 +263,20 @@ public class OverviewPanel { color = sr.findSequenceColour(av.alignment.getSequenceAt(lastrow), lastcol); + if (av.showSequenceFeatures) color = fr.findFeatureColour(color, - av.alignment.getSequenceAt(lastrow), + av.alignment.getSequenceAt(lastrow), lastcol); } - mg.setColor(color); - mg.fillRect(col,row,1,1); + mg.drawLine(col,row,col,row); - 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); - } } } + System.gc(); resizing = false;