Exemplo n.º 1
0
  protected WidgetWrapper addWidget(
      Widget widget, int x, int y, boolean select, boolean loadingWidget) {
    java.awt.Dimension size = widget.getSize();
    WidgetWrapper wrapper = new WidgetWrapper(widget, this);
    wrapper.setVisible(false);
    // we need to add the wrapper before we can call wrapper.getPreferredSize(), because
    // that method looks at its parent and sees if it's an InterfacePanel
    // and zooms accordingly - ST 6/16/02
    add(wrapper, DEFAULT_LAYER);
    moveToFront(wrapper);

    if (select || !loadingWidget) {
      wrapper.setSize(wrapper.getPreferredSize());
    } else {
      wrapper.setSize(size); // //wrapper.getPreferredSize());
    }

    if (workspace.snapOn() && !loadingWidget) {
      int gridX = (x / GRID_SNAP) * GRID_SNAP;
      int gridY = (y / GRID_SNAP) * GRID_SNAP;
      wrapper.setLocation(gridX, gridY);
    } else {
      wrapper.setLocation(x, y);
    }
    wrapper.validate();
    wrapper.setVisible(true);

    zoomer.zoomWidget(wrapper, true, loadingWidget, 1.0, zoomer.zoomFactor());

    if (select) {
      newWidget = wrapper;
      newWidget.originalBounds = newWidget.getBounds();
      newWidget.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.CROSSHAIR_CURSOR));
    }
    org.nlogo.log.Logger.logAddWidget(widget.classDisplayName(), widget.displayName());
    return wrapper;
  }
Exemplo n.º 2
0
 public boolean isZoomed() {
   return zoomer.zoomFactor() != 1.0;
 }