use of org.eclipse.draw2d.Viewport 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.Viewport in project archi by archimatetool.
the class ScrollableSelectionFeedbackEditPolicy method deactivate.
/**
* @see org.eclipse.gef.editpolicies.SelectionEditPolicy#deactivate()
*/
@Override
public void deactivate() {
// hideSelection(), so they do not have to be unregistered here
for (Iterator iterator = ViewportUtilities.getViewportsPath(getHostFigureViewport(), ViewportUtilities.getRootViewport(getHostFigure())).iterator(); iterator.hasNext(); ) {
Viewport viewport = (Viewport) iterator.next();
viewport.removePropertyChangeListener(viewportViewLocationChangeListener);
}
super.deactivate();
}
use of org.eclipse.draw2d.Viewport in project archi by archimatetool.
the class ViewportAutoexposeHelper method detect.
/**
* Returns <code>true</code> if the given point is inside the viewport, but
* near its edge.
*
* @see org.eclipse.gef.AutoexposeHelper#detect(org.eclipse.draw2d.geometry.Point)
*/
@Override
public boolean detect(Point where) {
lastStepTime = 0;
Viewport port = findViewport(owner);
Rectangle rect = Rectangle.SINGLETON;
port.getClientArea(rect);
port.translateToParent(rect);
port.translateToAbsolute(rect);
return rect.contains(where) && !rect.shrink(threshold).contains(where);
}
use of org.eclipse.draw2d.Viewport in project archi by archimatetool.
the class GraphContainer method createContainerFigure.
private IFigure createContainerFigure() {
GraphContainer node = this;
IFigure containerFigure = new ContainerFigure();
containerFigure.setOpaque(true);
containerFigure.addLayoutListener(LayoutAnimator.getDefault());
containerFigure.setLayoutManager(new FreeformLayout());
expandGraphLabel = new ExpandGraphLabel(this, node.getText(), node.getImage(), false);
expandGraphLabel.setText(getText());
expandGraphLabel.setImage(getImage());
ContainerDimension containerDimension = computeContainerSize();
scrollPane = new ScrollPane();
scrollPane.addLayoutListener(LayoutAnimator.getDefault());
Viewport viewport = new FreeformViewport();
/*
* This is the code that helps remove the scroll bars moving when the
* nodes are dragged.
*
* viewport.setHorizontalRangeModel(new DefaultRangeModel() { public
* void setAll(int min, int ext, int max) { System.out.println("Max: " +
* max + " : current Max: " + getMaximum()); if (max < getMaximum()) {
* max = getMaximum(); } super.setAll(min, ext, max); }
*
* public void setMaximum(int maximum) { // TODO Auto-generated method
* stub System.out.println("Max: " + maximum + " : current Max: " +
* getMaximum()); if (maximum < getMaximum()) { return; }
* super.setMaximum(maximum); } });
*/
scrollPane.setViewport(viewport);
viewport.addLayoutListener(LayoutAnimator.getDefault());
scrollPane.setScrollBarVisibility(ScrollPane.AUTOMATIC);
// scalledLayer = new ScalableFreeformLayeredPane();
// $NON-NLS-1$
scalledLayer = new AspectRatioFreeformLayer("debug label");
scalledLayer.addLayoutListener(LayoutAnimator.getDefault());
// scalledLayer.setScale(computeChildScale());
scalledLayer.setScale(computeWidthScale(), computeHeightScale());
// container = new FreeformLayer();
// edgeLayer = new FreeformLayer();
zestLayer = new ZestRootLayer();
zestLayer.addLayoutListener(LayoutAnimator.getDefault());
// container.addLayoutListener(LayoutAnimator.getDefault());
// edgeLayer.addLayoutListener(LayoutAnimator.getDefault());
// scalledLayer.add(edgeLayer);
// scalledLayer.add(container);
scalledLayer.add(zestLayer);
// container.setLayoutManager(new FreeformLayout());
zestLayer.setLayoutManager(new FreeformLayout());
scrollPane.setSize(computeChildArea());
scrollPane.setLocation(new Point(0, containerDimension.labelHeight - SUBLAYER_OFFSET));
scrollPane.setForegroundColor(ColorConstants.gray);
expandGraphLabel.setBackgroundColor(getBackgroundColor());
expandGraphLabel.setForegroundColor(getForegroundColor());
expandGraphLabel.setLocation(new Point(0, 0));
containerFigure.add(scrollPane);
containerFigure.add(expandGraphLabel);
scrollPane.getViewport().setContents(scalledLayer);
scrollPane.setBorder(new LineBorder());
return containerFigure;
}
use of org.eclipse.draw2d.Viewport 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();
}
Aggregations