Class ViewportUtilities

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

public final class ViewportUtilities extends Object
Utility class to support working with Viewports.
Since:
3.6
  • Method Details

    • getEnclosingViewportsPath

      public static List<Viewport> 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 List<Viewport> 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 List<Viewport> 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.