Search in sources :

Example 61 with Insets

use of org.eclipse.draw2d.geometry.Insets in project archi by archimatetool.

the class CompoundBorder method getPreferredSize.

/**
 * @see org.eclipse.draw2d.Border#getPreferredSize(IFigure)
 */
@Override
public Dimension getPreferredSize(IFigure fig) {
    Dimension prefSize = new Dimension(inner.getPreferredSize(fig));
    Insets outerInsets = outer.getInsets(fig);
    prefSize.expand(outerInsets.getWidth(), outerInsets.getHeight());
    prefSize.union(outer.getPreferredSize(fig));
    return prefSize;
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 62 with Insets

use of org.eclipse.draw2d.geometry.Insets in project archi by archimatetool.

the class ScrollableSelectionFeedbackEditPolicy method showFeedback.

/**
 * Creates feedback figures for all node figures nested within the host
 * figure's viewport, as well as for all incoming and outgoing connections
 * of these nodes. Feedback figures are only created in case there are
 * children or connections, which are not fully visible.
 */
protected void showFeedback() {
    // ensure primary and connection layer are revalidated,
    // so the bounds of all their child figures, which are
    // used to calculate the feedback figure constraints,
    // are valid
    getLayer(LayerConstants.PRIMARY_LAYER).validate();
    getLayer(LayerConstants.CONNECTION_LAYER).validate();
    // check if there is a node child exceeding the client are
    Rectangle clientArea = getAbsoluteClientArea(getHostFigure());
    boolean primaryLayerChildExceedsViewport = !clientArea.equals(getAbsoluteViewportArea(((IScrollableFigure) getHostFigure()).getScrollPane().getViewport()));
    // check if there is a connection exceeding the client area
    boolean connectionLayerChildExceedsClientArea = false;
    List connectionLayerChildren = getLayer(LayerConstants.CONNECTION_LAYER).getChildren();
    for (Iterator iterator = connectionLayerChildren.iterator(); iterator.hasNext() && !connectionLayerChildExceedsClientArea; ) {
        IFigure connectionLayerChild = (IFigure) iterator.next();
        connectionLayerChildExceedsClientArea = (ViewportUtilities.getNearestEnclosingViewport(connectionLayerChild) == ((IScrollableFigure) getHostFigure()).getScrollPane().getViewport() && !clientArea.getExpanded(new Insets(1, 1, 1, 1)).contains(getAbsoluteBounds(connectionLayerChild)));
    }
    // bounds exceed the client area
    if (primaryLayerChildExceedsViewport || connectionLayerChildExceedsClientArea) {
        createNodeFeedbackFigures();
        createConnectionFeedbackFigures();
    }
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) Rectangle(org.eclipse.draw2d.geometry.Rectangle) IScrollableFigure(org.eclipse.draw2d.IScrollableFigure) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IFigure(org.eclipse.draw2d.IFigure)

Example 63 with Insets

use of org.eclipse.draw2d.geometry.Insets in project archi by archimatetool.

the class OverlayScrollPaneLayout method calculatePreferredSize.

/**
 * {@inheritDoc} In OverlayScrollPane, scrollbars are overlayed on top of
 * the Viewport, so the preferred size is just the Viewports preferred size.
 *
 * @since 2.0
 */
@Override
protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) {
    ScrollPane scrollpane = (ScrollPane) container;
    Insets insets = scrollpane.getInsets();
    int excludedWidth = insets.getWidth();
    int excludedHeight = insets.getHeight();
    return scrollpane.getViewport().getPreferredSize(wHint - excludedWidth, hHint - excludedHeight).getExpanded(excludedWidth, excludedHeight);
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) ScrollPane(org.eclipse.draw2d.ScrollPane)

Example 64 with Insets

use of org.eclipse.draw2d.geometry.Insets in project archi by archimatetool.

the class MoveHandleLocator method relocate.

/**
 * Sets the handle's bounds to that of its owner figure's bounds, expanded
 * by the handle's Insets.
 *
 * @param target
 *            The IFigure to relocate
 */
@Override
public void relocate(IFigure target) {
    Insets insets = target.getInsets();
    Rectangle bounds;
    if (getReference() instanceof HandleBounds)
        bounds = ((HandleBounds) getReference()).getHandleBounds();
    else
        bounds = getReference().getBounds();
    bounds = new PrecisionRectangle(bounds.getResized(-1, -1));
    getReference().translateToAbsolute(bounds);
    target.translateToRelative(bounds);
    bounds.translate(-insets.left, -insets.top);
    bounds.resize(insets.getWidth() + 1, insets.getHeight() + 1);
    target.setBounds(bounds);
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle)

