From: amwaterhouse Date: Fri, 24 Mar 2006 15:32:50 +0000 (+0000) Subject: Load data file added X-Git-Tag: Root_VamJalview_2_07b+~12 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=0ad0cc7fe1de5c299363b0dc9b4b032d5d199275;p=jalview.git Load data file added --- diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index a4f5e4d..b2c8901 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -360,6 +360,27 @@ public class AlignFrame thread.start(); } + public void associatedData_actionPerformed(ActionEvent e) + { + // Pick the tree file + JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache. + getProperty( + "LAST_DIRECTORY")); + chooser.setFileView(new JalviewFileView()); + chooser.setDialogTitle("Load Jalview Annotations or Features File"); + chooser.setToolTipText("Load Jalview Annotations / Features file"); + + int value = chooser.showOpenDialog(null); + + if (value == JalviewFileChooser.APPROVE_OPTION) + { + String choice = chooser.getSelectedFile().getPath(); + jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice); + loadJalviewDataFile(choice); + } + + } + /** * DOCUMENT ME! * @@ -685,6 +706,10 @@ public class AlignFrame AlignFrame af = new AlignFrame(alignment); String newtitle = new String("Copied sequences"); + //>>>This is a fix for the moment, until a better solution is found!!<<< + FeatureRenderer fr = af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer(); + fr.featureColours = alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureColours; + if (title.startsWith("Copied sequences")) { newtitle = title; @@ -2608,8 +2633,7 @@ public boolean parseGroupsFile(String file) alignPanel.seqPanel.seqCanvas.getFeatureRenderer().setColour(type, ucs.findColour("A")); } - sf = new SequenceFeature(type, desc, "", start, end); - sf.setFeatureGroup(featureGroup); + sf = new SequenceFeature(type, desc, "", start, end, featureGroup); seq.getDatasetSequence().addSequenceFeature(sf); } @@ -2683,57 +2707,68 @@ public void drop(DropTargetDropEvent evt) { e.printStackTrace(); } - if (files != null) { try { - boolean isAnnotation = false; for (int i = 0; i < files.size(); i++) { - String file = files.get(i).toString(); - - isAnnotation = new AnnotationReader().readAnnotationFile(viewport.alignment, file); - - if( !isAnnotation ) - { - boolean isGroupsFile = parseGroupsFile(file); - if (!isGroupsFile) - { - String protocol = "File"; - String format = new IdentifyFile().Identify(file, protocol); - SequenceI[] sequences = new FormatAdapter().readFile(file, protocol, format); - - FastaFile ff = new FastaFile(); - Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); - c.setContents(new StringSelection(ff.print(sequences)), this); - - this.paste(false); - - } - } + loadJalviewDataFile(files.get(i).toString()); } + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } +} + + // This method will attempt to load a "dropped" file first by testing + // whether its and Annotation file, then group file. If both are + // false then the user may have dropped an alignment file onto this + // AlignFrame + void loadJalviewDataFile(String file) + { + try{ + boolean isAnnotation = new AnnotationReader().readAnnotationFile(viewport. + alignment, file); - if(isAnnotation) + if (!isAnnotation) + { + boolean isGroupsFile = parseGroupsFile(file); + if (!isGroupsFile) { - int height = alignPanel.annotationPanel.adjustPanelHeight(); - alignPanel.annotationScroller.setPreferredSize( - new Dimension(alignPanel.annotationScroller.getWidth(), - height)); + String protocol = "File"; + String format = new IdentifyFile().Identify(file, protocol); + SequenceI[] sequences = new FormatAdapter().readFile(file, protocol, + format); - alignPanel.annotationSpaceFillerHolder.setPreferredSize(new Dimension( - alignPanel.annotationSpaceFillerHolder.getWidth(), - height)); + FastaFile ff = new FastaFile(); + Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); + c.setContents(new StringSelection(ff.print(sequences)), this); - alignPanel.addNotify(); + this.paste(false); } } - catch (Exception ex) + + if (isAnnotation) { - ex.printStackTrace(); + int height = alignPanel.annotationPanel.adjustPanelHeight(); + alignPanel.annotationScroller.setPreferredSize( + new Dimension(alignPanel.annotationScroller.getWidth(), + height)); + + alignPanel.annotationSpaceFillerHolder.setPreferredSize(new Dimension( + alignPanel.annotationSpaceFillerHolder.getWidth(), + height)); + + alignPanel.addNotify(); } - } -} + }catch(Exception ex) + { + ex.printStackTrace(); + } + } }