package jalview.io;
import jalview.analysis.SequenceIdMatcher;
+import jalview.api.FeatureColourI;
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceDummy;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.schemes.AnnotationColourGradient;
-import jalview.schemes.GraduatedColor;
+import jalview.schemes.FeatureColour;
import jalview.schemes.UserColourScheme;
import jalview.util.Format;
import jalview.util.MapList;
}
else
{
- Object colour = null;
+ FeatureColourI colour = null;
String colscheme = st.nextToken();
if (colscheme.indexOf("|") > -1
|| colscheme.trim().equalsIgnoreCase("label"))
}
try
{
- colour = new jalview.schemes.GraduatedColor(
+ colour = new FeatureColour(
new UserColourScheme(mincol).findColour('A'),
new UserColourScheme(maxcol).findColour('A'), min,
max);
}
if (colour != null)
{
- ((jalview.schemes.GraduatedColor) colour)
- .setColourByLabel(labelCol);
- ((jalview.schemes.GraduatedColor) colour)
- .setAutoScaled(abso == null);
+ colour.setColourByLabel(labelCol);
+ colour.setAutoScaled(abso == null);
// add in any additional parameters
String ttype = null, tval = null;
if (gcol.hasMoreTokens())
ttype = gcol.nextToken();
if (ttype.toLowerCase().startsWith("below"))
{
- ((jalview.schemes.GraduatedColor) colour)
- .setThreshType(AnnotationColourGradient.BELOW_THRESHOLD);
+ colour.setBelowThreshold(true);
}
else if (ttype.toLowerCase().startsWith("above"))
{
- ((jalview.schemes.GraduatedColor) colour)
- .setThreshType(AnnotationColourGradient.ABOVE_THRESHOLD);
+ colour.setAboveThreshold(true);
}
else
{
- ((jalview.schemes.GraduatedColor) colour)
- .setThreshType(AnnotationColourGradient.NO_THRESHOLD);
if (!ttype.toLowerCase().startsWith("no"))
{
System.err
}
}
}
- if (((GraduatedColor) colour).getThreshType() != AnnotationColourGradient.NO_THRESHOLD)
+ if (colour.hasThreshold())
{
try
{
gcol.nextToken();
tval = gcol.nextToken();
- ((jalview.schemes.GraduatedColor) colour)
- .setThresh(new Float(tval).floatValue());
+ colour.setThreshold(new Float(tval).floatValue());
} catch (Exception e)
{
System.err
else
{
UserColourScheme ucs = new UserColourScheme(colscheme);
- colour = ucs.findColour('A');
+ colour = new FeatureColour(ucs.findColour('A'));
}
if (colour != null)
{
*
* @param seqs
* source of sequence features
- * @param visible
+ * @param map
* hash of feature types and colours
* @return features file contents
*/
public String printJalviewFormat(SequenceI[] seqs,
- Map<String, Object> visible)
+ Map<String, FeatureColourI> map)
{
- return printJalviewFormat(seqs, visible, true, true);
+ return printJalviewFormat(seqs, map, true, true);
}
/**
* generate a features file for seqs with colours from visible (if any)
*
- * @param seqs
+ * @param sequences
* source of features
* @param visible
* hash of Colours for each feature type
* of group or type)
* @return features file contents
*/
- public String printJalviewFormat(SequenceI[] seqs, Map visible,
+ public String printJalviewFormat(SequenceI[] sequences,
+ Map<String, FeatureColourI> visible,
boolean visOnly, boolean nonpos)
{
StringBuffer out = new StringBuffer();
// write feature colours only if we're given them and we are generating
// viewed features
// TODO: decide if feature links should also be written here ?
- Iterator en = visible.keySet().iterator();
- String type, color;
+ Iterator<String> en = visible.keySet().iterator();
+ String feature, color;
while (en.hasNext())
{
- type = en.next().toString();
+ feature = en.next();
- if (visible.get(type) instanceof GraduatedColor)
+ FeatureColourI gc = visible.get(feature);
+ if (!gc.isSimpleColour())
{
- GraduatedColor gc = (GraduatedColor) visible.get(type);
color = (gc.isColourByLabel() ? "label|" : "")
- + Format.getHexString(gc.getMinColor()) + "|"
- + Format.getHexString(gc.getMaxColor())
- + (gc.isAutoScale() ? "|" : "|abso|") + gc.getMin() + "|"
+ + Format.getHexString(gc.getMinColour()) + "|"
+ + Format.getHexString(gc.getMaxColour())
+ + (gc.isAutoScaled() ? "|" : "|abso|") + gc.getMin()
+ + "|"
+ gc.getMax() + "|";
- if (gc.getThreshType() != AnnotationColourGradient.NO_THRESHOLD)
+ if (gc.isBelowThreshold())
{
- if (gc.getThreshType() == AnnotationColourGradient.BELOW_THRESHOLD)
- {
- color += "below";
- }
- else
- {
- if (gc.getThreshType() != AnnotationColourGradient.ABOVE_THRESHOLD)
- {
- System.err.println("WARNING: Unsupported threshold type ("
- + gc.getThreshType() + ") : Assuming 'above'");
- }
- color += "above";
- }
- // add the value
- color += "|" + gc.getThresh();
+ color += "below|" + gc.getThreshold();
+ }
+ else if (gc.isAboveThreshold())
+ {
+ color += "above|" + gc.getThreshold();
}
else
{
color += "none";
}
}
- else if (visible.get(type) instanceof java.awt.Color)
- {
- color = Format.getHexString((java.awt.Color) visible.get(type));
- }
else
{
- // legacy support for integer objects containing colour triplet values
- color = Format.getHexString(new java.awt.Color(Integer
- .parseInt(visible.get(type).toString())));
+ color = Format.getHexString(gc.getColour());
}
- out.append(type);
+ // else
+ // {
+ // // legacy support for integer objects containing colour triplet
+ // values
+ // color = Format.getHexString(new java.awt.Color(Integer
+ // .parseInt(visible.get(type).toString())));
+ // }
+ out.append(feature);
out.append("\t");
out.append(color);
out.append(newline);
int groupIndex = 0;
boolean isnonpos = false;
- for (int i = 0; i < seqs.length; i++)
+ for (int i = 0; i < sequences.length; i++)
{
- next = seqs[i].getSequenceFeatures();
+ next = sequences[i].getSequenceFeatures();
if (next != null)
{
for (int j = 0; j < next.length; j++)
group = null;
}
- for (int i = 0; i < seqs.length; i++)
+ for (int i = 0; i < sequences.length; i++)
{
- next = seqs[i].getSequenceFeatures();
+ next = sequences[i].getSequenceFeatures();
if (next != null)
{
for (int j = 0; j < next.length; j++)
out.append("\t");
}
- out.append(seqs[i].getName());
+ out.append(sequences[i].getName());
out.append("\t-1\t");
out.append(next[j].begin);
out.append("\t");
* default.
*
* @param seqs
- * @param visible
+ * @param map
* @return
*/
- public String printGFFFormat(SequenceI[] seqs, Map<String, Object> visible)
+ public String printGFFFormat(SequenceI[] seqs,
+ Map<String, FeatureColourI> map)
{
- return printGFFFormat(seqs, visible, true, true);
+ return printGFFFormat(seqs, map, true, true);
}
public String printGFFFormat(SequenceI[] seqs,
- Map<String, Object> visible, boolean visOnly, boolean nonpos)
+ Map<String, FeatureColourI> map, boolean visOnly, boolean nonpos)
{
StringBuffer out = new StringBuffer();
SequenceFeature[] next;
{
isnonpos = next[j].begin == 0 && next[j].end == 0;
if ((!nonpos && isnonpos)
- || (!isnonpos && visOnly && !visible
+ || (!isnonpos && visOnly && !map
.containsKey(next[j].type)))
{
continue;
/**
* this is only for the benefit of object polymorphism - method does nothing.
*/
+ @Override
public void parse()
{
// IGNORED
*
* @return error message
*/
+ @Override
public String print()
{
return "USE printGFFFormat() or printJalviewFormat()";