// Handle dragging of control points public void selected(SelectEvent event) { // Ignore select events if the tools is armed, or in a move/rotate action. In either case we // don't // want to change the currently selected or hightlighted control point. if (measureTool == null || (this.isArmed() && this.isUseRubberBand()) || this.isMoving()) return; if (dragger == null) dragger = new BasicDragger(measureTool.getWwd()); // Have rollover events highlight the rolled-over object. if (event.getEventAction().equals(SelectEvent.ROLLOVER) && !dragger.isDragging()) { this.highlight(event.getTopObject()); this.measureTool.getWwd().redraw(); } this.doSelected(event); // We missed any roll-over events while dragging, so highlight any under the cursor now, // or de-highlight the dragged control point if it's no longer under the cursor. if (event.getEventAction().equals(SelectEvent.DRAG_END)) { PickedObjectList pol = this.measureTool.getWwd().getObjectsAtCurrentPosition(); if (pol != null) { this.highlight(pol.getTopObject()); this.measureTool.getWwd().redraw(); } } }
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())); } }
protected void doSelected(SelectEvent event) { if (this.movingTarget != null) return; if (!event.getEventAction().equals(SelectEvent.DRAG) && !event.getEventAction().equals(SelectEvent.DRAG_END)) return; if (event.getTopObject() == null || !(event.getTopObject() instanceof MeasureTool.ControlPoint) || ((MeasureTool.ControlPoint) event.getTopObject()).getParent() != measureTool) return; // Have drag events drag the selected object. this.dragSelected(event); }
/** * Implementation of WorldWind selection API. * * @param event selection event */ @Override public void selected(SelectEvent event) { // short circuit exit if highlighting is not enabled if (!highlightingEnabled) { return; } if (event.getEventAction().equals(highlightEvent)) { final Object topObject = event.getTopObject(); if (topObject instanceof SurfaceShape) { SurfaceShape shape = (SurfaceShape) topObject; final Object layer = shape.getValue(AVKey.LAYER); if (layer instanceof SurfShapesLayer) { SurfShapesLayer sl = (SurfShapesLayer) layer; if (sl.getName().equals(getName())) { internalHighlight(shape, false); } wwd.redraw(); } } } }
public void selected(SelectEvent event) { // Have rollover events highlight the rolled-over object. if (event.getEventAction().equals(SelectEvent.ROLLOVER) && !this.dragger.isDragging()) { this.highlight(event.getTopObject()); this.wwd.redraw(); } // Drag the selected object. if (event.getEventAction().equals(SelectEvent.DRAG) || event.getEventAction().equals(SelectEvent.DRAG_END)) { this.dragger.selected(event); if (this.dragger.isDragging()) this.wwd.redraw(); } // We missed any roll-over events while dragging, so highlight any under the cursor now. if (event.getEventAction().equals(SelectEvent.DRAG_END)) { PickedObjectList pol = this.wwd.getObjectsAtCurrentPosition(); if (pol != null) { this.highlight(pol.getTopObject()); this.wwd.redraw(); } } }
protected void dragSelected(SelectEvent event) { MeasureTool.ControlPoint point = (MeasureTool.ControlPoint) event.getTopObject(); LatLon lastPosition = point.getPosition(); if (point.getValue(MeasureTool.CONTROL_TYPE_LOCATION_INDEX) != null) lastPosition = measureTool .getPositions() .get((Integer) point.getValue(MeasureTool.CONTROL_TYPE_LOCATION_INDEX)); // Delegate dragging computations to a dragger. this.dragger.selected(event); measureTool.moveControlPoint(point); if (measureTool.isShowAnnotation()) measureTool.updateAnnotation(point.getPosition()); measureTool.firePropertyChange( MeasureTool.EVENT_POSITION_REPLACE, lastPosition, point.getPosition()); measureTool.getWwd().redraw(); }
public void selected(SelectEvent event) { try { if (event.isRollover()) { if (this.lastSelectedObject == event.getTopObject()) return; // same thing selected if (this.lastSelectedObject != null) { this.hideAnnotationPanel(); this.lastSelectedObject = null; } if (event.getTopObject() != null && event.getTopObject() instanceof AVList) { String annoText = ((AVList) event.getTopObject()).getStringValue(Constants.INFO_PANEL_TEXT); if (!WWUtil.isEmpty(annoText)) { this.lastSelectedObject = (AVList) event.getTopObject(); this.showAnnotationPanel(annoText); } } } } catch (Exception e) { // Wrap the handler in a try/catch to keep exceptions from bubbling up Util.getLogger().warning(e.getMessage() != null ? e.getMessage() : e.toString()); } }
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(""); }
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(); } }