import MCview.*;
import jalview.analysis.*;
+import jalview.api.AlignmentViewPanel;
+import jalview.api.StructureSelectionManagerProvider;
import jalview.datamodel.*;
public class StructureSelectionManager
{
- static StructureSelectionManager instance;
+ static IdentityHashMap<StructureSelectionManagerProvider,StructureSelectionManager> instances;
StructureMapping[] mappings;
}\r
Hashtable mappingData = new Hashtable();
- public static StructureSelectionManager getStructureSelectionManager()
+ public static StructureSelectionManager getStructureSelectionManager(StructureSelectionManagerProvider context)
{
- if (instance == null)
+ if (instances == null)
{
- instance = new StructureSelectionManager();
+ instances = new java.util.IdentityHashMap<StructureSelectionManagerProvider,StructureSelectionManager>();
+ }
+ StructureSelectionManager instance=instances.get(context);
+ if (instance==null)
+ {
+ instances.put(context, instance=new StructureSelectionManager());
}
-
return instance;
}
}
}
}
- if (results.getSize() > 0)
+ if (results!=null)
{
for (int i = 0; i < listeners.size(); i++)
{
modifySeqMappingList(true, codonFrames);
}
- Vector sel_listeners = new Vector();
+ Vector<SelectionListener> sel_listeners = new Vector<SelectionListener>();
public void addSelectionListener(SelectionListener selecter)
{
}
}
}
+
+ Vector<AlignmentViewPanelListener> view_listeners=new Vector<AlignmentViewPanelListener>();
+ public synchronized void sendViewPosition(jalview.api.AlignmentViewPanel source, int startRes,
+ int endRes, int startSeq, int endSeq)
+ {
+
+ if (view_listeners != null && view_listeners.size() > 0)
+ {
+ Enumeration<AlignmentViewPanelListener> listeners = view_listeners.elements();
+ while (listeners.hasMoreElements())
+ {
+ AlignmentViewPanelListener slis = listeners
+ .nextElement();
+ if (slis != source)
+ {
+ slis.viewPosition(startRes, endRes, startSeq, endSeq, source);
+ }
+ ;
+ }
+ }
+ }
+
+
+ public void finalize() throws Throwable {
+ if (listeners!=null) {
+ listeners.clear();
+ listeners=null;
+ }
+ if (mappingData!=null)
+ {
+ mappingData.clear();
+ mappingData=null;
+ }
+ if (sel_listeners!=null)
+ {
+ sel_listeners.clear();
+ sel_listeners=null;
+ }
+ if (view_listeners!=null)
+ {
+ view_listeners.clear();
+ view_listeners=null;
+ }
+ mappings=null;
+ seqmappingrefs=null;
+ }
+
+ /**
+ * release all references associated with this manager provider
+ * @param jalviewLite
+ */
+ public static void release(StructureSelectionManagerProvider jalviewLite)
+ {
+ StructureSelectionManager mnger=(instances.get(jalviewLite));
+ if (mnger!=null)
+ {
+ instances.remove(jalviewLite);
+ try {
+ mnger.finalize();
+ } catch (Throwable x){};
+ }
+ }
+
}