Exemplo n.º 1
0
  NodePresenter(VGraphExplorer parent, NodeProxy model) {
    this.parent = parent;
    this.model = model;
    graph = parent.getGraph();

    view.setTitle(model.getId());
    Style style = view.getElement().getStyle();
    style.setLeft(model.getX(), Unit.PX);
    style.setTop(model.getY(), Unit.PX);

    view.addDomHandler(this, MouseDownEvent.getType());
    view.addDomHandler(this, MouseMoveEvent.getType());
    view.addDomHandler(this, MouseUpEvent.getType());

    parent.add(view);
  }
Exemplo n.º 2
0
  private void limitToBoundingBox() {
    Element element = view.getElement();
    Style style = element.getStyle();

    int width = element.getOffsetWidth();
    model.setWidth(width);
    int xRadius = width / 2;
    int leftEdge = model.getX() - xRadius;
    leftEdge = limit(0, leftEdge, parent.getOffsetWidth() - width);
    model.setX(leftEdge + xRadius);
    style.setLeft(leftEdge, Unit.PX);

    int height = element.getOffsetHeight();
    model.setHeight(height);
    int yRadius = height / 2;
    int topEdge = model.getY() - yRadius;
    topEdge = limit(0, topEdge, parent.getOffsetHeight() - height);
    model.setY(topEdge + yRadius);
    style.setTop(topEdge, Unit.PX);
  }