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;
* YES_OPTION corresponds to the Amend button
*/
boolean typeChanged = !lastFeatureAdded.equals(sf.type);
- sf.type = lastFeatureAdded;
- sf.featureGroup = lastFeatureGroupAdded;
- sf.description = lastDescriptionAdded;
-
- setColour(sf.type, fcol);
- getFeaturesDisplayed().setVisible(sf.type);
-
+ String newType = lastFeatureAdded;
+ String newFeatureGroup = lastFeatureGroupAdded;
+ String newDescription = lastDescriptionAdded;
+
+ setColour(newType, fcol);
+ getFeaturesDisplayed().setVisible(newType);
+ int newBegin = sf.begin;
+ int newEnd = sf.end;
try
{
- sf.begin = ((Integer) start.getValue()).intValue();
- sf.end = ((Integer) end.getValue()).intValue();
+ newBegin = ((Integer) start.getValue()).intValue();
+ newEnd = ((Integer) end.getValue()).intValue();
} catch (NumberFormatException ex)
{
+ // JSpinner doesn't accept invalid format data :-)
+ }
+
+ /*
+ * replace the feature by deleting it and adding a new one
+ * (to ensure integrity of SequenceFeatures data store)
+ */
+ sequences.get(0).deleteFeature(sf);
+ SequenceFeature newSf = new SequenceFeature(newType,
+ newDescription, newBegin, newEnd, sf.getScore(),
+ newFeatureGroup);
+ // ensure any additional properties are copied
+ if (sf.otherDetails != null)
+ {
+ newSf.otherDetails = new HashMap<String, Object>(sf.otherDetails);
+ }
+ 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
+ sequences.get(0).addSequenceFeature(newSf);
- ffile.parseDescriptionHTML(sf, false);
if (typeChanged)
{
findAllFeatures();