⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 awtinputhandler.java

📁 world wind java sdk 源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            if (!mouseEvent.isConsumed())            {                this.viewInputHandler.mousePressed(mouseEvent);            }        }    }    public void mouseReleased(MouseEvent mouseEvent)    {        if (this.wwd == null) // include this test to ensure any derived implementation performs it        {            return;        }        if (mouseEvent == null)        {            return;        }        this.mousePoint = mouseEvent.getPoint();        this.callMouseReleasedListeners(mouseEvent);        if (!mouseEvent.isConsumed())        {            this.viewInputHandler.mouseReleased(mouseEvent);        }        this.doHover(true);        this.cancelDrag();    }    public void mouseEntered(MouseEvent mouseEvent)    {        if (this.wwd == null) // include this test to ensure any derived implementation performs it        {            return;        }        if (mouseEvent == null)        {            return;        }        this.viewInputHandler.mouseEntered(mouseEvent);        this.cancelHover();        this.cancelDrag();    }    public void mouseExited(MouseEvent mouseEvent)    {        if (this.wwd == null) // include this test to ensure any derived implementation performs it        {            return;        }        if (mouseEvent == null)        {            return;        }        this.viewInputHandler.mouseExited(mouseEvent);        this.cancelHover();        this.cancelDrag();    }    public void mouseDragged(MouseEvent mouseEvent)    {        if (this.wwd == null) // include this test to ensure any derived implementation performs it        {            return;        }        if (mouseEvent == null)        {            return;        }        Point prevMousePoint = this.mousePoint;        this.mousePoint = mouseEvent.getPoint();        this.callMouseDraggedListeners(mouseEvent);        if (MouseEvent.BUTTON1_DOWN_MASK == mouseEvent.getModifiersEx())        {            PickedObjectList pickedObjects = this.objectsAtButtonPress;            if (this.isDragging                || (pickedObjects != null && pickedObjects.getTopPickedObject() != null                && !pickedObjects.getTopPickedObject().isTerrain()))            {                this.isDragging = true;                this.callSelectListeners(new DragSelectEvent(this.wwd, SelectEvent.DRAG, mouseEvent, pickedObjects,                    prevMousePoint));            }        }        if (!this.isDragging)        {            if (!mouseEvent.isConsumed())            {                this.viewInputHandler.mouseDragged(mouseEvent);            }        }        // Redraw to update the current position and selection.        if (this.wwd.getSceneController() != null)        {            this.wwd.getSceneController().setPickPoint(mouseEvent.getPoint());            this.wwd.redraw();        }    }    public void mouseMoved(MouseEvent mouseEvent)    {        if (this.wwd == null) // include this test to ensure any derived implementation performs it        {            return;        }        if (mouseEvent == null)        {            return;        }        this.mousePoint = mouseEvent.getPoint();        this.callMouseMovedListeners(mouseEvent);        if (!mouseEvent.isConsumed())        {            this.viewInputHandler.mouseMoved(mouseEvent);        }        // Redraw to update the current position and selection.        if (this.wwd.getSceneController() != null)        {            this.wwd.getSceneController().setPickPoint(mouseEvent.getPoint());            this.wwd.redraw();        }    }    public void mouseWheelMoved(MouseWheelEvent mouseWheelEvent)    {        if (this.wwd == null) // include this test to ensure any derived implementation performs it        {            return;        }        if (mouseWheelEvent == null)        {            return;        }        this.viewInputHandler.mouseWheelMoved(mouseWheelEvent);    }    public void focusGained(FocusEvent focusEvent)    {        if (this.wwd == null) // include this test to ensure any derived implementation performs it        {            return;        }        if (focusEvent == null)        {            return;        }        this.viewInputHandler.focusGained(focusEvent);    }    public void focusLost(FocusEvent focusEvent)    {        if (this.wwd == null) // include this test to ensure any derived implementation performs it        {            return;        }        if (focusEvent == null)        {            return;        }        this.viewInputHandler.focusLost(focusEvent);    }    protected boolean isPickListEmpty(PickedObjectList pickList)    {        return pickList == null || pickList.size() < 1;    }    protected void doHover(boolean reset)    {        PickedObjectList pickedObjects = this.wwd.getObjectsAtCurrentPosition();        if (!(this.isPickListEmpty(this.hoverObjects) || this.isPickListEmpty(pickedObjects)))        {            PickedObject hover = this.hoverObjects.getTopPickedObject();            PickedObject last = pickedObjects.getTopPickedObject();            Object oh = hover == null ? null : hover.getObject() != null ? hover.getObject() :                hover.getParentLayer() != null ? hover.getParentLayer() : null;            Object ol = last == null ? null : last.getObject() != null ? last.getObject() :                last.getParentLayer() != null ? last.getParentLayer() : null;            if (oh != null && ol != null && oh.equals(ol))            {                return; // object picked is the hover object. don't do anything but wait for the timer to expire.            }        }        this.cancelHover();        if (!reset)        {            return;        }        if ((pickedObjects != null)            && (pickedObjects.getTopObject() != null)            && pickedObjects.getTopPickedObject().isTerrain())        {            return;        }        this.hoverObjects = pickedObjects;        this.hoverTimer.restart();    }    private void cancelHover()    {        if (this.isHovering)        {            this.callSelectListeners(new SelectEvent(this.wwd, SelectEvent.HOVER, this.mousePoint, null));        }        this.isHovering = false;        this.hoverObjects = null;        this.hoverTimer.stop();    }    protected boolean pickMatches(PickedObjectList pickedObjects)    {        if (this.isPickListEmpty(this.wwd.getObjectsAtCurrentPosition()) || this.isPickListEmpty(pickedObjects))        {            return false;        }        PickedObject lastTop = this.wwd.getObjectsAtCurrentPosition().getTopPickedObject();        if (null != lastTop && lastTop.isTerrain())        {            return false;        }        PickedObject newTop = pickedObjects.getTopPickedObject();        //noinspection SimplifiableIfStatement        if (lastTop == null || newTop == null || lastTop.getObject() == null || newTop.getObject() == null)        {            return false;        }        return lastTop.getObject().equals(newTop.getObject());    }    protected void cancelDrag()    {        if (this.isDragging)        {            this.callSelectListeners(new DragSelectEvent(this.wwd, SelectEvent.DRAG_END, null,                this.objectsAtButtonPress, this.mousePoint));        }        this.isDragging = false;    }    public void addSelectListener(SelectListener listener)    {        this.eventListeners.add(SelectListener.class, listener);    }    public void removeSelectListener(SelectListener listener)    {        this.eventListeners.remove(SelectListener.class, listener);    }    protected void callSelectListeners(SelectEvent event)    {        for (SelectListener listener : this.eventListeners.getListeners(SelectListener.class))        {            listener.selected(event);        }    }    public void addKeyListener(KeyListener listener)    {        this.eventListeners.add(KeyListener.class, listener);    }    public void removeKeyListener(KeyListener listener)    {        this.eventListeners.remove(KeyListener.class, listener);    }    public void addMouseListener(MouseListener listener)    {        this.eventListeners.add(MouseListener.class, listener);    }    public void removeMouseListener(MouseListener listener)    {        this.eventListeners.remove(MouseListener.class, listener);    }    public void addMouseMotionListener(MouseMotionListener listener)    {        this.eventListeners.add(MouseMotionListener.class, listener);    }    public void removeMouseMotionListener(MouseMotionListener listener)    {        this.eventListeners.remove(MouseMotionListener.class, listener);    }    public void addMouseWheelListener(MouseWheelListener listener)    {        this.eventListeners.add(MouseWheelListener.class, listener);    }    public void removeMouseWheelListener(MouseWheelListener listener)    {        this.eventListeners.remove(MouseWheelListener.class, listener);    }    protected void callKeyPressedListeners(KeyEvent event)    {        for (KeyListener listener : this.eventListeners.getListeners(KeyListener.class))        {            listener.keyPressed(event);        }    }    protected void callKeyReleasedListeners(KeyEvent event)    {        for (KeyListener listener : this.eventListeners.getListeners(KeyListener.class))        {            listener.keyReleased(event);        }    }    protected void callKeyTypedListeners(KeyEvent event)    {        for (KeyListener listener : this.eventListeners.getListeners(KeyListener.class))        {            listener.keyTyped(event);        }    }    protected void callMousePressedListeners(MouseEvent event)    {        for (MouseListener listener : this.eventListeners.getListeners(MouseListener.class))        {            listener.mousePressed(event);        }    }    protected void callMouseReleasedListeners(MouseEvent event)    {        for (MouseListener listener : this.eventListeners.getListeners(MouseListener.class))        {            listener.mouseReleased(event);        }    }    protected void callMouseClickedListeners(MouseEvent event)    {        for (MouseListener listener : this.eventListeners.getListeners(MouseListener.class))        {            listener.mouseClicked(event);        }    }    protected void callMouseDraggedListeners(MouseEvent event)    {        for (MouseMotionListener listener : this.eventListeners.getListeners(MouseMotionListener.class))        {            listener.mouseDragged(event);        }    }    protected void callMouseMovedListeners(MouseEvent event)    {        for (MouseMotionListener listener : this.eventListeners.getListeners(MouseMotionListener.class))        {            listener.mouseMoved(event);        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -