aa[activeRow].validateRangeAndDisplay();
adjustPanelHeight();
+ ap.alignmentChanged();
repaint();
return;
@Override
public AlignmentAnnotation findOrCreateAnnotation(String name,
- boolean autoCalc, SequenceI seqRef, SequenceGroup groupRef)
+ String calcId, boolean autoCalc, SequenceI seqRef, SequenceGroup groupRef)
{
+ assert(name!=null);
for (AlignmentAnnotation annot : getAlignmentAnnotation())
{
if (annot.autoCalculated == autoCalc
- && annot.getCalcId().equals(name)
+ && (name.equals(annot.label))
+ && (calcId==null || annot.getCalcId().equals(calcId))
&& annot.sequenceRef == seqRef && annot.groupRef == groupRef)
{
return annot;
AlignmentAnnotation annot = new AlignmentAnnotation(name, name,
new Annotation[1], 0f, 0f, AlignmentAnnotation.BAR_GRAPH);
annot.hasText = false;
- annot.setCalcId(new String(name));
+ annot.setCalcId(new String(calcId));
annot.autoCalculated = autoCalc;
if (seqRef != null)
{
/**
* search for or create a specific annotation row on the alignment
- *
- * @param method - CalcId for the annotation (must match)
+ * @param name name for annotation (must match)
+ * @param calcId calcId for the annotation (null or must match)
* @param autoCalc - value of autocalc flag for the annotation
* @param seqRef - null or specific sequence reference
* @param groupRef - null or specific group reference
+ * @param method - CalcId for the annotation (must match)
+ *
* @return existing annotation matching the given attributes
*/
- public AlignmentAnnotation findOrCreateAnnotation(String name, boolean autoCalc,
- SequenceI seqRef, SequenceGroup groupRef);
+ public AlignmentAnnotation findOrCreateAnnotation(String name, String calcId,
+ boolean autoCalc, SequenceI seqRef, SequenceGroup groupRef);
/**
* move the given group up or down in the alignment by the given number of rows.
import java.beans.*;
import java.io.*;
import java.util.Hashtable;
-import java.util.Vector;
import java.awt.*;
import java.awt.event.*;
if (av.showAnnotation && (endSeq == av.getAlignment().getHeight()))
{
+ // draw annotation - need to offset for current scroll position
+ int offset=-alabels.scrollOffset;
+ pg.translate(0, offset);
pg.translate(-idWidth - 3, (endSeq - startSeq) * av.charHeight + 3);
alabels.drawComponent((Graphics2D) pg, idWidth);
pg.translate(idWidth + 3, 0);
annotationPanel.renderer.drawComponent(annotationPanel, av, (Graphics2D) pg, -1, startRes, endRes + 1);
+ pg.translate(0, -offset);
}
return Printable.PAGE_EXISTS;
void makeAlignmentImage(int type, File file)
{
+ long progress=System.currentTimeMillis();
+ if (alignFrame!=null) {
+ alignFrame.setProgressBar("Saving "+(type == jalview.util.ImageMaker.PNG ? "PNG image":"EPS file") , progress);
+ }
+ try {
int maxwidth = av.getAlignment().getWidth();
if (av.hasHiddenColumns())
{
{
jalview.util.ImageMaker im;
+ final String imageAction,imageTitle;
if (type == jalview.util.ImageMaker.PNG)
{
- im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.PNG,
- "Create PNG image from alignment", width, height, file,
- null);
- }
- else
- {
- im = new jalview.util.ImageMaker(this, jalview.util.ImageMaker.EPS,
- "Create EPS file from alignment", width, height, file,
- alignFrame.getTitle());
+ imageAction="Create PNG image from alignment";
+ imageTitle=null;
+ } else {
+ imageAction="Create EPS file from alignment";
+ imageTitle=alignFrame.getTitle();
}
-
+ im = new jalview.util.ImageMaker(this, type, imageAction, width, height, file,
+ imageTitle);
if (av.getWrapAlignment())
{
if (im.getGraphics() != null)
{
ex.printStackTrace();
}
+ }
+ finally {
+ if (alignFrame!=null)
+ {
+ alignFrame.setProgressBar("Export complete.", progress);
+ }
+ }
}
/**
{
new OOMWarning(string, error, this);
}
+
+ public FeatureRenderer cloneFeatureRenderer()
+ {
+
+ return new FeatureRenderer(this);
+ }
+
+ public void updateFeatureRenderer(FeatureRenderer fr)
+ {
+ fr.transferSettings(seqPanel.seqCanvas.getFeatureRenderer());
+ }
+
+ public void updateFeatureRendererFrom(FeatureRenderer fr)
+ {
+ if (seqPanel.seqCanvas.getFeatureRenderer()!=null) {
+ seqPanel.seqCanvas.getFeatureRenderer().transferSettings(fr);
+ }
+ }
}
aa[activeRow].validateRangeAndDisplay();
adjustPanelHeight();
+ ap.alignmentChanged();
repaint();
return;
AlignmentPanel ap = (alignment==null) ? appJmolWindow.ap : (AlignmentPanel) alignment;
if (ap.av.showSequenceFeatures)
{
- if (fr == null)
+ if (fr==null)
{
- fr = new FeatureRenderer(ap);
+ fr=ap.cloneFeatureRenderer();
+ } else {
+ ap.updateFeatureRenderer(fr);
}
-
- fr.transferSettings(ap.
- seqPanel.seqCanvas.getFeatureRenderer());
}
return fr;
package jalview.gui;
import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
import java.awt.*;
import java.awt.event.*;
FontMetrics fm;
int charOffset;
-
- Hashtable featureColours = new Hashtable();
+
+ Map featureColours = new ConcurrentHashMap();
// A higher level for grouping features of a
// particular type
- Hashtable featureGroups = new Hashtable();
+ Map featureGroups = new ConcurrentHashMap();
// This is actually an Integer held in the hashtable,
// Retrieved using the key feature type
{
String[] renderOrder;
- Hashtable featureGroups;
+ Map featureGroups;
- Hashtable featureColours;
+ Map featureColours;
float transparency;
- Hashtable featureOrder;
+ Map featureOrder;
public FeatureRendererSettings(String[] renderOrder,
Hashtable featureGroups, Hashtable featureColours,
public FeatureRendererSettings(FeatureRenderer fr)
{
renderOrder = null;
- featureGroups = new Hashtable();
- featureColours = new Hashtable();
- featureOrder = new Hashtable();
+ featureGroups = new ConcurrentHashMap();
+ featureColours = new ConcurrentHashMap();
+ featureOrder = new ConcurrentHashMap();
if (fr.renderOrder != null)
{
this.renderOrder = new String[fr.renderOrder.length];
System.arraycopy(fr.renderOrder, 0, renderOrder, 0,
- renderOrder.length);
+ fr.renderOrder.length);
}
if (fr.featureGroups != null)
{
- this.featureGroups = new Hashtable(fr.featureGroups);
+ this.featureGroups = new ConcurrentHashMap(fr.featureGroups);
}
if (fr.featureColours != null)
{
- this.featureColours = new Hashtable(fr.featureColours);
+ this.featureColours = new ConcurrentHashMap(fr.featureColours);
}
- Enumeration en = fr.featureColours.keys();
- while (en.hasMoreElements())
+ Iterator en = fr.featureColours.keySet().iterator();
+ while (en.hasNext())
{
- Object next = en.nextElement();
+ Object next = en.next();
Object val = featureColours.get(next);
if (val instanceof GraduatedColor)
{
this.transparency = fr.transparency;
if (fr.featureOrder != null)
{
- this.featureOrder = new Hashtable(fr.featureOrder);
+ this.featureOrder = new ConcurrentHashMap(fr.featureOrder);
}
}
}
}
- Hashtable featureOrder = null;
+ Map featureOrder = null;
/**
* analogous to colour - store a normalized ordering for all feature types in
PrintWriter out = new PrintWriter(new OutputStreamWriter(
new FileOutputStream(choice), "UTF-8"));
- Enumeration e = fr.featureColours.keys();
+ Iterator e = fr.featureColours.keySet().iterator();
float[] sortOrder = new float[fr.featureColours.size()];
String[] sortTypes = new String[fr.featureColours.size()];
int i = 0;
- while (e.hasMoreElements())
+ while (e.hasNext())
{
- sortTypes[i] = e.nextElement().toString();
+ sortTypes[i] = e.next().toString();
sortOrder[i] = fr.getOrder(sortTypes[i]);
i++;
}
if (fr.featureGroups != null)
{
- Enumeration en = fr.featureGroups.keys();
+ Iterator en = fr.featureGroups.keySet().iterator();
gps = new String[fr.featureColours.size()];
int g = 0;
boolean valid = false;
- while (en.hasMoreElements())
+ while (en.hasNext())
{
- String gp = (String) en.nextElement();
+ String gp = (String) en.next();
Boolean on = (Boolean) fr.featureGroups.get(gp);
if (on != null && on.booleanValue())
{
}
// Make sure we save none displayed feature settings
- Enumeration en = ap.seqPanel.seqCanvas.getFeatureRenderer().featureColours
- .keys();
- while (en.hasMoreElements())
+ Iterator en = ap.seqPanel.seqCanvas.getFeatureRenderer().featureColours
+ .keySet().iterator();
+ while (en.hasNext())
{
- String key = en.nextElement().toString();
+ String key = en.next().toString();
if (settingsAdded.contains(key))
{
continue;
fs.addSetting(setting);
settingsAdded.addElement(key);
}
- en = ap.seqPanel.seqCanvas.getFeatureRenderer().featureGroups.keys();
+ en = ap.seqPanel.seqCanvas.getFeatureRenderer().featureGroups.keySet().iterator();
Vector groupsAdded = new Vector();
- while (en.hasMoreElements())
+ while (en.hasNext())
{
- String grp = en.nextElement().toString();
+ String grp = en.next().toString();
if (groupsAdded.contains(grp))
{
continue;
* @return true if features were added\r
*/\r
public boolean parse(AlignmentI align, \r
- Hashtable colours, boolean removeHTML, boolean relaxedIdMatching)\r
+ Map colours, boolean removeHTML, boolean relaxedIdMatching)\r
{\r
return parse(align, colours, null, removeHTML, relaxedIdMatching);\r
}\r
* @param removeHTML - process html strings into plain text\r
* @return true if features were added\r
*/\r
- public boolean parse(AlignmentI align, Hashtable colours,\r
- Hashtable featureLink, boolean removeHTML)\r
+ public boolean parse(AlignmentI align, Map colours,\r
+ Map featureLink, boolean removeHTML)\r
{\r
return parse(align, colours, featureLink, removeHTML, false);\r
}\r
* @return true if features were added\r
*/\r
public boolean parse(AlignmentI align,\r
- Hashtable colours, Hashtable featureLink, boolean removeHTML, boolean relaxedIdmatching)\r
+ Map colours, Map featureLink, boolean removeHTML, boolean relaxedIdmatching)\r
{\r
\r
String line = null;\r
StringTokenizer st;\r
SequenceFeature sf;\r
String featureGroup = null, groupLink = null;\r
- Hashtable typeLink = new Hashtable();\r
+ Map typeLink = new Hashtable();\r
/**\r
* when true, assume GFF style features rather than Jalview style.\r
*/\r
}
}
// this will overwrite any existing t-coffee scores for the alignment
- AlignmentAnnotation aa=al.findOrCreateAnnotation(TCOFFEE_SCORE,false,s,null);
+ AlignmentAnnotation aa=al.findOrCreateAnnotation(TCOFFEE_SCORE,TCOFFEE_SCORE,false,s, null);
if (s!=null)
{
aa.label="T-COFFEE";
*/
public BuriedColourScheme()
{
- super(ResidueProperties.buried, ResidueProperties.buriedmin,
+ super(ResidueProperties.aaIndex, ResidueProperties.buried, ResidueProperties.buriedmin,
ResidueProperties.buriedmax);
}
{
public HelixColourScheme()
{
- super(ResidueProperties.helix, ResidueProperties.helixmin,
+ super(ResidueProperties.aaIndex, ResidueProperties.helix, ResidueProperties.helixmin,
ResidueProperties.helixmax);
}
*/
public HydrophobicColourScheme()
{
- super(ResidueProperties.hyd, ResidueProperties.hydmin,
+ super(ResidueProperties.aaIndex, ResidueProperties.hyd, ResidueProperties.hydmin,
ResidueProperties.hydmax);
}
*/
public NucleotideColourScheme()
{
- super(ResidueProperties.nucleotide, 0);
+ super(ResidueProperties.nucleotideIndex, ResidueProperties.nucleotide, 0);
}
/**
*/
public PurinePyrimidineColourScheme()
{
- super(ResidueProperties.purinepyrimidine, 0);
+ super(ResidueProperties.purinepyrimidineIndex, ResidueProperties.purinepyrimidine, 0);
}
/**
import java.util.Hashtable;
import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.SequenceI;
/**
* Looks at the information computed from an RNA Stockholm format file on the
*/
public RNAHelicesColour(AlignmentAnnotation annotation)
{
+ super(ResidueProperties.nucleotideIndex);
this.annotation = annotation;
refresh();
}
*
* @return color in RGB
*/
+ @Override
public Color findColour(char c)
{
return ResidueProperties.purinepyrimidine[ResidueProperties.purinepyrimidineIndex[c]];
*
* @return Color in RGB
*/
- public Color findColour(char c, int j)
+ @Override
+ public Color findColour(char c, int j, SequenceI seq)
{
refresh();
Color currentColour = Color.white;
*/
public class ResidueColourScheme implements ColourSchemeI
{
-
+ final int[] symbolIndex;
boolean conservationColouring = false;
Color[] colors = null;
/**
* Creates a new ResidueColourScheme object.
- *
+ * @param final int[] index table into colors (ResidueProperties.naIndex or ResidueProperties.aaIndex)
* @param colors
- * DOCUMENT ME!
+ * colours for symbols in sequences
* @param threshold
- * DOCUMENT ME!
+ * threshold for conservation shading
*/
- public ResidueColourScheme(Color[] colours, int threshold)
+ public ResidueColourScheme(int[] aaOrnaIndex, Color[] colours, int threshold)
{
+ symbolIndex = aaOrnaIndex;
this.colors = colours;
this.threshold = threshold;
}
/**
- * Creates a new ResidueColourScheme object.
+ * Creates a new ResidueColourScheme object with a lookup table for indexing the colour map
+ */
+ public ResidueColourScheme(int[] aaOrNaIndex)
+ {
+ symbolIndex = aaOrNaIndex;
+ }
+ /**
+ * Creates a new ResidueColourScheme object - default constructor for non-sequence dependent colourschemes
*/
public ResidueColourScheme()
{
+ symbolIndex = null;
}
/**
public Color findColour(char c)
{
return colors == null ? Color.white
- : colors[ResidueProperties.aaIndex[c]];
+ : colors[symbolIndex[c]];
}
@Override
{
Color currentColour;
- if ((threshold == 0) || aboveThreshold(c, j))
+ if (colors!=null && symbolIndex!=null && (threshold == 0) || aboveThreshold(c, j))
{
- currentColour = colors[ResidueProperties.aaIndex[c]];
+ currentColour = colors[symbolIndex[c]];
}
else
{
* @param max
* DOCUMENT ME!
*/
- public ScoreColourScheme(double[] scores, double min, double max)
+ public ScoreColourScheme(int symbolIndex[], double[] scores, double min, double max)
{
- super();
+ super(symbolIndex);
this.scores = scores;
this.min = min;
*/
public StrandColourScheme()
{
- super(ResidueProperties.strand, ResidueProperties.strandmin,
+ super(ResidueProperties.aaIndex, ResidueProperties.strand, ResidueProperties.strandmin,
ResidueProperties.strandmax);
}
{
public TaylorColourScheme()
{
- super(ResidueProperties.taylor, 0);
+ super(ResidueProperties.aaIndex, ResidueProperties.taylor, 0);
}
}
*/
public TurnColourScheme()
{
- super(ResidueProperties.turn, ResidueProperties.turnmin,
+ super(ResidueProperties.aaIndex,ResidueProperties.turn, ResidueProperties.turnmin,
ResidueProperties.turnmax);
}
*/
public ZappoColourScheme()
{
- super(ResidueProperties.zappo, 0);
+ super(ResidueProperties.aaIndex, ResidueProperties.zappo, 0);
}
}
public void updateResultAnnotation(boolean immediate)
{
-
if (immediate || !calcMan.isWorking(this) && scoremanager != null)
{
AlignmentAnnotation annotation;
- ;
Map<String, TreeSet<Score>> scoremap = scoremanager.asMap();
int alWidth = alignViewport.getAlignment().getWidth();
AlignmentI alignment;
else
{
// simple annotation row
- annotation = alignViewport.getAlignment().findOrCreateAnnotation(scr.getMethod(), true, null, null);
+ annotation = alignViewport.getAlignment()
+ .findOrCreateAnnotation(scr.getMethod(), getCalcId(), true,
+ null, null);
+
Annotation[] elm = new Annotation[alWidth];
if (alWidth == gapMap.length) // scr.getScores().size())
{
package jalview.ws.jws2;
import jalview.api.AlignCalcWorkerI;
+import jalview.bin.Cache;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
+import jalview.schemes.GraduatedColor;
import jalview.ws.jws2.jabaws2.Jws2Instance;
import jalview.ws.params.WsParamSetI;
+import java.awt.Color;
+import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import compbio.data.sequence.Range;
import compbio.data.sequence.Score;
if (immediate || !calcMan.isWorking(this) && scoremanager != null)
{
boolean dispFeatures = false;
+ Map<String,Object> fc=new Hashtable<String, Object>();
for (String seqId : seqNames.keySet())
{
SequenceI dseq, seq = seqNames.get(seqId);
}
;
ScoreHolder scores = scoremanager.getAnnotationForSequence(seqId);
-
+ float last=Float.NaN,val=Float.NaN;
for (Score scr : scores.scores)
{
{
sf = new SequenceFeature(typeName + "(" + scr.getMethod()
+ ")", "Disordered Region", base + rn.from, base
- + rn.to, vals.next().floatValue(), methodName);
+ + rn.to, val=vals.next().floatValue(), methodName);
}
else
{
base + rn.to, methodName);
}
dseq.addSequenceFeature(sf);
+ if (last!=val && last!=Float.NaN)
+ {
+ fc.put(sf.getType(),sf);
+ }
+ last=val;
dispFeatures = true;
}
}
{
SequenceFeature sf = new SequenceFeature(typeName + "("
+ scr.getMethod() + ")", "Disordered Region", start,
- start, vals.next().floatValue(), methodName);
+ start, val=vals.next().floatValue(), methodName);
+ if (last!=val && last!=Float.NaN)
+ {
+ fc.put(sf.getType(),sf);
+ }
+ last=val;
dseq.addSequenceFeature(sf);
dispFeatures = true;
}
{
if (dispFeatures)
{
+ jalview.gui.FeatureRenderer fr = ((jalview.gui.AlignmentPanel) ap).cloneFeatureRenderer();
// TODO: configure feature display settings for added types if they don't already exist
-
+ for (String ft:fc.keySet())
+ {
+ Cache.log.debug("Set graduated feature for new type:"+ft);
+ Object gc=fr.getFeatureStyle(ft);
+ if (gc instanceof Color)
+ {
+ // set graduated color as fading to white for minimum, and autoscaling to values on alignment
+ GraduatedColor ggc=new GraduatedColor(Color.white, (Color)gc,Float.MIN_VALUE, Float.MAX_VALUE);
+ ggc.setAutoScaled(true);
+ fr.setColour(ft, ggc);
+ }
+ }
+ af.alignPanel.updateFeatureRendererFrom(fr);
af.alignPanel.av.setShowSequenceFeatures(true);
ap.paintAlignment(true);
}
}
- /*
- * else { ap.paintAlignment(true); }
- */
}
}