X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fworkers%2FColumnCounterSetWorker.java;h=a711f2bd91c869437b1131cc8f0ecb731dd8f246;hb=3cc6cd558fa548219f4e12b3abbb6b88d0d20c23;hp=6c5707de49350783762586db4085bbf6973f863a;hpb=0fdb1b858c58883a08c0fa50c1540fd2a316687b;p=jalview.git diff --git a/src/jalview/workers/ColumnCounterSetWorker.java b/src/jalview/workers/ColumnCounterSetWorker.java index 6c5707d..a711f2b 100644 --- a/src/jalview/workers/ColumnCounterSetWorker.java +++ b/src/jalview/workers/ColumnCounterSetWorker.java @@ -57,7 +57,7 @@ class ColumnCounterSetWorker extends AlignCalcWorker AlignmentViewPanel panel, FeatureSetCounterI counter) { super(viewport, panel); - ourAnnots = new ArrayList(); + ourAnnots = new ArrayList<>(); this.counter = counter; calcMan.registerWorker(this); } @@ -70,44 +70,22 @@ class ColumnCounterSetWorker extends AlignCalcWorker public void run() { boolean annotationAdded = false; - try + if (alignViewport.isClosed()) { - calcMan.notifyStart(this); + abortAndDestroy(); + return; + } - while (!calcMan.notifyWorking(this)) + if (alignViewport.getAlignment() != null) + { + try { - try - { - Thread.sleep(200); - } catch (InterruptedException ex) - { - ex.printStackTrace(); - } - } - if (alignViewport.isClosed()) + annotationAdded = computeAnnotations(); + } catch (IndexOutOfBoundsException x) { - abortAndDestroy(); + // probable race condition. just finish and return without any fuss. return; } - - if (alignViewport.getAlignment() != null) - { - try - { - annotationAdded = computeAnnotations(); - } catch (IndexOutOfBoundsException x) - { - // probable race condition. just finish and return without any fuss. - return; - } - } - } catch (OutOfMemoryError error) - { - ap.raiseOOMWarning("calculating feature counts", error); - calcMan.disableWorker(this); - } finally - { - calcMan.workerComplete(this); } if (ap != null) @@ -116,7 +94,7 @@ class ColumnCounterSetWorker extends AlignCalcWorker { ap.adjustAnnotationHeight(); } - ap.paintAlignment(true); + ap.paintAlignment(true, true); } } @@ -182,19 +160,19 @@ class ColumnCounterSetWorker extends AlignCalcWorker for (int anrow = 0; anrow < rows; anrow++) { Annotation[] anns = new Annotation[width]; + long rmax = 0; /* - * add non-zero counts as annotations + * add counts as annotations. zeros are needed since select-by-annotation ignores empty annotation positions */ for (int i = 0; i < counts.length; i++) { int count = counts[i][anrow]; - if (count > 0) - { - Color color = ColorUtils.getGraduatedColour(count, 0, minColour, - max[anrow], maxColour); - String str = String.valueOf(count); - anns[i] = new Annotation(str, str, '0', count, color); - } + + Color color = ColorUtils.getGraduatedColour(count, 0, minColour, + max[anrow], maxColour); + String str = String.valueOf(count); + anns[i] = new Annotation(str, str, '0', count, color); + rmax = Math.max(count, rmax); } /* @@ -212,7 +190,8 @@ class ColumnCounterSetWorker extends AlignCalcWorker ann.scaleColLabel = true; ann.graph = AlignmentAnnotation.BAR_GRAPH; ann.annotations = anns; - setGraphMinMax(ann, anns); + ann.graphMin = 0f; // minimum always zero count + ann.graphMax = rmax; // maximum count from loop over feature columns ann.validateRangeAndDisplay(); if (!ourAnnots.contains(ann)) { @@ -228,6 +207,7 @@ class ColumnCounterSetWorker extends AlignCalcWorker * * @param alignment * @param col + * (0..) * @param row * @param fr */ @@ -248,14 +228,12 @@ class ColumnCounterSetWorker extends AlignCalcWorker { return null; } - int pos = seq.findPosition(col); /* * compute a count for any displayed features at residue */ - // NB have to adjust pos if using AlignmentView.getVisibleAlignment // see JAL-2075 - List features = fr.findFeaturesAtRes(seq, pos); + List features = fr.findFeaturesAtColumn(seq, col + 1); int[] count = this.counter.count(String.valueOf(res), features); return count; }