Package versusSNP.util

Source Code of versusSNP.util.HTMLSequenceFormatter

package versusSNP.util;

import java.io.IOException;
import java.io.StringReader;

import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;

import versusSNP.blast.util.AlignmentStore;
import versusSNP.genome.Sequence;

public final class HTMLSequenceFormatter {
  public static final int LINE_CHARS = 60;
  public static final int SEGMENT_CHARS = 10;
 
  public static Document format(Sequence sequence) throws IOException, BadLocationException {
    HTMLEditorKit editorKit = new HTMLEditorKit();
    HTMLDocument doc = (HTMLDocument)editorKit.createDefaultDocument();
    editorKit.read(new StringReader(HTMLUtils.renderSequence(sequence.getSequence(), true)), doc, 0);
    return doc;
  }

  public static Document format(AlignmentStore alignmentStore) throws IOException, BadLocationException {
    HTMLEditorKit editorKit = new HTMLEditorKit();
    HTMLDocument doc = (HTMLDocument)editorKit.createDefaultDocument();
    editorKit.read(new StringReader(alignmentStore.getHTMLAlignment()), doc, 0);
    return doc;
  }
}
TOP

Related Classes of versusSNP.util.HTMLSequenceFormatter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.