Font font = new Font("Arial", Font.PLAIN, 11);
+ private boolean hasHiddenRows;
+
/**
* Creates a new AnnotationLabels object.
*
repaint();
}
+ /**
+ * sets selectedRow to -2 if no annotation preset, -1 if no visible row is at
+ * y
+ *
+ * @param y
+ * coordinate position to search for a row
+ */
void getSelectedRow(int y)
{
int height = 0;
AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();
-
+ selectedRow = -2;
if (aa != null)
{
for (int i = 0; i < aa.length; i++)
{
+ selectedRow = -1;
if (!aa[i].visible)
{
continue;
break;
}
}
- } else {
- selectedRow = -1;
}
}
{
EditNameDialog dialog = new EditNameDialog(annotation.label,
annotation.description, " Annotation Name ",
- "Annotation Description ", "Edit Annotation Name/Description");
+ "Annotation Description ", "Edit Annotation Name/Description",
+ ap.alignFrame);
if (!dialog.accept)
{
// Swap these annotations
AlignmentAnnotation startAA = ap.av.alignment
.getAlignmentAnnotation()[start];
+ if (end == -1)
+ {
+ end = ap.av.alignment.getAlignmentAnnotation().length - 1;
+ }
AlignmentAnnotation endAA = ap.av.alignment.getAlignmentAnnotation()[end];
ap.av.alignment.getAlignmentAnnotation()[end] = startAA;
AlignmentAnnotation[] aa = ap.av.alignment.getAlignmentAnnotation();
if (SwingUtilities.isLeftMouseButton(evt))
{
- if (aa!=null && selectedRow < aa.length)
+ if (selectedRow > -1 && selectedRow < aa.length)
{
if (aa[selectedRow].groupRef != null)
{
JPopupMenu pop = new JPopupMenu("Annotations");
JMenuItem item = new JMenuItem(ADDNEW);
item.addActionListener(this);
-
- if ((aa == null) || (aa.length == 0))
+ pop.add(item);
+ if (selectedRow < 0)
{
- item = new JMenuItem(SHOWALL);
- item.addActionListener(this);
- pop.add(item);
+ if (hasHiddenRows)
+ { // let the user make everything visible again
+ item = new JMenuItem(SHOWALL);
+ item.addActionListener(this);
+ pop.add(item);
+ }
pop.show(this, evt.getX(), evt.getY());
return;
}
-
- pop.add(item);
item = new JMenuItem(EDITNAME);
item.addActionListener(this);
pop.add(item);
item = new JMenuItem(DELETE);
item.addActionListener(this);
pop.add(item);
- item = new JMenuItem(SHOWALL);
- item.addActionListener(this);
- pop.add(item);
+ if (hasHiddenRows)
+ {
+ item = new JMenuItem(SHOWALL);
+ item.addActionListener(this);
+ pop.add(item);
+ }
item = new JMenuItem(OUTPUT_TEXT);
item.addActionListener(this);
pop.add(item);
if (aa != null)
{
+ hasHiddenRows = false;
for (int i = 0; i < aa.length; i++)
{
g.setColor(Color.black);
if (!aa[i].visible)
{
+ hasHiddenRows = true;
continue;
}