From: kiramt Date: Tue, 6 Feb 2018 13:28:54 +0000 (+0000) Subject: Merge branch 'develop' into feature/JAL-2759 X-Git-Tag: Release_2_10_4~55^2~1^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8c5cefb3ac80bd094a8dab7ce6735a11583b1772;p=jalview.git Merge branch 'develop' into feature/JAL-2759 Conflicts: benchmarking/README src/jalview/datamodel/Alignment.java src/jalview/datamodel/AlignmentAnnotation.java src/jalview/gui/SeqCanvas.java src/jalview/gui/SeqPanel.java --- 8c5cefb3ac80bd094a8dab7ce6735a11583b1772 diff --cc benchmarking/README index bd2562f,ccf53c1..d1ec146 --- a/benchmarking/README +++ b/benchmarking/README @@@ -24,7 -27,14 +27,18 @@@ to install the jalview.jar file in the To get JSON output instead use: java -jar target/benchmarks.jar -rf json + To run a specific benchmark file use: + java -jar target/benchmarks.jar + - JSON output can be viewed quickly by drag-dropping on http://jmh.morethan.io/ + JSON output can be viewed quickly by drag-dropping on http://jmh.morethan.io/ + + To get help use the standard -h option: + java -jar target/benchmarks.jar -h + + More information here: + http://openjdk.java.net/projects/code-tools/jmh/ + http://java-performance.info/jmh/ + + + 6. If you make changes to the Jalview code everything will need to be refreshed, by performing steps 3-5 again. ++ diff --cc src/jalview/datamodel/Alignment.java index b6a5e0f,f268d37..9475f00 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@@ -28,7 -28,7 +28,8 @@@ import jalview.util.LinkedIdentityHashS import jalview.util.MessageManager; import java.util.ArrayList; + import java.util.Arrays; +import java.util.BitSet; import java.util.Collections; import java.util.Enumeration; import java.util.HashSet; diff --cc src/jalview/datamodel/AlignmentAnnotation.java index 6c33c1b,f7bf4d8..0098d76 --- a/src/jalview/datamodel/AlignmentAnnotation.java +++ b/src/jalview/datamodel/AlignmentAnnotation.java @@@ -1473,113 -1473,70 +1473,179 @@@ public class AlignmentAnnotatio return graphMin < graphMax; } + /** + * delete any columns in alignmentAnnotation that are hidden (including + * sequence associated annotation). + * + * @param hiddenColumns + * the set of hidden columns + */ + public void makeVisibleAnnotation(HiddenColumns hiddenColumns) + { + if (annotations != null) + { + makeVisibleAnnotation(0, annotations.length, hiddenColumns); + } + } + + /** + * delete any columns in alignmentAnnotation that are hidden (including + * sequence associated annotation). + * + * @param start + * remove any annotation to the right of this column + * @param end + * remove any annotation to the left of this column + * @param hiddenColumns + * the set of hidden columns + */ + public void makeVisibleAnnotation(int start, int end, + HiddenColumns hiddenColumns) + { + if (annotations != null) + { + if (hiddenColumns.hasHiddenColumns()) + { + removeHiddenAnnotation(start, end, hiddenColumns); + } + else + { + restrict(start, end); + } + } + } + + /** + * The actual implementation of deleting hidden annotation columns + * + * @param start + * remove any annotation to the right of this column + * @param end + * remove any annotation to the left of this column + * @param hiddenColumns + * the set of hidden columns + */ + private void removeHiddenAnnotation(int start, int end, + HiddenColumns hiddenColumns) + { + // mangle the alignmentAnnotation annotation array + ArrayList annels = new ArrayList<>(); + Annotation[] els = null; + + int w = 0; + + Iterator blocks = hiddenColumns.getVisContigsIterator(start, + end + 1, false); + + int copylength; + int annotationLength; + while (blocks.hasNext()) + { + int[] block = blocks.next(); + annotationLength = block[1] - block[0] + 1; + + if (blocks.hasNext()) + { + // copy just the visible segment of the annotation row + copylength = annotationLength; + } + else + { + if (annotationLength + block[0] <= annotations.length) + { + // copy just the visible segment of the annotation row + copylength = annotationLength; + } + else + { + // copy to the end of the annotation row + copylength = annotations.length - block[0]; + } + } + + els = new Annotation[annotationLength]; + annels.add(els); + System.arraycopy(annotations, block[0], els, 0, copylength); + w += annotationLength; + } + + if (w != 0) + { + annotations = new Annotation[w]; + + w = 0; + for (Annotation[] chnk : annels) + { + System.arraycopy(chnk, 0, annotations, w, chnk.length); + w += chnk.length; + } + } + } + + public static Iterable findAnnotations( + Iterable list, SequenceI seq, String calcId, + String label) + { + + ArrayList aa = new ArrayList<>(); + for (AlignmentAnnotation ann : list) + { + if ((calcId == null || (ann.getCalcId() != null + && ann.getCalcId().equals(calcId))) + && (seq == null || (ann.sequenceRef != null + && ann.sequenceRef == seq)) + && (label == null + || (ann.label != null && ann.label.equals(label)))) + { + aa.add(ann); + } + } + return aa; + } + + /** + * Answer true if any annotation matches the calcId passed in (if not null). + * + * @param list + * annotation to search + * @param calcId + * @return + */ + public static boolean hasAnnotation(List list, + String calcId) + { + + if (calcId != null && !"".equals(calcId)) + { + for (AlignmentAnnotation a : list) + { + if (a.getCalcId() == calcId) + { + return true; + } + } + } + return false; + } + + public static Iterable findAnnotation( + List list, String calcId) + { + + List aa = new ArrayList<>(); + if (calcId == null) + { + return aa; + } + for (AlignmentAnnotation a : list) + { + + if (a.getCalcId() == calcId || (a.getCalcId() != null + && calcId != null && a.getCalcId().equals(calcId))) + { + aa.add(a); + } + } + return aa; + } } diff --cc src/jalview/gui/SeqCanvas.java index cdf84b7,1e1105f..fb81f4d --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@@ -1775,12 -1799,27 +1775,19 @@@ public class SeqCanvas extends JCompone { fastPaint(scrollX, 0); } - // bizarrely, we only need to scroll on the x value here as fastpaint - // copies the full height of the image anyway. Passing in the y value - // causes nasty repaint artefacts, which only disappear on a full - // repaint. + } + else if (eventName.equals(ViewportRanges.STARTSEQ)) + { + // scroll + fastPaint(0, (int) evt.getNewValue() - (int) evt.getOldValue()); + } + else if (eventName.equals(ViewportRanges.STARTRESANDSEQ)) + { + if (av.getWrapAlignment()) + { + fastPaintWrapped(scrollX); } - - else - { - fastPaint(scrollX, 0); - } - // bizarrely, we only need to scroll on the x value here as fastpaint - // copies the full height of the image anyway. Passing in the y value - // causes nasty repaint artefacts, which only disappear on a full - // repaint. + } } /** diff --cc src/jalview/gui/SeqPanel.java index 9359569,61cac46..84b85e9 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@@ -434,7 -422,10 +434,10 @@@ public class SeqPanel extends JPane { if (av.getWrapAlignment()) { - av.getRanges().scrollToWrappedVisible(seqCanvas.cursorX); + // scrollToWrappedVisible expects x-value to have hidden cols subtracted + int x = av.getAlignment().getHiddenColumns() - .findColumnPosition(seqCanvas.cursorX); ++ .absoluteToVisibleColumn(seqCanvas.cursorX); + av.getRanges().scrollToWrappedVisible(x); } else { diff --cc src/jalview/renderer/AnnotationRenderer.java index 25a81f9,8a80d41..adca17e --- a/src/jalview/renderer/AnnotationRenderer.java +++ b/src/jalview/renderer/AnnotationRenderer.java @@@ -162,7 -162,8 +162,8 @@@ public class AnnotationRendere boolean validRes, boolean validEnd) { g.setColor(STEM_COLOUR); - int sCol = (lastSSX / charWidth) + startRes; + int sCol = (lastSSX / charWidth) - + hiddenColumns.adjustForHiddenColumns(startRes); ++ + hiddenColumns.visibleToAbsoluteColumn(startRes); int x1 = lastSSX; int x2 = (x * charWidth); @@@ -228,7 -229,8 +229,8 @@@ // System.out.println(nonCanColor); g.setColor(nonCanColor); - int sCol = (lastSSX / charWidth) + startRes; + int sCol = (lastSSX / charWidth) - + hiddenColumns.adjustForHiddenColumns(startRes); ++ + hiddenColumns.visibleToAbsoluteColumn(startRes); int x1 = lastSSX; int x2 = (x * charWidth); @@@ -1147,7 -1149,8 +1149,8 @@@ { g.setColor(HELIX_COLOUR); - int sCol = (lastSSX / charWidth) + startRes; + int sCol = (lastSSX / charWidth) - + hiddenColumns.adjustForHiddenColumns(startRes); ++ + hiddenColumns.visibleToAbsoluteColumn(startRes); int x1 = lastSSX; int x2 = (x * charWidth);