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.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.beans.PropertyChangeEvent;
+import java.util.Iterator;
import java.util.List;
import javax.swing.JMenuItem;
* The panel containing the sequence ruler (when not in wrapped mode), and
* supports a range of mouse operations to select, hide or reveal columns.
*/
-public class ScalePanel extends JPanel implements MouseMotionListener,
- MouseListener, ViewportListenerI
+public class ScalePanel extends JPanel
+ implements MouseMotionListener, MouseListener, ViewportListenerI
{
protected int offy = 4;
{
av.showColumn(reveal[0]);
reveal = null;
- ap.paintAlignment(true);
- if (ap.overviewPanel != null)
- {
- ap.overviewPanel.updateOverviewImage();
- }
+ ap.paintAlignment(true, true);
av.sendSelection();
}
});
pop.add(item);
- if (av.getAlignment().getHiddenColumns().hasHiddenColumns())
+ if (av.getAlignment().getHiddenColumns().hasMultiHiddenColumnRegions())
{
item = new JMenuItem(MessageManager.getString("action.reveal_all"));
item.addActionListener(new ActionListener()
{
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();
}
});
sg.setEndRes(max);
}
av.setSelectionGroup(sg);
- ap.paintAlignment(false);
+ ap.paintAlignment(false, false);
av.sendSelection();
}
}
else
{
- 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);
}
}
@Override
public void paintComponent(Graphics g)
{
- drawScale(g, av.getRanges().getStartRes(), av.getRanges().getEndRes(),
- getWidth(), getHeight());
+ /*
+ * 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(),
+ getWidth(), getHeight());
+ }
}
// scalewidth will normally be screenwidth,
if (av.getShowHiddenMarkers())
{
- List<Integer> positions = hidden.findHiddenRegionPositions();
- for (int pos : positions)
+ Iterator<Integer> it = hidden.getBoundedStartIterator(startx,
+ startx + widthx + 1);
+ while (it.hasNext())
{
- res = pos - startx;
+ res = it.next() - startx;
- if (res < 0 || res > widthx)
- {
- continue;
- }
-
- gg.fillPolygon(new int[] {
- -1 + res * avCharWidth - avCharHeight / 4,
+ 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 }, 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)
+ || evt.getPropertyName().equals(ViewportRanges.STARTRESANDSEQ)
+ || evt.getPropertyName().equals(ViewportRanges.MOVE_VIEWPORT))
+ {
+ // scroll event, repaint panel
+ repaint();
+ }
}
}