@Override public PhylogenyData copy() { List<Point> new_points = null; List<Polygon> new_polygons = null; if ( getPoints() != null ) { new_points = new ArrayList<Point>(); for( final Point point : getPoints() ) { new_points.add( ( Point ) point.copy() ); } } if ( getPolygons() != null ) { new_polygons = new ArrayList<Polygon>(); for( final Polygon polygon : getPolygons() ) { new_polygons.add( ( Polygon ) polygon.copy() ); } } return new Distribution( getDesc(), new_points, new_polygons ); }
final public static void ensurePresenceOfDistribution( final PhylogenyNode node ) { if ( !node.getNodeData().isHasDistribution() ) { node.getNodeData().setDistribution( new Distribution( "" ) ); } }
@Override public PhylogenyData parse( final XmlElement element ) throws PhyloXmlDataFormatException { String desc = ""; List<Point> points = null; List<Polygon> polygons = null; for( int i = 0; i < element.getNumberOfChildElements(); ++i ) { final XmlElement child_element = element.getChildElement( i ); if ( child_element.getQualifiedName().equals( PhyloXmlMapping.DISTRIBUTION_DESC ) ) { desc = child_element.getValueAsString(); } else if ( child_element.getQualifiedName().equals( PhyloXmlMapping.POINT ) ) { if ( points == null ) { points = new ArrayList<Point>(); } points.add( ( Point ) PointParser.getInstance().parse( child_element ) ); } else if ( child_element.getQualifiedName().equals( PhyloXmlMapping.POLYGON ) ) { if ( polygons == null ) { polygons = new ArrayList<Polygon>(); } polygons.add( ( Polygon ) PolygonParser.getInstance().parse( child_element ) ); } } return new Distribution( desc, points, polygons ); }
private List<Point> obtainPoints() { ForesterUtil.ensurePresenceOfDistribution( getMyNode() ); Distribution d = getMyNode().getNodeData().getDistribution(); if ( d.getPoints() == null ) { d = new Distribution( d.getDesc(), new ArrayList<Point>(), d.getPolygons() ); getMyNode().getNodeData().setDistribution( d ); } final List<Point> ps = d.getPoints(); if ( ps.isEmpty() ) { ps.add( new Point() ); } else if ( ps.get( 0 ) == null ) { ps.set( 0, new Point() ); } return ps; }
private void addDistribution( final DefaultMutableTreeNode top, Distribution dist, final String name ) { if ( dist == null ) { dist = new Distribution( "" );
ForesterUtil.ensurePresenceOfDistribution( getMyNode() ); final Distribution d = getMyNode().getNodeData().getDistribution(); getMyNode().getNodeData().setDistribution( new Distribution( value, d.getPoints(), d.getPolygons() ) ); break;
private void createNodes( final DefaultMutableTreeNode top, final PhylogenyNode phylogeny_node ) { if ( !phylogeny_node.getNodeData().isHasTaxonomy() ) { phylogeny_node.getNodeData().addTaxonomy( new Taxonomy() ); } if ( !phylogeny_node.getNodeData().isHasSequence() ) { phylogeny_node.getNodeData().addSequence( new Sequence() ); } if ( !phylogeny_node.getNodeData().isHasDistribution() ) { phylogeny_node.getNodeData().addDistribution( new Distribution( "" ) ); } if ( !phylogeny_node.getNodeData().isHasReference() ) { phylogeny_node.getNodeData().addReference( new Reference( "" ) ); } addBasics( top, phylogeny_node, NodePanel.BASIC ); addTaxonomy( top, phylogeny_node.getNodeData().getTaxonomy(), NodePanel.TAXONOMY ); addSequence( top, phylogeny_node.getNodeData().getSequence(), NodePanel.SEQUENCE ); if ( !phylogeny_node.isExternal() ) { addEvents( top, phylogeny_node.getNodeData().getEvent(), NodePanel.EVENTS ); } addDate( top, phylogeny_node.getNodeData().getDate(), NodePanel.DATE ); addDistribution( top, phylogeny_node.getNodeData().getDistribution(), NodePanel.DISTRIBUTION ); addReference( top, phylogeny_node.getNodeData().getReference(), NodePanel.LIT_REFERENCE ); // addProperties( top, phylogeny_node.getNodeData().getProperties(), "Properties" ); }