Example 65 with Insets

use of org.eclipse.draw2d.geometry.Insets in project archi by archimatetool.

the class ScrollPaneSolver method solve.

/**
 * Solves for the viewport area, insets, and visibility of horizontal and
 * vertical scrollbars of a ScrollPane
 *
 * @param clientArea
 *            The ScrollPane's client area
 * @param viewport
 *            The ScrollPane's Viewport
 * @param hVis
 *            Horizontal scrollbar visibility
 * @param vVis
 *            Vertical scrollbar visibility
 * @param vBarWidth
 *            Width of vertical scrollbar
 * @param hBarHeight
 *            Height of horizontal scrollbar
 * @return the Result
 */
@SuppressWarnings("deprecation")
public static Result solve(Rectangle clientArea, Viewport viewport, int hVis, int vVis, int vBarWidth, int hBarHeight) {
    Result result = new Result();
    result.insets = new Insets();
    result.insets.bottom = hBarHeight;
    result.insets.right = vBarWidth;
    Dimension available = clientArea.getSize();
    Dimension guaranteed = new Dimension(available).shrink((vVis == NEVER ? 0 : result.insets.right), (hVis == NEVER ? 0 : result.insets.bottom));
    guaranteed.width = Math.max(guaranteed.width, 0);
    guaranteed.height = Math.max(guaranteed.height, 0);
    int wHint = guaranteed.width;
    int hHint = guaranteed.height;
    Dimension preferred = viewport.getPreferredSize(wHint, hHint).getCopy();
    Insets viewportInsets = viewport.getInsets();
    /*
         * This was calling viewport.getMinimumSize(), but viewport's minimum
         * size was really small, and wasn't a function of its contents.
         */
    Dimension viewportMinSize = new Dimension(viewportInsets.getWidth(), viewportInsets.getHeight());
    if (viewport.getContents() != null) {
        if (viewport.getContentsTracksHeight() && hHint > -1)
            hHint = Math.max(0, hHint - viewportInsets.getHeight());
        if (viewport.getContentsTracksWidth() && wHint > -1)
            wHint = Math.max(0, wHint - viewportInsets.getWidth());
        viewportMinSize.expand(viewport.getContents().getMinimumSize(wHint, hHint));
    }
    /*
         * Adjust preferred size if tracking flags set. Basically, tracking ==
         * "compress view until its minimum size is reached".
         */
    if (viewport.getContentsTracksHeight())
        preferred.height = viewportMinSize.height;
    if (viewport.getContentsTracksWidth())
        preferred.width = viewportMinSize.width;
    boolean none = available.contains(preferred), both = !none && preferred.containsProper(guaranteed), showV = both || preferred.height > available.height, showH = both || preferred.width > available.width;
    // Adjust for visibility override flags
    result.showV = vVis != NEVER && (showV || vVis == ALWAYS);
    result.showH = hVis != NEVER && (showH || hVis == ALWAYS);
    if (!result.showV)
        result.insets.right = 0;
    if (!result.showH)
        result.insets.bottom = 0;
    result.viewportArea = clientArea.getCropped(result.insets);
    viewport.setBounds(result.viewportArea);
    return result;
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) Dimension(org.eclipse.draw2d.geometry.Dimension)

Aggregations

Insets (org.eclipse.draw2d.geometry.Insets)77 Rectangle (org.eclipse.draw2d.geometry.Rectangle)33 Dimension (org.eclipse.draw2d.geometry.Dimension)32 IFigure (org.eclipse.draw2d.IFigure)12 List (java.util.List)9 Graphics (org.eclipse.draw2d.Graphics)5 AbstractBorder (org.eclipse.draw2d.AbstractBorder)4 PrintDialog (org.eclipse.swt.printing.PrintDialog)4 Printer (org.eclipse.swt.printing.Printer)4 PrinterData (org.eclipse.swt.printing.PrinterData)4 MarginBorder (org.eclipse.draw2d.MarginBorder)3 PrintFigureOperation (org.eclipse.draw2d.PrintFigureOperation)3 Point (org.eclipse.draw2d.geometry.Point)3 Border (org.eclipse.draw2d.Border)2 ScrollBar (org.eclipse.draw2d.ScrollBar)2 ScrollPane (org.eclipse.draw2d.ScrollPane)2 Viewport (org.eclipse.draw2d.Viewport)2 Node (org.eclipse.draw2d.graph.Node)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 EntityPart (org.jkiss.dbeaver.ext.erd.part.EntityPart)2