Package java.awt.event

Examples of java.awt.event.MouseEvent


                            } else if (key.getKeyCode()==KeyEvent.VK_MINUS) {
                                zoom(-cameraZoom);
                                viewMoved(new CellTransform(viewRot, viewTranslation));
                            }
                        } else if (event instanceof MouseEvent3D) {
                            MouseEvent mouse = (MouseEvent)((MouseEvent3D)event).getAwtEvent();
                            if (mouse instanceof MouseWheelEvent) {
                                int clicks = ((MouseWheelEvent)mouse).getWheelRotation();
                                zoom(-cameraZoom*clicks);
                                viewMoved(new CellTransform(viewRot, viewTranslation));
                            } else if (mouse.isControlDown()) {
                                int diffX = mouse.getX() - mouseX;
                                int diffY = mouse.getY() - mouseY;

                                float scale =  mouse.isShiftDown()? 4f : 16f;

                                elevation += Math.toRadians(diffY)/scale;
                                if (elevation>Math.PI/2)
                                    elevation = (float)Math.PI/2;
                                else if (elevation<-Math.PI/2)
                                    elevation = -(float)Math.PI/2;

                                angle += Math.toRadians(diffX)/scale;
                                if (angle>Math.PI/2)
                                    angle = (float)Math.PI/2;
                                else if (angle<-Math.PI/2)
                                    angle = -(float)Math.PI/2;

                                cameraLook.set((float)Math.sin(angle), (float)Math.sin(elevation), 1);
                                cameraLook.normalize();

                                mouseX = mouse.getX();
                                mouseY = mouse.getY();
                                update(avatarPos, avatarRot);
                            } else {
                                mouseX = mouse.getX();
                                mouseY = mouse.getY();
                            }
                        }
                    }
                   
                    /**
 
View Full Code Here


    * @param event the event attempting to begin a cell edit
    * @return true if cell is ready for editing, false otherwise
    */
    public boolean isCellEditable(EventObject event) {
        if (event instanceof MouseEvent) {
            final MouseEvent me = (MouseEvent) event;

            // we're going to check if the MouseEvent was overtop of the node component
            // and if it was, ask the node component if it wants a cell edit

            // extract information about the location of the click
            final JTable table = (JTable) me.getSource();
            final Point clickPoint = me.getPoint();
            final int row = table.rowAtPoint(clickPoint);
            final int column = table.columnAtPoint(clickPoint);

            // translate the clickPoint to be relative to the rendered component
            final Rectangle cellRect = table.getCellRect(row, column, true);
            clickPoint.translate(-cellRect.x, -cellRect.y);

            // get the rendered component which we will query about the MouseEvent
            final TreeTableCellPanel renderedPanel = TreeTableUtilities.prepareRenderer(me);

            // if the click occurred over the node component
            if (renderedPanel != null && renderedPanel.isPointOverNodeComponent(clickPoint)) {
                // create a new MouseEvent that is translated over the node component
                final Rectangle delegateRendererBounds = renderedPanel.getNodeComponent().getBounds();
                final MouseEvent translatedMouseEvent = new MouseEvent(me.getComponent(), me.getID(), me.getWhen(), me.getModifiers(), me.getX() - delegateRendererBounds.x, me.getY() - delegateRendererBounds.y, me.getClickCount(), me.isPopupTrigger(), me.getButton());

                // allow the actual node editor to decide
                return delegate.isCellEditable(translatedMouseEvent);
            }

View Full Code Here

    public boolean isCellEditable(EventObject e) {
      if (e == null) {
        return true;
      }
      if (e instanceof MouseEvent) {
        MouseEvent me = (MouseEvent) e;
        // If the modifiers are not 0 (or the left mouse button),
        // tree may try and toggle the selection, and table
        // will then try and toggle, resulting in the
        // selection remaining the same. To avoid this, we
        // only dispatch when the modifiers are 0 (or the left mouse
        // button).
        if (me.getModifiers() == 0 || me.getModifiers() == InputEvent.BUTTON1_MASK) {
          for (int counter = getColumnCount() - 1; counter >= 0; counter--) {
            if (getColumnClass(counter) == TreeTableModel.class) {
              MouseEvent newME = new MouseEvent(JTreeTable.this.tree, me.getID(), me.getWhen(), me.getModifiers(), me.getX() - getCellRect(0, counter, true).x, me.getY(), me
                  .getClickCount(), me.isPopupTrigger());
              JTreeTable.this.tree.dispatchEvent(newME);
              break;
            }
          }
View Full Code Here

        x += columnModel.getColumn(column).getWidth() / 2;

        // position the y coordinate half may down the header
        int y = table.getTableHeader().getPreferredSize().height / 2;

        table.getTableHeader().dispatchEvent(new MouseEvent(table, MouseEvent.MOUSE_CLICKED, 0, 0, x, y, 1, false, MouseEvent.BUTTON1));
    }
View Full Code Here

     * Fake a click on the specified column. This is useful for tests where the
     * table has not been layed out on screen and may have invalid dimensions.
     */
    private void clickColumnHeader(JTable table, int column) {
        Rectangle columnHeader = table.getTableHeader().getHeaderRect(column);
        MouseEvent mouseEvent = new MouseEvent(table.getTableHeader(), 0, 0, 0, columnHeader.x, columnHeader.y, 1, false, MouseEvent.BUTTON1);
        MouseListener[] listeners = table.getTableHeader().getMouseListeners();
        for(int i = 0; i < listeners.length; i++) {
            listeners[i].mouseClicked(mouseEvent);
        }
    }
View Full Code Here

                    DataManager.getInstance().getDataContext(component),
                    JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
                    true, null, 10);

            if (inputEvent instanceof MouseEvent) {
                MouseEvent mouseEvent = (MouseEvent) inputEvent;
                popup.showInScreenCoordinates(component, mouseEvent.getLocationOnScreen());
                       
            } else {
                popup.show(component);
            }
View Full Code Here

        @Override
        public void commitEvent(Event event) {
            // Fetch and cast some event objects
            MouseEvent3D mouseEvent = (MouseEvent3D)event;
            MouseEvent awtMouseEvent = (MouseEvent)mouseEvent.getAwtEvent();

            // Figure out where the initial mouse button press happened and
            // store the initial position. We also store the center of the
            // affordance.
            if (event instanceof MouseButtonEvent3D) {
                MouseButtonEvent3D buttonEvent = (MouseButtonEvent3D)event;
                if (buttonEvent.isPressed() &&
                        buttonEvent.getButton() == ButtonId.BUTTON1) {
                   
                    // Figure out where the button press is in screen and world
                    // coordinates. Also fetch the current rotation for cell.
                    MouseEvent awtButtonEvent = (MouseEvent)buttonEvent.getAwtEvent();
                    dragStartScreen = new Point(awtButtonEvent.getX(), awtButtonEvent.getY());
                    dragStartWorld = buttonEvent.getIntersectionPointWorld();
                   
                    // Figure out the world coordinates of the center of the
                    // affordance.
                    Entity entity = event.getEntity();
View Full Code Here

        @Override
        public void commitEvent(Event event) {
            // Fetch and cast some event objects
            MouseEvent3D mouseEvent = (MouseEvent3D)event;
            MouseEvent awtMouseEvent = (MouseEvent)mouseEvent.getAwtEvent();

            // Figure out where the initial mouse button press happened and
            // store the initial position
            if (event instanceof MouseButtonEvent3D) {
                MouseButtonEvent3D buttonEvent = (MouseButtonEvent3D) event;
                if (buttonEvent.isPressed() &&
                        buttonEvent.getButton() == ButtonId.BUTTON1) {
                   
                    // Fetch the initial location of the mouse drag event and
                    // store away the necessary information
                    MouseEvent awtButtonEvent = (MouseEvent) buttonEvent.getAwtEvent();
                    dragStartScreen = new Point(awtButtonEvent.getX(), awtButtonEvent.getY());
                    dragStartWorld = buttonEvent.getIntersectionPointWorld();
                   
                    // Show the position label, make sure we do this in an
                    // AWT Event Thread
                    showPositionLabel(awtMouseEvent);
View Full Code Here

        @Override
        public void commitEvent(Event event) {
            // Fetch and cast some event objects
            MouseEvent3D mouseEvent = (MouseEvent3D)event;
            MouseEvent awtMouseEvent = (MouseEvent)mouseEvent.getAwtEvent();

            // Figure out where the initial mouse button press happened and
            // store the initial position. We also store the center of the
            // affordance.
            if (event instanceof MouseButtonEvent3D) {
                MouseButtonEvent3D be = (MouseButtonEvent3D)event;
                if (be.isPressed() && be.getButton() == ButtonId.BUTTON1) {
                   
                    // Figure out where the button press is in screen and world
                    // coordinates. Also fetch the current rotation for cell.
                    MouseEvent awtButtonEvent = (MouseEvent)be.getAwtEvent();
                    dragStartScreen = new Point(awtButtonEvent.getX(), awtButtonEvent.getY());
                    dragStartWorld = be.getIntersectionPointWorld();

                    // Figure out the world coordinates of the center of the
                    // affordance.
                    Entity entity = event.getEntity();
View Full Code Here

                    } else if (ke.getID()==ke.KEY_RELEASED) {
                        currentPressedKeys.remove(ke.getKeyCode());
                        inputGroup.processKeyEvent(ke); // give the group the event
                    }
                } else if (evt instanceof MouseEvent3D && evt.isFocussed()) {
                    MouseEvent me = (MouseEvent) ((MouseEvent3D)evt).getAwtEvent();
                    inputGroup.processMouseEvent(me); // give the group the event
                }
            }
            events.clear();
        }
View Full Code Here

TOP

Related Classes of java.awt.event.MouseEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.