// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
//
// Contact: phylosoft @ gmail . com
-// WWW: www.phylosoft.org/forester
+// WWW: https://sites.google.com/site/cmzmasek/home/software/forester
package org.forester.io.parsers.phyloxml;
import org.forester.phylogeny.data.Distribution;
import org.forester.phylogeny.data.Event;
import org.forester.phylogeny.data.Identifier;
+import org.forester.phylogeny.data.NodeVisualData;
import org.forester.phylogeny.data.PhylogenyDataUtil;
import org.forester.phylogeny.data.PropertiesMap;
import org.forester.phylogeny.data.Property;
+import org.forester.phylogeny.data.Property.AppliesTo;
import org.forester.phylogeny.data.Reference;
import org.forester.phylogeny.data.Sequence;
import org.forester.phylogeny.data.SequenceRelation;
catch ( final PhylogenyParserException ex ) {
throw new SAXException( ex.getMessage() );
}
+ catch ( final PhyloXmlDataFormatException e ) {
+ throw new SAXException( e.getMessage() );
+ }
}
else if ( local_name.equals( PhyloXmlMapping.SEQUENCE_RELATION ) ) {
try {
}
}
}
- catch ( final PhylogenyParserException ex ) {
+ catch ( final PhyloXmlDataFormatException ex ) {
throw new SAXException( ex.getMessage() );
}
}
try {
PhyloXmlHandler.mapElementToPhylogeny( getCurrentXmlElement(), getCurrentPhylogeny() );
}
- catch ( final PhylogenyParserException ex ) {
- throw new SAXException( ex.getMessage() );
+ catch ( final PhylogenyParserException e ) {
+ throw new SAXException( e.getMessage() );
+ }
+ catch ( final PhyloXmlDataFormatException e ) {
+ throw new SAXException( e.getMessage() );
}
finishPhylogeny();
reset();
}
private void mapElementToPhylogenyNode( final XmlElement xml_element, final PhylogenyNode node )
- throws PhylogenyParserException {
+ throws PhylogenyParserException, PhyloXmlDataFormatException {
if ( xml_element.isHasAttribute( PhyloXmlMapping.BRANCH_LENGTH ) ) {
double d = 0;
try {
}
else if ( qualified_name.equals( PhyloXmlMapping.BINARY_CHARACTERS ) ) {
node.getNodeData().setBinaryCharacters( ( BinaryCharacters ) BinaryCharactersParser.getInstance()
- .parse( element ) );
+ .parse( element ) );
}
else if ( qualified_name.equals( PhyloXmlMapping.COLOR ) ) {
node.getBranchData().setBranchColor( ( BranchColor ) ColorParser.getInstance().parse( element ) );
node.getNodeData().setEvent( ( Event ) EventParser.getInstance().parse( element ) );
}
else if ( qualified_name.equals( PhyloXmlMapping.PROPERTY ) ) {
- if ( !node.getNodeData().isHasProperties() ) {
- node.getNodeData().setProperties( new PropertiesMap() );
+ final Property prop = ( Property ) PropertyParser.getInstance().parse( element );
+ if ( prop.getRef().startsWith( NodeVisualData.APTX_VISUALIZATION_REF )
+ && ( prop.getAppliesTo() == AppliesTo.NODE ) ) {
+ if ( node.getNodeData().getNodeVisualData() == null ) {
+ node.getNodeData().setNodeVisualData( new NodeVisualData() );
+ }
+ node.getNodeData().getNodeVisualData().parseProperty( prop );
+ }
+ else {
+ if ( !node.getNodeData().isHasProperties() ) {
+ node.getNodeData().setProperties( new PropertiesMap() );
+ }
+ node.getNodeData().getProperties().addProperty( prop );
}
- node.getNodeData().getProperties()
- .addProperty( ( Property ) PropertyParser.getInstance().parse( element ) );
}
}
}
final XmlElement element = new XmlElement( namespace_uri, local_name, local_name, attributes );
if ( element.isHasAttribute( PhyloXmlMapping.PHYLOGENY_IS_REROOTABLE_ATTR ) ) {
getCurrentPhylogeny().setRerootable( Boolean.parseBoolean( element
- .getAttribute( PhyloXmlMapping.PHYLOGENY_IS_REROOTABLE_ATTR ) ) );
+ .getAttribute( PhyloXmlMapping.PHYLOGENY_IS_REROOTABLE_ATTR ) ) );
}
if ( element.isHasAttribute( PhyloXmlMapping.PHYLOGENY_BRANCHLENGTH_UNIT_ATTR ) ) {
getCurrentPhylogeny()
- .setDistanceUnit( element.getAttribute( PhyloXmlMapping.PHYLOGENY_BRANCHLENGTH_UNIT_ATTR ) );
+ .setDistanceUnit( element.getAttribute( PhyloXmlMapping.PHYLOGENY_BRANCHLENGTH_UNIT_ATTR ) );
}
if ( element.isHasAttribute( PhyloXmlMapping.PHYLOGENY_IS_ROOTED_ATTR ) ) {
getCurrentPhylogeny().setRooted( Boolean.parseBoolean( element
- .getAttribute( PhyloXmlMapping.PHYLOGENY_IS_ROOTED_ATTR ) ) );
+ .getAttribute( PhyloXmlMapping.PHYLOGENY_IS_ROOTED_ATTR ) ) );
}
if ( element.isHasAttribute( PhyloXmlMapping.PHYLOGENY_TYPE_ATTR ) ) {
getCurrentPhylogeny().setType( ( element.getAttribute( PhyloXmlMapping.PHYLOGENY_TYPE_ATTR ) ) );
}
private static void mapElementToPhylogeny( final XmlElement xml_element, final Phylogeny phylogeny )
- throws PhylogenyParserException {
+ throws PhylogenyParserException, PhyloXmlDataFormatException {
for( int i = 0; i < xml_element.getNumberOfChildElements(); ++i ) {
final XmlElement element = xml_element.getChildElement( i );
final String qualified_name = element.getQualifiedName();