From: cmzmasek@gmail.com Date: Tue, 21 Jun 2011 23:21:42 +0000 (+0000) Subject: in progress X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f56cb8f21fffb174eed6b72ff016e1db2f69dcd4;p=jalview.git in progress --- diff --git a/forester/java/src/org/forester/archaeopteryx/Configuration.java b/forester/java/src/org/forester/archaeopteryx/Configuration.java index 0eead28..348d29d 100644 --- a/forester/java/src/org/forester/archaeopteryx/Configuration.java +++ b/forester/java/src/org/forester/archaeopteryx/Configuration.java @@ -45,10 +45,11 @@ import java.util.TreeMap; import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE; import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION; -import org.forester.archaeopteryx.Options.NodeFill; -import org.forester.archaeopteryx.Options.NodeShape; import org.forester.archaeopteryx.Options.OVERVIEW_PLACEMENT_TYPE; import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE; +import org.forester.phylogeny.data.NodeVisualization; +import org.forester.phylogeny.data.NodeVisualization.NodeFill; +import org.forester.phylogeny.data.NodeVisualization.NodeShape; import org.forester.util.ForesterUtil; public final class Configuration { @@ -1073,13 +1074,13 @@ public final class Configuration { } else if ( key.equals( "default_node_fill" ) ) { final String fill_str = ( ( String ) st.nextElement() ).trim(); - if ( fill_str.equalsIgnoreCase( Options.NodeFill.NONE.toString() ) ) { + if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.NONE.toString() ) ) { setDefaultNodeFill( NodeFill.NONE ); } - else if ( fill_str.equalsIgnoreCase( Options.NodeFill.GRADIENT.toString() ) ) { + else if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.GRADIENT.toString() ) ) { setDefaultNodeFill( NodeFill.GRADIENT ); } - else if ( fill_str.equalsIgnoreCase( Options.NodeFill.SOLID.toString() ) ) { + else if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.SOLID.toString() ) ) { setDefaultNodeFill( NodeFill.SOLID ); } else { @@ -1089,10 +1090,10 @@ public final class Configuration { } else if ( key.equals( "default_node_shape" ) ) { final String shape_str = ( ( String ) st.nextElement() ).trim(); - if ( shape_str.equalsIgnoreCase( Options.NodeShape.CIRCLE.toString() ) ) { + if ( shape_str.equalsIgnoreCase( NodeVisualization.NodeShape.CIRCLE.toString() ) ) { setDefaultNodeShape( NodeShape.CIRCLE ); } - else if ( shape_str.equalsIgnoreCase( Options.NodeShape.RECTANGLE.toString() ) ) { + else if ( shape_str.equalsIgnoreCase( NodeVisualization.NodeShape.RECTANGLE.toString() ) ) { setDefaultNodeShape( NodeShape.RECTANGLE ); } else { diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrame.java b/forester/java/src/org/forester/archaeopteryx/MainFrame.java index 95d8b92..80555c0 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrame.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrame.java @@ -47,6 +47,8 @@ import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE; import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION; import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE; import org.forester.phylogeny.Phylogeny; +import org.forester.phylogeny.data.NodeVisualization.NodeFill; +import org.forester.phylogeny.data.NodeVisualization.NodeShape; import org.forester.util.ForesterConstants; import org.forester.util.ForesterUtil; @@ -1118,13 +1120,13 @@ public abstract class MainFrame extends JFrame implements ActionListener { static void cycleNodeFill( final Options op, final TreePanel tree_panel ) { switch ( op.getDefaultNodeFill() ) { case GRADIENT: - op.setDefaultNodeFill( Options.NodeFill.SOLID ); + op.setDefaultNodeFill( NodeFill.SOLID ); break; case NONE: - op.setDefaultNodeFill( Options.NodeFill.GRADIENT ); + op.setDefaultNodeFill( NodeFill.GRADIENT ); break; case SOLID: - op.setDefaultNodeFill( Options.NodeFill.NONE ); + op.setDefaultNodeFill( NodeFill.NONE ); break; default: throw new RuntimeException( "unknown fill: " + op.getDefaultNodeFill() ); @@ -1134,10 +1136,10 @@ public abstract class MainFrame extends JFrame implements ActionListener { static void cycleNodeShape( final Options op, final TreePanel tree_panel ) { switch ( op.getDefaultNodeShape() ) { case CIRCLE: - op.setDefaultNodeShape( Options.NodeShape.RECTANGLE ); + op.setDefaultNodeShape( NodeShape.RECTANGLE ); break; case RECTANGLE: - op.setDefaultNodeShape( Options.NodeShape.CIRCLE ); + op.setDefaultNodeShape( NodeShape.CIRCLE ); break; default: throw new RuntimeException( "unknown shape: " + op.getDefaultNodeShape() ); diff --git a/forester/java/src/org/forester/archaeopteryx/Options.java b/forester/java/src/org/forester/archaeopteryx/Options.java index 0f9b7a0..4b75521 100644 --- a/forester/java/src/org/forester/archaeopteryx/Options.java +++ b/forester/java/src/org/forester/archaeopteryx/Options.java @@ -27,6 +27,9 @@ package org.forester.archaeopteryx; import java.awt.Font; +import org.forester.phylogeny.data.NodeVisualization; +import org.forester.phylogeny.data.NodeVisualization.NodeFill; +import org.forester.phylogeny.data.NodeVisualization.NodeShape; import org.forester.util.ForesterUtil; /* @@ -34,44 +37,44 @@ import org.forester.util.ForesterUtil; */ final public class Options { - static final double MIN_CONFIDENCE_DEFAULT = 0.0; - private boolean _show_branch_length_values; - private boolean _internal_number_are_confidence_for_nh_parsing; - private boolean _show_scale; - private boolean _show_overview; - private boolean _antialias_screen; - private boolean _antialias_print; - private boolean _graphics_export_visible_only; - private int _print_size_x; - private int _print_size_y; - private double _min_confidence_value; - private boolean _print_black_and_white; - private boolean _print_using_actual_size; - private boolean _graphics_export_using_actual_size; - private PHYLOGENY_GRAPHICS_TYPE _phylogeny_graphics_type; - private CLADOGRAM_TYPE _cladogram_type; - private OVERVIEW_PLACEMENT_TYPE _ov_placement; - private NODE_LABEL_DIRECTION _node_label_direction; - private Font _base_font; - private boolean _match_whole_terms_only; - private boolean _search_case_sensitive; - private float _print_line_width; - private boolean _inverse_search_result; - private double _scale_bar_length; - private short _number_of_digits_after_comma_for_confidence_values; - private short _number_of_digits_after_comma_for_branch_length_values; - private boolean _nh_parsing_replace_underscores; - private boolean _nh_parsing_extract_pfam_taxonomy_codes; - private boolean _editable; - private boolean _background_color_gradient; - private boolean _show_domain_labels; - private boolean _color_labels_same_as_parent_branch; - private boolean _abbreviate_scientific_names; - private NodeShape _default_node_shape; - private NodeFill _default_node_fill; - private short _default_node_shape_size; - private boolean _taxonomy_colorize_node_shapes; - private boolean _show_default_node_shapes; + static final double MIN_CONFIDENCE_DEFAULT = 0.0; + private boolean _show_branch_length_values; + private boolean _internal_number_are_confidence_for_nh_parsing; + private boolean _show_scale; + private boolean _show_overview; + private boolean _antialias_screen; + private boolean _antialias_print; + private boolean _graphics_export_visible_only; + private int _print_size_x; + private int _print_size_y; + private double _min_confidence_value; + private boolean _print_black_and_white; + private boolean _print_using_actual_size; + private boolean _graphics_export_using_actual_size; + private PHYLOGENY_GRAPHICS_TYPE _phylogeny_graphics_type; + private CLADOGRAM_TYPE _cladogram_type; + private OVERVIEW_PLACEMENT_TYPE _ov_placement; + private NODE_LABEL_DIRECTION _node_label_direction; + private Font _base_font; + private boolean _match_whole_terms_only; + private boolean _search_case_sensitive; + private float _print_line_width; + private boolean _inverse_search_result; + private double _scale_bar_length; + private short _number_of_digits_after_comma_for_confidence_values; + private short _number_of_digits_after_comma_for_branch_length_values; + private boolean _nh_parsing_replace_underscores; + private boolean _nh_parsing_extract_pfam_taxonomy_codes; + private boolean _editable; + private boolean _background_color_gradient; + private boolean _show_domain_labels; + private boolean _color_labels_same_as_parent_branch; + private boolean _abbreviate_scientific_names; + private NodeVisualization.NodeShape _default_node_shape; + private NodeVisualization.NodeFill _default_node_fill; + private short _default_node_shape_size; + private boolean _taxonomy_colorize_node_shapes; + private boolean _show_default_node_shapes; private Options() { init(); @@ -503,14 +506,6 @@ final public class Options { HORIZONTAL, RADIAL; } - enum NodeFill { - NONE, GRADIENT, SOLID - } - - enum NodeShape { - CIRCLE, RECTANGLE - } - static enum OVERVIEW_PLACEMENT_TYPE { UPPER_LEFT( "upper left" ), UPPER_RIGHT( "upper right" ), diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index 5866ba3..1f03048 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -92,8 +92,6 @@ import javax.swing.PopupFactory; import org.forester.archaeopteryx.ControlPanel.NodeClickAction; import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE; import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION; -import org.forester.archaeopteryx.Options.NodeFill; -import org.forester.archaeopteryx.Options.NodeShape; import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE; import org.forester.archaeopteryx.phylogeny.data.RenderableDomainArchitecture; import org.forester.archaeopteryx.phylogeny.data.RenderableVector; @@ -107,6 +105,9 @@ import org.forester.phylogeny.data.Annotation; import org.forester.phylogeny.data.BranchColor; import org.forester.phylogeny.data.Confidence; import org.forester.phylogeny.data.Event; +import org.forester.phylogeny.data.NodeVisualization; +import org.forester.phylogeny.data.NodeVisualization.NodeFill; +import org.forester.phylogeny.data.NodeVisualization.NodeShape; import org.forester.phylogeny.data.PhylogenyData; import org.forester.phylogeny.data.PropertiesMap; import org.forester.phylogeny.data.Property; @@ -2584,11 +2585,11 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee ForesterUtil.roundToInt( node.getYcoord() - d ) ); _polygon.addPoint( ForesterUtil.roundToInt( node.getXcoord() + box_size ), ForesterUtil.roundToInt( node.getYcoord() + d ) ); - if ( getOptions().getDefaultNodeFill() == NodeFill.SOLID ) { + if ( getOptions().getDefaultNodeFill() == NodeVisualization.NodeFill.SOLID ) { g.setColor( c ); g.fillPolygon( _polygon ); } - else if ( getOptions().getDefaultNodeFill() == NodeFill.NONE ) { + else if ( getOptions().getDefaultNodeFill() == NodeVisualization.NodeFill.NONE ) { g.setColor( getBackground() ); g.fillPolygon( _polygon ); g.setColor( c ); @@ -2804,13 +2805,13 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee background, outline_color ); } - else if ( getOptions().getDefaultNodeFill() == NodeFill.SOLID ) { + else if ( getOptions().getDefaultNodeFill() == NodeVisualization.NodeFill.SOLID ) { g.setColor( outline_color ); drawOvalFilled( x - half_box_size, y - half_box_size, box_size, box_size, g ); } } - else if ( getOptions().getDefaultNodeShape() == NodeShape.RECTANGLE ) { - if ( getOptions().getDefaultNodeFill() == NodeFill.GRADIENT ) { + else if ( getOptions().getDefaultNodeShape() == NodeVisualization.NodeShape.RECTANGLE ) { + if ( getOptions().getDefaultNodeFill() == NodeVisualization.NodeFill.GRADIENT ) { drawRectGradient( x - half_box_size, y - half_box_size, box_size, @@ -2820,7 +2821,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee to_pdf ? outline_color : getBackground(), outline_color ); } - else if ( getOptions().getDefaultNodeFill() == NodeFill.NONE ) { + else if ( getOptions().getDefaultNodeFill() == NodeVisualization.NodeFill.NONE ) { Color background = getBackground(); if ( to_pdf ) { background = Color.WHITE; @@ -2834,7 +2835,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee background, outline_color ); } - else if ( getOptions().getDefaultNodeFill() == NodeFill.SOLID ) { + else if ( getOptions().getDefaultNodeFill() == NodeVisualization.NodeFill.SOLID ) { g.setColor( outline_color ); drawRectFilled( x - half_box_size, y - half_box_size, box_size, box_size, g ); } diff --git a/forester/java/src/org/forester/go/BasicGoXRef.java b/forester/java/src/org/forester/go/BasicGoXRef.java index 99a0c9e..b877bb4 100644 --- a/forester/java/src/org/forester/go/BasicGoXRef.java +++ b/forester/java/src/org/forester/go/BasicGoXRef.java @@ -96,6 +96,9 @@ public class BasicGoXRef implements GoXRef { else if ( type.equals( PO_STR ) ) { _type = Type.PO; } + else if ( type.equals( SABIO_RK_STR ) ) { + _type = Type.SABIO_RK; + } else { throw new IllegalArgumentException( "unknown GO xref type: " + type ); } diff --git a/forester/java/src/org/forester/go/GoXRef.java b/forester/java/src/org/forester/go/GoXRef.java index 41a9305..7f0a5e5 100644 --- a/forester/java/src/org/forester/go/GoXRef.java +++ b/forester/java/src/org/forester/go/GoXRef.java @@ -47,6 +47,7 @@ public interface GoXRef extends Comparable { public static final String CORUM_STR = "CORUM"; public static final String UNIPATHWAY_STR = "UniPathway"; public static final String PO_STR = "PO"; + public static final String SABIO_RK_STR = "SABIO-RK"; public Type getType(); @@ -72,6 +73,7 @@ public interface GoXRef extends Comparable { NIF_SUBCELLULAR, CORUM, UNIPATHWAY, - PO; + PO, + SABIO_RK; } } diff --git a/forester/java/src/org/forester/phylogeny/data/NodeData.java b/forester/java/src/org/forester/phylogeny/data/NodeData.java index 89c4a86..d0a7fc2 100644 --- a/forester/java/src/org/forester/phylogeny/data/NodeData.java +++ b/forester/java/src/org/forester/phylogeny/data/NodeData.java @@ -38,17 +38,18 @@ import org.forester.util.ForesterUtil; public class NodeData implements PhylogenyData { - private String _node_name; - private Event _event; - private List _sequences; - private Identifier _node_identifier; - private List _taxonomies; - private List _distributions; - private Date _date; - private BinaryCharacters _binary_characters; - private PropertiesMap _properties; - private List _references; - private List _vector; + private String _node_name; + private Event _event; + private List _sequences; + private Identifier _node_identifier; + private List _taxonomies; + private List _distributions; + private Date _date; + private BinaryCharacters _binary_characters; + private PropertiesMap _properties; + private List _references; + private List _vector; + private List _node_visualizations; public NodeData() { init(); @@ -141,6 +142,14 @@ public class NodeData implements PhylogenyData { } } } + if ( ( getNodeVisualizations() != null ) && ( getNodeVisualizations().size() > 0 ) ) { + new_data.setNodeVisualizations( new ArrayList() ); + for( final NodeVisualization v : getNodeVisualizations() ) { + if ( v != null ) { + new_data.getNodeVisualizations().add( ( NodeVisualization ) v.copy() ); + } + } + } if ( isHasDate() ) { new_data.setDate( ( Date ) getDate().copy() ); } @@ -527,4 +536,12 @@ public class NodeData implements PhylogenyData { public void setNodeName( final String node_name ) { _node_name = node_name; } + + public void setNodeVisualizations( final List _node_visualizations ) { + this._node_visualizations = _node_visualizations; + } + + public List getNodeVisualizations() { + return _node_visualizations; + } } diff --git a/forester/java/src/org/forester/phylogeny/data/NodeVisualization.java b/forester/java/src/org/forester/phylogeny/data/NodeVisualization.java new file mode 100644 index 0000000..7b51574 --- /dev/null +++ b/forester/java/src/org/forester/phylogeny/data/NodeVisualization.java @@ -0,0 +1,148 @@ +// $Id: +// FORESTER -- software libraries and applications +// for evolutionary biology research and applications. +// +// Copyright (C) 2008-2009 Christian M. Zmasek +// Copyright (C) 2008-2009 Burnham Institute for Medical Research +// All rights reserved +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +// +// Contact: phylosoft @ gmail . com +// WWW: www.phylosoft.org + +package org.forester.phylogeny.data; + +import java.awt.Color; +import java.io.IOException; +import java.io.Writer; + +public class NodeVisualization implements PhylogenyData { + + public enum NodeFill { + NONE, GRADIENT, SOLID + } + + public enum NodeShape { + CIRCLE, RECTANGLE + } + private NodeShape _shape; + private NodeFill _fill_type; + private Color _border_color; + private Color _fill_color; + private double _size; + + public NodeVisualization() { + _shape = NodeShape.CIRCLE; + _fill_type = NodeFill.SOLID; + _border_color = null; + _fill_color = null; + _size = 0; + } + + public NodeVisualization( final NodeShape shape, + final NodeFill fill_type, + final Color border_color, + final Color fill_color, + final double size ) { + _shape = shape; + _fill_type = fill_type; + _border_color = border_color; + _fill_color = fill_color; + _size = size; + } + + @Override + public StringBuffer asSimpleText() { + return asText(); + } + + @Override + public StringBuffer asText() { + final StringBuffer sb = new StringBuffer(); + return sb; + } + + @Override + public PhylogenyData copy() { + return new NodeVisualization( 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() ); + } + + public Color getBorderColor() { + return _border_color; + } + + public Color getFillColor() { + return _fill_color; + } + + public NodeFill getFillType() { + return _fill_type; + } + + public NodeShape getShape() { + return _shape; + } + + public double getSize() { + return _size; + } + + @Override + public boolean isEqual( final PhylogenyData data ) { + throw new UnsupportedOperationException(); + } + + public void setBorderColor( final Color border_color ) { + _border_color = border_color; + } + + public void setFillColor( final Color fill_color ) { + _fill_color = fill_color; + } + + public void setFillType( final NodeFill fill_type ) { + _fill_type = fill_type; + } + + public void setShape( final NodeShape shape ) { + _shape = shape; + } + + public void setSize( final double size ) { + _size = size; + } + + @Override + public StringBuffer toNHX() { + throw new UnsupportedOperationException(); + } + + @Override + public void toPhyloXML( final Writer writer, final int level, final String indentation ) throws IOException { + throw new UnsupportedOperationException(); + } + + @Override + public String toString() { + return asText().toString(); + } +}