public class StructureSelectionManager
{
+ public static StructureSelectionManager getStructureSelectionManager(
+ StructureSelectionManagerProvider context)
+ {
+ IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> map = Instance
+ .getInstance().structureSelections;
+
+ if (map == null)
+ {
+ map = Instance
+ .getInstance().structureSelections = new IdentityHashMap<>();
+ }
+ StructureSelectionManager instance = map.get(context);
+ if (instance == null)
+ {
+ // BH: actually, not possible except for coding error; this is an attempt
+ // to discover that.
+ if (context == null && !map.isEmpty())
+ {
+ throw new Error(MessageManager.getString(
+ "error.implementation_error_structure_selection_manager_null"),
+ new NullPointerException(MessageManager
+ .getString("exception.ssm_context_is_null")));
+ }
+ map.put(context, instance = new StructureSelectionManager());
+ }
+ return instance;
+ }
+
+ /**
+ * release all references associated with this manager provider
+ *
+ * @param provider
+ */
+
+ public static void release(StructureSelectionManagerProvider provider)
+ {
+ IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> map = Instance
+ .getInstance().structureSelections;
+ if (map != null)
+ {
+ map.remove(provider);
+ }
+ }
+
public StructureSelectionManager()
{
}
* Import structure data and register a structure mapping for broadcasting
* colouring, mouseovers and selection events (convenience wrapper).
*
+ * This is the standard entry point.
+ *
* @param sequence
* - one or more sequences to be mapped to pdbFile
* @param targetChains
* broadcasting colouring, mouseovers and selection events (convenience
* wrapper).
*
+ *
+ *
* @param forStructureView
- * when true, record the mapping for use in mouseOvers
+ * when true (testng only), record the mapping for use in mouseOvers
+ * (testng only)
* @param sequence
* - one or more sequences to be mapped to pdbFile
* @param targetChains
* mapping operation
* @return null or the structure data parsed as a pdb file
*/
- synchronized public StructureFile computeMapping(
+ synchronized private StructureFile computeMapping(
boolean forStructureView, SequenceI[] sequenceArray,
String[] targetChainIds, String pdbFile, DataSourceType sourceType,
IProgressIndicator progress)
}
/**
- * Resets this object to its initial state by removing all registered
- * listeners, codon mappings, PDB file mappings
+ * Reset this object to its initial state by removing all registered
+ * listeners, codon mappings, PDB file mappings.
+ *
+ * Called only by Desktop and testng.
+ *
*/
public void resetAll()
{
- if (mappings != null)
- {
- mappings.clear();
- }
- if (seqmappings != null)
- {
- seqmappings.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();
- }
+ mappings.clear();
+ seqmappings.clear();
+ sel_listeners.clear();
+ listeners.clear();
+ commandListeners.clear();
+ view_listeners.clear();
+ pdbFileNameId.clear();
+ pdbIdFileName.clear();
}
public void addSelectionListener(SelectionListener selecter)
return seqmappings;
}
- public static StructureSelectionManager getStructureSelectionManager(
- StructureSelectionManagerProvider context)
- {
- IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> map = Instance
- .getInstance().structureSelections;
-
- if (map == null)
- {
- map = Instance
- .getInstance().structureSelections = new IdentityHashMap<>();
- }
- StructureSelectionManager instance = map.get(context);
- if (instance == null)
- {
- // BH: actually, not possible except for coding error; this is an attempt
- // to discover that.
- if (context == null && !map.isEmpty())
- {
- throw new Error(MessageManager.getString(
- "error.implementation_error_structure_selection_manager_null"),
- new NullPointerException(MessageManager
- .getString("exception.ssm_context_is_null")));
- }
- map.put(context,
- instance = new StructureSelectionManager());
- }
- return instance;
- }
-
- /**
- * release all references associated with this manager provider
- *
- * @param provider
- */
-
- public static void release(StructureSelectionManagerProvider provider)
- {
- IdentityHashMap<StructureSelectionManagerProvider, StructureSelectionManager> map = Instance
- .getInstance().structureSelections;
- if (map != null)
- {
- map.remove(provider);
- }
- }
-
}