use of org.eclipse.draw2d.RangeModel in project whole by wholeplatform.
the class WholeViewportAutoexposeHelper method step.
@Override
public boolean step(Point where) {
Viewport port = findViewport(owner);
Rectangle rect = Rectangle.SINGLETON;
port.getClientArea(rect);
port.translateToParent(rect);
port.translateToAbsolute(rect);
if (!rect.contains(where) || rect.shrink(threshold).contains(where))
return false;
// set scroll offset (speed factor)
int scrollOffset = 0;
// calculate time based scroll offset
if (lastStepTime == 0)
lastStepTime = System.currentTimeMillis();
long difference = System.currentTimeMillis() - lastStepTime;
if (difference > 0) {
scrollOffset = ((int) difference / 3);
lastStepTime = System.currentTimeMillis();
}
if (scrollOffset == 0)
return true;
rect.shrink(threshold);
int region = rect.getPosition(where);
RangeModel hm = port.getHorizontalRangeModel();
RangeModel vm = port.getVerticalRangeModel();
final Point loc = port.getViewLocation();
if ((region & PositionConstants.SOUTH) != 0)
loc.y = Math.min(loc.y + scrollOffset, vm.getMaximum() - vm.getExtent());
else if ((region & PositionConstants.NORTH) != 0)
loc.y = Math.max(loc.y - scrollOffset, 0);
if ((region & PositionConstants.EAST) != 0)
loc.x = Math.min(loc.x + scrollOffset, hm.getMaximum() - hm.getExtent());
else if ((region & PositionConstants.WEST) != 0)
loc.x = Math.max(loc.x - scrollOffset, 0);
if (loc.x != hm.getValue() || loc.y != vm.getValue())
Display.getCurrent().asyncExec(new Runnable() {
public void run() {
exposeLocation(loc);
}
});
return true;
}
use of org.eclipse.draw2d.RangeModel in project archi by archimatetool.
the class PaletteScrollBar method initialize.
@Override
protected void initialize() {
super.initialize();
setLayoutManager(new ScrollBarLayout(transposer) {
@SuppressWarnings("deprecation")
@Override
protected Rectangle layoutButtons(ScrollBar scrollBar) {
Rectangle bounds = transposer.t(scrollBar.getClientArea());
Dimension buttonSize = new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT);
getButtonUp().setBounds(transposer.t(new Rectangle(bounds.getTop().getTranslated(-(buttonSize.width / 2), 0), buttonSize)));
Rectangle r = new Rectangle(bounds.getBottom().getTranslated(-(buttonSize.width / 2), -buttonSize.height), buttonSize);
getButtonDown().setBounds(transposer.t(r));
Rectangle trackBounds = bounds.getCropped(new Insets(buttonSize.height, 0, buttonSize.height, 0));
RangeModel model = scrollBar.getRangeModel();
getButtonUp().setVisible(model.getValue() != model.getMinimum());
getButtonDown().setVisible(model.getValue() != model.getMaximum() - model.getExtent());
return trackBounds;
}
});
setPageUp(null);
setPageDown(null);
setThumb(null);
setOpaque(false);
}
use of org.eclipse.draw2d.RangeModel in project archi by archimatetool.
the class ViewportMouseWheelHelper method handleMouseWheelScrolled.
/**
* Finds the viewport of the given EditPart and scrolls it as requested. If
* it can't be scrolled then leaves doit to be true so that the given
* EditPart's ancestors might have a chance to scroll.
*
* @see org.eclipse.gef.MouseWheelHelper#handleMouseWheelScrolled(org.eclipse.swt.widgets.Event)
*/
@Override
public void handleMouseWheelScrolled(Event event) {
Viewport viewport = findViewport(owner);
if (viewport == null || !viewport.isShowing())
return;
RangeModel rModel = viewport.getVerticalRangeModel();
if (rModel.getExtent() < (rModel.getMaximum() - rModel.getMinimum())) {
int currentPos = rModel.getValue();
int scrollHeight = lineHeight;
if (event.detail == SWT.SCROLL_PAGE)
scrollHeight = pageHeight > lineHeight ? pageHeight : Math.max(lineHeight, viewport.getClientArea(Rectangle.SINGLETON).height - 26);
scrollHeight *= event.count;
viewport.setVerticalLocation(currentPos - scrollHeight);
if (rModel.getValue() != currentPos)
event.doit = false;
}
}
use of org.eclipse.draw2d.RangeModel in project archi by archimatetool.
the class RulerComposite method disposeRulerViewer.
private void disposeRulerViewer(GraphicalViewer viewer) {
if (viewer == null)
return;
/*
* There's a tie from the editor's range model to the RulerViewport (via
* a listener) to the RulerRootEditPart to the RulerViewer. Break this
* tie so that the viewer doesn't leak and can be garbage collected.
*/
RangeModel rModel = new DefaultRangeModel();
Viewport port = ((FigureCanvas) viewer.getControl()).getViewport();
port.setHorizontalRangeModel(rModel);
port.setVerticalRangeModel(rModel);
rulerEditDomain.removeViewer(viewer);
viewer.getControl().dispose();
}
use of org.eclipse.draw2d.RangeModel in project cubrid-manager by CUBRID.
the class ERSchemaEditor method setLocatePoint.
/**
* Set the ERD focus location onto the gave point
*
* @param x
* @param y
*/
public void setLocatePoint(int x, int y) {
int setMax = Math.max(x, y);
RangeModel recModel = getViewPort().getVerticalRangeModel();
int max = recModel.getMaximum();
int extent = recModel.getExtent();
if (setMax > max - extent) {
getViewPort().getVerticalRangeModel().setMaximum(setMax + extent);
}
getViewPort().setViewLocation(x, y);
}
Aggregations