*/
public class PaintRefresher
{
- static Map<String, List<Component>> components = new HashMap<String, List<Component>>();
+ private static final int ALIGNMENT_CHANGED = 1 << 0;
+ private static final int VALIDATE_SEQUENCES = 1 << 1;
+
+ static Map<String, List<Component>> components = new HashMap<>();
/**
* Add the given component to those registered under the given sequence set
}
else
{
- List<Component> vcoms = new ArrayList<Component>();
+ List<Component> vcoms = new ArrayList<>();
vcoms.add(comp);
components.put(seqSetId, vcoms);
}
{
List<Component> comps = components.get(id);
+ int mode = (alignmentChanged ? ALIGNMENT_CHANGED : 0) | (validateSequences ? VALIDATE_SEQUENCES : 0);
if (comps == null)
{
return;
}
+ repaintComponents(source, mode, comps.toArray(new Component[comps.size()]));
+ }
- for (Component comp : comps)
+ public static void repaintComponents(Component source, int mode,
+ Component... comps)
+ {
+ for (int i = 0; i < comps.length; i++)
{
- if (comp == source)
+ Component comp = comps[i];
+ if (comp == null)
{
continue;
}
-
- if (validateSequences && comp instanceof AlignmentPanel
- && source instanceof AlignmentPanel)
+ if (comp instanceof AlignmentPanel)
{
- validateSequences(((AlignmentPanel) source).av.getAlignment(),
- ((AlignmentPanel) comp).av.getAlignment());
+ if ((mode & VALIDATE_SEQUENCES) != 0 && source instanceof AlignmentPanel)
+ {
+ validateSequences(((AlignmentPanel) source).av.getAlignment(),
+ ((AlignmentPanel) comp).av.getAlignment());
+ }
+ if ((mode & ALIGNMENT_CHANGED) != 0)
+ {
+ ((AlignmentPanel) comp).alignmentChanged();
+ }
}
-
- if (comp instanceof AlignmentPanel && alignmentChanged)
+ else if (comp instanceof IdCanvas)
{
- ((AlignmentPanel) comp).alignmentChanged();
+ // BH 2019.04.22 fixes JS problem of repaint() consolidation
+ // that occurs in JavaScript but not Java [JAL-3226]
+ ((IdCanvas) comp).setNoFastPaint();
+ }
+ else if (comp instanceof SeqCanvas)
+ {
+ // BH 2019.04.22 fixes JS problem of repaint() consolidation
+ // that occurs in JavaScript but not Java [JAL-3226]
+ ((SeqCanvas) comp).setNoFastPaint();
}
-
comp.repaint();
}
}
System.err.println(
"IMPLEMENTATION PROBLEM: DATASET out of sync due to an insert whilst calling PaintRefresher.validateSequences(AlignmentI, ALignmentI)");
}
- List<SequenceI> alsq;
- synchronized (alsq = comp.getSequences())
+ List<SequenceI> alsq = comp.getSequences();
+ synchronized (alsq)
{
alsq.add(i, a1[i]);
}
{
return new AlignmentPanel[0];
}
- List<AlignmentPanel> tmp = new ArrayList<AlignmentPanel>();
+ List<AlignmentPanel> tmp = new ArrayList<>();
for (Component comp : comps)
{
if (comp instanceof AlignmentPanel)
return tmp.toArray(new AlignmentPanel[tmp.size()]);
}
+
}