@Override
  public void draw(IBNAView view, ICoordinateMapper cm, GL2 gl, Rectangle clip, IResources r) {

    if (control == null) {
      control = createControl(view, cm);
    }

    // update bounds
    final Rectangle newBounds = getBounds(control, view, cm);
    final Rectangle oldBounds = control.getBounds();
    if (!oldBounds.equals(newBounds)) {
      SWTWidgetUtils.async(
          control,
          new Runnable() {
            @Override
            public void run() {
              if (oldBounds.width != newBounds.width || oldBounds.height != newBounds.height) {
                control.setSize(newBounds.width, newBounds.height);
                if (control instanceof Composite) {
                  ((Composite) control).layout(true, true);
                  control.pack(true);
                }
              }
              control.setLocation(newBounds.x, newBounds.y);
            }
          });
    }
  }
 @Override
 public boolean isInThing(IBNAView view, ICoordinateMapper cm, ICoordinate location) {
   if (control != null) {
     Point local = location.getLocalPoint();
     local.x += cm.getLocalOrigin().x;
     local.y += cm.getLocalOrigin().y;
     return control.getBounds().contains(local.x, local.y);
   }
   return false;
 }
Ejemplo n.º 3
0
    public void nativeRebound(int x, int y, int w, int h) {
      Rectangle rect = component.getBounds();
      if (rect.x == x && rect.y == y && rect.width == w && rect.height == h) return;

      component.setBounds(x, y, w, h);
    }