public final class NodeVisualData implements PhylogenyData {\r
\r
public static final String APTX_VISUALIZATION_REF = "style:";\r
+ public static final int DEFAULT_SIZE = -1;\r
public static final String FONT_COLOR_REF = APTX_VISUALIZATION_REF + "font_color";\r
public static final String FONT_COLOR_TYPE = "xsd:token";\r
public static final String FONT_REF = APTX_VISUALIZATION_REF + "font";\r
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_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_TYPE = "xsd:token";\r
+ public static final String NODE_COLOR_REF = APTX_VISUALIZATION_REF + "node_color";\r
+ public static final String NODE_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_CIRCLE = "circle";\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
private static final int DEFAULT_TRANSPARENCY = -1;\r
- private Color _border_color;\r
- private Color _fill_color;\r
private NodeFill _fill_type;\r
private Font _font;\r
private Color _font_color;\r
private String _font_name;\r
private byte _font_size;\r
private FontType _font_style;\r
+ private Color _node_color;\r
private NodeShape _shape;\r
private float _size;\r
private float _transparency;\r
final Color font_color,\r
final NodeShape shape,\r
final NodeFill fill_type,\r
- final Color border_color,\r
- final Color fill_color,\r
+ final Color node_color,\r
final float size,\r
final float transparency ) {\r
setFontName( font_name );\r
setFontColor( font_color );\r
setShape( shape );\r
setFillType( fill_type );\r
- setBorderColor( border_color );\r
- setFillColor( fill_color );\r
+ setNodeColor( node_color );\r
setSize( size );\r
setTransparency( transparency );\r
}\r
.getGreen(), getFontColor().getBlue() ) : null,\r
getShape(),\r
getFillType(),\r
- getBorderColor() != null ? new Color( getBorderColor().getRed(), getBorderColor()\r
- .getGreen(), getBorderColor().getBlue() ) : null,\r
- getFillColor() != null ? new Color( getFillColor().getRed(), getFillColor()\r
- .getGreen(), getFillColor().getBlue() ) : null,\r
+ getNodeColor() != null ? new Color( getNodeColor().getRed(), getNodeColor()\r
+ .getGreen(), getNodeColor().getBlue() ) : null,\r
getSize(),\r
getTransparency() );\r
}\r
\r
- public final Color getBorderColor() {\r
- return _border_color;\r
- }\r
-\r
- public final Color getFillColor() {\r
- return _fill_color;\r
- }\r
-\r
public final NodeFill getFillType() {\r
return _fill_type;\r
}\r
return Font.PLAIN;\r
}\r
\r
+ public final Color getNodeColor() {\r
+ return _node_color;\r
+ }\r
+\r
public final NodeShape getShape() {\r
return _shape;\r
}\r
return ( ForesterUtil.isEmpty( getFontName() ) && ( getFontStyle() == FontType.PLAIN )\r
&& ( getFontSize() == DEFAULT_FONT_SIZE ) && ( getFontColor() == null )\r
&& ( getShape() == NodeShape.DEFAULT ) && ( getFillType() == NodeFill.DEFAULT )\r
- && ( getBorderColor() == null ) && ( getFillColor() == null ) && ( getSize() == DEFAULT_SIZE ) && ( getTransparency() == DEFAULT_TRANSPARENCY ) );\r
+ && ( getNodeColor() == null ) && ( getSize() == DEFAULT_SIZE ) && ( getTransparency() == DEFAULT_TRANSPARENCY ) );\r
}\r
\r
@Override\r
return;\r
}\r
}\r
- }\r
-\r
- public final void setBorderColor( final Color border_color ) {\r
- _border_color = border_color;\r
- }\r
-\r
- public final void setFillColor( final Color fill_color ) {\r
- _fill_color = fill_color;\r
+ else if ( prop.getRef().equals( NODE_SIZE_REF ) ) {\r
+ float s = -1.0f;\r
+ try {\r
+ s = Float.parseFloat( 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_COLOR_REF ) ) {\r
+ try {\r
+ setNodeColor( Color.decode( prop.getValue() ) );\r
+ }\r
+ catch ( final NumberFormatException e ) {\r
+ return;\r
+ }\r
+ }\r
+ else if ( prop.getRef().equals( NODE_SHAPE_REF ) ) {\r
+ setShape( prop.getValue() );\r
+ }\r
+ else if ( prop.getRef().equals( NODE_FILL_TYPE_REF ) ) {\r
+ setFillType( prop.getValue() );\r
+ }\r
}\r
\r
public final void setFillType( final NodeFill fill_type ) {\r
_fill_type = fill_type;\r
}\r
\r
+ public final void setFillType( final String fill ) {\r
+ if ( fill.equalsIgnoreCase( NODE_FILL_NONE ) ) {\r
+ setFillType( NodeFill.NONE );\r
+ }\r
+ else if ( fill.equalsIgnoreCase( NODE_FILL_SOLID ) ) {\r
+ setFillType( NodeFill.SOLID );\r
+ }\r
+ else if ( fill.equalsIgnoreCase( NODE_FILL_GRADIENT ) ) {\r
+ setFillType( NodeFill.GRADIENT );\r
+ }\r
+ else {\r
+ setFillType( NodeFill.DEFAULT );\r
+ }\r
+ }\r
+\r
public final void setFontColor( final Color font_color ) {\r
_font_color = font_color;\r
}\r
}\r
}\r
\r
+ public final void setNodeColor( final Color node_color ) {\r
+ _node_color = node_color;\r
+ }\r
+\r
public final void setShape( final NodeShape shape ) {\r
_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
setFontColor( null );\r
setShape( NodeShape.DEFAULT );\r
setFillType( NodeFill.DEFAULT );\r
- setBorderColor( null );\r
- setFillColor( null );\r
+ setNodeColor( null );\r
setSize( DEFAULT_SIZE );\r
setTransparency( DEFAULT_TRANSPARENCY );\r
_font = null;\r
FONT_COLOR_TYPE,\r
AppliesTo.NODE ) );\r
}\r
- //\r
if ( getShape() != NodeShape.DEFAULT ) {\r
String shape = null;\r
if ( getShape() == NodeShape.RECTANGLE ) {\r
NODE_SIZE_TYPE,\r
AppliesTo.NODE ) );\r
}\r
- if ( getFillColor() != null ) {\r
- properties.add( new Property( NODE_FILL_COLOR_REF,\r
- colorToHex( getFillColor() ),\r
- "",\r
- NODE_FILL_COLOR_TYPE,\r
- AppliesTo.NODE ) );\r
- }\r
- if ( getBorderColor() != null ) {\r
- properties.add( new Property( NODE_BORDER_COLOR_REF,\r
- colorToHex( getBorderColor() ),\r
+ if ( getNodeColor() != null ) {\r
+ properties.add( new Property( NODE_COLOR_REF,\r
+ colorToHex( getNodeColor() ),\r
"",\r
- NODE_BORDER_COLOR_TYPE,\r
+ NODE_COLOR_TYPE,\r
AppliesTo.NODE ) );\r
}\r
if ( getFillType() != NodeFill.DEFAULT ) {\r