X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPaintRefresher.java;h=7c155b7a22049970f41952fe099efe81d58b4d24;hb=012fc200ee0d124003524855ac7cd50be4b7456c;hp=0fe4b85e7a19ac63c83373aeeed3b93840c58877;hpb=efc31b4a8d5cee63555586804a2b79c06bdb5a14;p=jalview.git diff --git a/src/jalview/gui/PaintRefresher.java b/src/jalview/gui/PaintRefresher.java index 0fe4b85..7c155b7 100755 --- a/src/jalview/gui/PaintRefresher.java +++ b/src/jalview/gui/PaintRefresher.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,7 +33,7 @@ import java.util.*; */ public class PaintRefresher { - static Hashtable components = new Hashtable(); + static Hashtable components; /** * DOCUMENT ME! @@ -41,57 +41,90 @@ public class PaintRefresher * @param comp DOCUMENT ME! * @param al DOCUMENT ME! */ - public static void Register(Component comp, AlignmentI al) + public static void Register(Component comp, String seqSetId) { - if (components.containsKey(al)) + if (components == null) + components = new Hashtable(); + + if (components.containsKey(seqSetId)) { - Vector comps = (Vector) components.get(al); - comps.addElement(comp); + Vector comps = (Vector) components.get(seqSetId); + if(!comps.contains(comp)) + comps.addElement(comp); } else { Vector vcoms = new Vector(); vcoms.addElement(comp); - components.put(al, vcoms); + components.put(seqSetId, vcoms); } } - /** - * DOCUMENT ME! - * - * @param al DOCUMENT ME! - */ - public static void Refresh(AlignmentI al) + public static void RemoveComponent(Component comp) { - Refresh(null, al); + if (components == null) + return; + + Enumeration en = components.keys(); + while(en.hasMoreElements()) + { + String id = en.nextElement().toString(); + Vector comps = (Vector) components.get(id); + comps.remove(comp); + if(comps.size()==0) + { + components.remove(id); + } + } } - /** - * DOCUMENT ME! - * - * @param c DOCUMENT ME! - * @param al DOCUMENT ME! - */ - public static void Refresh(Component c, AlignmentI al) + public static void Refresh(Component source, String id) + { + Refresh( source, id, null, null); + } + + public static void Refresh(Component source, String id, + SequenceI removeSeq, + SequenceI addSeq) { - Component temp; - Vector coms = (Vector) components.get(al); - Enumeration e = coms.elements(); + if (components == null) + return; + + Component comp; + Vector comps = (Vector) components.get(id); + + if(comps==null) + { + return; + } + + Enumeration e = comps.elements(); + while (e.hasMoreElements()) + { + comp = (Component) e.nextElement(); - while (e.hasMoreElements()) + if(comp==source) + continue; + + if (!comp.isValid()) + { + comps.removeElement(comp); + } + else if(comp instanceof AlignmentPanel) { - temp = (Component) e.nextElement(); - - if (!temp.isValid()) - { - coms.removeElement(temp); - } - else if (temp == c) - { - continue; - } - - temp.repaint(); + AlignmentPanel ap = (AlignmentPanel)comp; + if(addSeq!=null) + ap.av.alignment.addSequence(addSeq); + if(removeSeq!=null) + ap.av.alignment.deleteSequence(removeSeq); + + // if(source instanceof AlignmentPanel) + // ap.av.alignment.setGroups( + // ((AlignmentPanel)source).av.alignment.getGroups() ); + } + comp.repaint(); + } + } }