+ final void adjustFeatures(Edit command, int index, int i, int j, boolean insert)\r
+ {\r
+ SequenceI seq = command.seqs[index];\r
+ SequenceI sequence = seq.getDatasetSequence();\r
+ if(sequence==null)\r
+ sequence = seq;\r
+\r
+ if(insert)\r
+ {\r
+ if (command.editedFeatures != null\r
+ && command.editedFeatures.containsKey(seq))\r
+ sequence.setSequenceFeatures(\r
+ (SequenceFeature[]) command.editedFeatures.get(seq)\r
+ );\r
+\r
+ return;\r
+ }\r
+\r
+\r
+ SequenceFeature [] sf = sequence.getSequenceFeatures();\r
+\r
+\r
+ if(sf==null)\r
+ {\r
+ return;\r
+ }\r
+\r
+ SequenceFeature [] oldsf = new SequenceFeature[sf.length];\r
+\r
+ int cSize = j - i;\r
+\r
+ for (int s = 0; s < sf.length; s++)\r
+ {\r
+ SequenceFeature copy = new SequenceFeature(sf[s]);\r
+\r
+ oldsf[s] = copy;\r
+\r
+ if (sf[s].getEnd() < i)\r
+ continue;\r
+\r
+ if (sf[s].getBegin() > j)\r
+ {\r
+ sf[s].setBegin(copy.getBegin() - cSize);\r
+ sf[s].setEnd(copy.getEnd() - cSize);\r
+ continue;\r
+ }\r
+\r
+ if (sf[s].getBegin() >= i)\r
+ sf[s].setBegin(i);\r
+\r
+ if (sf[s].getEnd() < j)\r
+ sf[s].setEnd(j - 1);\r
+\r
+ sf[s].setEnd(sf[s].getEnd() - (cSize));\r
+\r
+ if (sf[s].getBegin() > sf[s].getEnd())\r
+ sequence.deleteFeature(sf[s]);\r
+ }\r
+\r
+ if (command.editedFeatures == null)\r
+ command.editedFeatures = new Hashtable();\r
+\r
+ command.editedFeatures.put(seq, oldsf);\r
+\r
+ }\r
+\r