X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FAnnotationFile.java;h=ae34f6b8c1b42e7d9b3b4a5fbe12bbd5ae262ec4;hb=7d6bf4ac01167499c0f4e07de63edcdd72a6d595;hp=82e71b546fc42c5e991a2e902a86802ad5f49419;hpb=7d67fb613ec026dc9a265e351e7fab542e3f1d61;p=jalview.git diff --git a/src/jalview/io/AnnotationFile.java b/src/jalview/io/AnnotationFile.java index 82e71b5..ae34f6b 100755 --- a/src/jalview/io/AnnotationFile.java +++ b/src/jalview/io/AnnotationFile.java @@ -32,8 +32,9 @@ import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.schemes.ColourSchemeI; import jalview.schemes.ColourSchemeProperty; -import jalview.schemes.UserColourScheme; +import jalview.util.ColorUtils; +import java.awt.Color; import java.io.BufferedReader; import java.io.FileReader; import java.io.InputStreamReader; @@ -581,7 +582,7 @@ public class AnnotationFile if (sg.cs != null) { text.append("colour="); - text.append(ColourSchemeProperty.getColourName(sg.cs)); + text.append(sg.cs.toString()); text.append("\t"); if (sg.cs.getThreshold() != 0) { @@ -1223,29 +1224,21 @@ public class AnnotationFile Annotation parseAnnotation(String string, int graphStyle) { - boolean hasSymbols = (graphStyle == AlignmentAnnotation.NO_GRAPH); // don't - // do the - // glyph - // test - // if we - // don't - // want - // secondary - // structure + // don't do the glyph test if we don't want secondary structure + boolean hasSymbols = (graphStyle == AlignmentAnnotation.NO_GRAPH); String desc = null, displayChar = null; char ss = ' '; // secondaryStructure float value = 0; boolean parsedValue = false, dcset = false; // find colour here - java.awt.Color colour = null; + Color colour = null; int i = string.indexOf("["); int j = string.indexOf("]"); if (i > -1 && j > -1) { - UserColourScheme ucs = new UserColourScheme(); - - colour = ucs.getColourFromString(string.substring(i + 1, j)); + colour = ColorUtils.parseColourString(string.substring(i + 1, + j)); if (i > 0 && string.charAt(i - 1) == ',') { // clip the preceding comma as well @@ -1347,7 +1340,7 @@ public class AnnotationFile void colourAnnotations(AlignmentI al, String label, String colour) { - UserColourScheme ucs = new UserColourScheme(colour); + Color awtColour = ColorUtils.parseColourString(colour); Annotation[] annotations; for (int i = 0; i < al.getAlignmentAnnotation().length; i++) { @@ -1358,7 +1351,7 @@ public class AnnotationFile { if (annotations[j] != null) { - annotations[j].colour = ucs.findColour('A'); + annotations[j].colour = awtColour; } } } @@ -1428,15 +1421,22 @@ public class AnnotationFile SequenceGroup groupRef) { String group = st.nextToken(); - AlignmentAnnotation annotation = null, alannot[] = al - .getAlignmentAnnotation(); - float value = new Float(st.nextToken()).floatValue(); + AlignmentAnnotation[] alannot = al.getAlignmentAnnotation(); + String nextToken = st.nextToken(); + float value = 0f; + try + { + value = Float.valueOf(nextToken); + } catch (NumberFormatException e) + { + System.err.println("line " + nlinesread + ": Threshold '" + nextToken + + "' invalid, setting to zero"); + } String label = st.hasMoreTokens() ? st.nextToken() : null; - java.awt.Color colour = null; + Color colour = null; if (st.hasMoreTokens()) { - UserColourScheme ucs = new UserColourScheme(st.nextToken()); - colour = ucs.findColour('A'); + colour = ColorUtils.parseColourString(st.nextToken()); } if (alannot != null) { @@ -1450,10 +1450,6 @@ public class AnnotationFile } } } - if (annotation == null) - { - return; - } } void addGroup(AlignmentI al, StringTokenizer st) @@ -1627,7 +1623,7 @@ public class AnnotationFile } else if (key.equalsIgnoreCase("colour")) { - sg.cs = ColourSchemeProperty.getColour(al, value); + sg.cs = ColourSchemeProperty.getColourScheme(al, value); } else if (key.equalsIgnoreCase("pidThreshold")) { @@ -1648,7 +1644,7 @@ public class AnnotationFile } else if (key.equalsIgnoreCase("outlineColour")) { - sg.setOutlineColour(new UserColourScheme(value).findColour('A')); + sg.setOutlineColour(ColorUtils.parseColourString(value)); } else if (key.equalsIgnoreCase("displayBoxes")) { @@ -1668,11 +1664,11 @@ public class AnnotationFile } else if (key.equalsIgnoreCase("textCol1")) { - sg.textColour = new UserColourScheme(value).findColour('A'); + sg.textColour = ColorUtils.parseColourString(value); } else if (key.equalsIgnoreCase("textCol2")) { - sg.textColour2 = new UserColourScheme(value).findColour('A'); + sg.textColour2 = ColorUtils.parseColourString(value); } else if (key.equalsIgnoreCase("textColThreshold")) { @@ -1680,9 +1676,8 @@ public class AnnotationFile } else if (key.equalsIgnoreCase("idColour")) { - // consider warning if colour doesn't resolve to a real colour - sg.setIdColour((def = new UserColourScheme(value)) - .findColour('A')); + Color idColour = ColorUtils.parseColourString(value); + sg.setIdColour(idColour == null ? Color.black : idColour); } else if (key.equalsIgnoreCase("hide")) {