From 081ab5f646bcae3f5192e9c1786e2d68ce015ed8 Mon Sep 17 00:00:00 2001 From: "cmzmasek@gmail.com" Date: Wed, 26 Mar 2014 23:17:19 +0000 Subject: [PATCH] cleanup --- .../src/org/forester/archaeopteryx/MainFrame.java | 1 - .../src/org/forester/archaeopteryx/Options.java | 4 +- .../src/org/forester/phylogeny/data/NodeData.java | 42 ++-- .../forester/phylogeny/data/NodeVisualData.java | 203 ++++++++++---------- 4 files changed, 120 insertions(+), 130 deletions(-) diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrame.java b/forester/java/src/org/forester/archaeopteryx/MainFrame.java index 0820cbf..7ef6dd6 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrame.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrame.java @@ -65,7 +65,6 @@ import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY; import org.forester.phylogeny.PhylogenyNode; import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE; import org.forester.phylogeny.data.Annotation; - import org.forester.phylogeny.data.NodeVisualData.NodeFill; import org.forester.phylogeny.data.NodeVisualData.NodeShape; import org.forester.sdi.GSDI; diff --git a/forester/java/src/org/forester/archaeopteryx/Options.java b/forester/java/src/org/forester/archaeopteryx/Options.java index 3a10245..fdaeacb 100644 --- a/forester/java/src/org/forester/archaeopteryx/Options.java +++ b/forester/java/src/org/forester/archaeopteryx/Options.java @@ -51,8 +51,8 @@ final public class Options { private CLADOGRAM_TYPE _cladogram_type; private boolean _color_by_taxonomic_group; private boolean _color_labels_same_as_parent_branch; - private NodeVisualData.NodeFill _default_node_fill; - private NodeVisualData.NodeShape _default_node_shape; + private NodeVisualData.NodeFill _default_node_fill; + private NodeVisualData.NodeShape _default_node_shape; private short _default_node_shape_size; private boolean _editable; private NODE_DATA _ext_desc_data_to_return; diff --git a/forester/java/src/org/forester/phylogeny/data/NodeData.java b/forester/java/src/org/forester/phylogeny/data/NodeData.java index 609b203..7e180d4 100644 --- a/forester/java/src/org/forester/phylogeny/data/NodeData.java +++ b/forester/java/src/org/forester/phylogeny/data/NodeData.java @@ -52,17 +52,17 @@ public class NodeData implements PhylogenyData { TAXONOMY_CODE, UNKNOWN; } - private String _node_name; - private Event _event; - private List _sequences; - private List _taxonomies; - private List _distributions; - private Date _date; - private BinaryCharacters _binary_characters; - private PropertiesMap _properties; - private List _references; - private List _vector; - private NodeVisualData _node_visual_data; + private String _node_name; + private Event _event; + private List _sequences; + private List _taxonomies; + private List _distributions; + private Date _date; + private BinaryCharacters _binary_characters; + private PropertiesMap _properties; + private List _references; + private List _vector; + private NodeVisualData _node_visual_data; public NodeData() { init(); @@ -71,15 +71,15 @@ public class NodeData implements PhylogenyData { private void init() { _node_name = ""; _event = null; - _sequences= null; - _taxonomies= null; - _distributions= null; - _date= null; - _binary_characters= null; - _properties= null; - _references= null; - _vector= null; - _node_visual_data= null; + _sequences = null; + _taxonomies = null; + _distributions = null; + _date = null; + _binary_characters = null; + _properties = null; + _references = null; + _vector = null; + _node_visual_data = null; } public void addDistribution( final Distribution distribution ) { @@ -162,7 +162,7 @@ public class NodeData implements PhylogenyData { } } } - if ( getNodeVisualData() != null && !getNodeVisualData().isEmpty() ) { + if ( ( getNodeVisualData() != null ) && !getNodeVisualData().isEmpty() ) { new_data.setNodeVisualData( ( NodeVisualData ) getNodeVisualData().copy() ); } if ( isHasDate() ) { diff --git a/forester/java/src/org/forester/phylogeny/data/NodeVisualData.java b/forester/java/src/org/forester/phylogeny/data/NodeVisualData.java index e77016f..e3b19a4 100644 --- a/forester/java/src/org/forester/phylogeny/data/NodeVisualData.java +++ b/forester/java/src/org/forester/phylogeny/data/NodeVisualData.java @@ -1,3 +1,4 @@ + package org.forester.phylogeny.data; import java.awt.Color; @@ -6,45 +7,43 @@ import java.io.Writer; import java.util.ArrayList; import java.util.List; - import org.forester.phylogeny.data.Property.AppliesTo; import org.forester.util.ForesterUtil; - public final class NodeVisualData implements PhylogenyData { - - private static final int DEFAULT_SIZE = -1; - private static final int DEFAULT_TRANSPARANCY = -1; - private static final byte DEFAULT_FONT_SIZE = -1; - private NodeShape _shape; - private NodeFill _fill_type; - private Color _border_color; - private Color _fill_color; - - private String _font; - private FontType _font_type; - private byte _font_size; - private Color _font_color; - - private float _size; - private float _transparancy; + + public static final String SIZE_REF = "aptx_visualiation:node_size"; + public static final String SIZE_TYPE = "xsd:decimal"; + private static final byte DEFAULT_FONT_SIZE = -1; + private static final int DEFAULT_SIZE = -1; + private static final int DEFAULT_TRANSPARANCY = -1; + private Color _border_color; + private Color _fill_color; + private NodeFill _fill_type; + private String _font; + private Color _font_color; + private byte _font_size; + private FontType _font_type; + private NodeShape _shape; + private float _size; + private float _transparancy; public NodeVisualData() { init(); } - public NodeVisualData( final String font, - final FontType font_type, - byte font_size, - Color font_color, - final NodeShape shape, - final NodeFill fill_type, - final Color border_color, - final Color fill_color, - final float size, - final float transparancy ) { + public NodeVisualData( final String font, + final FontType font_type, + final byte font_size, + final Color font_color, + final NodeShape shape, + final NodeFill fill_type, + final Color border_color, + final Color fill_color, + final float size, + final float transparancy ) { setFont( font ); - setFontType(font_type ); + setFontType( font_type ); setFontSize( font_size ); setFontColor( font_color ); setShape( shape ); @@ -67,20 +66,20 @@ public final class NodeVisualData implements PhylogenyData { } @Override - public final PhylogenyData copy() { - return new NodeVisualData( ForesterUtil.isEmpty( getFont() ) ? new String( getFont()) : null , + public final PhylogenyData copy() { + return new NodeVisualData( !ForesterUtil.isEmpty( getFont() ) ? new String( getFont() ) : null, getFontType(), getFontSize(), getFontColor() != null ? new Color( getFontColor().getRed(), getFontColor() - .getGreen(), getFontColor().getBlue() ) : null, + .getGreen(), getFontColor().getBlue() ) : null, getShape(), - getFillType(), - getBorderColor() != null ? new Color( getBorderColor().getRed(), getBorderColor() - .getGreen(), getBorderColor().getBlue() ) : null, - getFillColor() != null ? new Color( getFillColor().getRed(), getFillColor() - .getGreen(), getFillColor().getBlue() ) : null, - getSize(), - getTransparancy() ); + getFillType(), + getBorderColor() != null ? new Color( getBorderColor().getRed(), getBorderColor() + .getGreen(), getBorderColor().getBlue() ) : null, + getFillColor() != null ? new Color( getFillColor().getRed(), getFillColor() + .getGreen(), getFillColor().getBlue() ) : null, + getSize(), + getTransparancy() ); } public final Color getBorderColor() { @@ -95,6 +94,22 @@ public final class NodeVisualData implements PhylogenyData { return _fill_type; } + public final String getFont() { + return _font; + } + + public final Color getFontColor() { + return _font_color; + } + + public final byte getFontSize() { + return _font_size; + } + + public final FontType getFontType() { + return _font_type; + } + public final NodeShape getShape() { return _shape; } @@ -107,17 +122,11 @@ public final class NodeVisualData implements PhylogenyData { return _transparancy; } - private final void init() { - setFont( null ); - setFontType( FontType.NORMAL ); - setFontSize( DEFAULT_FONT_SIZE ); - setFontColor( null ); - setShape( NodeShape.DEFAULT ); - setFillType( NodeFill.DEFAULT ); - setBorderColor( null ); - setFillColor( null ); - setSize( DEFAULT_SIZE ); - setTransparancy( DEFAULT_TRANSPARANCY ); + public final boolean isEmpty() { + return ( ForesterUtil.isEmpty( getFont() ) && ( getFontType() == FontType.NORMAL ) + && ( getFontSize() == DEFAULT_FONT_SIZE ) && ( getFontColor() == null ) + && ( getShape() == NodeShape.DEFAULT ) && ( getFillType() == NodeFill.DEFAULT ) + && ( getBorderColor() == null ) && ( getFillColor() == null ) && ( getSize() == DEFAULT_SIZE ) && ( getTransparancy() == DEFAULT_TRANSPARANCY ) ); } @Override @@ -137,6 +146,27 @@ public final class NodeVisualData implements PhylogenyData { _fill_type = fill_type; } + public final void setFont( final String font ) { + if ( !ForesterUtil.isEmpty( font ) ) { + _font = font; + } + else { + _font = null; + } + } + + public final void setFontColor( final Color font_color ) { + _font_color = font_color; + } + + public final void setFontSize( final byte font_size ) { + _font_size = font_size; + } + + public final void setFontType( final FontType font_type ) { + _font_type = font_type; + } + public final void setShape( final NodeShape shape ) { _shape = shape; } @@ -164,16 +194,17 @@ public final class NodeVisualData implements PhylogenyData { return asText().toString(); } - public enum NodeFill { - NONE, GRADIENT, SOLID, DEFAULT - } - - public enum NodeShape { - CIRCLE, RECTANGLE, DEFAULT - } - - public enum FontType { - NORMAL, BOLD, ITALIC, BOLD_ITALIC + private final void init() { + setFont( null ); + setFontType( FontType.NORMAL ); + setFontSize( DEFAULT_FONT_SIZE ); + setFontColor( null ); + setShape( NodeShape.DEFAULT ); + setFillType( NodeFill.DEFAULT ); + setBorderColor( null ); + setFillColor( null ); + setSize( DEFAULT_SIZE ); + setTransparancy( DEFAULT_TRANSPARANCY ); } private final List toProperties() { @@ -186,56 +217,16 @@ public final class NodeVisualData implements PhylogenyData { properties.add( new Property( SIZE_REF, String.valueOf( getBorderColor() ), "", SIZE_TYPE, AppliesTo.NODE ) ); return properties; } - public static final String SIZE_REF = "aptx_visualiation:node_sise"; - public static final String SIZE_TYPE = "xsd:decimal"; - - public final boolean isEmpty() { - return ( ForesterUtil.isEmpty( getFont() ) && - getFontType() == FontType.NORMAL && - getFontSize() == DEFAULT_FONT_SIZE && - getFontColor() == null && - getShape() == NodeShape.DEFAULT && - getFillType() == NodeFill.DEFAULT && - getBorderColor() == null && - getFillColor() == null && - getSize() == DEFAULT_SIZE && - getTransparancy() == DEFAULT_TRANSPARANCY ); - } - - public final String getFont() { - return _font; - } - public final void setFont( final String font ) { - if ( !ForesterUtil.isEmpty( font ) ) { - _font = font; - } - else { - _font = null; - } - } - - public final FontType getFontType() { - return _font_type; - } - - public final void setFontType( FontType font_type ) { - _font_type = font_type; - } - - public final byte getFontSize() { - return _font_size; - } - - public final void setFontSize( byte font_size ) { - _font_size = font_size; + public enum FontType { + BOLD, BOLD_ITALIC, ITALIC, NORMAL } - public final Color getFontColor() { - return _font_color; + public enum NodeFill { + DEFAULT, GRADIENT, NONE, SOLID } - public final void setFontColor( Color font_color ) { - _font_color = font_color; + public enum NodeShape { + CIRCLE, DEFAULT, RECTANGLE } } -- 1.7.10.2