use of org.eclipse.draw2d.Viewport in project dbeaver by dbeaver.
the class ERDOutlinePage method createControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createControl(Composite parent) {
// create canvas and lws
overview = new Canvas(parent, SWT.NONE);
LightweightSystem lws = new LightweightSystem(overview);
// create thumbnail
thumbnail = new ScrollableThumbnail((Viewport) rootEditPart.getFigure());
thumbnail.setBorder(new MarginBorder(3));
thumbnail.setSource(rootEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS));
lws.setContents(thumbnail);
}
use of org.eclipse.draw2d.Viewport in project archi by archimatetool.
the class OverviewOutlinePage method createControl.
@Override
public void createControl(Composite parent) {
if (fEditPart == null) {
return;
}
// create canvas and lws
fCanvas = new Canvas(parent, SWT.NONE);
LightweightSystem lws = new LightweightSystem(fCanvas);
fThumbnail = new ScrollableThumbnail((Viewport) fEditPart.getFigure());
fThumbnail.setUseScaledGraphics(false);
fThumbnail.setSource(fEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS));
fThumbnail.setBorder(new MarginBorder(3));
lws.setContents(fThumbnail);
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(fCanvas, HELP_ID);
}
use of org.eclipse.draw2d.Viewport in project archi by archimatetool.
the class OverlayScrollPaneLayout method layout.
/**
* {@inheritDoc}
*/
@Override
public void layout(IFigure parent) {
ScrollPane scrollpane = (ScrollPane) parent;
Rectangle clientArea = parent.getClientArea();
ScrollBar hBar = scrollpane.getHorizontalScrollBar(), vBar = scrollpane.getVerticalScrollBar();
Viewport viewport = scrollpane.getViewport();
Insets insets = new Insets();
insets.bottom = hBar.getPreferredSize(clientArea.width, clientArea.height).height;
insets.right = vBar.getPreferredSize(clientArea.width, clientArea.height).width;
int hVis = scrollpane.getHorizontalScrollBarVisibility(), vVis = scrollpane.getVerticalScrollBarVisibility();
Dimension available = clientArea.getSize(), preferred = viewport.getPreferredSize(available.width, available.height).getCopy();
boolean none = available.contains(preferred), both = !none && vVis != NEVER && hVis != NEVER && preferred.contains(available), showV = both || preferred.height > available.height, showH = both || preferred.width > available.width;
// Adjust for visibility override flags
showV = !(vVis == NEVER) && (showV || vVis == ALWAYS);
showH = !(hVis == NEVER) && (showH || hVis == ALWAYS);
if (!showV)
insets.right = 0;
if (!showH)
insets.bottom = 0;
Rectangle bounds, viewportArea = clientArea;
if (showV) {
bounds = new Rectangle(viewportArea.right() - insets.right, viewportArea.y, insets.right, viewportArea.height);
vBar.setBounds(bounds);
// vBar.setMaximum(preferred.height);
}
if (showH) {
bounds = new Rectangle(viewportArea.x, viewportArea.bottom() - insets.bottom, viewportArea.width, insets.bottom);
hBar.setBounds(bounds);
// hBar.setMaximum(preferred.width);
}
vBar.setVisible(showV);
hBar.setVisible(showH);
viewport.setBounds(viewportArea);
}
use of org.eclipse.draw2d.Viewport in project archi by archimatetool.
the class GraphicalRootEditPart method createFigure.
/**
* @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
*/
@Override
protected IFigure createFigure() {
innerLayers = new LayeredPane();
printableLayers = new LayeredPane();
Layer layer = new Layer();
layer.setLayoutManager(new StackLayout());
printableLayers.add(layer, PRIMARY_LAYER);
layer = new ConnectionLayer();
layer.setPreferredSize(new Dimension(5, 5));
printableLayers.add(layer, CONNECTION_LAYER);
innerLayers.add(printableLayers, PRINTABLE_LAYERS);
layer = new Layer();
layer.setPreferredSize(new Dimension(5, 5));
innerLayers.add(layer, HANDLE_LAYER);
layer = new FeedbackLayer();
layer.setPreferredSize(new Dimension(5, 5));
innerLayers.add(layer, FEEDBACK_LAYER);
ScrollPane pane = new ScrollPane();
pane.setViewport(new Viewport(true));
pane.setContents(innerLayers);
return pane;
}
use of org.eclipse.draw2d.Viewport in project archi by archimatetool.
the class ViewportExposeHelper method exposeDescendant.
/**
* Exposes the descendant EditPart by smoothly scrolling the
* <code>Viewport</code>. The smoothness is determined by the minimum and
* maximum frame count, and the overall amount being scrolled.
*
* @see org.eclipse.gef.ExposeHelper#exposeDescendant(EditPart)
*/
@Override
public void exposeDescendant(EditPart part) {
Viewport port = findViewport(owner);
if (port == null)
return;
IFigure target = ((GraphicalEditPart) part).getFigure();
/*
* All calculations are done relative to the contents of the viewport.
* The expose margin is added in absolute coordinates, and then taken
* back to relative viewport coordinates.
*/
Rectangle exposeRegion = target.getBounds().getCopy();
target.translateToAbsolute(exposeRegion);
if (exposeMargin != null)
exposeRegion.expand(exposeMargin);
port.getContents().translateToRelative(exposeRegion);
Point offset = port.getContents().getBounds().getLocation();
// By substracting the offset, the region is now the difference from the
// contents origin.
exposeRegion.translate(offset.negate());
exposeRegion.translate(port.getHorizontalRangeModel().getMinimum(), port.getVerticalRangeModel().getMinimum());
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));
Point startLocation = port.getViewLocation();
int dx = finalLocation.x - startLocation.x;
int dy = finalLocation.y - startLocation.y;
int frames = (Math.abs(dx) + Math.abs(dy)) / 15;
frames = Math.max(frames, getMinimumFrameCount());
frames = Math.min(frames, getMaximumFrameCount());
int stepX = Math.min((dx / frames), (viewportSize.width / 3));
int stepY = Math.min((dy / frames), (viewportSize.height / 3));
for (int i = 1; i < frames; i++) {
port.setViewLocation(startLocation.x + stepX * i, startLocation.y + stepY * i);
port.getUpdateManager().performUpdate();
}
port.setViewLocation(finalLocation);
}
Aggregations