From: cmzmasek@gmail.com Date: Thu, 3 Apr 2014 02:53:40 +0000 (+0000) Subject: inprogress X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e6176aa35853eeaa7ab3a4f2d8a1431d9c76a290;p=jalview.git inprogress --- diff --git a/forester/java/src/org/forester/archaeopteryx/Configuration.java b/forester/java/src/org/forester/archaeopteryx/Configuration.java index cf3330d..5223e7e 100644 --- a/forester/java/src/org/forester/archaeopteryx/Configuration.java +++ b/forester/java/src/org/forester/archaeopteryx/Configuration.java @@ -58,7 +58,7 @@ public final class Configuration { final static String clickto_options[][] = { { "Display Node Data", "display" }, { "Collapse/Uncollapse", "display" }, { "Root/Reroot", "display" }, { "Sub/Super Tree", "display" }, { "Swap Descendants", "display" }, { "Colorize Subtree(s)", "display" }, - { "Colorize Node", "display" }, { "Change Node Font", "display" }, { "Open Sequence DB", "display" }, + { "Colorize Node(s)", "display" }, { "Change Node Font", "display" }, { "Open Sequence DB", "display" }, { "Go to PDB", "display" }, { "Open Taxonomy DB", "display" }, { "Blast", "display" }, { "Cut Subtree", "display" }, { "Copy Subtree", "display" }, { "Paste Subtree", "display" }, { "Delete Subtree/Node", "display" }, { "Add New Node", "display" }, { "Edit Node Data", "display" }, @@ -91,7 +91,7 @@ public final class Configuration { { "Phylogram", "display", "?" }, { "Node Name", "display", "yes" }, { "Taxonomy Code", "display", "yes" }, { "Seq Annotations", "nodisplay", "no" }, { "Confidence Values", "display", "?" }, { "Node Events", "display", "?" }, { "Colorize by Taxonomy", "display", "no" }, - { "Use Branch Colors", "display", "no" }, { "Use Branch Widths", "display", "no" }, + { "Use Visual Styles", "display", "no" }, { "Use Branch Widths", "display", "no" }, { "Show Custom Nodes", "display", "yes" }, { "Protein Domains", "nodisplay", "no" }, { "Binary Characters", "nodisplay", "no" }, { "Binary Char Counts", "nodisplay", "no" }, { "Seq Name", "display", "yes" }, { "Seq Accession", "display", "no" }, @@ -108,7 +108,7 @@ public final class Configuration { final static int write_confidence_values = 4; final static int write_events = 5; final static int color_according_to_species = 6; - final static int color_branches = 7; + final static int use_style = 7; final static int width_branches = 8; final static int show_custom_node_shapes = 9; final static int show_domain_architectures = 10; @@ -417,7 +417,7 @@ public final class Configuration { } public void setColorizeBranches( final boolean b ) { - display_options[ color_branches ][ 2 ] = b ? "yes" : "no"; + display_options[ use_style ][ 2 ] = b ? "yes" : "no"; } public void setColorLabelsSameAsParentBranch( final boolean color_labels_same_as_parent_branch ) { @@ -1522,8 +1522,8 @@ public final class Configuration { else if ( key.equals( "write_events" ) ) { key_index = Configuration.write_events; } - else if ( key.equals( "color_branches" ) ) { - key_index = Configuration.color_branches; + else if ( key.equals( "use_visual_styles" ) ) { + key_index = Configuration.use_style; } else if ( key.equals( "width_branches" ) ) { key_index = Configuration.width_branches; diff --git a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java index a2f0c68..a3712df 100644 --- a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java +++ b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java @@ -93,7 +93,7 @@ final class ControlPanel extends JPanel implements ActionListener { private JCheckBox _color_acc_species; private JCheckBox _color_according_to_annotation; private boolean _color_branches; - private JCheckBox _color_branches_cb; + private JCheckBox _use_visual_styles_cb; private int _color_subtree_cb_item; private int _change_node_font_item; // The settings from the conf file @@ -311,8 +311,8 @@ final class ControlPanel extends JPanel implements ActionListener { return _color_acc_species; } - public JCheckBox getColorBranchesCb() { - return _color_branches_cb; + public JCheckBox getUseVisualStylesCb() { + return _use_visual_styles_cb; } public JCheckBox getDisplayAsPhylogramCb() { @@ -593,10 +593,10 @@ final class ControlPanel extends JPanel implements ActionListener { addJCheckBox( getShowEventsCb(), ch_panel ); add( ch_panel ); break; - case Configuration.color_branches: - _color_branches_cb = new JCheckBox( title ); - getColorBranchesCb().setToolTipText( "To use branch color values, if present" ); - addJCheckBox( getColorBranchesCb(), ch_panel ); + case Configuration.use_style: + _use_visual_styles_cb = new JCheckBox( title ); + getUseVisualStylesCb().setToolTipText( "To use visual styles (colors, fonts), if present" ); + addJCheckBox( getUseVisualStylesCb(), ch_panel ); add( ch_panel ); break; case Configuration.width_branches: @@ -802,8 +802,8 @@ final class ControlPanel extends JPanel implements ActionListener { return ( ( _color_acc_species != null ) && _color_acc_species.isSelected() ); } - boolean isColorBranches() { - return ( ( ( getColorBranchesCb() != null ) && getColorBranchesCb().isSelected() ) || ( ( getColorBranchesCb() == null ) && _color_branches ) ); + boolean isUseVisualStyles() { + return ( ( ( getUseVisualStylesCb() != null ) && getUseVisualStylesCb().isSelected() ) || ( ( getUseVisualStylesCb() == null ) && _color_branches ) ); } boolean isDrawPhylogram() { @@ -1032,9 +1032,9 @@ final class ControlPanel extends JPanel implements ActionListener { getShowEventsCb().setSelected( state ); } break; - case Configuration.color_branches: - if ( getColorBranchesCb() != null ) { - getColorBranchesCb().setSelected( state ); + case Configuration.use_style: + if ( getUseVisualStylesCb() != null ) { + getUseVisualStylesCb().setSelected( state ); } break; case Configuration.width_branches: @@ -2106,9 +2106,9 @@ final class ControlPanel extends JPanel implements ActionListener { setCheckbox( Configuration.color_according_to_annotation, _configuration.doCheckOption( Configuration.color_according_to_annotation ) ); } - if ( _configuration.doDisplayOption( Configuration.color_branches ) ) { - addCheckbox( Configuration.color_branches, _configuration.getDisplayTitle( Configuration.color_branches ) ); - setCheckbox( Configuration.color_branches, _configuration.doCheckOption( Configuration.color_branches ) ); + if ( _configuration.doDisplayOption( Configuration.use_style ) ) { + addCheckbox( Configuration.use_style, _configuration.getDisplayTitle( Configuration.use_style ) ); + setCheckbox( Configuration.use_style, _configuration.doCheckOption( Configuration.use_style ) ); } if ( _configuration.doDisplayOption( Configuration.width_branches ) ) { addCheckbox( Configuration.width_branches, _configuration.getDisplayTitle( Configuration.width_branches ) ); diff --git a/forester/java/src/org/forester/archaeopteryx/TreePanel.java b/forester/java/src/org/forester/archaeopteryx/TreePanel.java index 9fae835..68b6376 100644 --- a/forester/java/src/org/forester/archaeopteryx/TreePanel.java +++ b/forester/java/src/org/forester/archaeopteryx/TreePanel.java @@ -869,8 +869,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee final int colorizations = TreePanelUtil.colorPhylogenyAccordingToRanks( _phylogeny, rank, this ); if ( colorizations > 0 ) { _control_panel.setColorBranches( true ); - if ( _control_panel.getColorBranchesCb() != null ) { - _control_panel.getColorBranchesCb().setSelected( true ); + if ( _control_panel.getUseVisualStylesCb() != null ) { + _control_panel.getUseVisualStylesCb().setSelected( true ); } if ( _control_panel.getColorAccSpeciesCb() != null ) { _control_panel.getColorAccSpeciesCb().setSelected( false ); @@ -914,8 +914,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee AptxUtil.removeBranchColors( _phylogeny ); TreePanelUtil.colorPhylogenyAccordingToConfidenceValues( _phylogeny, this ); _control_panel.setColorBranches( true ); - if ( _control_panel.getColorBranchesCb() != null ) { - _control_panel.getColorBranchesCb().setSelected( true ); + if ( _control_panel.getUseVisualStylesCb() != null ) { + _control_panel.getUseVisualStylesCb().setSelected( true ); } setArrowCursor(); repaint(); @@ -981,7 +981,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } final Color getGraphicsForNodeBoxWithColorForParentBranch( final PhylogenyNode node ) { - if ( getControlPanel().isColorBranches() && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) { + if ( getControlPanel().isUseVisualStyles() && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) { return ( PhylogenyMethods.getBranchColorValue( node ) ); } else { @@ -2063,8 +2063,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee setWaitCursor(); TreePanelUtil.colorPhylogenyAccordingToExternalTaxonomy( _phylogeny, this ); _control_panel.setColorBranches( true ); - if ( _control_panel.getColorBranchesCb() != null ) { - _control_panel.getColorBranchesCb().setSelected( true ); + if ( _control_panel.getUseVisualStylesCb() != null ) { + _control_panel.getUseVisualStylesCb().setSelected( true ); } setEdited( true ); setArrowCursor(); @@ -2263,7 +2263,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee && !to_graphics_file && getCopiedAndPastedNodes().contains( node.getId() ) ) { g.setColor( getTreeColorSet().getFoundColor0() ); } - else if ( getControlPanel().isColorBranches() && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) { + else if ( getControlPanel().isUseVisualStyles() && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) { g.setColor( PhylogenyMethods.getBranchColorValue( node ) ); } else if ( to_pdf ) { @@ -2414,8 +2414,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee final PhylogenyNode node, final List additional_nodes ) { _control_panel.setColorBranches( true ); - if ( _control_panel.getColorBranchesCb() != null ) { - _control_panel.getColorBranchesCb().setSelected( true ); + if ( _control_panel.getUseVisualStylesCb() != null ) { + _control_panel.getUseVisualStylesCb().setSelected( true ); } if ( node != null ) { for( final PreorderTreeIterator it = new PreorderTreeIterator( node ); it.hasNext(); ) { @@ -2434,8 +2434,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee final PhylogenyNode node, final List additional_nodes ) { _control_panel.setColorBranches( true ); - if ( _control_panel.getColorBranchesCb() != null ) { - _control_panel.getColorBranchesCb().setSelected( true ); + if ( _control_panel.getUseVisualStylesCb() != null ) { + _control_panel.getUseVisualStylesCb().setSelected( true ); } if ( node != null ) { colorizeNodesHelper( c, node ); @@ -2449,14 +2449,10 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } private final static void colorizeNodesHelper( final Color c, final PhylogenyNode node ) { - NodeVisualData v; - if ( node.getNodeData().getNodeVisualData() != null ) { - v = node.getNodeData().getNodeVisualData(); + if ( node.getNodeData().getNodeVisualData() == null ) { + node.getNodeData().setNodeVisualData( new NodeVisualData() ); } - else { - v = new NodeVisualData(); - } - v.setFontColor( new Color( c.getRed(), c.getGreen(), c.getBlue() ) ); + node.getNodeData().getNodeVisualData().setFontColor( new Color( c.getRed(), c.getGreen(), c.getBlue() ) ); } final private void colorSubtree( final PhylogenyNode node ) { @@ -2469,8 +2465,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } _color_chooser.setPreviewPanel( new JPanel() ); SubtreeColorizationActionListener al; - if ( ( getFoundNodes0() != null ) && !getFoundNodes0().isEmpty() ) { - final List additional_nodes = getFoundNodes0AsListOfPhylogenyNodes(); + if ( ( getFoundNodes0() != null ) || ( getFoundNodes1() != null ) ) { + final List additional_nodes = getFoundNodesAsListOfPhylogenyNodes(); al = new SubtreeColorizationActionListener( _color_chooser, node, additional_nodes ); } else { @@ -2484,15 +2480,14 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee private void colorNodeFont( final PhylogenyNode node ) { _color_chooser.setPreviewPanel( new JPanel() ); NodeColorizationActionListener al; - if ( ( getFoundNodes0() != null ) && !getFoundNodes0().isEmpty() ) { - final List additional_nodes = getFoundNodes0AsListOfPhylogenyNodes(); + if ( ( getFoundNodes0() != null ) || ( getFoundNodes1() != null ) ) { + final List additional_nodes = getFoundNodesAsListOfPhylogenyNodes(); al = new NodeColorizationActionListener( _color_chooser, node, additional_nodes ); } else { al = new NodeColorizationActionListener( _color_chooser, node ); } - final JDialog dialog = JColorChooser - .createDialog( this, "Subtree colorization", true, _color_chooser, al, null ); + final JDialog dialog = JColorChooser.createDialog( this, "Node colorization", true, _color_chooser, al, null ); dialog.setVisible( true ); } @@ -2510,22 +2505,33 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } fc.showDialog( this, "Select Font" ); if ( ( fc.getFont() != null ) && !ForesterUtil.isEmpty( fc.getFont().getFamily().trim() ) ) { - if ( node.getNodeData().getNodeVisualData() == null ) { - node.getNodeData().setNodeVisualData( new NodeVisualData() ); + List nodes = new ArrayList(); + if ( ( getFoundNodes0() != null ) || ( getFoundNodes1() != null ) ) { + nodes = getFoundNodesAsListOfPhylogenyNodes(); } - final NodeVisualData vd = node.getNodeData().getNodeVisualData(); - final Font ff = fc.getFont(); - vd.setFontName( ff.getFamily().trim() ); - int s = ff.getSize(); - if ( s < 0 ) { - s = 0; + nodes.add( node ); + for( final PhylogenyNode n : nodes ) { + if ( n.getNodeData().getNodeVisualData() == null ) { + n.getNodeData().setNodeVisualData( new NodeVisualData() ); + } + final NodeVisualData vd = n.getNodeData().getNodeVisualData(); + final Font ff = fc.getFont(); + vd.setFontName( ff.getFamily().trim() ); + int s = ff.getSize(); + if ( s < 0 ) { + s = 0; + } + if ( s > Byte.MAX_VALUE ) { + s = Byte.MAX_VALUE; + } + vd.setFontSize( s ); + vd.setFontStyle( ff.getStyle() ); } - if ( s > Byte.MAX_VALUE ) { - s = Byte.MAX_VALUE; + if ( _control_panel.getUseVisualStylesCb() != null ) { + getControlPanel().getUseVisualStylesCb().setSelected( true ); } - vd.setFontSize( s ); - vd.setFontStyle( ff.getStyle() ); } + repaint(); } final private void copySubtree( final PhylogenyNode node ) { @@ -2840,18 +2846,19 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee return getMainPanel().getCutOrCopiedTree(); } - private List getFoundNodes0AsListOfPhylogenyNodes() { + private List getFoundNodesAsListOfPhylogenyNodes() { final List additional_nodes = new ArrayList(); - for( final Long id : getFoundNodes0() ) { - additional_nodes.add( _phylogeny.getNode( id ) ); + if ( getFoundNodes0() != null ) { + for( final Long id : getFoundNodes0() ) { + additional_nodes.add( _phylogeny.getNode( id ) ); + } } - return additional_nodes; - } - - private List getFoundNodes1AsListOfPhylogenyNodes() { - final List additional_nodes = new ArrayList(); - for( final Long id : getFoundNodes1() ) { - additional_nodes.add( _phylogeny.getNode( id ) ); + if ( getFoundNodes1() != null ) { + for( final Long id : getFoundNodes1() ) { + if ( ( getFoundNodes0() == null ) || !getFoundNodes0().contains( id ) ) { + additional_nodes.add( _phylogeny.getNode( id ) ); + } + } } return additional_nodes; } @@ -3870,7 +3877,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee else if ( getControlPanel().isColorAccordingToTaxonomy() ) { c = getTaxonomyBasedColor( node ); } - else if ( getOptions().isColorLabelsSameAsParentBranch() && getControlPanel().isColorBranches() + else if ( getOptions().isColorLabelsSameAsParentBranch() && getControlPanel().isUseVisualStyles() && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) { c = PhylogenyMethods.getBranchColorValue( node ); } @@ -4146,6 +4153,10 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee else if ( is_in_found_nodes ) { g.setColor( getColorForFoundNode( node ) ); } + else if ( getControlPanel().isUseVisualStyles() && ( node.getNodeData().getNodeVisualData() != null ) + && ( node.getNodeData().getNodeVisualData().getFontColor() != null ) ) { + g.setColor( node.getNodeData().getNodeVisualData().getFontColor() ); + } else if ( getControlPanel().isColorAccordingToTaxonomy() ) { g.setColor( getTaxonomyBasedColor( node ) ); } @@ -4154,7 +4165,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee .getNodeData().getSequence().getAnnotations().isEmpty() ) ) ) { g.setColor( calculateColorForAnnotation( node.getNodeData().getSequence().getAnnotations() ) ); } - else if ( getOptions().isColorLabelsSameAsParentBranch() && getControlPanel().isColorBranches() + else if ( getOptions().isColorLabelsSameAsParentBranch() && getControlPanel().isUseVisualStyles() && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) { g.setColor( PhylogenyMethods.getBranchColorValue( node ) ); } @@ -4217,7 +4228,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee } _sb.append( propertiesToString( node ) ); } - if ( getControlPanel().isColorBranches() && ( node.getNodeData().getNodeVisualData() != null ) ) { + if ( getControlPanel().isUseVisualStyles() && ( node.getNodeData().getNodeVisualData() != null ) ) { final Font f = node.getNodeData().getNodeVisualData().getFont(); g.setFont( f != null ? f : getTreeFontSet().getLargeFont() ); } @@ -4875,7 +4886,7 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee else if ( getControlPanel().isColorAccordingToTaxonomy() ) { g.setColor( getTaxonomyBasedColor( node ) ); } - else if ( getOptions().isColorLabelsSameAsParentBranch() && getControlPanel().isColorBranches() + else if ( getOptions().isColorLabelsSameAsParentBranch() && getControlPanel().isUseVisualStyles() && ( PhylogenyMethods.getBranchColorValue( node ) != null ) ) { g.setColor( PhylogenyMethods.getBranchColorValue( node ) ); } @@ -5291,15 +5302,8 @@ public final class TreePanel extends JPanel implements ActionListener, MouseWhee private void showExtDescNodeData( final PhylogenyNode node ) { final List data = new ArrayList(); final List nodes = node.getAllExternalDescendants(); - if ( ( getFoundNodes0() != null ) && !getFoundNodes0().isEmpty() ) { - for( final PhylogenyNode n : getFoundNodes0AsListOfPhylogenyNodes() ) { - if ( !nodes.contains( n ) ) { - nodes.add( n ); - } - } - } - if ( ( getFoundNodes1() != null ) && !getFoundNodes1().isEmpty() ) { - for( final PhylogenyNode n : getFoundNodes1AsListOfPhylogenyNodes() ) { + if ( ( getFoundNodes0() != null ) || ( getFoundNodes1() != null ) ) { + for( final PhylogenyNode n : getFoundNodesAsListOfPhylogenyNodes() ) { if ( !nodes.contains( n ) ) { nodes.add( n ); } diff --git a/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlHandler.java b/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlHandler.java index 4eed70c..2c347a1 100644 --- a/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlHandler.java +++ b/forester/java/src/org/forester/io/parsers/phyloxml/PhyloXmlHandler.java @@ -325,18 +325,12 @@ public final class PhyloXmlHandler extends DefaultHandler { } else if ( qualified_name.equals( PhyloXmlMapping.PROPERTY ) ) { final Property prop = ( Property ) PropertyParser.getInstance().parse( element ); - if ( prop.getRef().startsWith( NodeVisualData.APTX_VISUALIZATION_REF ) ) { - if ( prop.getAppliesTo() == AppliesTo.NODE ) { - if ( node.getNodeData().getNodeVisualData() == null ) { - node.getNodeData().setNodeVisualData( new NodeVisualData() ); - } - final NodeVisualData vd = node.getNodeData().getNodeVisualData(); - vd.parseProperty( prop ); - } - else { - System.err.println( "Do not know how to handle " + NodeVisualData.APTX_VISUALIZATION_REF - + " property applied to " + prop.getAppliesTo() ); + if ( prop.getRef().startsWith( NodeVisualData.APTX_VISUALIZATION_REF ) + && ( prop.getAppliesTo() == AppliesTo.NODE ) ) { + if ( node.getNodeData().getNodeVisualData() == null ) { + node.getNodeData().setNodeVisualData( new NodeVisualData() ); } + node.getNodeData().getNodeVisualData().parseProperty( prop ); } else { if ( !node.getNodeData().isHasProperties() ) {