From a00a50870e5a92ea78f765eb2ff48d9f1c2012e2 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Wed, 13 Apr 2005 16:32:55 +0000 Subject: [PATCH] treeMenuItem added, conservation sliders, finder top layer --- src/jalview/gui/AlignFrame.java | 127 ++++++++++++++++++++++++--------------- 1 file changed, 77 insertions(+), 50 deletions(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 3123184..3048b2c 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -30,8 +30,17 @@ public class AlignFrame extends GAlignFrame { final AlignmentPanel alignPanel; final AlignViewport viewport; + public static final int NEW_WINDOW_WIDTH = 700; + public static final int NEW_WINDOW_HEIGHT = 500; + public AlignFrame(AlignmentI al) { + try{ + String ip = java.net.InetAddress.getLocalHost().getHostAddress(); + if( !ip.startsWith("10.")) + alignMenu.setVisible(false); + } + catch(java.net.UnknownHostException e){} viewport = new AlignViewport(al,true,true,false); String fontName = jalview.bin.Cache.getProperty("FONT_NAME"); @@ -348,10 +357,7 @@ public class AlignFrame extends GAlignFrame SequenceI[] newSeqs = new SequenceI[seqs.size()]; seqs.toArray(newSeqs); AlignFrame af = new AlignFrame(new Alignment(newSeqs)); - int newHeight = newSeqs.length * af.viewport.getCharHeight() + 200; - if (newHeight > 500) - newHeight = 500; - Desktop.addInternalFrame(af, "Copied sequences", 700, 500); + Desktop.addInternalFrame(af, "Copied sequences", NEW_WINDOW_WIDTH, NEW_WINDOW_HEIGHT); } else { @@ -560,10 +566,11 @@ public class AlignFrame extends GAlignFrame public void findMenuItem_actionPerformed(ActionEvent e) { - JInternalFrame frame = new JInternalFrame(); - Finder finder = new Finder(viewport, alignPanel, frame); - frame.setContentPane(finder); - Desktop.addInternalFrame(frame, "Find", 340,110); + JInternalFrame frame = new JInternalFrame(); + Finder finder = new Finder(viewport, alignPanel, frame); + frame.setContentPane(finder); + Desktop.addInternalFrame(frame, "Find", 340,110, false); + frame.setLayer(JLayeredPane.PALETTE_LAYER); } @@ -786,16 +793,16 @@ public class AlignFrame extends GAlignFrame } - if ( viewport.getAbovePIDThreshold()) + if ( viewport.getAbovePIDThreshold() ) { - int threshold = 0; - threshold = Desktop.setPIDSliderSource(alignPanel, cs, "Background"); + // int threshold = 0; + // threshold = Desktop.setPIDSliderSource(alignPanel, cs, "Background"); Desktop.hideConservationSlider(); - if (cs instanceof ResidueColourScheme) - ( (ResidueColourScheme) cs).setThreshold(threshold); - else if (cs instanceof ScoreColourScheme) - ( (ScoreColourScheme) cs).setThreshold(threshold); + // if (cs instanceof ResidueColourScheme) + // ( (ResidueColourScheme) cs).setThreshold(threshold); + // else if (cs instanceof ScoreColourScheme) + // ( (ScoreColourScheme) cs).setThreshold(threshold); viewport.setGlobalColourScheme(cs); @@ -824,10 +831,9 @@ if ( viewport.getConservationSelected() ) ccs = new ConservationColourScheme(c, cs); - int threshold = Desktop.setConservationSliderSource(alignPanel, ccs, - "Background"); + // int threshold = Desktop.setConservationSliderSource(alignPanel, ccs, "Background"); - ccs.inc = threshold; + // ccs.inc = threshold; viewport.setGlobalColourScheme(ccs); @@ -838,6 +844,16 @@ if ( viewport.getConservationSelected() ) alignPanel.RefreshPanels(); } + protected void modifyPID_actionPerformed(ActionEvent e) + { + Desktop.setPIDSliderSource(alignPanel, viewport.getGlobalColourScheme(), "Background"); + } + + protected void modifyConservation_actionPerformed(ActionEvent e) + { + Desktop.setConservationSliderSource(alignPanel, viewport.globalColourScheme, "Background"); + } + protected void conservationMenuItem_actionPerformed(ActionEvent e) { @@ -895,10 +911,7 @@ if ( viewport.getConservationSelected() ) JInternalFrame frame = new JInternalFrame(); UserDefinedColours chooser = new UserDefinedColours( frame, alignPanel, null); frame.setContentPane(chooser); - Desktop.addInternalFrame(frame,"User defined colours", 450,540 ); - frame.setResizable(false); - frame.setIconifiable(false); - frame.setMaximizable(false); + Desktop.addInternalFrame(frame,"User defined colours", 450,540, false ); } public void PIDColour_actionPerformed(ActionEvent e) @@ -936,24 +949,12 @@ if ( viewport.getConservationSelected() ) alignPanel.RefreshPanels(); } - public void sortTreeOrderMenuItem_actionPerformed(ActionEvent e) - { - addHistoryItem("sort"); - if(viewport.getCurrentTree()==null) - return; - - AlignmentSorter.sortByTree(viewport.getAlignment(), viewport.getCurrentTree()); - alignPanel.RefreshPanels(); - } - public void removeRedundancyMenuItem_actionPerformed(ActionEvent e) { RedundancyPanel sp = new RedundancyPanel(alignPanel); JInternalFrame frame = new JInternalFrame(); frame.setContentPane(sp); - Desktop.addInternalFrame(frame, "Redundancy threshold selection", 400, 100); - frame.setMaximizable(false); - frame.setResizable(false); + Desktop.addInternalFrame(frame, "Redundancy threshold selection", 400, 100, false); } @@ -1027,22 +1028,48 @@ if ( viewport.getConservationSelected() ) return; } - TreePanel tp=null; - if (viewport.getSelectionGroup() != null && viewport.getSelectionGroup().getSize() > 3) - { - tp = new TreePanel(viewport, viewport.getSelectionGroup().sequences,type, pwType, + final TreePanel tp; + if (viewport.getSelectionGroup() != null && + viewport.getSelectionGroup().getSize() > 3) + { + tp = new TreePanel(viewport, viewport.getSelectionGroup().sequences, type, + pwType, 0, viewport.alignment.getWidth()); - } - else - { - tp = new TreePanel(viewport, viewport.getAlignment().getSequences(), - type, pwType, 0, viewport.alignment.getWidth()); - } + } + else + { + tp = new TreePanel(viewport, viewport.getAlignment().getSequences(), + type, pwType, 0, viewport.alignment.getWidth()); + } + + addTreeMenuItem(tp, title); Desktop.addInternalFrame(tp, title, 600, 500); } + void addTreeMenuItem(final TreePanel treePanel, String title) + { + final JMenuItem item = new JMenuItem(title); + sortByTreeMenu.add(item); + item.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(ActionEvent e) + { + addHistoryItem("sort"); + AlignmentSorter.sortByTree(viewport.getAlignment(), treePanel.getTree()); + alignPanel.RefreshPanels(); + } + }); + + treePanel.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() + { + public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) + { + sortByTreeMenu.remove(item); + }; + }); + } public void clustalAlignMenuItem_actionPerformed(ActionEvent e) @@ -1052,7 +1079,7 @@ if ( viewport.getConservationSelected() ) Thread t = new Thread(ct); t.start(); frame.setContentPane(ct); - Desktop.addInternalFrame(frame, title, 300, 80); + Desktop.addInternalFrame(frame, title, 320, 90); } @@ -1123,10 +1150,9 @@ if ( viewport.getConservationSelected() ) if (alignment != null) { AlignFrame af = new AlignFrame(new Alignment(alignment)); - af.clustalColour.setSelected(true); - af.clustalColour_actionPerformed(null); - Desktop.addInternalFrame(af, getTitle().concat(" - ClustalW Alignment"), - 700, 500); // JBPNote - is there a new window geom. property ? + Desktop.addInternalFrame(af, getTitle().concat(" - ClustalW Alignment"),NEW_WINDOW_WIDTH, NEW_WINDOW_HEIGHT); + af.clustalColour_actionPerformed(null); + af.clustalColour.setSelected(true); } else JOptionPane.showMessageDialog(Desktop.desktop, "Problem obtaining clustal alignment", "Web service error", @@ -1229,6 +1255,7 @@ if ( viewport.getConservationSelected() ) tp = new TreePanel(viewport, viewport.getAlignment().getSequences(), fin, "FromFile", choice); Desktop.addInternalFrame(tp, title, 600, 500); + addTreeMenuItem(tp, title); } } catch (Exception ex) -- 1.7.10.2