- * Optionally, update all rows, including those not in the 'apply to' scope. - * This makes more sense when switching between selected and unselected - * sequences. When selecting annotation types, or show/hide, we only apply the - * settings to the selected sequences. + * Set annotations (with one of the selected types) to the selected Show/Hide + * visibility, if they are in the new application scope. Set to the opposite + * if outside the scope. *
* Note this only affects sequence-specific annotations, others are left * unchanged. */ - protected void repaintAnnotations(boolean updateAllRows) + protected void changeApplyTo_actionPerformed() { + setAnnotationVisibility(true); + + // copied from AnnotationLabel.actionPerformed (after show/hide row)... + // TODO should drive this functionality into AlignmentPanel + ap.updateAnnotation(); + // this.ap.annotationPanel.adjustPanelHeight(); + // this.ap.alabels.setSize(this.ap.alabels.getSize().width, + // this.ap.annotationPanel.getSize().height); + // this.ap.validate(); + this.ap.paintAlignment(true); + } + + /** + * Update display when an annotation type is selected or deselected. + *
+ * If the type is selected, set visibility of annotations of that type which + * are in the application scope (all, selected or unselected sequences). + *
+ * If the type is unselected, set visibility to the opposite value. That is, + * treat select/deselect as a 'toggle' operation. + * + * @param type + */ + protected void changeTypeSelected_actionPerformed(String type) + { + boolean typeSelected = this.selectedTypes.containsKey(type); for (AlignmentAnnotation aa : this.ap.getAlignment() .getAlignmentAnnotation()) { - if (aa.sequenceRef != null) + if (aa.sequenceRef != null && type.equals(aa.label) + && isInActionScope(aa)) { - setAnnotationVisibility(aa, updateAllRows); + aa.visible = typeSelected ? this.showSelected : !this.showSelected; } } - // copied from AnnotationLabel.actionPerformed (after show/hide row)... - // TODO should drive this functionality into AlignmentPanel ap.updateAnnotation(); - this.ap.annotationPanel.adjustPanelHeight(); - this.ap.alabels.setSize(this.ap.alabels.getSize().width, - this.ap.annotationPanel.getSize().height); - this.ap.validate(); + // // this.ap.annotationPanel.adjustPanelHeight(); + // this.ap.alabels.setSize(this.ap.alabels.getSize().width, + // this.ap.annotationPanel.getSize().height); + // this.ap.validate(); + this.ap.paintAlignment(true); + } + + /** + * Update display on change of choice of Show or Hide + *
+ * For annotations of any selected type, set visibility of annotations of that + * type which are in the application scope (all, selected or unselected + * sequences). + * + * @param type + */ + protected void changeShowHide_actionPerformed() + { + setAnnotationVisibility(false); + + this.ap.updateAnnotation(); + // this.ap.annotationPanel.adjustPanelHeight(); this.ap.paintAlignment(true); } /** + * Update visibility flags on annotation rows as per the current user choices. + * + * @param updateAllRows + */ + protected void setAnnotationVisibility(boolean updateAllRows) + { + for (AlignmentAnnotation aa : this.ap.getAlignment() + .getAlignmentAnnotation()) + { + if (aa.sequenceRef != null) + { + setAnnotationVisibility(aa, updateAllRows); + } + } + } + + /** * Determine and set the visibility of the given annotation from the currently * selected options. *
- * If its sequence is in the selected application scope - * (all/selected/unselected sequences), then we set its visibility. + * Only update annotations whose type is one of the selected types. *
- * If the annotation type is one of those currently selected by checkbox, set - * its visibility to the selected value. If it is not currently selected, set - * it to the opposite value. So, unselecting an annotation type with 'hide' - * selected, will cause those annotations to be unhidden. + * If its sequence is in the selected application scope + * (all/selected/unselected sequences), then we set its visibility according + * to the current choice of Show or Hide. *
* If force update of all rows is wanted, then set rows not in the sequence
* selection scope to the opposite visibility to those in scope.
@@ -212,22 +289,16 @@ public class AnnotationChooser extends JPanel
protected void setAnnotationVisibility(AlignmentAnnotation aa,
boolean updateAllRows)
{
- boolean setToVisible = false;
if (this.selectedTypes.containsKey(aa.label))
{
- setToVisible = this.showSelected;
- }
- else
- {
- setToVisible = !this.showSelected;
- }
- if (isInActionScope(aa))
- {
- aa.visible = setToVisible;
- }
- else if (updateAllRows)
- {
- aa.visible = !setToVisible;
+ if (isInActionScope(aa))
+ {
+ aa.visible = this.showSelected;
+ }
+ else if (updateAllRows)
+ {
+ aa.visible = !this.showSelected;
+ }
}
// TODO force not visible if associated sequence is hidden?
// currently hiding a sequence does not hide its annotation rows
@@ -252,6 +323,11 @@ public class AnnotationChooser extends JPanel
// we don't care if the annotation's sequence is selected or not
result = true;
}
+ else if (this.sg == null)
+ {
+ // shouldn't happen - defensive programming
+ result = true;
+ }
else if (this.sg.getSequences().contains(aa.sequenceRef))
{
// annotation is for a member of the selection group
@@ -279,7 +355,6 @@ public class AnnotationChooser extends JPanel
public static List