From 0ad0cc7fe1de5c299363b0dc9b4b032d5d199275 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Fri, 24 Mar 2006 15:32:50 +0000 Subject: [PATCH] Load data file added --- src/jalview/gui/AlignFrame.java | 111 +++++++++++++++++++++++++-------------- 1 file changed, 73 insertions(+), 38 deletions(-) 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(); + } + } } -- 1.7.10.2