From da8e34c5aeee5e83aa844d374eb21e4c2e3cebef Mon Sep 17 00:00:00 2001 From: hansonr Date: Wed, 7 Aug 2019 21:17:21 -0500 Subject: [PATCH] JAL-3401 JAL-3253-applet fixes too-early multiple calls to AlignPanel.repaint() and, via repaint manager to the desktop, also SeqCanvas.paintComponent. See Jalview2XML.java --- src/jalview/gui/AlignmentPanel.java | 36 ++++++++++++++++++++++++++++- src/jalview/gui/SeqCanvas.java | 4 ++++ src/jalview/project/Jalview2XML.java | 41 ++++++++++++++++++++++++++++------ 3 files changed, 73 insertions(+), 8 deletions(-) diff --git a/src/jalview/gui/AlignmentPanel.java b/src/jalview/gui/AlignmentPanel.java index c8f0194..b636fa7 100644 --- a/src/jalview/gui/AlignmentPanel.java +++ b/src/jalview/gui/AlignmentPanel.java @@ -592,7 +592,7 @@ public class AlignmentPanel extends GAlignmentPanel implements */ public void updateLayout() { - fontChanged(); + fontChanged(); // fires repaint setAnnotationVisible(av.isShowAnnotation()); boolean wrap = av.getWrapAlignment(); ViewportRanges ranges = av.getRanges(); @@ -860,6 +860,7 @@ public class AlignmentPanel extends GAlignmentPanel implements @Override public void paintComponent(Graphics g) { + invalidate(); // needed so that the id width adjuster works correctly Dimension d = getIdPanel().getIdCanvas().getPreferredSize(); @@ -1854,4 +1855,37 @@ public class AlignmentPanel extends GAlignmentPanel implements overviewPanel.canvas.finalizeDraw(miniMe); } + + private boolean holdRepaint = false; + + public boolean getHoldRepaint() + { + return holdRepaint; + } + + public void setHoldRepaint(boolean b) + { + if (holdRepaint == b) + { + return; + } + holdRepaint = b; + if (!b) + { + repaint(); + } + } + + @Override + public void repaint() + { + if (holdRepaint) + { + // System.out.println("AP repaint holding"); + // Platform.stackTrace(); + return; + } + super.repaint(); + } + } diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 536bfef..123e649 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -372,6 +372,10 @@ public class SeqCanvas extends JPanel implements ViewportListenerI public void paintComponent(Graphics g) { + if (av.getAlignPanel().getHoldRepaint()) + { + return; + } int charHeight = av.getCharHeight(); int charWidth = av.getCharWidth(); diff --git a/src/jalview/project/Jalview2XML.java b/src/jalview/project/Jalview2XML.java index 0291a0a..c28f24d 100644 --- a/src/jalview/project/Jalview2XML.java +++ b/src/jalview/project/Jalview2XML.java @@ -2862,12 +2862,16 @@ public class Jalview2XML IdentityHashMap importedDatasets = new IdentityHashMap<>(); Map gatherToThisFrame = new HashMap<>(); final String file = jprovider.getFilename(); + + List alignFrames = new ArrayList<>(); + try { JarInputStream jin = null; JarEntry jarentry = null; int entryCount = 1; + // Look for all the entry names ending with ".xml" // This includes all panels and at least one frame. // Platform.timeCheck(null, Platform.TIME_MARK); @@ -2879,9 +2883,14 @@ public class Jalview2XML jarentry = jin.getNextJarEntry(); } String name = (jarentry == null ? null : jarentry.getName()); + +// System.out.println("Jalview2XML opening " + name); if (name != null && name.endsWith(".xml")) { + // DataSet for.... is read last. + + // The question here is what to do with the two // .xml files in the jvp file. // Some number of them, "...Dataset for...", will be the @@ -2911,8 +2920,14 @@ public class Jalview2XML _af = loadFromObject(model, file, true, jprovider); // Platform.timeCheck("Jalview2XML.loadFromObject", // Platform.TIME_MARK); + + if (_af != null) + { + alignFrames.add(_af); + } if (_af != null && model.getViewport().size() > 0) { + // That is, this is one of the AlignmentPanel models if (af == null) { @@ -2979,6 +2994,13 @@ public class Jalview2XML errorMessage = "Out of memory loading jalview XML file"; System.err.println("Out of memory whilst loading jalview XML file"); e.printStackTrace(); + } finally + { + for (AlignFrame alf : alignFrames) + { + alf.alignPanel.setHoldRepaint(false); + } + } /* @@ -3519,7 +3541,7 @@ public class Jalview2XML // now, for 2.10 projects, this is also done if the xml doc includes // dataset sequences not actually present in any particular view. // - Platform.timeCheck("J2XML features0", Platform.TIME_MARK); +// Platform.timeCheck("J2XML features0", Platform.TIME_RESET); for (int i = 0; i < vamsasSeqs.size(); i++) { JSeq jseq = jseqs.get(i); @@ -3574,11 +3596,11 @@ public class Jalview2XML } // adds feature to datasequence's feature set (since Jalview 2.10) +// Platform.timeCheck(null, Platform.TIME_SET); al.getSequenceAt(i).addSequenceFeature(sf); +// Platform.timeCheck(null, Platform.TIME_MARK); } } - Platform.timeCheck("J2XML features done", Platform.TIME_MARK); - if (vamsasSeqs.get(i).getDBRef().size() > 0) { // adds dbrefs to datasequence's set (since Jalview 2.10) @@ -3649,7 +3671,10 @@ public class Jalview2XML } } } + } + +// Platform.timeCheck("features done", Platform.TIME_GET); // Platform.timeCheck("Jalview2XML.loadFromObject-endmultiview", // Platform.TIME_MARK); } // end !multipleview @@ -4180,6 +4205,8 @@ public class Jalview2XML }); } // and finally return. + // but do not set holdRepaint true just yet, because this could be the + // initial frame with just its dataset. return af; } @@ -4976,7 +5003,7 @@ public class Jalview2XML { AlignFrame af = null; af = new AlignFrame(al, safeInt(view.getWidth()), - safeInt(view.getHeight()), uniqueSeqSetId, viewId) + safeInt(view.getHeight()), uniqueSeqSetId, viewId) // { // // @Override @@ -4988,7 +5015,7 @@ public class Jalview2XML // // } ; - + af.alignPanel.setHoldRepaint(true); af.setFileName(file, FileFormat.Jalview); final AlignViewport viewport = af.getViewport(); @@ -5676,8 +5703,8 @@ public class Jalview2XML SequenceI[] dsseqs = new SequenceI[dseqs.size()]; dseqs.copyInto(dsseqs); ds = new jalview.datamodel.Alignment(dsseqs); - debug("Created new dataset " + vamsasSet.getDatasetId() - + " for alignment " + System.identityHashCode(al)); +// debug("Jalview2XML Created new dataset " + vamsasSet.getDatasetId() +// + " for alignment " + System.identityHashCode(al)); addDatasetRef(vamsasSet.getDatasetId(), ds); } // set the dataset for the newly imported alignment. -- 1.7.10.2