Package ca.ualberta.stothard.cgview
Class CgviewFactory
java.lang.Object
org.xml.sax.helpers.DefaultHandler
ca.ualberta.stothard.cgview.CgviewFactory
- All Implemented Interfaces:
CgviewConstants
,ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
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
-
Field Summary
Fields inherited from interface ca.ualberta.stothard.cgview.CgviewConstants
BASES, BOUNDS_BUTTON, BOUNDS_FEATURE, BOUNDS_RULER, CENTISOMES, DECORATION_CLOCKWISE_ARROW, DECORATION_COUNTERCLOCKWISE_ARROW, DECORATION_HIDDEN, DECORATION_STANDARD, DIRECT_STRAND, INNER_LABELS_AUTO, INNER_LABELS_NO_SHOW, INNER_LABELS_SHOW, LABEL, LABEL_FORCE, LABEL_NONE, LABEL_ZOOMED, LEGEND_DRAW_ZOOMED, LEGEND_ITEM_ALIGN_CENTER, LEGEND_ITEM_ALIGN_LEFT, LEGEND_ITEM_ALIGN_RIGHT, LEGEND_LOWER_CENTER, LEGEND_LOWER_LEFT, LEGEND_LOWER_RIGHT, LEGEND_MIDDLE_CENTER, LEGEND_MIDDLE_LEFT, LEGEND_MIDDLE_LEFT_OF_CENTER, LEGEND_MIDDLE_RIGHT, LEGEND_MIDDLE_RIGHT_OF_CENTER, LEGEND_NO_DRAW_ZOOMED, LEGEND_UPPER_CENTER, LEGEND_UPPER_LEFT, LEGEND_UPPER_RIGHT, POSITIONS_AUTO, POSITIONS_NO_SHOW, POSITIONS_SHOW, REVERSE_STRAND, SWATCH_NO_SHOW, SWATCH_SHOW
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addToCgviewFromFile
(Cgview cgview, String filename) Adds FeatureSlot, Feature, and FeatureRange objects described in an XML file to an existing Cgview object.void
addToCgviewFromString
(Cgview cgview, String xml) Adds FeatureSlot, Feature, and FeatureRange objects described in a String of XML to an existing Cgview object.void
characters
(char[] ch, int start, int length) createCgviewFromFile
(String filename) Generates a Cgview object from an XML file.Generates a Cgview object from a String of XML content.void
void
endElement
(String uri, String name, String qName) void
void
setLabelFontSize
(int size) Sets the font size of feature labels.void
setLegendFontSize
(int size) Sets the font size of legends.void
setRulerFontSize
(int size) Sets the font size of the sequence ruler.void
void
startElement
(String uri, String name, String qName, Attributes atts) Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.xml.sax.ContentHandler
declaration
-
Constructor Details
-
CgviewFactory
public CgviewFactory()Constructs a new CgviewFactory object.
-
-
Method Details
-
createCgviewFromFile
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
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
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
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
- Specified by:
setDocumentLocator
in interfaceContentHandler
- Overrides:
setDocumentLocator
in classDefaultHandler
-
startDocument
public void startDocument()- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classDefaultHandler
-
endDocument
public void endDocument()- Specified by:
endDocument
in interfaceContentHandler
- Overrides:
endDocument
in classDefaultHandler
-
startElement
public void startElement(String uri, String name, String qName, Attributes atts) throws SAXException - Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classDefaultHandler
- Throws:
SAXException
-
characters
public void characters(char[] ch, int start, int length) - Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classDefaultHandler
-
endElement
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classDefaultHandler
- Throws:
SAXException
-