use of org.eclipse.draw2d.Viewport in project archi by archimatetool.
the class ViewportHelper method findViewport.
protected Viewport findViewport(GraphicalEditPart part) {
IFigure figure = null;
Viewport port = null;
do {
if (figure == null)
figure = part.getContentPane();
else
figure = figure.getParent();
if (figure instanceof Viewport) {
port = (Viewport) figure;
break;
}
} while (figure != part.getFigure() && figure != null);
return port;
}
use of org.eclipse.draw2d.Viewport in project archi by archimatetool.
the class ScrollingGraphicalViewer method reveal.
/**
* Extends the superclass implementation to scroll the native Canvas control
* after the super's implementation has completed.
*
* @see org.eclipse.gef.EditPartViewer#reveal(org.eclipse.gef.EditPart)
*/
@Override
public void reveal(EditPart part) {
super.reveal(part);
Viewport port = getFigureCanvas().getViewport();
IFigure target = ((GraphicalEditPart) part).getFigure();
Rectangle exposeRegion = target.getBounds().getCopy();
target = target.getParent();
while (target != null && target != port) {
target.translateToParent(exposeRegion);
target = target.getParent();
}
exposeRegion.expand(5, 5);
Dimension viewportSize = port.getClientArea().getSize();
Point topLeft = exposeRegion.getTopLeft();
Point bottomRight = exposeRegion.getBottomRight().translate(viewportSize.getNegated());
Point finalLocation = new Point();
if (viewportSize.width < exposeRegion.width)
finalLocation.x = Math.min(bottomRight.x, Math.max(topLeft.x, port.getViewLocation().x));
else
finalLocation.x = Math.min(topLeft.x, Math.max(bottomRight.x, port.getViewLocation().x));
if (viewportSize.height < exposeRegion.height)
finalLocation.y = Math.min(bottomRight.y, Math.max(topLeft.y, port.getViewLocation().y));
else
finalLocation.y = Math.min(topLeft.y, Math.max(bottomRight.y, port.getViewLocation().y));
getFigureCanvas().scrollSmoothTo(finalLocation.x, finalLocation.y);
}
use of org.eclipse.draw2d.Viewport in project archi by archimatetool.
the class ScrollableSelectionFeedbackEditPolicy method activate.
/**
* @see org.eclipse.gef.editpolicies.SelectionEditPolicy#activate()
*/
@Override
public void activate() {
super.activate();
// unregistered within hideFeedback()
for (Iterator iterator = ViewportUtilities.getViewportsPath(getHostFigureViewport(), ViewportUtilities.getRootViewport(getHostFigure())).iterator(); iterator.hasNext(); ) {
Viewport viewport = (Viewport) iterator.next();
viewport.addPropertyChangeListener(viewportViewLocationChangeListener);
}
}
use of org.eclipse.draw2d.Viewport in project jbosstools-hibernate by jbosstools.
the class DiagramContentOutlinePage method initializeOverview.
/**
*/
protected void initializeOverview() {
LightweightSystem lws = new LightweightSystem(overview);
RootEditPart rep = getGraphicalViewer().getRootEditPart();
if (rep instanceof ScalableFreeformRootEditPart) {
ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) rep;
if (this.thumbnail != null) {
this.thumbnail.deactivate();
}
thumbnail = new ScrollableThumbnail((Viewport) root.getFigure());
thumbnail.setBorder(new MarginBorder(3));
thumbnail.setSource(root.getLayer(LayerConstants.PRINTABLE_LAYERS));
lws.setContents(thumbnail);
}
}
Aggregations