*/
package jalview.gui;
-import jalview.datamodel.ColumnSelection;
-import jalview.datamodel.HiddenColumns;
-import jalview.datamodel.SequenceGroup;
-import jalview.renderer.ScaleRenderer;
-import jalview.renderer.ScaleRenderer.ScaleMark;
-import jalview.util.MessageManager;
-import jalview.util.Platform;
-import jalview.viewmodel.ViewportListenerI;
-import jalview.viewmodel.ViewportRanges;
-
import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
-import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.SequenceGroup;
+import jalview.renderer.ScaleRenderer;
+import jalview.renderer.ScaleRenderer.ScaleMark;
+import jalview.util.MessageManager;
+import jalview.util.Platform;
+import jalview.viewmodel.ViewportListenerI;
+import jalview.viewmodel.ViewportRanges;
+
/**
* The panel containing the sequence ruler (when not in wrapped mode), and
* supports a range of mouse operations to select, hide or reveal columns.
@Override
public void mousePressed(MouseEvent evt)
{
- int x = (evt.getX() / av.getCharWidth()) + av.getRanges().getStartRes();
- final int res;
-
- if (av.hasHiddenColumns())
- {
- x = av.getAlignment().getHiddenColumns().visibleToAbsoluteColumn(x);
- }
-
- if (x >= av.getAlignment().getWidth())
- {
- res = av.getAlignment().getWidth() - 1;
- }
- else
- {
- res = x;
- }
+ int res = ap.getSeqPanel().findAlignmentColumn(evt);
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);
- if (av.getAlignment().getHiddenColumns().hasMultiHiddenColumnRegions())
+ if (av.getAlignment().getHiddenColumns()
+ .hasMultiHiddenColumnRegions())
{
item = new JMenuItem(MessageManager.getString("action.reveal_all"));
item.addActionListener(new ActionListener()
});
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;
}
/**
}
av.setSelectionGroup(sg);
ap.paintAlignment(false, false);
+ PaintRefresher.Refresh(this, av.getSequenceSetId());
av.sendSelection();
}
mouseDragging = false;
ap.getSeqPanel().stopScrolling();
- int xCords = Math.max(0, evt.getX()); // prevent negative X coordinates
- int res = (xCords / av.getCharWidth())
- + av.getRanges().getStartRes();
- if (av.hasHiddenColumns())
- {
- res = av.getAlignment().getHiddenColumns()
- .visibleToAbsoluteColumn(res);
- }
- res = Math.min(res, av.getRanges().getEndRes());
- res = Math.max(0, res);
+ int res = ap.getSeqPanel().findAlignmentColumn(evt);
if (!stretchingGroup)
{
ap.paintAlignment(false, false);
av.isSelectionGroupChanged(true);
av.isColSelChanged(true);
+ PaintRefresher.Refresh(ap, av.getSequenceSetId());
av.sendSelection();
}
public void mouseDragged(MouseEvent evt)
{
mouseDragging = true;
+ int res = ap.getSeqPanel().findAlignmentColumn(evt);
+
ColumnSelection cs = av.getColumnSelection();
- HiddenColumns hidden = av.getAlignment().getHiddenColumns();
- int res = (evt.getX() / av.getCharWidth())
- + av.getRanges().getStartRes();
- res = Math.max(0, res);
- res = hidden.visibleToAbsoluteColumn(res);
- res = Math.min(res, av.getAlignment().getWidth() - 1);
min = Math.min(res, min);
max = Math.max(res, max);
stretchingGroup = true;
cs.stretchGroup(res, sg, min, max);
ap.paintAlignment(false, false);
+ PaintRefresher.Refresh(ap, av.getSequenceSetId());
}
}
{
if (mouseDragging)
{
+ mouseDragging = false;
ap.getSeqPanel().stopScrolling();
}
}
{
this.setToolTipText(null);
reveal = null;
+ final int res = ap.getSeqPanel().findAlignmentColumn(evt);
+
+ highlightAllStructPos(res);
if (!av.hasHiddenColumns())
{
return;
}
-
- int res = (evt.getX() / av.getCharWidth())
- + av.getRanges().getStartRes();
-
reveal = av.getAlignment().getHiddenColumns()
- .getRegionWithEdgeAtRes(res);
-
- res = av.getAlignment().getHiddenColumns().visibleToAbsoluteColumn(res);
-
+ .getRegionWithEdgeAtRes(av.getAlignment().getHiddenColumns()
+ .absoluteToVisibleColumn(res));
+ if (reveal == null)
+ {
+ return;
+ }
ToolTipManager.sharedInstance().registerComponent(this);
this.setToolTipText(
MessageManager.getString("label.reveal_hidden_columns"));
repaint();
}
+ public void highlightAllStructPos(int col)
+ {
+ ap.getStructureSelectionManager().highlightPositionsOnMany(
+ ap.av.getAlignment().getSequencesArray(), new int[]
+ { col, col }, ap);
+
+ }
+
/**
* DOCUMENT ME!
*
@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
gg.fillPolygon(
new int[]
- { -1 + res * avCharWidth - avCharHeight / 4,
- -1 + res * avCharWidth + avCharHeight / 4,
- -1 + res * avCharWidth }, new int[]
- { y, y, y + 2 * yOf }, 3);
+ { -1 + res * avCharWidth - avCharHeight / 4,
+ -1 + res * avCharWidth + avCharHeight / 4,
+ -1 + res * avCharWidth },
+ new int[]
+ { y, y, y + 2 * yOf }, 3);
}
}
}
|| evt.getPropertyName().equals(ViewportRanges.MOVE_VIEWPORT))
{
// scroll event, repaint panel
-
- // Call repaint on alignment panel so that repaints from other alignment
- // panel components can be aggregated. Otherwise performance of the overview
- // window and others may be adversely affected.
+
+ // Call repaint on alignment panel so that repaints from other alignment
+ // panel components can be aggregated. Otherwise performance of the
+ // overview
+ // window and others may be adversely affected.
av.getAlignPanel().repaint();
}
}