import javax.swing.table.*;
import jalview.analysis.AlignmentSorter;
+import jalview.bin.Cache;
import jalview.commands.OrderCommand;
import jalview.datamodel.*;
import jalview.io.*;
InputStreamReader in = new InputStreamReader(new FileInputStream(
file), "UTF-8");
- jalview.binding.JalviewUserColours jucs = new jalview.binding.JalviewUserColours();
- jucs = (jalview.binding.JalviewUserColours) jucs.unmarshal(in);
-
+ jalview.schemabinding.version2.JalviewUserColours jucs = new jalview.schemabinding.version2.JalviewUserColours();
+ jucs = (jalview.schemabinding.version2.JalviewUserColours) jucs.unmarshal(in);
+
for (int i = jucs.getColourCount() - 1; i >= 0; i--)
{
String name;
- // TODO: update Colour XML
- fr.setColour(name = jucs.getColour(i).getName(), new Color(
+ jalview.schemabinding.version2.Colour newcol = jucs.getColour(i);
+ if (newcol.hasMax())
+ {
+ Color mincol=null,maxcol=null;
+ float thrsh=Float.NaN;
+ try {
+ mincol = new Color(
+ Integer.parseInt(newcol.getMinRGB(), 16));
+ maxcol = new Color(
+ Integer.parseInt(newcol.getRGB(), 16));
+
+ } catch (Exception e)
+ {
+ Cache.log.warn("Couldn't parse out graduated feature color.",e);
+ }
+ GraduatedColor gcol =
+ new GraduatedColor(mincol,maxcol,
+ newcol.getMin(),newcol.getMax());
+ if (newcol.hasAutoScale())
+ {
+ gcol.setAutoScaled(newcol.getAutoScale());
+ }
+ if (newcol.hasColourByLabel())
+ {
+ gcol.setColourByLabel(newcol.getColourByLabel());
+ }
+ if (newcol.hasThreshold())
+ {
+ gcol.setThresh(newcol.getThreshold());
+ gcol.setThreshType(AnnotationColourGradient.NO_THRESHOLD); // default
+ }
+ if (newcol.getThreshType().length()>0)
+ {
+ String ttyp = newcol.getThreshType();
+ if (ttyp.equalsIgnoreCase("NONE")) {
+ gcol.setThreshType(AnnotationColourGradient.NO_THRESHOLD);
+ }
+ if (ttyp.equalsIgnoreCase("ABOVE"))
+ {
+ gcol.setThreshType(AnnotationColourGradient.ABOVE_THRESHOLD);
+ }
+ if (ttyp.equalsIgnoreCase("BELOW")){
+ gcol.setThreshType(AnnotationColourGradient.BELOW_THRESHOLD);
+ }
+ }
+ fr.setColour(name = newcol.getName(), gcol);
+ } else {
+ fr.setColour(name = jucs.getColour(i).getName(), new Color(
Integer.parseInt(jucs.getColour(i).getRGB(), 16)));
+ }
fr.setOrder(name, (i == 0) ? 0 : i / jucs.getColourCount());
}
if (table != null)
if (value == JalviewFileChooser.APPROVE_OPTION)
{
String choice = chooser.getSelectedFile().getPath();
- jalview.binding.JalviewUserColours ucs = new jalview.binding.JalviewUserColours();
+ jalview.schemabinding.version2.JalviewUserColours ucs = new jalview.schemabinding.version2.JalviewUserColours();
ucs.setSchemeName("Sequence Features");
try
{
}
jalview.util.QuickSort.sort(sortOrder, sortTypes);
sortOrder = null;
+ Object fcol;
+ GraduatedColor gcol;
for (i = 0; i < sortTypes.length; i++)
{
- jalview.binding.Colour col = new jalview.binding.Colour();
+ jalview.schemabinding.version2.Colour col = new jalview.schemabinding.version2.Colour();
col.setName(sortTypes[i]);
col.setRGB(jalview.util.Format.getHexString(fr.getColour(col
.getName())));
+ fcol = fr.getFeatureStyle(sortTypes[i]);
+ if (fcol instanceof GraduatedColor)
+ {
+ gcol = (GraduatedColor) fcol;
+ col.setMin(gcol.getMin());
+ col.setMax(gcol.getMax());
+ col.setMinRGB(jalview.util.Format.getHexString(gcol
+ .getMinColor()));
+ col.setAutoScale(gcol.isAutoScale());
+ col.setThreshold(gcol.getThresh());
+ col.setColourByLabel(gcol.isColourByLabel());
+ switch (gcol.getThreshType())
+ {
+ case AnnotationColourGradient.NO_THRESHOLD:
+ col.setThreshType("NONE");
+ break;
+ case AnnotationColourGradient.ABOVE_THRESHOLD:
+ col.setThreshType("ABOVE");
+ break;
+ case AnnotationColourGradient.BELOW_THRESHOLD:
+ col.setThreshType("BELOW");
+ break;
+ }
+ }
ucs.addColour(col);
}
ucs.marshal(out);