From: Renia Correya Date: Wed, 16 Oct 2024 12:59:40 +0000 (+0100) Subject: JAL-4435 Added Show Secondary Structure Providers menu in tree panel X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=83b4b3874f98d3650b60dc397ecf068138349c7b;p=jalview.git JAL-4435 Added Show Secondary Structure Providers menu in tree panel THis change is for secondary structure similarity tree panel. Secondary structure providers will be displayed as internal node labels if this menu option is selected. The labels will be displayed only if the node count is greater than 3. --- diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 156766f..b9738a0 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -334,6 +334,7 @@ label.nucleotide_matrix = Nucleotide matrix label.protein_matrix = Protein matrix label.show_bootstrap_values = Show Bootstrap Values label.show_distances = Show distances +label.show_secondary_structure_provider = Show Secondary Structure Providers label.mark_unassociated_leaves = Mark Unassociated Leaves label.fit_to_window = Fit To Window label.newick_format = Newick Format diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java index 49b569a..59b8d4b 100755 --- a/src/jalview/gui/TreeCanvas.java +++ b/src/jalview/gui/TreeCanvas.java @@ -103,6 +103,8 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, boolean fitToWindow = true; boolean showDistances = false; + + boolean showSecondaryStructureProvider = false; boolean showBootstrap = false; @@ -445,7 +447,12 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, nodeLabel = nodeLabel + String.valueOf(node.bootstrap); } - if (node.hasLabel()) + + //Display secondary structure providers as labels only if: + // ~ node has Label assigned (Secondary structure providers) + // ~ node count is greater than 3 + // ~ showSecondaryStructureProvider option is set to true by the user + if ( node.hasLabel() && showSecondaryStructureProvider && node.count > 3) { String label = node.getLabel(); @@ -459,7 +466,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, // Split the nodeLabel by "|" String[] lines = nodeLabel.split("\\|"); - // Iterate over the lines and draw each line separately + // Iterate over the lines and draw each string separately String longestLabelString = ""; int i = 0; for (i = 0; i < lines.length; i++) { @@ -1444,6 +1451,19 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, this.showDistances = state; repaint(); } + + /** + * DOCUMENT ME! + * + * @param state + * DOCUMENT ME! + */ + public void setShowSecondaryStructureProvider(boolean state) + { + this.showSecondaryStructureProvider = state; + repaint(); + } + /** * DOCUMENT ME! diff --git a/src/jalview/gui/TreePanel.java b/src/jalview/gui/TreePanel.java index bfdc119..6a1b381 100755 --- a/src/jalview/gui/TreePanel.java +++ b/src/jalview/gui/TreePanel.java @@ -218,9 +218,17 @@ public class TreePanel extends GTreePanel if (similarityParams != null && similarityParams.getSecondaryStructureSource() != null) { - + //setting showSecondaryStructureProviderMenu to true if the + //similarity is based on secondary structure + showSecondaryStructureProviderMenu.setVisible(true); addSubtitlePanel(" Secondary Structure Provider : " + similarityParams.getSecondaryStructureSource()); + + } + else { + //setting showSecondaryStructureProviderMenu to false if the + //similarity is not based on secondary structure + showSecondaryStructureProviderMenu.setVisible(false); } if (leafAnnotations != null) { @@ -760,6 +768,18 @@ public class TreePanel extends GTreePanel { treeCanvas.setShowDistances(distanceMenu.isSelected()); } + + /** + * DOCUMENT ME! + * + * @param e + * DOCUMENT ME! + */ + @Override + public void showSecondaryStructureProviderMenu_actionPerformed(ActionEvent e) + { + treeCanvas.setShowSecondaryStructureProvider(showSecondaryStructureProviderMenu.isSelected()); + } /** * DOCUMENT ME! diff --git a/src/jalview/jbgui/GTreePanel.java b/src/jalview/jbgui/GTreePanel.java index 2a1b11f..884f3eb 100755 --- a/src/jalview/jbgui/GTreePanel.java +++ b/src/jalview/jbgui/GTreePanel.java @@ -61,6 +61,11 @@ public class GTreePanel extends JInternalFrame public JCheckBoxMenuItem bootstrapMenu = new JCheckBoxMenuItem(); public JCheckBoxMenuItem distanceMenu = new JCheckBoxMenuItem(); + + //Menu option for the user to select their preference in + //displaying secondary structure providers as labels. + //Visible only for secondary structure similarity. + public JCheckBoxMenuItem showSecondaryStructureProviderMenu = new JCheckBoxMenuItem(); public JCheckBoxMenuItem fitToWindow = new JCheckBoxMenuItem(); @@ -174,6 +179,15 @@ public class GTreePanel extends JInternalFrame distanceMenu_actionPerformed(e); } }); + showSecondaryStructureProviderMenu.setText(MessageManager.getString("label.show_secondary_structure_provider")); + showSecondaryStructureProviderMenu.addActionListener(new java.awt.event.ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + showSecondaryStructureProviderMenu_actionPerformed(e); + } + }); fitToWindow.setSelected(true); fitToWindow.setText(MessageManager.getString("label.fit_to_window")); fitToWindow.addActionListener(new java.awt.event.ActionListener() @@ -245,6 +259,7 @@ public class GTreePanel extends JInternalFrame viewMenu.add(fitToWindow); viewMenu.add(font); viewMenu.add(distanceMenu); + viewMenu.add(showSecondaryStructureProviderMenu); viewMenu.add(bootstrapMenu); viewMenu.add(placeholdersMenu); viewMenu.add(sortAssocViews); @@ -265,6 +280,10 @@ public class GTreePanel extends JInternalFrame public void distanceMenu_actionPerformed(ActionEvent e) { } + + public void showSecondaryStructureProviderMenu_actionPerformed(ActionEvent e) + { + } public void bootstrapMenu_actionPerformed(ActionEvent e) {