From 58a20dcbfcd8fb5570ae3b522f54f63c623a0439 Mon Sep 17 00:00:00 2001 From: "cmzmasek@gmail.com" Date: Thu, 18 Oct 2012 19:37:23 +0000 Subject: [PATCH 1/1] in progress --- .../java/src/org/forester/archaeopteryx/NodePanel.java | 2 +- .../src/org/forester/phylogeny/data/Distribution.java | 16 +++++++++++++--- .../java/src/org/forester/phylogeny/data/Point.java | 9 +++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/forester/java/src/org/forester/archaeopteryx/NodePanel.java b/forester/java/src/org/forester/archaeopteryx/NodePanel.java index c7a9ce8..01577d8 100644 --- a/forester/java/src/org/forester/archaeopteryx/NodePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/NodePanel.java @@ -317,7 +317,7 @@ class NodePanel extends JPanel implements TreeSelectionListener { addSubelement( category, DIST_DESCRIPTION, dist.getDesc() ); if ( ( dist.getPoints() != null ) && ( dist.getPoints().size() > 0 ) ) { final Point p0 = dist.getPoints().get( 0 ); - if ( p0 != null ) { + if ( ( p0 != null ) && !Point.isSeemsEmpty( p0 ) ) { addSubelement( category, DIST_GEODETIC_DATUM, p0.getGeodeticDatum() ); addSubelement( category, DIST_LATITUDE, String.valueOf( p0.getLatitude() ) ); addSubelement( category, DIST_LONGITUDE, String.valueOf( p0.getLongitude() ) ); diff --git a/forester/java/src/org/forester/phylogeny/data/Distribution.java b/forester/java/src/org/forester/phylogeny/data/Distribution.java index 92c219d..e799d82 100644 --- a/forester/java/src/org/forester/phylogeny/data/Distribution.java +++ b/forester/java/src/org/forester/phylogeny/data/Distribution.java @@ -61,6 +61,12 @@ public class Distribution implements PhylogenyData { } public boolean isEmpty() { + if ( ForesterUtil.isEmpty( _desc ) && ( ( getPoints() != null ) && ( getPoints().size() == 1 ) ) + && ForesterUtil.isEmpty( _polygons ) ) { + if ( Point.isSeemsEmpty( getPoints().get( 0 ) ) ) { + return true; + } + } return ForesterUtil.isEmpty( _desc ) && ForesterUtil.isEmpty( _points ) && ForesterUtil.isEmpty( _polygons ); } @@ -79,7 +85,7 @@ public class Distribution implements PhylogenyData { int i = 0; if ( getPoints() != null ) { for( final Point point : getPoints() ) { - if ( point != null ) { + if ( ( point != null ) && !Point.isSeemsEmpty( point ) ) { sb.append( ForesterUtil.LINE_SEPARATOR ); sb.append( " Point " + i + ": " ); sb.append( point.asSimpleText() ); @@ -162,12 +168,16 @@ public class Distribution implements PhylogenyData { final String ind = indentation + PhylogenyWriter.PHYLO_XML_INTENDATION_BASE; if ( getPoints() != null ) { for( final Point point : getPoints() ) { - point.toPhyloXML( writer, level, ind ); + if ( ( point != null ) && !Point.isSeemsEmpty( point ) ) { + point.toPhyloXML( writer, level, ind ); + } } } if ( getPolygons() != null ) { for( final Polygon polygon : getPolygons() ) { - polygon.toPhyloXML( writer, level, ind ); + if ( polygon != null ) { + polygon.toPhyloXML( writer, level, ind ); + } } } writer.write( ForesterUtil.LINE_SEPARATOR ); diff --git a/forester/java/src/org/forester/phylogeny/data/Point.java b/forester/java/src/org/forester/phylogeny/data/Point.java index a20b3d9..7684f16 100644 --- a/forester/java/src/org/forester/phylogeny/data/Point.java +++ b/forester/java/src/org/forester/phylogeny/data/Point.java @@ -149,4 +149,13 @@ public class Point implements PhylogenyData { public String toString() { return asSimpleText().toString(); } + + static public final boolean isSeemsEmpty( final Point p ) { + return ( ( ( p.getAltitude() == null ) || ( p.getAltitude().compareTo( BigDecimal.ZERO ) <= 0 ) ) + && ( ( p.getLongitude() == null ) || ( p.getLongitude().compareTo( BigDecimal.ZERO ) <= 0 ) ) + && ( ( p.getLatitude() == null ) || ( p.getLatitude().compareTo( BigDecimal.ZERO ) <= 0 ) ) + && ( ForesterUtil.isEmpty( p.getGeodeticDatum() ) || p.getGeodeticDatum() + .equalsIgnoreCase( UNKNOWN_GEODETIC_DATUM ) ) && ( ForesterUtil.isEmpty( p.getAltiudeUnit() ) || p + .getAltiudeUnit().equalsIgnoreCase( "?" ) ) ); + } } -- 1.7.10.2