当前位置: 首页>>代码示例>>Java>>正文


Java SelectEvent.getMouseEvent方法代码示例

本文整理汇总了Java中gov.nasa.worldwind.event.SelectEvent.getMouseEvent方法的典型用法代码示例。如果您正苦于以下问题:Java SelectEvent.getMouseEvent方法的具体用法?Java SelectEvent.getMouseEvent怎么用?Java SelectEvent.getMouseEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gov.nasa.worldwind.event.SelectEvent的用法示例。


在下文中一共展示了SelectEvent.getMouseEvent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: selected

import gov.nasa.worldwind.event.SelectEvent; //导入方法依赖的package包/类
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)))
    {
        // 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))
    {
        // Release pressed control

        if (pressedControl != null)
            event.consume();

        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();
    }
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:82,代码来源:ViewControlsSelectListener.java

示例2: selected

import gov.nasa.worldwind.event.SelectEvent; //导入方法依赖的package包/类
/**
	 * This listener is set in set {@link #setupWWSelectionListener(boolean)}
	 * <p>
	 * {@inheritDoc}
	 * 
	 * @see gov.nasa.worldwind.event.SelectListener#selected(gov.nasa.worldwind.event.SelectEvent)
	 */
	@Override
	public void selected(final SelectEvent event) {

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

		final String eventAction = event.getEventAction();

//		System.out.println(UI.timeStampNano() + " [" + getClass().getSimpleName() + "] \teventAction: " + eventAction);
//		// TODO remove SYSTEM.OUT.PRINTLN

		if (Map3Manager.getMap3View().isContextMenuVisible()) {

			// prevent actions when context menu is visible

			return;
		}

		if (eventAction == SelectEvent.HOVER) {

			// not yet used

		} else if (eventAction == SelectEvent.RIGHT_PRESS) {

			/**
			 * When the context menu should be displayed and the right mouse button is pressed,
			 * first a SelectEvent.HOVER is fired before SelectEvent.RIGHT_PRESS is fired. Therefor
			 * the context state must be set here.
			 * <p>
			 * The context menu is opened with a ww mouse listener in Map3View.
			 */

//			map3View.setContextMenuVisible(true);

		} else {

			// get hovered object
			final PickedObject pickedObject = event.getTopPickedObject();

			ITrackPath hoveredTrackPath = null;
			Integer hoveredPositionIndex = null;

			if (pickedObject != null && pickedObject.getObject() instanceof ITrackPath) {

				hoveredTrackPath = (ITrackPath) pickedObject.getObject();

				final Object pickOrdinal = pickedObject.getValue(AVKey.ORDINAL);
				hoveredPositionIndex = (Integer) pickOrdinal;
			}

			selectTrackPath(hoveredTrackPath, hoveredPositionIndex, eventAction, true);
		}
	}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:62,代码来源:TourTrackLayer.java


注:本文中的gov.nasa.worldwind.event.SelectEvent.getMouseEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。