예제 #1
0
  public void selected(SelectEvent event) {
    // Select/unselect object on left click,
    // or follow URL if one was clicked
    if (event.getEventAction().equals(SelectEvent.LEFT_CLICK)) {
      if (event.hasObjects()) {
        if (event.getTopObject() instanceof Annotation) {
          // if URL was clicked, open in browser
          PickedObject po = event.getTopPickedObject();

          if (po.getValue(AVKey.URL) != null && po.getValue(AVKey.URL) instanceof String) {
            // Execute the URL.
            this.processUrl((String) po.getValue(AVKey.URL), true);

            return;
          }
        }

        if (event.getTopObject() instanceof Selectable) {
          if (this.selectedObject != event.getTopObject()
              || (this.selectedObject instanceof Selectable
                  && !((Selectable) this.selectedObject).isSelected())) {
            // either a new object was clicked, or this.selectedObject was clicked
            // but it's been unselected already from outside this listener
            select(
                event.getTopObject(),
                event.getTopPickedObject().getParentLayer(),
                event.getTopPickedObject().getPosition());
            return;
          } else {
            // same, already selected object clikcked
            select(null, null, null);
            return;
          }
        }
      }
    } // Highlight on rollover
    else if (event.getEventAction().equals(SelectEvent.ROLLOVER)) {
      if (!(event.getTopObject() instanceof DialogAnnotation)) {
        highlight(event.getTopObject());

        // if URL was rollod-over, show it in status bar
        PickedObject po = event.getTopPickedObject();

        if (po != null
            && po.getValue(AVKey.URL) != null
            && po.getValue(AVKey.URL) instanceof String) {
          // show the URL.
          this.processUrl((String) po.getValue(AVKey.URL), false);

          return;
        }
      } // if
    }

    setStatusText("");
  }
예제 #2
0
  public void selected(SelectEvent event) {
    if (event == null) {
      String msg = Logging.getMessage("nullValue.EventIsNull");
      Logging.logger().log(java.util.logging.Level.FINE, msg);
      throw new IllegalArgumentException(msg);
    }

    if (event.getTopObject() != null && !(event.getTopObject() instanceof RegionShape)) {
      this.setCursor(null);
      return;
    }

    if (event.getEventAction().equals(SelectEvent.LEFT_PRESS)) {
      this.setPreviousPosition(this.getWwd().getCurrentPosition());
    } else if (event.getEventAction().equals(SelectEvent.DRAG)) {
      DragSelectEvent dragEvent = (DragSelectEvent) event;
      Object topObject = dragEvent.getTopObject();
      if (topObject == null) return;

      RegionShape dragObject = (RegionShape) topObject;

      if (this.getOperation() == SIZING) {
        Sector newSector = this.resizeShape(dragObject, this.getSide());
        if (newSector != null) dragObject.setSector(newSector);
      } else {
        this.setSide(this.determineAdjustmentSide(dragObject, this.getEdgeFactor()));

        if (this.getSide() == NONE || this.getOperation() == MOVING) {
          this.setOperation(MOVING);
          this.dragWholeShape(dragEvent, dragObject);
        } else {
          Sector newSector = this.resizeShape(dragObject, this.getSide());
          if (newSector != null) dragObject.setSector(newSector);
          this.setOperation(SIZING);
        }
      }

      this.setPreviousPosition(this.getWwd().getCurrentPosition());
      this.notifySectorChanged();
    } else if (event.getEventAction().equals(SelectEvent.DRAG_END)) {
      this.setOperation(NONE);
      this.setPreviousPosition(null);
    } else if (event.getEventAction().equals(SelectEvent.ROLLOVER)) {
      if (!(this.getWwd() instanceof Component)) return;

      if (event.getTopObject() == null || event.getTopPickedObject().isTerrain()) {
        this.setCursor(null);
        return;
      }

      if (!(event.getTopObject() instanceof Movable)) return;

      this.setCursor(
          this.determineAdjustmentSide((Movable) event.getTopObject(), this.getEdgeFactor()));
    }
  }
  public void selected(SelectEvent event) {
    if (this.wwd == null) return;

    if (!(this.wwd.getView() instanceof OrbitView)) return;

    OrbitView view = (OrbitView) this.wwd.getView();

    if (this.viewControlsLayer.getHighlightedObject() != null) {
      this.viewControlsLayer.highlight(null);
      this.wwd.redraw(); // must redraw so the de-highlight can take effect
    }

    if (event.getMouseEvent() != null && event.getMouseEvent().isConsumed()) return;

    if (event.getTopObject() == null
        || event.getTopPickedObject().getParentLayer() != this.getParentLayer()
        || !(event.getTopObject() instanceof AVList)) return;

    String controlType = ((AVList) event.getTopObject()).getStringValue(AVKey.VIEW_OPERATION);
    if (controlType == null) return;

    ScreenAnnotation selectedObject = (ScreenAnnotation) event.getTopObject();

    this.lastPickPoint = event.getPickPoint();
    if (event.getEventAction().equals(SelectEvent.ROLLOVER)) {
      // Highlight on rollover
      this.viewControlsLayer.highlight(selectedObject);
      this.wwd.redraw();
    }
    if (event.getEventAction().equals(SelectEvent.DRAG)) {
      // just consume drag events
      event.consume();
    } else if (event.getEventAction().equals(SelectEvent.HOVER)) {
      // Highlight on hover
      this.viewControlsLayer.highlight(selectedObject);
      this.wwd.redraw();
    } else if (event.getEventAction().equals(SelectEvent.LEFT_PRESS)
        || (event.getEventAction().equals(SelectEvent.DRAG) && controlType.equals(AVKey.VIEW_PAN))
        || (event.getEventAction().equals(SelectEvent.DRAG)
            && controlType.equals(AVKey.VIEW_LOOK))) {
      MyLogger.specialLog(SpecialLog.CONTROLS);
      // Handle left press on controls
      this.pressedControl = selectedObject;
      this.pressedControlType = controlType;

      // Consume drag events, but do not consume left press events. It is not necessary to consume
      // left press
      // events here, and doing so prevents the WorldWindow from gaining focus.
      if (event.getEventAction().equals(SelectEvent.DRAG)) event.consume();
    } else if (event.getEventAction().equals(SelectEvent.LEFT_CLICK)
        || event.getEventAction().equals(SelectEvent.LEFT_DOUBLE_CLICK)
        || event.getEventAction().equals(SelectEvent.DRAG_END)) {
      if (controlType.equals("trash it")) {
        SettingsDialog d = new SettingsDialog(appFrame, globalSettings);
        //            	GoToDialog d = new GoToDialog(appFrame);
        d.setVisible(true);
        //            	event.consume();
      }
      //            if (controlType.equals("auxiliary")) {
      //
      //            	AccountDialog d = new AccountDialog(appFrame);
      //        		d.setVisible(true);
      //        		if (d.ok) {
      //        			appFrame.setTitle("Chunkmapper");
      //        			ViewControlsLayer.singleton.hideAuxiliaryButton();
      //        		}
      //            }

      // Release pressed control
      this.pressedControl = null;
      resetOrbitView(view);
      view.firePropertyChange(AVKey.VIEW, null, view);
    }

    // Keep pressed control highlighted - overrides rollover non currently pressed controls
    if (this.pressedControl != null) {
      this.viewControlsLayer.highlight(this.pressedControl);
      this.wwd.redraw();
    }
  }