inprogress
[jalview.git] / forester / java / src / org / forester / phylogeny / data / NodeVisualData.java
index a2018a2..da0dc24 100644 (file)
@@ -26,22 +26,22 @@ public final class NodeVisualData implements PhylogenyData {
     public static final String FONT_STYLE_REF         = APTX_VISUALIZATION_REF + "font_style";\r
     public static final String FONT_STYLE_TYPE        = "xsd:token";\r
     public static final String FONT_TYPE              = "xsd:token";\r
-    public static final String NODE_BORDER_COLOR_REF  = APTX_VISUALIZATION_REF + "border_color";\r
+    public static final String NODE_BORDER_COLOR_REF  = APTX_VISUALIZATION_REF + "node_border_color";\r
     public static final String NODE_BORDER_COLOR_TYPE = "xsd:token";\r
-    public static final String NODE_FILL_COLOR_REF    = APTX_VISUALIZATION_REF + "fill_color";\r
+    public static final String NODE_FILL_COLOR_REF    = APTX_VISUALIZATION_REF + "node_fill_color";\r
     public static final String NODE_FILL_COLOR_TYPE   = "xsd:token";\r
     public static final String NODE_FILL_GRADIENT     = "gradient";\r
     public static final String NODE_FILL_NONE         = "none";\r
     public static final String NODE_FILL_SOLID        = "solid";\r
-    public static final String NODE_FILL_TYPE_REF     = APTX_VISUALIZATION_REF + "fill_type";\r
+    public static final String NODE_FILL_TYPE_REF     = APTX_VISUALIZATION_REF + "node_fill_type";\r
     public static final String NODE_FILL_TYPE_TYPE    = "xsd:token";\r
     public static final String NODE_SHAPE_CIRCLE      = "cicle";\r
     public static final String NODE_SHAPE_RECTANGLE   = "rectangle";\r
-    public static final String NODE_SHAPE_REF         = APTX_VISUALIZATION_REF + "shape";\r
+    public static final String NODE_SHAPE_REF         = APTX_VISUALIZATION_REF + "node_shape";\r
     public static final String NODE_SHAPE_TYPE        = "xsd:token";\r
-    public static final String NODE_SIZE_REF          = APTX_VISUALIZATION_REF + "size";\r
+    public static final String NODE_SIZE_REF          = APTX_VISUALIZATION_REF + "node_size";\r
     public static final String NODE_SIZE_TYPE         = "xsd:float";\r
-    public static final String NODE_TRANSPARENCY_REF  = APTX_VISUALIZATION_REF + "transparency";\r
+    public static final String NODE_TRANSPARENCY_REF  = APTX_VISUALIZATION_REF + "node_transparency";\r
     public static final String NODE_TRANSPARENCY_TYPE = "xsd:float";\r
     private static final byte  DEFAULT_FONT_SIZE      = -1;\r
     private static final int   DEFAULT_SIZE           = -1;\r
@@ -215,6 +215,43 @@ public final class NodeVisualData implements PhylogenyData {
                 return;\r
             }\r
         }\r
+        //\r
+        else if ( prop.getRef().equals( NODE_SIZE_REF ) ) {\r
+            int s = -1;\r
+            try {\r
+                s = Integer.parseInt( prop.getValue() );\r
+            }\r
+            catch ( final NumberFormatException e ) {\r
+                return;\r
+            }\r
+            if ( s >= 0 ) {\r
+                setSize( s );\r
+            }\r
+        }\r
+        else if ( prop.getRef().equals( NODE_FILL_COLOR_REF ) ) {\r
+            try {\r
+                setFillColor( Color.decode( prop.getValue() ) );\r
+            }\r
+            catch ( final NumberFormatException e ) {\r
+                return;\r
+            }\r
+        }\r
+        else if ( prop.getRef().equals( NODE_BORDER_COLOR_REF ) ) {\r
+            try {\r
+                setBorderColor( Color.decode( prop.getValue() ) );\r
+            }\r
+            catch ( final NumberFormatException e ) {\r
+                return;\r
+            }\r
+        }\r
+        else if ( prop.getRef().equals( NODE_SHAPE_REF ) ) {\r
+            try {\r
+                setShape( prop.getValue() );\r
+            }\r
+            catch ( final NumberFormatException e ) {\r
+                return;\r
+            }\r
+        }\r
     }\r
 \r
     public final void setBorderColor( final Color border_color ) {\r
@@ -293,7 +330,22 @@ public final class NodeVisualData implements PhylogenyData {
         _shape = shape;\r
     }\r
 \r
+    public final void setShape( final String shape ) {\r
+        if ( shape.equalsIgnoreCase( NODE_SHAPE_CIRCLE ) ) {\r
+            setShape( NodeShape.CIRCLE );\r
+        }\r
+        else if ( shape.equalsIgnoreCase( NODE_SHAPE_RECTANGLE ) ) {\r
+            setShape( NodeShape.RECTANGLE );\r
+        }\r
+        else {\r
+            setShape( NodeShape.DEFAULT );\r
+        }\r
+    }\r
+\r
     public final void setSize( final float size ) {\r
+        if ( ( size != DEFAULT_SIZE ) && ( size < 0 ) ) {\r
+            throw new IllegalArgumentException( "negative size: " + size );\r
+        }\r
         _size = size;\r
     }\r
 \r
@@ -371,7 +423,6 @@ public final class NodeVisualData implements PhylogenyData {
                                           FONT_COLOR_TYPE,\r
                                           AppliesTo.NODE ) );\r
         }\r
-        //\r
         if ( getShape() != NodeShape.DEFAULT ) {\r
             String shape = null;\r
             if ( getShape() == NodeShape.RECTANGLE ) {\r