public Viewport getViewport() { FigureCanvas canvas = this.getFigureCanvas(); if (canvas != null) { return canvas.getViewport(); } return null; }
protected Point getPointerLocation(Point origPointerLocation) { Point compensatedLocation = origPointerLocation; FigureCanvas figureCanvas = (FigureCanvas) viewer.getControl(); int yOffset = figureCanvas.getViewport().getVerticalRangeModel().getValue(); int xOffset = figureCanvas.getViewport().getHorizontalRangeModel().getValue(); compensatedLocation.y = compensatedLocation.y + yOffset; compensatedLocation.x = compensatedLocation.x + xOffset; return compensatedLocation; } }
public void propertyChange(PropertyChangeEvent evt) { System.out.println("scroll-change"); Rectangle bounds = new Rectangle(0, 0, 40, 40); Point p = ((FigureCanvas)sgv.getControl()).getViewport().getViewLocation(); bounds.translate(p); setBounds(bounds); }
public IndexFigure(ScrollingGraphicalViewer sgv) { this.sgv = sgv; ((FigureCanvas)sgv.getControl()).getViewport().getHorizontalRangeModel().addPropertyChangeListener(this); ((FigureCanvas)sgv.getControl()).getViewport().getVerticalRangeModel().addPropertyChangeListener(this); Rectangle bounds = new Rectangle(0, 0, 40, 40); translateToAbsolute(bounds); setBounds(bounds); } public void propertyChange(PropertyChangeEvent evt)
private boolean scrollPage(KeyEvent event, int direction) { if (!(getViewer().getControl() instanceof FigureCanvas)) return false; FigureCanvas figCanvas = (FigureCanvas) getViewer().getControl(); Point loc = figCanvas.getViewport().getViewLocation(); Rectangle area = figCanvas.getViewport().getClientArea(Rectangle.SINGLETON).scale(.8); if (direction == PositionConstants.NORTH) { figCanvas.scrollToY(loc.y - area.height); } else { figCanvas.scrollToY(loc.y + area.height); } return true; } }
public Rectangle getBounds() { Point p = ((FigureCanvas)sgv.getControl()).getViewport().getViewLocation(); bounds.translate(p); return super.getBounds().getCopy().translate(p); } }