Class CgviewFactory

java.lang.Object
org.xml.sax.helpers.DefaultHandler
ca.ualberta.stothard.cgview.CgviewFactory
All Implemented Interfaces:
CgviewConstants, ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class CgviewFactory extends DefaultHandler implements CgviewConstants
This class reads an XML document and creates a Cgview object. The various elements and attributes in the file are used to describe sequence features (position, type, name, color, label font, and opacity). Optional XML attributes can be included, to control global map characteristics, and to add legends, a title, and footnotes.
Author:
Paul Stothard
  • Constructor Details

    • CgviewFactory

      public CgviewFactory()
      Constructs a new CgviewFactory object.
  • Method Details

    • createCgviewFromFile

      public Cgview createCgviewFromFile(String filename) throws SAXException, IOException
      Generates a Cgview object from an XML file.
      Parameters:
      filename - the XML file to read.
      Returns:
      the newly created Cgview object.
      Throws:
      SAXException
      IOException
    • createCgviewFromString

      public Cgview createCgviewFromString(String xml) throws SAXException, IOException
      Generates a Cgview object from a String of XML content.
      Parameters:
      xml - the XML content to read.
      Returns:
      the newly created Cgview object.
      Throws:
      SAXException
      IOException
    • addToCgviewFromFile

      public void addToCgviewFromFile(Cgview cgview, String filename) throws SAXException, IOException
      Adds FeatureSlot, Feature, and FeatureRange objects described in an XML file to an existing Cgview object. Any Legend and LegendItem objects in the XML are ignored, as are attributes in the cgview element.
      Parameters:
      cgview - the Cgview object to modify.
      filename - the XML file to supply the additional map content.
      Throws:
      SAXException
      IOException
    • addToCgviewFromString

      public void addToCgviewFromString(Cgview cgview, String xml) throws SAXException, IOException
      Adds FeatureSlot, Feature, and FeatureRange objects described in a String of XML to an existing Cgview object. Any Legend and LegendItem objects in the XML are ignored, as are attributes in the cgview element.
      Parameters:
      cgview - the Cgview object to modify.
      xml - the XML content to read.
      Throws:
      SAXException
      IOException
    • setLabelFontSize

      public void setLabelFontSize(int size)
      Sets the font size of feature labels. Use this method before calling createCgviewFromURL() or createCgviewFromFile().
      Parameters:
      size - the font size of feature labels.
    • setRulerFontSize

      public void setRulerFontSize(int size)
      Sets the font size of the sequence ruler. Use this method before calling createCgviewFromURL() or createCgviewFromFile().
      Parameters:
      size - the font size of the sequence ruler.
    • setLegendFontSize

      public void setLegendFontSize(int size)
      Sets the font size of legends. Use this method before calling createCgviewFromURL() or createCgviewFromFile().
      Parameters:
      size - the font size of legends.
    • setDocumentLocator

      public void setDocumentLocator(Locator loc)
      Specified by:
      setDocumentLocator in interface ContentHandler
      Overrides:
      setDocumentLocator in class DefaultHandler
    • startDocument

      public void startDocument()
      Specified by:
      startDocument in interface ContentHandler
      Overrides:
      startDocument in class DefaultHandler
    • endDocument

      public void endDocument()
      Specified by:
      endDocument in interface ContentHandler
      Overrides:
      endDocument in class DefaultHandler
    • startElement

      public void startElement(String uri, String name, String qName, Attributes atts) throws SAXException
      Specified by:
      startElement in interface ContentHandler
      Overrides:
      startElement in class DefaultHandler
      Throws:
      SAXException
    • characters

      public void characters(char[] ch, int start, int length)
      Specified by:
      characters in interface ContentHandler
      Overrides:
      characters in class DefaultHandler
    • endElement

      public void endElement(String uri, String name, String qName) throws SAXException
      Specified by:
      endElement in interface ContentHandler
      Overrides:
      endElement in class DefaultHandler
      Throws:
      SAXException