X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FMainPanel.java;h=6551f1bd01ee4b3c387d4dc5f7a326eb05073aad;hb=28cf1afacf61a15e72411b1e58c3694f78d6d0dd;hp=7e20578de5d7d7aa865fbec6321e0e3e2d4b4ad3;hpb=bfe6fc2e246794a6845c7c8cf99031c2bcd6281c;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/MainPanel.java b/forester/java/src/org/forester/archaeopteryx/MainPanel.java index 7e20578..6551f1b 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainPanel.java +++ b/forester/java/src/org/forester/archaeopteryx/MainPanel.java @@ -24,7 +24,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA // // Contact: phylosoft @ gmail . com -// WWW: www.phylosoft.org/forester +// WWW: https://sites.google.com/site/cmzmasek/home/software/forester package org.forester.archaeopteryx; @@ -36,8 +36,10 @@ import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.awt.image.BufferedImage; import java.util.ArrayList; +import java.util.HashMap; import java.util.Hashtable; import java.util.List; +import java.util.Map; import java.util.Set; import javax.swing.JPanel; @@ -64,13 +66,14 @@ public class MainPanel extends JPanel implements ComponentListener { private TreeColorSet _colorset; private TreeFontSet _fontset; private Phylogeny _cut_or_copied_tree; - private Set _copied_and_pasted_nodes; + private Set _copied_and_pasted_nodes; private Hashtable _image_map; + private static Map _lineage_to_rank_map; MainPanel() { } - MainPanel( final Configuration configuration, final MainFrame parent ) { + public MainPanel( final Configuration configuration, final MainFrame parent ) { if ( configuration == null ) { throw new IllegalArgumentException( "configuration is null" ); } @@ -85,23 +88,22 @@ public class MainPanel extends JPanel implements ComponentListener { getControlPanel().showWhole(); } - void addPhylogenyInNewTab( final Phylogeny phy, - final Configuration config, - final String default_name, - final String full_path ) { + public void addPhylogenyInNewTab( final Phylogeny phy, + final Configuration config, + final String default_name, + final String full_path ) { final TreePanel treepanel = new TreePanel( phy, config, this ); getControlPanel().phylogenyAdded( config ); treepanel.setControlPanel( getControlPanel() ); _treepanels.add( treepanel ); String name = ""; - // if ( !ForesterUtil.isEmpty( phy.getName() ) ) { - // name = phy.getName(); - // } - // else if ( phy.getIdentifier() != null ) { - // name = phy.getIdentifier().toString(); - // } - /* else */ - if ( !ForesterUtil.isEmpty( default_name ) ) { + if ( !ForesterUtil.isEmpty( phy.getName() ) ) { + name = phy.getName(); + } + else if ( phy.getIdentifier() != null ) { + name = phy.getIdentifier().toString(); + } + else if ( !ForesterUtil.isEmpty( default_name ) ) { name = default_name; } else { @@ -136,10 +138,7 @@ public class MainPanel extends JPanel implements ComponentListener { treegraphic_scroll_pane_panel.add( treegraphic_scroll_pane, BorderLayout.CENTER ); _treegraphic_scroll_pane_panels.add( treegraphic_scroll_pane_panel ); _treegraphic_scroll_panes.add( treegraphic_scroll_pane ); - getTabbedPane().addTab( name, - null, - treegraphic_scroll_pane_panel, - Util.createDescriptionForTab( phy, full_path ) ); + getTabbedPane().addTab( name, null, treegraphic_scroll_pane_panel, "" ); getTabbedPane().setSelectedIndex( getTabbedPane().getTabCount() - 1 ); getControlPanel().showWhole(); } @@ -150,6 +149,25 @@ public class MainPanel extends JPanel implements ComponentListener { treepanel.setControlPanel( getControlPanel() ); _treepanels.add( treepanel ); final JScrollPane treegraphic_scroll_pane = new JScrollPane( treepanel ); + treegraphic_scroll_pane.getHorizontalScrollBar().addAdjustmentListener( new AdjustmentListener() { + + @Override + public void adjustmentValueChanged( final AdjustmentEvent e ) { + if ( treepanel.isOvOn() || getOptions().isShowScale() ) { + treepanel.repaint(); + } + } + } ); + treegraphic_scroll_pane.getVerticalScrollBar().addAdjustmentListener( new AdjustmentListener() { + + @Override + public void adjustmentValueChanged( final AdjustmentEvent e ) { + if ( treepanel.isOvOn() || getOptions().isShowScale() ) { + treepanel.repaint(); + //System.out.println( e.getValue() ); + } + } + } ); treegraphic_scroll_pane.getHorizontalScrollBar().setUnitIncrement( 20 ); treegraphic_scroll_pane.getHorizontalScrollBar().setBlockIncrement( 50 ); treegraphic_scroll_pane.getVerticalScrollBar().setUnitIncrement( 20 ); @@ -204,15 +222,15 @@ public class MainPanel extends JPanel implements ComponentListener { // Do nothing. } - private Configuration getConfiguration() { + Configuration getConfiguration() { return _configuration; } - ControlPanel getControlPanel() { + public ControlPanel getControlPanel() { return _control_panel; } - public Set getCopiedAndPastedNodes() { + public Set getCopiedAndPastedNodes() { return _copied_and_pasted_nodes; } @@ -265,7 +283,7 @@ public class MainPanel extends JPanel implements ComponentListener { } } - TreePanel getCurrentTreePanel() { + public TreePanel getCurrentTreePanel() { final int selected = getTabbedPane().getSelectedIndex(); if ( selected >= 0 ) { return _treepanels.get( selected ); @@ -303,7 +321,7 @@ public class MainPanel extends JPanel implements ComponentListener { return getCurrentScrollPane().getViewport().getExtentSize(); } - JTabbedPane getTabbedPane() { + public JTabbedPane getTabbedPane() { return _tabbed_pane; } @@ -370,7 +388,7 @@ public class MainPanel extends JPanel implements ComponentListener { repaint(); } - public void setCopiedAndPastedNodes( final Set node_ids ) { + public void setCopiedAndPastedNodes( final Set node_ids ) { _copied_and_pasted_nodes = node_ids; } @@ -391,6 +409,7 @@ public class MainPanel extends JPanel implements ComponentListener { void setupTreeGraphic( final Configuration config_settings, final ControlPanel control ) { control.setSpeciesColors( config_settings.getSpeciesColors() ); + control.setSequenceColors( config_settings.getSequenceColors() ); control.setAnnotationColors( config_settings.getAnnotationColors() ); RenderableDomainArchitecture.setColorMap( config_settings.getDomainColors() ); } @@ -413,4 +432,11 @@ public class MainPanel extends JPanel implements ComponentListener { synchronized Hashtable getImageMap() { return _image_map; } + + public synchronized static Map getLineageToRankMap() { + if ( _lineage_to_rank_map == null ) { + _lineage_to_rank_map = new HashMap(); + } + return _lineage_to_rank_map; + } }