Package org.eclipse.draw2d

Examples of org.eclipse.draw2d.Viewport


   * @return the info whether the form is within the currently visible
   *         viewport area
   */
  protected static boolean isFormInVisibleArea(String formId,
      FigurePassingObject figurePassingObject) {
    Viewport editorViewport = MusicPlugin.getDefault().getActiveEditor()
        .getEditorViewport();
    Point point = figurePassingObject.getLocationMap().get(formId);
    Dimension dimension = figurePassingObject.getDimensionMap().get(formId);
    if (isVisibleArea(editorViewport, point) // upper left
        || isVisibleArea(editorViewport,
View Full Code Here


    if(elem == null)
      return;
   
    Point location = FigureMultipassController.figurePassingObject.getLocationMap().get(elem.getId());

    Viewport port = getFigureCanvas().getViewport();
    Dimension viewportSize = port.getClientArea().getSize();

    if(!FigureRenderLibrary.isVisibleArea(port, location)) {
      getFigureCanvas().scrollTo(location.x - (viewportSize.width / 2),
          location.y - (viewportSize.height / 2));
    }
View Full Code Here

    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);
    }
    if (showH) {
      bounds = new Rectangle(viewportArea.x,
        viewportArea.bottom() - insets.bottom,
        viewportArea.width, insets.bottom);
      hBar.setBounds(bounds);
    }
    vBar.setVisible(showV);
    hBar.setVisible(showH);
    viewport.setBounds(viewportArea);
  }
View Full Code Here

    // there's no need to scroll to the main edit part because it is always visible
    if (part instanceof MainTrayEditPart) return;

    MainTrayEditPart mainPart = getMainTrayEditPart(part);
    ScrollPane scrollpane = ((MainTrayEditPart.MainTrayContainerFigure)mainPart.getFigure()).getChildrenScrollPane();
    Viewport viewport = scrollpane.getViewport();
    Rectangle partBounds = part.getFigure().getBounds().getCopy();
    Rectangle portBounds = viewport.getBounds();
    if (!portBounds.contains(partBounds)) {
      Point topLocation = partBounds.getTopLeft();
     
      Point currentLocation = viewport.getViewLocation();
      int step = getScrollStep(part);
      if (currentLocation.getPosition(topLocation) == PositionConstants.NORTH) {
        currentLocation.y -= step;
        // ensure that we don't leave things "half-scrolled" at the top
        currentLocation.y = (currentLocation.y < step) ? 0 : currentLocation.y;
      } else {
        currentLocation.y += step;
      }
      viewport.setViewLocation(currentLocation);

      // refreshes the scrollbar so they can disppear if needed
      ScrollBar scrollbar = scrollpane.getVerticalScrollBar();
      scrollbar.invalidate();
      scrollbar.validate();
View Full Code Here

    // will break the tray scrolling.
    canvas.getViewport().setLayoutManager(new ViewportLayout() {
     
      @Override
      public void layout(IFigure figure) {
        Viewport viewport = (Viewport)figure;
        IFigure contents = viewport.getContents();
       
        if (contents == null) return;
        Point p = viewport.getClientArea().getLocation();

        p.translate(viewport.getViewLocation().getNegated());
       
        Dimension newSize = viewport.getClientArea().getSize();
       
        contents.setBounds(new Rectangle(p, newSize));
      }
    });
   
View Full Code Here

 
  public Rectangle getFreeformExtent() {
    Rectangle _xblockexpression = null;
    {
      final Rectangle freeformExtent = super.getFreeformExtent();
      final Viewport parentViewport = this.findViewport(this);
      Rectangle _xifexpression = null;
      boolean _notEquals = (!Objects.equal(parentViewport, null));
      if (_notEquals) {
        Rectangle _xblockexpression_1 = null;
        {
          IFigure _parent = parentViewport.getParent();
          Rectangle _bounds = _parent.getBounds();
          final Dimension viewDimension = _bounds.getSize();
          parentViewport.translateToAbsolute(viewDimension);
          this.translateToRelative(viewDimension);
          Dimension _size = freeformExtent.getSize();
          Dimension _size_1 = freeformExtent.getSize();
          viewDimension.shrink(_size.width, _size_1.height);
          int _max = Math.max(0, viewDimension.width);
View Full Code Here

    }
    return _xblockexpression;
  }
 
  protected Viewport findViewport(final IFigure figure) {
    Viewport _switchResult = null;
    boolean _matched = false;
    if (!_matched) {
      if (Objects.equal(figure, null)) {
        _matched=true;
        _switchResult = null;
View Full Code Here

  public IFigure findFigureAt(final Point location) {
    return rootFigure.findFigureAt(location);
  }

  public void reveal(final IFigure figure) {
    Viewport viewport = canvas.getViewport();
    Rectangle viewportBounds = viewport.getBounds().getCopy();
    viewportBounds.translate(viewport.getViewLocation());
    Rectangle figureBounds = figure.getBounds().getCopy();
    figure.translateToAbsolute(figureBounds);
    figureBounds.translate(viewport.getViewLocation());
    if (!viewportBounds.contains(figureBounds)) {
      int newX = viewportBounds.x;
      int newY = viewportBounds.y;
      if(viewportBounds.x > figureBounds.x) {
        newX = figureBounds.x;
View Full Code Here

TOP

Related Classes of org.eclipse.draw2d.Viewport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.