From 56d68286221ccea4f894ef480df4173a880152b2 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 22 May 2017 16:40:14 +0100 Subject: [PATCH] JAL-2505 updates after conflicting merge of JAL-2504 --- src/jalview/appletgui/FeatureRenderer.java | 46 +++++++++++++++++----------- src/jalview/gui/FeatureRenderer.java | 22 +++---------- 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/src/jalview/appletgui/FeatureRenderer.java b/src/jalview/appletgui/FeatureRenderer.java index 38ecf76..81b207f 100644 --- a/src/jalview/appletgui/FeatureRenderer.java +++ b/src/jalview/appletgui/FeatureRenderer.java @@ -394,11 +394,14 @@ public class FeatureRenderer extends /* * only update default type and group if we used defaults */ - String enteredType = name.getText().trim(); + final String enteredType = name.getText().trim(); + final String enteredGroup = group.getText().trim(); + final String enteredDesc = description.getText().replace('\n', ' '); + if (dialog.accept && useLastDefaults) { lastFeatureAdded = enteredType; - lastFeatureGroupAdded = group.getText().trim(); + lastFeatureGroupAdded = enteredGroup; } if (!create) @@ -406,26 +409,33 @@ public class FeatureRenderer extends SequenceFeature sf = features[featureIndex]; if (dialog.accept) { - sf.type = enteredType; - sf.featureGroup = group.getText().trim(); - if (sf.featureGroup != null && sf.featureGroup.length() < 1) - { - sf.featureGroup = null; - } - sf.description = description.getText().replace('\n', ' '); if (!colourPanel.isGcol) { // update colour - otherwise its already done. setColour(sf.type, new FeatureColour(colourPanel.getBackground())); } + int newBegin = sf.begin; + int newEnd = sf.end; try { - sf.begin = Integer.parseInt(start.getText()); - sf.end = Integer.parseInt(end.getText()); + newBegin = Integer.parseInt(start.getText()); + newEnd = Integer.parseInt(end.getText()); } catch (NumberFormatException ex) { - // + // } + + /* + * replace the feature by deleting it and adding a new one + * (to ensure integrity of SequenceFeatures data store) + */ + sequences[0].deleteFeature(sf); + SequenceFeature newSf = new SequenceFeature(sf, newBegin, newEnd, + enteredGroup); + newSf.setDescription(enteredDesc); + ffile.parseDescriptionHTML(newSf, false); + // amend features dialog only updates one sequence at a time + sequences[0].addSequenceFeature(newSf); boolean typeOrGroupChanged = (!featureType.equals(sf.type) || !featureGroup .equals(sf.featureGroup)); @@ -451,12 +461,12 @@ public class FeatureRenderer extends { for (int i = 0; i < sequences.length; i++) { - features[i].type = enteredType; - features[i].featureGroup = group.getText().trim(); - features[i].description = description.getText() - .replace('\n', ' '); - sequences[i].addSequenceFeature(features[i]); - ffile.parseDescriptionHTML(features[i], false); + SequenceFeature sf = features[i]; + SequenceFeature sf2 = new SequenceFeature(enteredType, + enteredDesc, sf.getBegin(), sf.getEnd(), Float.NaN, + enteredGroup); + ffile.parseDescriptionHTML(sf2, false); + sequences[i].addSequenceFeature(sf2); } Color newColour = colourPanel.getBackground(); diff --git a/src/jalview/gui/FeatureRenderer.java b/src/jalview/gui/FeatureRenderer.java index c0e3e73..c6610e1 100644 --- a/src/jalview/gui/FeatureRenderer.java +++ b/src/jalview/gui/FeatureRenderer.java @@ -43,7 +43,6 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.Arrays; import java.util.Comparator; -import java.util.HashMap; import java.util.List; import javax.swing.JColorChooser; @@ -449,24 +448,11 @@ public class FeatureRenderer extends * (to ensure integrity of SequenceFeatures data store) */ sequences.get(0).deleteFeature(sf); - SequenceFeature newSf = new SequenceFeature(enteredType, - enteredDescription, newBegin, newEnd, sf.getScore(), + SequenceFeature newSf = new SequenceFeature(sf, newBegin, newEnd, enteredGroup); - // ensure any additional properties are copied - if (sf.otherDetails != null) - { - newSf.otherDetails = new HashMap(sf.otherDetails); - } + sf.setDescription(enteredDescription); ffile.parseDescriptionHTML(newSf, false); - // add any additional links not parsed from description - if (sf.links != null) - { - for (String link : sf.links) - { - newSf.addLink(link); - } - } - // amend features only gets one sequence to act on + // amend features dialog only updates one sequence at a time sequences.get(0).addSequenceFeature(newSf); if (refreshSettings) @@ -486,8 +472,8 @@ public class FeatureRenderer extends SequenceFeature sf2 = new SequenceFeature(enteredType, enteredDescription, sf.getBegin(), sf.getEnd(), Float.NaN, enteredGroup); - sequences.get(i).addSequenceFeature(sf2); ffile.parseDescriptionHTML(sf2, false); + sequences.get(i).addSequenceFeature(sf2); } setColour(enteredType, fcol); -- 1.7.10.2