X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FAnnotationFile.java;h=2182b24b9b7bb6154102bf0cdbf3b0582f47cf1f;hb=1f029391e9e263b132a62eaefcc2fe68badacfd6;hp=aa29ced5c7db573a390dbceb340b5f7fd081e983;hpb=3da878124135ff033f42d19d8733891b09e953cd;p=jalview.git diff --git a/src/jalview/io/AnnotationFile.java b/src/jalview/io/AnnotationFile.java index aa29ced..2182b24 100755 --- a/src/jalview/io/AnnotationFile.java +++ b/src/jalview/io/AnnotationFile.java @@ -20,6 +20,17 @@ */ package jalview.io; +import java.awt.Color; +import java.io.BufferedReader; +import java.util.ArrayList; +import java.util.BitSet; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; +import java.util.Vector; + import jalview.analysis.Conservation; import jalview.api.AlignViewportI; import jalview.datamodel.AlignmentAnnotation; @@ -35,51 +46,32 @@ import jalview.schemes.ColourSchemeI; import jalview.schemes.ColourSchemeProperty; import jalview.util.ColorUtils; -import java.awt.Color; -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.InputStreamReader; -import java.io.StringReader; -import java.net.URL; -import java.util.ArrayList; -import java.util.BitSet; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.Vector; - public class AnnotationFile { - public AnnotationFile() - { - init(); - } + private static final String GRAPHLINE = "GRAPHLINE"; + + private static final String COMBINE = "COMBINE"; - /** - * character used to write newlines - */ protected String newline = System.getProperty("line.separator"); + private StringBuffer text; + + private SequenceI refSeq = null; + + private String refSeqId = null; + + private long nlinesread = 0; + + private String lastread = ""; + /** - * set new line string and reset the output buffer - * - * @param nl + * Constructor */ - public void setNewlineString(String nl) + public AnnotationFile() { - newline = nl; init(); } - public String getNewlineString() - { - return newline; - } - - StringBuffer text; - private void init() { text = new StringBuffer("JALVIEW_ANNOTATION" + newline + "# Created: " @@ -274,7 +266,7 @@ public class AnnotationFile if (row.graphGroup > -1) { graphGroupSeen.set(row.graphGroup); - Integer key = new Integer(row.graphGroup); + Integer key = Integer.valueOf(row.graphGroup); if (graphGroup.containsKey(key)) { graphGroup.put(key, graphGroup.get(key) + "\t" + row.label); @@ -642,10 +634,6 @@ public class AnnotationFile } } - SequenceI refSeq = null; - - String refSeqId = null; - public boolean annotateAlignmentView(AlignViewportI viewport, Object file, DataSourceType protocol) { @@ -682,32 +670,11 @@ public class AnnotationFile BufferedReader in = null; try { - if (sourceType == DataSourceType.FILE) - { - in = FileLoader.getBuffereReader(file); - } - else if (sourceType == DataSourceType.URL) - { - URL url = new URL(file.toString()); - in = new BufferedReader(new InputStreamReader(url.openStream())); - } - else if (sourceType == DataSourceType.PASTE) - { - in = new BufferedReader(new StringReader(file.toString())); - } - else if (sourceType == DataSourceType.CLASSLOADER) - { - java.io.InputStream is = getClass().getResourceAsStream("/" + file); - if (is != null) - { - in = new BufferedReader(new java.io.InputStreamReader(is)); - } - } + in = new FileParse().getBufferedReader(file, sourceType); if (in != null) { return parseAnnotationFrom(al, hidden, in); } - } catch (Exception ex) { ex.printStackTrace(); @@ -722,12 +689,6 @@ public class AnnotationFile return false; } - long nlinesread = 0; - - String lastread = ""; - - private static String GRAPHLINE = "GRAPHLINE", COMBINE = "COMBINE"; - public boolean parseAnnotationFrom(AlignmentI al, HiddenColumns hidden, BufferedReader in) throws Exception { @@ -762,7 +723,7 @@ public class AnnotationFile autoAnnotsKey(aa[aai], aa[aai].sequenceRef, (aa[aai].groupRef == null ? null : aa[aai].groupRef.getName())), - new Integer(1)); + Integer.valueOf(1)); } } } @@ -1271,7 +1232,7 @@ public class AnnotationFile { displayChar = token; // foo - value = new Float(token).floatValue(); + value = Float.valueOf(token).floatValue(); parsedValue = true; continue; } catch (NumberFormatException ex)