Package org.eclipse.draw2d

Examples of org.eclipse.draw2d.Viewport


        while (targetElementConstraint == null && parentElement != null) {
            targetElementConstraint = parentElement.getConstraint();
            parentElement = parentElement.getParent();
        }
        if (targetElementConstraint != null) {
            Viewport viewport = (Viewport) ((FreeformGraphicalRootEditPart) getGraphicalViewer().getRootEditPart()).getFigure();
            Dimension dim = viewport.getSize();
            Point startLocation = viewport.getViewLocation().getCopy();
            Point preferredEndLocation = new Point(targetElementConstraint.x - dim.width / 2 + targetElementConstraint.width / 2,
                targetElementConstraint.y - dim.height / 2 + targetElementConstraint.height / 2);
            moveViewport(viewport, startLocation, preferredEndLocation);
        }
        getGraphicalViewer().select(target);
View Full Code Here


   * @see org.eclipse.jst.pagedesigner.validation.caret.IMovementMediator#getConstainedEditableContainer(org.eclipse.jst.pagedesigner.validation.caret.Target)
   */
  public EditPart getConstainedEditableContainer(DesignPosition position,
      Point p, GraphicalViewer viewer) {
    Rectangle rect = new Rectangle(p.x, p.y, 1, 1);
    Viewport port = ((IHTMLGraphicalViewer) viewer).getViewport();

    Point viewLocation = port.getViewLocation();
    Point lastLocation = viewLocation.getCopy();
    new ExposeHelper((IHTMLGraphicalViewer) viewer).exposeArea(rect);
    viewLocation = port.getViewLocation();
    Dimension offset = lastLocation.getDifference(viewLocation);

    p.translate(offset.width, offset.height);
    EditPart part = viewer.findObjectAt(p);
    if (part != null && !(part instanceof ScalableRootEditPart)) {
View Full Code Here

  public void exposeArea(Rectangle rect) {
    if (_viewer == null) {
      return;
    }
    FigureCanvas canvas = (FigureCanvas) _viewer.getControl();
    Viewport port = _viewer.getViewport();

    if (port == null) {
      return;
    }
    Rectangle exposeRegion = rect.getCopy();
    Rectangle portBounds = port.getBounds().getCopy();
    Point viewLocation = port.getViewLocation();
    Dimension diff = calculateDiff(portBounds, exposeRegion);
    if (diff != null) {
      viewLocation.x -= diff.width;
      viewLocation.y -= diff.height;
      canvas.scrollSmoothTo(viewLocation.x, viewLocation.y);
View Full Code Here

  private void exposeVertical(int offset) {
    if (_viewer == null) {
      return;
    }
    FigureCanvas canvas = (FigureCanvas) _viewer.getControl();
    Viewport port = _viewer.getViewport();

    if (port == null) {
      return;
    }
    Point viewLocation = port.getViewLocation();
    viewLocation.y += offset;
    canvas.scrollSmoothTo(viewLocation.x, viewLocation.y);
  }
View Full Code Here

  private void exposeHorizontal(int offset) {
    if (_viewer == null) {
      return;
    }
    FigureCanvas canvas = (FigureCanvas) _viewer.getControl();
    Viewport port = _viewer.getViewport();

    if (port == null) {
      return;
    }
    Point viewLocation = port.getViewLocation();
    viewLocation.x += offset;
    canvas.scrollSmoothTo(viewLocation.x, viewLocation.y);
  }
View Full Code Here

  /**
   * @return the location of the view port
   */
  public Point getViewpostLocation() {
    if (_viewer != null) {
      Viewport port = _viewer.getViewport();

      if (port != null) {
        return port.getViewLocation();
      }
    }
    return null;
  }
View Full Code Here

  private int getHorizontalBoundsOffset(Point p, boolean forward) {
    if (_viewer == null) {
      return DEFAULT_OFFSET;
    }
    Viewport port = _viewer.getViewport();

    if (port == null) {
      return DEFAULT_OFFSET;
    }
    if (forward) {
      Rectangle portBounds = port.getBounds().getCopy();
      return portBounds.getRight().x - p.x;
    }
        return p.x;
  }
View Full Code Here

  private int getVerticalBoundsOffset(Point p, boolean up) {
    if (_viewer == null) {
      return DEFAULT_OFFSET;
    }
    Viewport port = _viewer.getViewport();

    if (port == null) {
      return DEFAULT_OFFSET;
    }
    if (!up) {
      Rectangle portBounds = port.getBounds().getCopy();
      return portBounds.getBottom().y - p.y;
    }
        return p.y;
  }
View Full Code Here

  /**
   * this method is called after the view is fully initialized.
   */
  public void connectViewer() {
    Viewport viewport = _viewer.getViewport();
    if (viewport != null) {
      viewport.getHorizontalRangeModel().addPropertyChangeListener(
          new PropertyChangeListener() {
            public void propertyChange(
                PropertyChangeEvent propertychangeevent) {
              if ((propertychangeevent.getSource() instanceof RangeModel)
                  && (propertychangeevent.getPropertyName()
                      .equals(ICSSPropertyID.ATTR_VALUE) || propertychangeevent
                      .getPropertyName().equals("extent"))) //$NON-NLS-1$
                updateCaret();
            }

          });
      viewport.getVerticalRangeModel().addPropertyChangeListener(
          new PropertyChangeListener() {

            public void propertyChange(
                PropertyChangeEvent propertychangeevent) {
              if ((propertychangeevent.getSource() instanceof RangeModel)
View Full Code Here

  }

  public Viewport getEditorViewport() {
    if (getGraphicalViewer() == null
        || getGraphicalViewer().getControl() == null) {
      return new Viewport();
    }
    return ((FigureCanvas) getGraphicalViewer().getControl()).getViewport();
  }
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.