+ }
+ if (!newAlignment) {
+ ///////
+ // ADD HISTORY ITEM
+ //
+ addHistoryItem(new EditCommand(
+ "Add sequences",
+ EditCommand.PASTE,
+ sequences,
+ 0,
+ alignment.getWidth(),
+ alignment)
+ );
+ }
+ // Add any annotations attached to sequences
+ for (int i = 0; i < sequences.length; i++)
+ {
+ if (sequences[i].getAnnotation() != null)
+ {
+ for (int a = 0; a < sequences[i].getAnnotation().length; a++)
+ {
+ annotationAdded=true;
+ sequences[i].getAnnotation()[a].adjustForAlignment();
+ sequences[i].getAnnotation()[a].padAnnotation(alwidth);
+ alignment.addAnnotation(sequences[i].getAnnotation()[a]); // annotation was duplicated earlier
+ alignment.setAnnotationIndex(sequences[i].getAnnotation()[a], a);
+ }
+ }
+ }
+ if (!newAlignment) {
+
+ // propagate alignment changed.
+ viewport.setEndSeq(alignment.getHeight());
+ if (annotationAdded)
+ {
+ // Duplicate sequence annotation in all views.
+ AlignmentI[] alview = this.getViewAlignments();
+ for (int i = 0; i < sequences.length; i++)
+ {
+ AlignmentAnnotation sann[] = sequences[i].getAnnotation();
+ if (sann == null)
+ continue;
+ for (int avnum=0;avnum<alview.length; avnum++)
+ {
+ if (alview[avnum]!=alignment)
+ {
+ // duplicate in a view other than the one with input focus
+ int avwidth = alview[avnum].getWidth()+1;
+ // this relies on sann being preserved after we
+ // modify the sequence's annotation array for each duplication
+ for (int a=0; a<sann.length; a++)
+ {
+ AlignmentAnnotation newann = new AlignmentAnnotation(sann[a]);
+ sequences[i].addAlignmentAnnotation(newann);
+ newann.padAnnotation(avwidth);
+ alview[avnum].addAnnotation(newann); // annotation was duplicated earlier
+ alview[avnum].setAnnotationIndex(newann, a);
+ }
+ }
+ }
+ }
+ buildSortByAnnotationScoresMenu();
+ }
+ viewport.firePropertyChange("alignment", null, alignment.getSequences());
+
+ } else {
+ AlignFrame af = new AlignFrame(alignment, DEFAULT_WIDTH, DEFAULT_HEIGHT);
+ String newtitle = new String("Copied sequences");
+
+ if(Desktop.jalviewClipboard!=null && Desktop.jalviewClipboard[2]!=null)
+ {
+ Vector hc = (Vector)Desktop.jalviewClipboard[2];
+ for(int i=0; i<hc.size(); i++)
+ {
+ int [] region = (int[]) hc.elementAt(i);
+ af.viewport.hideColumns(region[0], region[1]);
+ }
+ }
+
+
+ //>>>This is a fix for the moment, until a better solution is found!!<<<
+ af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().transferSettings(
+ alignPanel.seqPanel.seqCanvas.getFeatureRenderer());
+
+ // TODO: maintain provenance of an alignment, rather than just make the title a concatenation of operations.
+ if (!externalPaste) {
+ if (title.startsWith("Copied sequences"))
+ {
+ newtitle = title;
+ }
+ else
+ {
+ newtitle = newtitle.concat("- from " + title);
+ }
+ } else {
+ newtitle = new String("Pasted sequences");
+ }
+
+ Desktop.addInternalFrame(af, newtitle, DEFAULT_WIDTH,
+ DEFAULT_HEIGHT);