Draw2d
3.9.100.201405261516

org.eclipse.draw2d
Class ViewportUtilities

java.lang.Object
  extended by org.eclipse.draw2d.ViewportUtilities

public final class ViewportUtilities
extends java.lang.Object

Utility class to support working with Viewports.

Since:
3.6

Method Summary
static java.util.List getEnclosingViewportsPath(IFigure figure)
          Returns all enclosing Viewports for a given IFigure, beginning with its direct enclosing Viewport up the root Viewport in the figure's parent hierarchy.
static Viewport getNearestCommonViewport(IFigure firstFigure, IFigure secondFigure)
          Returns the nearest common enclosing Viewport for two given Figures.
static Viewport getNearestEnclosingViewport(IFigure figure)
          Returns the nearest enclosing Viewport of a given IFigure by walking up the figure's hierarchy.
static Viewport getNearestViewport(IFigure figure)
          Returns the given figure in case it is a Viewport itself, otherwise its nearest enclosing Viewport.
static Viewport getRootViewport(IFigure figure)
          Returns the upper most enclosing Viewport for the given IFigure.
static java.util.List getViewportsPath(Viewport leafViewport, Viewport rootViewport)
          Returns a list containing the provided leaf Viewport as the first element, and all its enclosing Viewports up to the root Viewport, where the root Viewport forms the last element of the list.
static java.util.List getViewportsPath(Viewport leafViewport, Viewport rootViewport, boolean includeRootViewport)
          Returns a list containing the provided leaf Viewport as the first element, and all its enclosing Viewports up to the root Viewport.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getEnclosingViewportsPath

public static java.util.List getEnclosingViewportsPath(IFigure figure)
Returns all enclosing Viewports for a given IFigure, beginning with its direct enclosing Viewport up the root Viewport in the figure's parent hierarchy.

Parameters:
figure -
Returns:
A list of Viewports representing the figure's enclosing Viewport path, where the nearest enclosing Viewport as the first element and the root Viewport as the last element. In case there is no enclosing Viewport, an empty list is returned.

getViewportsPath

public static java.util.List getViewportsPath(Viewport leafViewport,
                                              Viewport rootViewport)
Returns a list containing the provided leaf Viewport as the first element, and all its enclosing Viewports up to the root Viewport, where the root Viewport forms the last element of the list.

Parameters:
leafViewport - The Viewport, whose parent hierarchy is processed.
rootViewport - an ancestor of the given leafViewport, which marks the end point of the hierarchy to be processed.
Returns:
A list of Viewports containing the leaf Viewport as the first element, the root Viewport as the last and in between all enclosing Viewports of the leaf Viewport up to the root. Returns an empty list in case leaf or root Viewport are null or in case the root viewport is not an ancestor of the leaf Viewport.

getViewportsPath

public static java.util.List getViewportsPath(Viewport leafViewport,
                                              Viewport rootViewport,
                                              boolean includeRootViewport)
Returns a list containing the provided leaf Viewport as the first element, and all its enclosing Viewports up to the root Viewport. The root Viewport forms the last element of the list, in case includeRootViewport is set to true, otherwise the viewport directly nested below the root viewport will be the last in the list.

Parameters:
leafViewport - The Viewport, whose parent hierarchy is processed.
rootViewport - an ancestor of the given leafViewport, which marks the end point of the hierarchy to be processed.
includeRootViewport - whether the provided rootViewport should be included in the list of returned viewports (as the last one) or not.
Returns:
A list of Viewports containing the leaf Viewport as the first element, the root Viewport as the last and in between all enclosing Viewports of the leaf Viewport up to the root. Returns an empty list in case leaf or root Viewport are null or in case the root viewport is not an ancestor of the leaf Viewport.

getNearestCommonViewport

public static Viewport getNearestCommonViewport(IFigure firstFigure,
                                                IFigure secondFigure)
Returns the nearest common enclosing Viewport for two given Figures.

Parameters:
firstFigure -
secondFigure -
Returns:
The nearest common Viewport of the two given figures, or null if no common enclosing Viewport could be found.

getRootViewport

public static Viewport getRootViewport(IFigure figure)
Returns the upper most enclosing Viewport for the given IFigure.

Parameters:
figure -
Returns:
The upper most enclosing Viewport or null if there is no enclosing Viewport for the given IFigure,

getNearestViewport

public static Viewport getNearestViewport(IFigure figure)
Returns the given figure in case it is a Viewport itself, otherwise its nearest enclosing Viewport.

Parameters:
figure -
Returns:
The given figure in case it is a Viewport itself, otherwise the nearest enclosing Viewport or null if there is no nearest enclosing Viewport.

getNearestEnclosingViewport

public static Viewport getNearestEnclosingViewport(IFigure figure)
Returns the nearest enclosing Viewport of a given IFigure by walking up the figure's hierarchy.

Parameters:
figure -
Returns:
The nearest enclosing Viewport of the given figure, or null if none could be found.

Draw2d
3.9.100.201405261516

Copyright (c) IBM Corp. and others 2000, 2011. All Rights Reserved.