From 7ebc9696776dd018372c73885706fad8648560c2 Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 19 Dec 2008 15:37:49 +0000 Subject: [PATCH] new sort by length method, justify edit menu entries and experimental support for variable height sequence feature rendering --- src/jalview/gui/AlignFrame.java | 66 ++++++++++++++++++++++++++++++++-- src/jalview/gui/AlignViewport.java | 13 ++++++- src/jalview/jbgui/GAlignFrame.java | 68 ++++++++++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+), 4 deletions(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index d5ddf7d..eee57fc 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -2149,11 +2149,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, public void padGapsMenuitem_actionPerformed(ActionEvent e) { viewport.padGaps = padGapsMenuitem.isSelected(); - viewport.firePropertyChange("alignment", null, viewport.getAlignment() .getSequences()); } - + + //else + { + // if (justifySeqs>0) + { + // alignment.justify(justifySeqs!=RIGHT_JUSTIFY); + } + } + //} + /** * DOCUMENT ME! * @@ -2413,7 +2421,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } /** - * DOCUMENT ME! + * Set or clear 'Show Sequence Features' * * @param evt * DOCUMENT ME! @@ -2427,6 +2435,27 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, alignPanel.getOverviewPanel().updateOverviewImage(); } } + /** + * Set or clear 'Show Sequence Features' + * + * @param evt + * DOCUMENT ME! + */ + public void showSeqFeaturesHeight_actionPerformed(ActionEvent evt) + { + viewport.setShowSequenceFeaturesHeight(showSeqFeaturesHeight.isSelected()); + if (viewport.getShowSequenceFeaturesHeight()) + { + // ensure we're actually displaying features + viewport.setShowSequenceFeatures(true); + showSeqFeatures.setSelected(true); + } + alignPanel.paintAlignment(true); + if (alignPanel.getOverviewPanel() != null) + { + alignPanel.getOverviewPanel().updateOverviewImage(); + } + } /** * DOCUMENT ME! @@ -3008,6 +3037,19 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, addHistoryItem(new OrderCommand("ID Sort", oldOrder, viewport.alignment)); alignPanel.paintAlignment(true); } + /** + * DOCUMENT ME! + * + * @param e + * DOCUMENT ME! + */ + public void sortLengthMenuItem_actionPerformed(ActionEvent e) + { + SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); + AlignmentSorter.sortByLength(viewport.getAlignment()); + addHistoryItem(new OrderCommand("Length Sort", oldOrder, viewport.alignment)); + alignPanel.paintAlignment(true); + } /** * DOCUMENT ME! @@ -4267,6 +4309,24 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, } } } + /** + * Left justify the whole alignment. + */ + protected void justifyLeftMenuItem_actionPerformed(ActionEvent e) + { + AlignmentI al = viewport.getAlignment(); + al.justify(false); + viewport.firePropertyChange("alignment", null, al); + } + /** + * Right justify the whole alignment. + */ + protected void justifyRightMenuItem_actionPerformed(ActionEvent e) + { + AlignmentI al = viewport.getAlignment(); + al.justify(true); + viewport.firePropertyChange("alignment", null, al); + } } class PrintThread extends Thread diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index ac3ff77..587ce55 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -58,6 +58,8 @@ import jalview.structure.StructureSelectionManager; */ public class AlignViewport implements SelectionSource { + private static final int RIGHT_JUSTIFY = 1; + int startRes; int endRes; @@ -1879,7 +1881,6 @@ public class AlignViewport implements SelectionSource { alignment.padGaps(); } - if (hconsensus != null && autoCalculateConsensus) { updateConsensus(ap); @@ -2147,6 +2148,8 @@ public class AlignViewport implements SelectionSource return followSelection; } private long sgrouphash=-1,colselhash=-1; + + boolean showSeqFeaturesHeight; /** * checks current SelectionGroup against record of last hash value, and updates record. * @return true if SelectionGroup changed since last call @@ -2177,5 +2180,13 @@ public class AlignViewport implements SelectionSource { jalview.structure.StructureSelectionManager.getStructureSelectionManager().sendSelection(new SequenceGroup(getSelectionGroup()), new ColumnSelection(getColumnSelection()), this); } + public void setShowSequenceFeaturesHeight(boolean selected) + { + showSeqFeaturesHeight = selected; + } + public boolean getShowSequenceFeaturesHeight() + { + return showSeqFeaturesHeight; + } } diff --git a/src/jalview/jbgui/GAlignFrame.java b/src/jalview/jbgui/GAlignFrame.java index fdda4ca..33d3565 100755 --- a/src/jalview/jbgui/GAlignFrame.java +++ b/src/jalview/jbgui/GAlignFrame.java @@ -68,6 +68,8 @@ public class GAlignFrame extends JInternalFrame protected JMenuItem sortIDMenuItem = new JMenuItem(); + protected JMenuItem sortLengthMenuItem = new JMenuItem(); + protected JMenuItem sortGroupMenuItem = new JMenuItem(); protected JMenu sortByAnnotScore = new JMenu(); @@ -143,6 +145,7 @@ public class GAlignFrame extends JInternalFrame public JCheckBoxMenuItem abovePIDThreshold = new JCheckBoxMenuItem(); public JCheckBoxMenuItem showSeqFeatures = new JCheckBoxMenuItem(); + public JCheckBoxMenuItem showSeqFeaturesHeight = new JCheckBoxMenuItem(); protected JRadioButtonMenuItem nucleotideColour = new JRadioButtonMenuItem(); @@ -275,6 +278,10 @@ public class GAlignFrame extends JInternalFrame JMenuItem alignmentProperties = new JMenuItem(); JMenu tooltipSettingsMenu = new JMenu(); + + private JMenuItem justifyLeftMenuItem=new JMenuItem(); + + private JMenuItem justifyRightMenuItem=new JMenuItem(); public GAlignFrame() { @@ -580,6 +587,22 @@ public class GAlignFrame extends JInternalFrame removeAllGapsMenuItem_actionPerformed(e); } }); + justifyLeftMenuItem.setText("Left Justify Alignment"); + justifyLeftMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + justifyLeftMenuItem_actionPerformed(e); + } + }); + justifyRightMenuItem.setText("Right Justify Alignment"); + justifyRightMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + justifyRightMenuItem_actionPerformed(e); + } + }); viewBoxesMenuItem.setText("Boxes"); viewBoxesMenuItem.setState(true); viewBoxesMenuItem.addActionListener(new java.awt.event.ActionListener() @@ -615,6 +638,14 @@ public class GAlignFrame extends JInternalFrame sortIDMenuItem_actionPerformed(e); } }); + sortLengthMenuItem.setText("By Length"); + sortLengthMenuItem.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + sortLengthMenuItem_actionPerformed(e); + } + }); sortGroupMenuItem.setText("by Group"); sortGroupMenuItem.addActionListener(new java.awt.event.ActionListener() { @@ -920,6 +951,14 @@ public class GAlignFrame extends JInternalFrame showSeqFeatures_actionPerformed(actionEvent); } }); + showSeqFeaturesHeight.setText("Vary Sequence Feature Height"); + showSeqFeaturesHeight.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent actionEvent) + { + showSeqFeaturesHeight_actionPerformed(actionEvent); + } + }); showDbRefsMenuitem.setText("Show Database Refs"); showDbRefsMenuitem.addActionListener(new ActionListener() { @@ -1513,6 +1552,9 @@ public class GAlignFrame extends JInternalFrame editMenu.add(removeAllGapsMenuItem); editMenu.add(removeRedundancyMenuItem); editMenu.addSeparator(); + editMenu.add(justifyLeftMenuItem); + editMenu.add(justifyRightMenuItem); + editMenu.addSeparator(); editMenu.add(padGapsMenuitem); viewMenu.add(newView); viewMenu.add(expandViews); @@ -1525,6 +1567,8 @@ public class GAlignFrame extends JInternalFrame viewMenu.add(annotationPanelMenuItem); viewMenu.addSeparator(); viewMenu.add(showSeqFeatures); + viewMenu.add(showSeqFeaturesHeight); + viewMenu.add(featureSettings); tooltipSettingsMenu.add(showDbRefsMenuitem); tooltipSettingsMenu.add(showNpFeatsMenuitem); @@ -1571,6 +1615,7 @@ public class GAlignFrame extends JInternalFrame pasteMenu.add(pasteNew); pasteMenu.add(pasteThis); sort.add(sortIDMenuItem); + sort.add(sortLengthMenuItem); sort.add(sortGroupMenuItem); sort.add(sortPairwiseMenuItem); sort.add(sortByTreeMenu); @@ -1614,6 +1659,25 @@ public class GAlignFrame extends JInternalFrame selectMenu.add(deleteGroups); } + protected void showSeqFeaturesHeight_actionPerformed( + ActionEvent actionEvent) + { + // TODO Auto-generated method stub + + } + + protected void justifyRightMenuItem_actionPerformed(ActionEvent e) + { + // TODO Auto-generated method stub + + } + + protected void justifyLeftMenuItem_actionPerformed(ActionEvent e) + { + // TODO Auto-generated method stub + + } + protected void followHighlight_actionPerformed() { // TODO Auto-generated method stub @@ -1753,6 +1817,10 @@ public class GAlignFrame extends JInternalFrame { } + protected void sortLengthMenuItem_actionPerformed(ActionEvent e) + { + } + protected void sortGroupMenuItem_actionPerformed(ActionEvent e) { } -- 1.7.10.2