From: amwaterhouse Date: Mon, 31 Oct 2005 15:57:24 +0000 (+0000) Subject: dbPrefix and jvsuffix added X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e378e950e3f2611dbf0dfeb2ffae60c37f7adcbe;p=jalview.git dbPrefix and jvsuffix added --- diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 7b394a3..1d408db 100755 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -42,7 +42,7 @@ import jalview.ws.*; * @version $Revision$ */ public class AlignFrame - extends GAlignFrame + extends GAlignFrame implements ClipboardOwner { /** DOCUMENT ME!! */ public static final int NEW_WINDOW_WIDTH = 700; @@ -103,8 +103,7 @@ public class AlignFrame al.setDataset(null); } - AlignViewport ds = new AlignViewport(al.getDataset()); - ds.setDataset(true); + AlignViewport ds = new AlignViewport(al.getDataset(), true); AlignmentPanel dap = new AlignmentPanel(this, ds); tabbedPane.add("Dataset", dap); viewports.add(ds); @@ -603,6 +602,12 @@ public class AlignFrame alignPanel.repaint(); } + public void lostOwnership(Clipboard clipboard, Transferable contents) + { + Desktop.jalviewClipboard = null; + } + + /** * DOCUMENT ME! * @@ -612,7 +617,7 @@ public class AlignFrame { if (viewport.getSelectionGroup() == null) { - System.out.println("null here"); + System.out.println("nothing selected"); return; } @@ -621,7 +626,7 @@ public class AlignFrame Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); Hashtable orderedSeqs = new Hashtable(); - SequenceI [] seqs = new SequenceI[sg.getSize()]; + SequenceI[] seqs = new SequenceI[sg.getSize()]; for (int i = 0; i < sg.getSize(); i++) { @@ -652,7 +657,6 @@ public class AlignFrame } } - //FIND START RES //Returns residue following index if gap startRes = seq.findPosition(sg.getStartRes()); @@ -676,12 +680,20 @@ public class AlignFrame } seqs[i] = new Sequence(seq.getName(), - seq.getSequence(sg.getStartRes(), sg.getEndRes()+1), + seq.getSequence(sg.getStartRes(), sg.getEndRes() + 1), startRes, endRes); + seqs[i].setDescription(seq.getDescription()); + seqs[i].setDBRef(seq.getDBRef()); + seqs[i].setSequenceFeatures(seq.getSequenceFeatures()); + seqs[i].setDatasetSequence(seq.getDatasetSequence()); } - c.setContents(new StringSelection(new FastaFile().print(seqs)), null); + Desktop.jalviewClipboard = new Object[]{seqs, viewport.alignment.getDataset()}; + FastaFile ff = new FastaFile(); + ff.addDBPrefix( viewport.showDBPrefix ); + ff.addJVSuffix( viewport.showJVSuffix ); + c.setContents(new StringSelection( ff.print(seqs)), this); } /** @@ -728,13 +740,29 @@ public class AlignFrame return; String format = IdentifyFile.Identify(str, "Paste"); - SequenceI[] sequences = new FormatAdapter().readFile(str, "Paste", format); + SequenceI[] sequences; + + if(Desktop.jalviewClipboard!=null) + { + // The clipboard was filled from within Jalview, we must use the sequences + // And dataset from the copied alignment + sequences = (SequenceI[])Desktop.jalviewClipboard[0]; + } + else + sequences = new FormatAdapter().readFile(str, "Paste", format); if (newAlignment) { + Alignment alignment = new Alignment(sequences); - alignment.setDataset( viewport.alignment.getDataset() ); + + if(Desktop.jalviewClipboard!=null) + alignment.setDataset( (Alignment)Desktop.jalviewClipboard[1] ); + else + alignment.setDataset( null ); + + AlignFrame af = new AlignFrame(alignment); String newtitle = new String("Copied sequences"); @@ -1223,14 +1251,23 @@ public class AlignFrame * * @param e DOCUMENT ME! */ - protected void fullSeqId_actionPerformed(ActionEvent e) + protected void seqLimit_actionPerformed(ActionEvent e) { - viewport.setShowFullId(fullSeqId.isSelected()); + viewport.setShowJVSuffix(seqLimits.isSelected()); alignPanel.idPanel.idCanvas.setPreferredSize(alignPanel.calculateIdWidth()); alignPanel.repaint(); } + public void seqDBRef_actionPerformed(ActionEvent e) + { + viewport.setShowDBPrefix(seqDBRef.isSelected()); + + alignPanel.idPanel.idCanvas.setPreferredSize(alignPanel.calculateIdWidth()); + alignPanel.repaint(); + } + + /** * DOCUMENT ME! * @@ -1332,12 +1369,13 @@ public class AlignFrame { viewport.showSequenceFeatures(sequenceFeatures.isSelected()); - if (viewport.showSequenceFeatures && - ! ( (Alignment) viewport.alignment).featuresAdded) + // if (viewport.showSequenceFeatures && + // ! ( (Alignment) viewport.alignment.getDataset()).featuresAdded) { - new SequenceFeatureFetcher(viewport. - alignment, - alignPanel); + // System.out.println("new fetcher"); + // new SequenceFeatureFetcher(viewport. + // alignment, + // alignPanel); } featureSettings.setEnabled(true); diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index f57e993..3ed2a7c 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -43,7 +43,8 @@ public class AlignViewport int endRes; int startSeq; int endSeq; - boolean showFullId = false; + boolean showDBPrefix = true; + boolean showJVSuffix = true; boolean showText = true; boolean showColourText = false; boolean showBoxes = true; @@ -90,6 +91,13 @@ public class AlignViewport boolean isDataset = false; + + public AlignViewport(AlignmentI al, boolean dataset) + { + isDataset = dataset; + setAlignment(al); + init(); + } /** * Creates a new AlignViewport object. * @@ -98,13 +106,18 @@ public class AlignViewport public AlignViewport(AlignmentI al) { setAlignment(al); + init(); + } + + void init() + { this.startRes = 0; - this.endRes = al.getWidth() - 1; + this.endRes = alignment.getWidth() - 1; this.startSeq = 0; - this.endSeq = al.getHeight() - 1; + this.endSeq = alignment.getHeight() - 1; - - showFullId = Cache.getDefault("SHOW_FULL_ID", true); + showDBPrefix = Cache.getDefault("SHOW_DBPREFIX", true); + showJVSuffix = Cache.getDefault("SHOW_JVSUFFIX", true); showAnnotation = Cache.getDefault("SHOW_ANNOTATIONS", true); showConservation = Cache.getDefault("SHOW_CONSERVATION", true); @@ -134,7 +147,7 @@ public class AlignViewport // We must set conservation and consensus before setting colour, // as Blosum and Clustal require this to be done - if(vconsensus==null) + if(vconsensus==null && !isDataset) { updateConservation(); updateConsensus(); @@ -913,9 +926,29 @@ public class AlignViewport * * @return DOCUMENT ME! */ - public boolean getShowFullId() + public boolean getShowJVSuffix() + { + return showJVSuffix; + } + + /** + * DOCUMENT ME! + * + * @param b DOCUMENT ME! + */ + public void setShowJVSuffix(boolean b) + { + showJVSuffix = b; + } + + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public boolean getShowDBPrefix() { - return showFullId; + return showDBPrefix; } /** @@ -923,9 +956,9 @@ public class AlignViewport * * @param b DOCUMENT ME! */ - public void setShowFullId(boolean b) + public void setShowDBPrefix(boolean b) { - showFullId = b; + showDBPrefix = b; } /**