\r
public final class NodeVisualData implements PhylogenyData {\r
\r
- public static final String APTX_VISUALIZATION_REF = "aptx_visualization:";\r
- public static final String FONT_REF = APTX_VISUALIZATION_REF + "node_font";\r
- public static final String FONT_SIZE_REF = APTX_VISUALIZATION_REF + "node_font_size";\r
+ public static final String APTX_VISUALIZATION_REF = "style:";\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_SIZE_REF = APTX_VISUALIZATION_REF + "font_size";\r
public static final String FONT_SIZE_TYPE = "xsd:unsignedByte";\r
public static final String FONT_STYLE_BOLD = "bold";\r
public static final String FONT_STYLE_BOLD_ITALIC = "bold_italic";\r
public static final String FONT_STYLE_ITALIC = "italic";\r
public static final String FONT_STYLE_PLAIN = "plain";\r
- public static final String FONT_STYLE_REF = APTX_VISUALIZATION_REF + "node_font_style";\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_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_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_TYPE = "xsd:token";\r
+ public static final String NODE_SIZE_REF = APTX_VISUALIZATION_REF + "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_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_TRANSPARANCY = -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 FontType _font_style;\r
private NodeShape _shape;\r
private float _size;\r
- private float _transparancy;\r
+ private float _transparency;\r
\r
public NodeVisualData() {\r
init();\r
final Color border_color,\r
final Color fill_color,\r
final float size,\r
- final float transparancy ) {\r
+ final float transparency ) {\r
setFontName( font_name );\r
setFontStyle( font_style );\r
setFontSize( font_size );\r
setBorderColor( border_color );\r
setFillColor( fill_color );\r
setSize( size );\r
- setTransparancy( transparancy );\r
+ setTransparency( transparency );\r
}\r
\r
@Override\r
getFillColor() != null ? new Color( getFillColor().getRed(), getFillColor()\r
.getGreen(), getFillColor().getBlue() ) : null,\r
getSize(),\r
- getTransparancy() );\r
+ getTransparency() );\r
}\r
\r
public final Color getBorderColor() {\r
return _size;\r
}\r
\r
- public final float getTransparancy() {\r
- return _transparancy;\r
+ public final float getTransparency() {\r
+ return _transparency;\r
}\r
\r
public final boolean isEmpty() {\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 ) && ( getTransparancy() == DEFAULT_TRANSPARANCY ) );\r
+ && ( getBorderColor() == null ) && ( getFillColor() == null ) && ( getSize() == DEFAULT_SIZE ) && ( getTransparency() == DEFAULT_TRANSPARENCY ) );\r
}\r
\r
@Override\r
else if ( prop.getRef().equals( FONT_STYLE_REF ) ) {\r
setFontStyle( prop.getValue() );\r
}\r
+ else if ( prop.getRef().equals( FONT_COLOR_REF ) ) {\r
+ try {\r
+ setFontColor( Color.decode( prop.getValue() ) );\r
+ }\r
+ catch ( final NumberFormatException e ) {\r
+ return;\r
+ }\r
+ }\r
}\r
\r
public final void setBorderColor( final Color border_color ) {\r
_size = size;\r
}\r
\r
- public final void setTransparancy( final float transparancy ) {\r
- _transparancy = transparancy;\r
+ public final void setTransparency( final float transparency ) {\r
+ _transparency = transparency;\r
}\r
\r
@Override\r
return asText().toString();\r
}\r
\r
+ private String colorToHex( final Color c ) {\r
+ return String.format( "#%02x%02x%02x", c.getRed(), c.getGreen(), c.getBlue() );\r
+ }\r
+\r
private final void init() {\r
setFontName( null );\r
setFontStyle( FontType.PLAIN );\r
setBorderColor( null );\r
setFillColor( null );\r
setSize( DEFAULT_SIZE );\r
- setTransparancy( DEFAULT_TRANSPARANCY );\r
+ setTransparency( DEFAULT_TRANSPARENCY );\r
_font = null;\r
}\r
\r
AppliesTo.NODE ) );\r
}\r
if ( getFontStyle() != FontType.PLAIN ) {\r
- String font_style = FONT_STYLE_PLAIN;\r
+ String font_style = "";\r
if ( getFontStyle() == FontType.ITALIC ) {\r
font_style = FONT_STYLE_ITALIC;\r
}\r
else if ( getFontStyle() == FontType.BOLD_ITALIC ) {\r
font_style = FONT_STYLE_BOLD_ITALIC;\r
}\r
+ else {\r
+ throw new RuntimeException( "unknown font style" + getShape() );\r
+ }\r
properties.add( new Property( FONT_STYLE_REF, font_style, "", FONT_STYLE_TYPE, AppliesTo.NODE ) );\r
}\r
+ if ( getFontColor() != null ) {\r
+ properties.add( new Property( FONT_COLOR_REF,\r
+ colorToHex( getFontColor() ),\r
+ "",\r
+ FONT_COLOR_TYPE,\r
+ AppliesTo.NODE ) );\r
+ }\r
+ //\r
+ if ( getShape() != NodeShape.DEFAULT ) {\r
+ String shape = null;\r
+ if ( getShape() == NodeShape.RECTANGLE ) {\r
+ shape = NODE_SHAPE_RECTANGLE;\r
+ }\r
+ else if ( getShape() == NodeShape.CIRCLE ) {\r
+ shape = NODE_SHAPE_CIRCLE;\r
+ }\r
+ else {\r
+ throw new RuntimeException( "unknown node shape" + getShape() );\r
+ }\r
+ properties.add( new Property( NODE_SHAPE_REF, shape, "", NODE_SHAPE_TYPE, AppliesTo.NODE ) );\r
+ }\r
+ if ( getSize() != DEFAULT_SIZE ) {\r
+ properties.add( new Property( NODE_SIZE_REF,\r
+ String.valueOf( getSize() ),\r
+ "",\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
+ "",\r
+ NODE_BORDER_COLOR_TYPE,\r
+ AppliesTo.NODE ) );\r
+ }\r
+ if ( getFillType() != NodeFill.DEFAULT ) {\r
+ String fill = null;\r
+ if ( getFillType() == NodeFill.GRADIENT ) {\r
+ fill = NODE_FILL_GRADIENT;\r
+ }\r
+ else if ( getFillType() == NodeFill.NONE ) {\r
+ fill = NODE_FILL_NONE;\r
+ }\r
+ else if ( getFillType() == NodeFill.SOLID ) {\r
+ fill = NODE_FILL_SOLID;\r
+ }\r
+ else {\r
+ throw new RuntimeException( "unknown fill type " + getFillType() );\r
+ }\r
+ properties.add( new Property( NODE_FILL_TYPE_REF, fill, "", NODE_FILL_TYPE_TYPE, AppliesTo.NODE ) );\r
+ }\r
+ if ( getTransparency() != DEFAULT_TRANSPARENCY ) {\r
+ properties.add( new Property( NODE_TRANSPARENCY_REF,\r
+ String.valueOf( getTransparency() ),\r
+ "",\r
+ NODE_TRANSPARENCY_TYPE,\r
+ AppliesTo.NODE ) );\r
+ }\r
return properties;\r
}\r
\r