*/
package jalview.structure;
+import jalview.analysis.AlignSeq;
+import jalview.api.StructureSelectionManagerProvider;
+import jalview.commands.CommandI;
+import jalview.commands.EditCommand;
+import jalview.commands.OrderCommand;
+import jalview.datamodel.AlignedCodonFrame;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.Annotation;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SearchResults;
+import jalview.datamodel.SequenceI;
+import jalview.io.AppletFormatAdapter;
+import jalview.util.MappingUtils;
+import jalview.util.MessageManager;
+
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import MCview.PDBChain;
import MCview.PDBfile;
-import jalview.analysis.AlignSeq;
-import jalview.api.StructureSelectionManagerProvider;
-import jalview.commands.CommandI;
-import jalview.commands.EditCommand;
-import jalview.commands.OrderCommand;
-import jalview.datamodel.AlignedCodonFrame;
-import jalview.datamodel.AlignmentAnnotation;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.Annotation;
-import jalview.datamodel.PDBEntry;
-import jalview.datamodel.SearchResults;
-import jalview.datamodel.SequenceI;
-import jalview.io.AppletFormatAdapter;
-import jalview.util.MappingUtils;
-import jalview.util.MessageManager;
-
public class StructureSelectionManager
{
public final static String NEWLINE = System.lineSeparator();
* Reference counters for the above mappings. Remove mappings when ref count
* goes to zero.
*/
- Map<AlignedCodonFrame, Integer> seqMappingRefCounts = new HashMap<AlignedCodonFrame, Integer>();
+ private Map<AlignedCodonFrame, Integer> seqMappingRefCounts = new HashMap<AlignedCodonFrame, Integer>();
private List<CommandListener> commandListeners = new ArrayList<CommandListener>();
{
results = MappingUtils.buildSearchResults(seq, index,
seqmappings);
- }
+ }
if (handlingVamsasMo)
{
results.addResult(seq, index, index);
}
- seqListener.highlightSequence(results);
+ if (!results.isEmpty())
+ {
+ seqListener.highlightSequence(results);
+ }
}
}
}
else if (listener instanceof SecondaryStructureListener)
{
((SecondaryStructureListener) listener).mouseOverSequence(seq,
- indexpos);
+ indexpos, index);
}
}
}
{
seqmappings.remove(acf);
seqMappingRefCounts.remove(acf);
+ if (seqmappings.isEmpty())
+ { // debug
+ System.out.println("All mappings removed");
+ }
}
}
}
}
}
+ /**
+ * Resets this object to its initial state by removing all registered
+ * listeners, codon mappings, PDB file mappings
+ */
+ public void resetAll()
+ {
+ if (mappings != null)
+ {
+ mappings.clear();
+ }
+ if (seqmappings != null)
+ {
+ seqmappings.clear();
+ }
+ if (seqMappingRefCounts != null)
+ {
+ seqMappingRefCounts.clear();
+ }
+ if (sel_listeners != null)
+ {
+ sel_listeners.clear();
+ }
+ if (listeners != null)
+ {
+ listeners.clear();
+ }
+ if (commandListeners != null)
+ {
+ commandListeners.clear();
+ }
+ if (view_listeners != null)
+ {
+ view_listeners.clear();
+ }
+ if (pdbFileNameId != null)
+ {
+ pdbFileNameId.clear();
+ }
+ if (pdbIdFileName != null)
+ {
+ pdbIdFileName.clear();
+ }
+ }
+
public void addSelectionListener(SelectionListener selecter)
{
if (!sel_listeners.contains(selecter))
}
return null;
}
+
+ /**
+ * Returns the reference count for a mapping
+ *
+ * @param acf
+ * @return
+ */
+ protected int getMappingReferenceCount(AlignedCodonFrame acf)
+ {
+ if (seqMappingRefCounts == null)
+ {
+ return 0;
+ }
+ Integer count = seqMappingRefCounts.get(acf);
+ return (count == null ? 0 : count.intValue());
+ }
}