X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FPaintRefresher.java;h=7c155b7a22049970f41952fe099efe81d58b4d24;hb=012fc200ee0d124003524855ac7cd50be4b7456c;hp=6bec8fdd40fb68627f9f9cea0356bdd959d41aeb;hpb=588042b69abf8e60bcc950b24c283933c7dd422f;p=jalview.git diff --git a/src/jalview/gui/PaintRefresher.java b/src/jalview/gui/PaintRefresher.java index 6bec8fd..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 @@ -18,45 +18,113 @@ */ package jalview.gui; -import java.util.*; +import jalview.datamodel.*; import java.awt.*; +import java.util.*; + + +/** + * DOCUMENT ME! + * + * @author $author$ + * @version $Revision$ + */ public class PaintRefresher { - static Vector components = new Vector(); + static Hashtable components; - public static void Register(Component c) - { - if (!components.contains(c)) + /** + * DOCUMENT ME! + * + * @param comp DOCUMENT ME! + * @param al DOCUMENT ME! + */ + public static void Register(Component comp, String seqSetId) { - components.add(c); + if (components == null) + components = new Hashtable(); + + if (components.containsKey(seqSetId)) + { + Vector comps = (Vector) components.get(seqSetId); + if(!comps.contains(comp)) + comps.addElement(comp); + } + else + { + Vector vcoms = new Vector(); + vcoms.addElement(comp); + components.put(seqSetId, vcoms); + } } - else + + public static void RemoveComponent(Component comp) { - components.remove(c); + 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); + } + } } - } - public static void Refresh(Component c) - { - Component temp; - Enumeration e = components.elements(); + public static void Refresh(Component source, String id) + { + Refresh( source, id, null, null); + } - while (e.hasMoreElements()) + public static void Refresh(Component source, String id, + SequenceI removeSeq, + SequenceI addSeq) { - temp = (Component) e.nextElement(); + if (components == null) + return; - if (!temp.isValid()) + Component comp; + Vector comps = (Vector) components.get(id); + + if(comps==null) { - components.removeElement(temp); + return; } - else if (temp == c) + + Enumeration e = comps.elements(); + while (e.hasMoreElements()) { - continue; + comp = (Component) e.nextElement(); + + if(comp==source) + continue; + + if (!comp.isValid()) + { + comps.removeElement(comp); + } + else if(comp instanceof AlignmentPanel) + { + 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(); } - temp.repaint(); } - } }