import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
-import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
/**
{
x = av.getAlignment().getHiddenColumns().visibleToAbsoluteColumn(x);
}
-
- if (x >= av.getAlignment().getWidth())
- {
- res = av.getAlignment().getWidth() - 1;
- }
- else
- {
- res = x;
- }
+ res = Math.min(x, av.getAlignment().getWidth() - 1);
min = res;
max = res;
if (evt.isPopupTrigger()) // Mac: mousePressed
{
rightMouseButtonPressed(evt, res);
+ return;
}
- else if (SwingUtilities.isRightMouseButton(evt) && !Platform.isAMac())
+ if (Platform.isWinRightButton(evt))
{
/*
* defer right-mouse click handling to mouse up on Windows
*/
return;
}
- else
- {
- leftMouseButtonPressed(evt, res);
- }
+ leftMouseButtonPressed(evt, res);
}
/**
*/
protected void rightMouseButtonPressed(MouseEvent evt, final int res)
{
+ JPopupMenu pop = buildPopupMenu(res);
+ if (pop.getSubElements().length > 0)
+ {
+ pop.show(this, evt.getX(), evt.getY());
+ }
+ }
+
+ /**
+ * Builds a popup menu with 'Hide' or 'Reveal' options, or both, or neither
+ *
+ * @param res
+ * column number (0..)
+ * @return
+ */
+ protected JPopupMenu buildPopupMenu(final int res)
+ {
JPopupMenu pop = new JPopupMenu();
/*
- * grab the hidden range in case mouseMoved nulls it
+ * logic here depends on 'reveal', set in mouseMoved;
+ * grab the hidden range in case mouseMoved nulls it later
*/
final int[] hiddenRange = reveal;
if (hiddenRange != null)
});
pop.add(item);
}
- pop.show(this, evt.getX(), evt.getY());
}
- else if (av.getColumnSelection().contains(res))
+
+ if (av.getColumnSelection().contains(res))
{
JMenuItem item = new JMenuItem(
MessageManager.getString("label.hide_columns"));
}
});
pop.add(item);
- pop.show(this, evt.getX(), evt.getY());
}
+ return pop;
}
/**
mouseDragging = false;
ap.getSeqPanel().stopScrolling();
+ // todo res calculation should be a method on AlignViewport
int xCords = Math.max(0, evt.getX()); // prevent negative X coordinates
+ ViewportRanges ranges = av.getRanges();
int res = (xCords / av.getCharWidth())
- + av.getRanges().getStartRes();
+ + ranges.getStartRes();
+ res = Math.min(res, ranges.getEndRes());
if (av.hasHiddenColumns())
{
res = av.getAlignment().getHiddenColumns()
.visibleToAbsoluteColumn(res);
}
- res = Math.min(res, av.getRanges().getEndRes());
res = Math.max(0, res);
if (!stretchingGroup)
{
if (mouseDragging)
{
+ mouseDragging = false;
ap.getSeqPanel().stopScrolling();
}
}
@Override
public void paintComponent(Graphics g)
{
- super.paintComponent(g);
+ //super.paintComponent(g); // BH 2019
/*
* shouldn't get called in wrapped mode as the scale above is