From 58eec3dbd8522a2af4e7da68311621bfc06c6534 Mon Sep 17 00:00:00 2001 From: "cmzmasek@gmail.com" Date: Wed, 2 Apr 2014 23:59:51 +0000 Subject: [PATCH] inprogress --- .../io/parsers/phyloxml/PhyloXmlHandler.java | 15 ++++-- .../forester/phylogeny/data/NodeVisualData.java | 53 +++++++++++++++++++- 2 files changed, 63 insertions(+), 5 deletions(-) diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlHandler.java b/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlHandler.java index d33cb74..4eed70c 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlHandler.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlHandler.java @@ -59,6 +59,7 @@ 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; @@ -325,11 +326,17 @@ public final class PhyloXmlHandler extends DefaultHandler { else if ( qualified_name.equals( PhyloXmlMapping.PROPERTY ) ) { final Property prop = ( Property ) PropertyParser.getInstance().parse( element ); if ( prop.getRef().startsWith( NodeVisualData.APTX_VISUALIZATION_REF ) ) { - if ( node.getNodeData().getNodeVisualData() == null ) { - node.getNodeData().setNodeVisualData( new NodeVisualData() ); + if ( prop.getAppliesTo() == AppliesTo.NODE ) { + if ( node.getNodeData().getNodeVisualData() == null ) { + node.getNodeData().setNodeVisualData( new NodeVisualData() ); + } + final NodeVisualData vd = node.getNodeData().getNodeVisualData(); + vd.parseProperty( prop ); + } + else { + System.err.println( "Do not know how to handle " + NodeVisualData.APTX_VISUALIZATION_REF + + " property applied to " + prop.getAppliesTo() ); } - final NodeVisualData vd = node.getNodeData().getNodeVisualData(); - vd.parseProperty( prop ); } else { if ( !node.getNodeData().isHasProperties() ) { diff --git a/forester/java/src/org/forester/phylogeny/data/NodeVisualData.java b/forester/java/src/org/forester/phylogeny/data/NodeVisualData.java index a2018a2..4ef6adc 100644 --- a/forester/java/src/org/forester/phylogeny/data/NodeVisualData.java +++ b/forester/java/src/org/forester/phylogeny/data/NodeVisualData.java @@ -215,6 +215,43 @@ public final class NodeVisualData implements PhylogenyData { return; } } + // + else if ( prop.getRef().equals( NODE_SIZE_REF ) ) { + int s = -1; + try { + s = Integer.parseInt( prop.getValue() ); + } + catch ( final NumberFormatException e ) { + return; + } + if ( s >= 0 ) { + setSize( s ); + } + } + else if ( prop.getRef().equals( NODE_FILL_COLOR_REF ) ) { + try { + setFillColor( Color.decode( prop.getValue() ) ); + } + catch ( final NumberFormatException e ) { + return; + } + } + else if ( prop.getRef().equals( NODE_BORDER_COLOR_REF ) ) { + try { + setBorderColor( Color.decode( prop.getValue() ) ); + } + catch ( final NumberFormatException e ) { + return; + } + } + else if ( prop.getRef().equals( NODE_SHAPE_REF ) ) { + try { + setShape( prop.getValue() ); + } + catch ( final NumberFormatException e ) { + return; + } + } } public final void setBorderColor( final Color border_color ) { @@ -293,7 +330,22 @@ public final class NodeVisualData implements PhylogenyData { _shape = shape; } + public final void setShape( final String shape ) { + if ( shape.equalsIgnoreCase( NODE_SHAPE_CIRCLE ) ) { + setShape( NodeShape.CIRCLE ); + } + else if ( shape.equalsIgnoreCase( NODE_SHAPE_RECTANGLE ) ) { + setShape( NodeShape.RECTANGLE ); + } + else { + setShape( NodeShape.DEFAULT ); + } + } + public final void setSize( final float size ) { + if ( ( size != DEFAULT_SIZE ) && ( size < 0 ) ) { + throw new IllegalArgumentException( "negative size: " + size ); + } _size = size; } @@ -371,7 +423,6 @@ public final class NodeVisualData implements PhylogenyData { FONT_COLOR_TYPE, AppliesTo.NODE ) ); } - // if ( getShape() != NodeShape.DEFAULT ) { String shape = null; if ( getShape() == NodeShape.RECTANGLE ) { -- 1.7.10.2