*/
package jalview.gui;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Vector;
+
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.GraphLine;
import jalview.datamodel.SequenceGroup;
import jalview.schemes.AnnotationColourGradient;
import jalview.util.MessageManager;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.util.Vector;
-
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
protected int[] annmap;
+ /*
+ * map from annotation to its menu item display label
+ * - so we know which item to pre-select on restore
+ */
+ private Map<AlignmentAnnotation, String> annotationLabels;
+
protected boolean enableSeqAss = false;
private AlignmentAnnotation currentAnnotation;
}
+ /**
+ * Builds and returns a list of menu items (display text) for choice of
+ * annotation. Also builds maps between annotations, their positions in the
+ * list, and their display labels in the list.
+ *
+ * @param isSeqAssociated
+ * @return
+ */
public Vector<String> getAnnotationItems(boolean isSeqAssociated)
{
+ annotationLabels = new HashMap<AlignmentAnnotation, String>();
+
Vector<String> list = new Vector<String>();
int index = 1;
int[] anmap = new int[av.getAlignment().getAlignmentAnnotation().length];
for (int i = 0; i < av.getAlignment().getAlignmentAnnotation().length; i++)
{
- if (av.getAlignment().getAlignmentAnnotation()[i].sequenceRef == null)
+ AlignmentAnnotation annotation = av.getAlignment()
+ .getAlignmentAnnotation()[i];
+ if (annotation.sequenceRef == null)
{
if (isSeqAssociated)
{
{
enableSeqAss = true;
}
- String label = av.getAlignment().getAlignmentAnnotation()[i].label;
+ String label = annotation.label;
// add associated sequence ID if available
- if (!isSeqAssociated
- && av.getAlignment().getAlignmentAnnotation()[i].sequenceRef != null)
+ if (!isSeqAssociated && annotation.sequenceRef != null)
{
- label = label
- + "_"
- + av.getAlignment().getAlignmentAnnotation()[i].sequenceRef
- .getName();
+ label = label + "_" + annotation.sequenceRef.getName();
}
// make label unique
if (!list.contains(label))
{
anmap[list.size()] = i;
list.add(label);
+ annotationLabels.put(annotation, label);
}
else
{
if (!isSeqAssociated)
{
anmap[list.size()] = i;
- list.add(label + "_" + (index++));
+ label = label + "_" + (index++);
+ list.add(label);
+ annotationLabels.put(annotation, label);
}
}
}
.getString("label.threshold_feature_below_threshold"));
}
+ /**
+ * Rebuilds the drop-down list of annotations to choose from when the 'per
+ * sequence only' checkbox is checked or unchecked.
+ *
+ * @param annotations
+ */
protected void seqAssociated_actionPerformed(JComboBox<String> annotations)
{
adjusting = true;
}
}
- protected boolean colorAlignmContaining(AlignmentAnnotation currentAnn,
- int selectedThresholdOption)
+ protected boolean colorAlignmentContaining(
+ AlignmentAnnotation currentAnn, int selectedThresholdOption)
{
AnnotationColourGradient acg = null;
acg.setPredefinedColours(true);
}
- acg.thresholdIsMinMax = thresholdIsMin.isSelected();
+ acg.setThresholdIsMinMax(thresholdIsMin.isSelected());
av.setGlobalColourScheme(acg);
selectedThresholdOption);
((AnnotationColourGradient) sg.cs).setSeqAssociated(seqAssociated
.isSelected());
-
}
else
{
((AnnotationColourGradient) sg.cs).setSeqAssociated(seqAssociated
.isSelected());
}
-
}
}
return false;
}
- public jalview.datamodel.AlignmentAnnotation getCurrentAnnotation()
+ public AlignmentAnnotation getCurrentAnnotation()
{
return currentAnnotation;
}
- public void setCurrentAnnotation(
- jalview.datamodel.AlignmentAnnotation currentAnnotation)
+ public void setCurrentAnnotation(AlignmentAnnotation currentAnnotation)
{
this.currentAnnotation = currentAnnotation;
}
public abstract void updateView();
public abstract void reset();
+
+ protected String getAnnotationMenuLabel(AlignmentAnnotation ann)
+ {
+ return annotationLabels.get(ann);
+ }
}