in progress
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Thu, 18 Oct 2012 19:37:23 +0000 (19:37 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Thu, 18 Oct 2012 19:37:23 +0000 (19:37 +0000)
forester/java/src/org/forester/archaeopteryx/NodePanel.java
forester/java/src/org/forester/phylogeny/data/Distribution.java
forester/java/src/org/forester/phylogeny/data/Point.java

index c7a9ce8..01577d8 100644 (file)
@@ -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() ) );
index 92c219d..e799d82 100644 (file)
@@ -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 );
index a20b3d9..7684f16 100644 (file)
@@ -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( "?" ) ) );
+    }
 }