import jalview.renderer.ScaleRenderer.ScaleMark;
import jalview.util.MessageManager;
import jalview.viewmodel.ViewportListenerI;
+import jalview.viewmodel.ViewportRanges;
import java.awt.Color;
import java.awt.FontMetrics;
import java.beans.PropertyChangeEvent;
import java.util.List;
-public class ScalePanel extends Panel implements MouseMotionListener,
- MouseListener, ViewportListenerI
+public class ScalePanel extends Panel
+ implements MouseMotionListener, MouseListener, ViewportListenerI
{
protected int offy = 4;
min = res;
max = res;
- if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK)
+ if ((evt.getModifiers()
+ & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK)
{
rightMouseButtonPressed(evt, res);
}
sg.setStartRes(min);
sg.setEndRes(max);
}
- ap.paintAlignment(true);
+ ap.paintAlignment(false, false);
av.sendSelection();
}
PopupMenu pop = new PopupMenu();
if (reveal != null)
{
- MenuItem item = new MenuItem(MessageManager.getString("label.reveal"));
+ MenuItem item = new MenuItem(
+ MessageManager.getString("label.reveal"));
item.addActionListener(new ActionListener()
{
@Override
{
av.showColumn(reveal[0]);
reveal = null;
- ap.paintAlignment(true);
- if (ap.overviewPanel != null)
- {
- ap.overviewPanel.updateOverviewImage();
- }
+ ap.paintAlignment(true, true);
av.sendSelection();
}
});
{
av.showAllHiddenColumns();
reveal = null;
- ap.paintAlignment(true);
- if (ap.overviewPanel != null)
- {
- ap.overviewPanel.updateOverviewImage();
- }
+ ap.paintAlignment(true, true);
av.sendSelection();
}
});
public void actionPerformed(ActionEvent e)
{
av.hideColumns(res, res);
- if (av.getSelectionGroup() != null
- && av.getSelectionGroup().getSize() == av.getAlignment()
- .getHeight())
+ if (av.getSelectionGroup() != null && av.getSelectionGroup()
+ .getSize() == av.getAlignment().getHeight())
{
av.setSelectionGroup(null);
}
- ap.paintAlignment(true);
- if (ap.overviewPanel != null)
- {
- ap.overviewPanel.updateOverviewImage();
- }
+ ap.paintAlignment(true, true);
av.sendSelection();
}
});
if (!stretchingGroup)
{
- ap.paintAlignment(false);
+ ap.paintAlignment(false, false);
return;
}
}
stretchingGroup = false;
- ap.paintAlignment(false);
+ ap.paintAlignment(false, false);
av.sendSelection();
}
{
stretchingGroup = true;
cs.stretchGroup(res, sg, min, max);
- ap.paintAlignment(false);
+ ap.paintAlignment(false, false);
}
}
int res = (evt.getX() / av.getCharWidth())
+ av.getRanges().getStartRes();
- res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(res);
-
- reveal = null;
- for (int[] region : av.getAlignment().getHiddenColumns()
- .getHiddenRegions())
- {
- if (res + 1 == region[0] || res - 1 == region[1])
- {
- reveal = region;
- break;
- }
- }
+ reveal = av.getAlignment().getHiddenColumns()
+ .getRegionWithEdgeAtRes(res);
repaint();
}
@Override
public void paint(Graphics g)
{
- drawScale(g, av.getRanges().getStartRes(), av.getRanges().getEndRes(),
- getSize().width,
- getSize().height);
+ /*
+ * shouldn't get called in wrapped mode as the scale above is
+ * drawn instead by SeqCanvas.drawNorthScale
+ */
+ if (!av.getWrapAlignment())
+ {
+ drawScale(g, av.getRanges().getStartRes(), av.getRanges().getEndRes(),
+ getSize().width, getSize().height);
+ }
}
// scalewidth will normally be screenwidth,
if (av.getShowHiddenMarkers())
{
int widthx = 1 + endx - startx;
- for (int i = 0; i < hidden.getHiddenRegions().size(); i++)
+ List<Integer> positions = hidden.findHiddenRegionPositions();
+ for (int pos : positions)
{
- res = hidden.findHiddenRegionPosition(i) - startx;
+ res = pos - startx;
if (res < 0 || res > widthx)
{
continue;
}
- 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);
+ 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);
}
}
}
public void propertyChange(PropertyChangeEvent evt)
{
// Respond to viewport change events (e.g. alignment panel was scrolled)
- repaint();
+ // Both scrolling and resizing change viewport ranges: scrolling changes
+ // both start and end points, but resize only changes end values.
+ // Here we only want to fastpaint on a scroll, with resize using a normal
+ // paint, so scroll events are identified as changes to the horizontal or
+ // vertical start value.
+ if (evt.getPropertyName().equals(ViewportRanges.STARTRES))
+ {
+ // scroll event, repaint panel
+ repaint();
+ }
}
}