final AlignViewport viewport;\r
public static final int NEW_WINDOW_WIDTH = 700;\r
public static final int NEW_WINDOW_HEIGHT = 500;\r
+ public String currentFileFormat = "Jalview";\r
\r
public AlignFrame(AlignmentI al)\r
{\r
- try{\r
- String ip = java.net.InetAddress.getLocalHost().getHostAddress();\r
- if( !ip.startsWith("10."))\r
- webService.setVisible(false);\r
- }\r
- catch(java.net.UnknownHostException e){}\r
viewport = new AlignViewport(al);\r
\r
-\r
alignPanel = new AlignmentPanel(this, viewport);\r
alignPanel.annotationPanel.adjustPanelHeight();\r
alignPanel.annotationSpaceFillerHolder.setPreferredSize(alignPanel.annotationPanel.getPreferredSize());\r
\r
}\r
\r
- protected void saveAs_actionPerformed(ActionEvent e)\r
+ public void saveAlignmentMenu_actionPerformed(ActionEvent e)\r
{\r
- String suffix [] = null;\r
- if(e.getActionCommand().equals("FASTA"))\r
- suffix = new String[]{"fa", "fasta"};\r
- else if(e.getActionCommand().equals("MSF"))\r
- suffix = new String[]{"msf"};\r
- else if(e.getActionCommand().equals("CLUSTAL"))\r
- suffix = new String[]{"aln"};\r
- else if(e.getActionCommand().equals("BLC"))\r
- suffix = new String[]{"blc"};\r
- else if(e.getActionCommand().equals("PIR"))\r
- suffix = new String[]{"pir"};\r
- else if(e.getActionCommand().equals("PFAM"))\r
- suffix = new String[]{"pfam"};\r
-\r
-\r
JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY")\r
- , suffix, e.getActionCommand()+" file");\r
+ , new String[]{"fa, fasta, fastq", "aln", "pfam", "msf", "pir","blc","jar"},\r
+ new String[]{"FASTA", "CLUSTAL", "PFAM", "MSF", "PIR", "BLC", "Jalview"},\r
+ currentFileFormat);\r
+\r
+ chooser.setAcceptAllFileFilterUsed(false);\r
chooser.setFileView(new JalviewFileView());\r
- chooser.setDialogTitle("Save Alignment to file - "+e.getActionCommand() +" format.");\r
+ chooser.setDialogTitle("Save Alignment to file");\r
chooser.setToolTipText("Save");\r
int value = chooser.showSaveDialog(this);\r
if(value == JalviewFileChooser.APPROVE_OPTION)\r
{\r
+ currentFileFormat = chooser.getSelectedFormat();\r
+\r
+ if (currentFileFormat.equals("Jalview"))\r
+ {\r
+ String shortName = title.replace('/', '_');\r
+ title = title.replace('\\', '_');\r
+ String choice = chooser.getSelectedFile().getPath();\r
+ Jalview2XML.SaveState(this, System.currentTimeMillis(), shortName,\r
+ choice);\r
+ // USE Jalview2XML to save this file\r
+ return;\r
+ }\r
+\r
String choice = chooser.getSelectedFile().getPath();\r
jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);\r
- String output = FormatAdapter.formatSequences(e.getActionCommand(), viewport.getAlignment().getSequences());\r
+ String output = FormatAdapter.formatSequences(currentFileFormat, viewport.getAlignment().getSequences());\r
try{\r
java.io.PrintWriter out = new java.io.PrintWriter( new java.io.FileWriter( choice ) );\r
out.println(output);\r
{\r
// must make sure we add new sequence objects her, not refs to the existing sequences\r
redoList.clear();\r
+\r
SequenceI[] seq = new SequenceI[viewport.getAlignment().getHeight()];\r
for(int i=0; i<viewport.getAlignment().getHeight(); i++)\r
{\r
viewport.getAlignment().getSequenceAt(i).getSequence());\r
}\r
\r
+\r
historyList.add(0, new Object[]{type, seq} );\r
updateEditMenuBar();\r
}\r
seq = (SequenceI[]) history[1];\r
AlignmentAnnotation [] old = viewport.alignment.getAlignmentAnnotation();\r
viewport.setAlignment( new Alignment(seq) );\r
+ viewport.alignment.setGapCharacter( Preferences.gapSymbol );\r
updateEditMenuBar();\r
for(int i=0; i<old.length; i++)\r
viewport.alignment.addAnnotation(old[i]);\r
SequenceI[] newSeqs = new SequenceI[seqs.size()];\r
seqs.toArray(newSeqs);\r
AlignFrame af = new AlignFrame(new Alignment(newSeqs));\r
- Desktop.addInternalFrame(af, "Copied sequences", NEW_WINDOW_WIDTH, NEW_WINDOW_HEIGHT);\r
+ String newtitle = new String("Copied sequences");\r
+ if( title.startsWith("Copied sequences"))\r
+ newtitle = title;\r
+ else\r
+ newtitle = newtitle.concat("- from "+title);\r
+\r
+ Desktop.addInternalFrame(af, newtitle, NEW_WINDOW_WIDTH, NEW_WINDOW_HEIGHT);\r
}\r
else\r
{\r
Object [] history = (Object[])redoList.remove(0);\r
SequenceI[] seq = (SequenceI[]) history[1];\r
viewport.setAlignment( new Alignment(seq) );\r
+ viewport.alignment.setGapCharacter( Preferences.gapSymbol );\r
updateEditMenuBar();\r
viewport.updateConsensus();\r
alignPanel.repaint();\r
{\r
viewport.alignment.deleteAllGroups();\r
viewport.setSelectionGroup(null);\r
-\r
alignPanel.repaint();\r
}\r
\r
JInternalFrame frame = new JInternalFrame();\r
Finder finder = new Finder(viewport, alignPanel, frame);\r
frame.setContentPane(finder);\r
- Desktop.addInternalFrame(frame, "Find", 340,110, false);\r
+ Desktop.addInternalFrame(frame, "Find", 340,110);\r
frame.setLayer(JLayeredPane.PALETTE_LAYER);\r
\r
}\r
{\r
sg.cs = new ClustalxColourScheme(sg.sequences, sg.getWidth());\r
}\r
- else\r
- try\r
- {\r
+ else if(cs!=null)\r
+ {\r
+ try{\r
sg.cs = (ColourSchemeI) cs.getClass().newInstance();\r
- }\r
- catch (Exception ex)\r
- {\r
- ex.printStackTrace();\r
- sg.cs = cs;\r
- }\r
+ }catch(Exception ex){ex.printStackTrace();}\r
+ }\r
\r
if(viewport.getAbovePIDThreshold())\r
{\r
ccs.setConsensus( AAFrequency.calculate(sg.sequences, 0, sg.getWidth()));\r
sg.cs = ccs;\r
}\r
- else\r
+ else if(cs!=null)\r
{\r
// MUST NOTIFY THE COLOURSCHEME OF CONSENSUS!\r
sg.cs.setConsensus(AAFrequency.calculate(sg.sequences, 0, sg.getWidth()));\r
{\r
String choice = chooser.getSelectedFile().getPath();\r
jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);\r
- TreePanel treepanel = null;\r
try\r
{\r
jalview.io.NewickFile fin = new jalview.io.NewickFile(choice, "File");\r
- fin.parse();\r
-\r
- if (fin.getTree() != null)\r
- {\r
- TreePanel tp = null;\r
- tp = new TreePanel(viewport, viewport.getAlignment().getSequences(),\r
- fin, "FromFile", choice);\r
- Desktop.addInternalFrame(tp, title, 600, 500);\r
- addTreeMenuItem(tp, title);\r
- }\r
+ ShowNewickTree(fin, choice);\r
}\r
catch (Exception ex)\r
{\r
}\r
}\r
\r
+ public void ShowNewickTree(NewickFile nf, String title)\r
+ {\r
+ try{\r
+ nf.parse();\r
+ if (nf.getTree() != null)\r
+ {\r
+ TreePanel tp = new TreePanel(viewport,\r
+ viewport.getAlignment().getSequences(),\r
+ nf, "FromFile", title);\r
+ Desktop.addInternalFrame(tp, title, 600, 500);\r
+ addTreeMenuItem(tp, title);\r
+ viewport.setCurrentTree(tp.getTree());\r
+ }\r
+ }catch(Exception ex){ex.printStackTrace();}\r
+ }\r
+\r
+\r
}\r