Example usage for java.awt.event MouseEvent BUTTON1

List of usage examples for java.awt.event MouseEvent BUTTON1

Introduction

In this page you can find the example usage for java.awt.event MouseEvent BUTTON1.

Prototype

int BUTTON1

To view the source code for java.awt.event MouseEvent BUTTON1.

Click Source Link

Document

Indicates mouse button #1; used by #getButton .

Usage

From source file:org.squidy.nodes.GestureRecognizerShake.java

public void gestureReceived(GestureEvent event) {
    // DataGesture dataGesture = null;
    DataString dataString = null;//w ww .j a  va2s . co  m

    DataKey dataKeyUp = null;
    DataKey dataKeyDown = null;
    DataButton dataButtonUp = null;
    DataButton dataButtonDown = null;
    if (event.isValid() && event.getProbability() > 0.8) {
        if (gesturesLoaded.containsKey(event.getId())) {
            System.out.println("New Gesture Event \"" + gesturesLoaded.get(event.getId()).getGesture()
                    + "\" with ID " + event.getId() + " and Probability " + event.getProbability()
                    + " from Source " + event.getSource());
            String gesture = gesturesLoaded.get(event.getId()).getGesture();
            if (gesture.contains("right")) {
                dataKeyUp = new DataKey(GestureRecognizerShake.class, KeyEvent.VK_RIGHT, true);
                dataKeyDown = new DataKey(GestureRecognizerShake.class, KeyEvent.VK_RIGHT, false);
                dataButtonUp = new DataButton(GestureRecognizerShake.class, MouseEvent.BUTTON1, true);
                dataButtonUp = new DataButton(GestureRecognizerShake.class, MouseEvent.BUTTON1, false);
            } else if (gesture.contains("left")) {
                dataKeyUp = new DataKey(GestureRecognizerShake.class, KeyEvent.VK_LEFT, true);
                dataKeyDown = new DataKey(GestureRecognizerShake.class, KeyEvent.VK_LEFT, false);
            } else if (gesture.contains("circle")) {
                dataKeyUp = new DataKey(GestureRecognizerShake.class, KeyEvent.VK_F5, true);
                dataKeyDown = new DataKey(GestureRecognizerShake.class, KeyEvent.VK_F5, false);
            }
            dataString = new DataString(GestureRecognizerShake.class,
                    gesturesLoaded.get(event.getId()).getGesture());
        } else {
            LOG.info("New Gesture Event (not loaded) with ID " + event.getId() + " and Probability "
                    + event.getProbability() + " from Source " + event.getSource());

            dataString = new DataString(GestureRecognizerShake.class,
                    gesturesLoaded.get(event.getId()).getGesture());
        }
        dataString.setAttribute(DataConstant.SESSION_ID, event.getId());

        if (dataString != null)
            publish(dataString);
        if (dataKeyUp != null)
            publish(dataKeyUp);
        if (dataKeyDown != null)
            publish(dataKeyDown);
    }
}

From source file:org.talend.dataprofiler.chart.TOPChartService.java

@Override
public void addMouseListenerForConceptChart(Object chartComposite, final Map<String, Object> actionMap) {
    final ChartComposite chartComp = (ChartComposite) chartComposite;
    final ChartMouseListener listener = new ChartMouseListener() {

        @Override//from ww  w  .j av a 2 s.co m
        public void chartMouseClicked(ChartMouseEvent event) {
            boolean flag = event.getTrigger().getButton() == MouseEvent.BUTTON1;
            chartComp.setDomainZoomable(flag);
            chartComp.setRangeZoomable(flag);
            if (!flag) {
                return;
            }

            ChartEntity chartEntity = event.getEntity();
            if (chartEntity != null && chartEntity instanceof CategoryItemEntity) {
                CategoryItemEntity cateEntity = (CategoryItemEntity) chartEntity;
                // highlight current selected bar
                Plot plot = event.getChart().getPlot();
                if (plot != null) {
                    // ((CategoryPlot) plot).getRenderer().setSeriesPaint(cateEntity.getSeries(), Green);
                    CustomConceptRenderer render = new CustomConceptRenderer(cateEntity.getCategoryIndex());
                    render.setShadowVisible(false);
                    render.setDrawBarOutline(false);
                    ((CategoryPlot) plot).setRenderer(render);
                    // ChartDecorator.decorateConceptChart(event.getChart(), PlotOrientation.HORIZONTAL);

                }
                Object action = getCurrentAction(cateEntity);
                Class<? extends Object> actionClass = action.getClass();
                try {
                    Method actionRunMethod = actionClass.getDeclaredMethod("run"); //$NON-NLS-1$
                    actionRunMethod.invoke(action);

                } catch (NoSuchMethodException e) {
                    log.error(e, e);
                } catch (SecurityException e) {
                    log.error(e, e);
                } catch (IllegalAccessException e) {
                    log.error(e, e);
                } catch (IllegalArgumentException e) {
                    log.error(e, e);
                } catch (InvocationTargetException e) {
                    log.error(e, e);
                }

            }
        }

        private Object getCurrentAction(CategoryItemEntity cateEntity) {
            return findCurrentAction(cateEntity.getColumnKey(), cateEntity.getRowKey());
        }

        /**
         * Find current action
         * 
         * @param firstKey
         * @param secondKey
         * @return
         */
        private Object findCurrentAction(final Object firstKey, Object secondKey) {
            Object action = actionMap.get(firstKey);
            if (action != null) {
                return action;
            }
            action = actionMap.get(secondKey);
            if (action != null) {
                return action;
            }
            return null;
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            // no action here

        }

    };
    chartComp.addChartMouseListener(listener);
    chartComp.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            chartComp.removeChartMouseListener(listener);
            chartComp.dispose();
        }

    });
}

From source file:org.squidy.nodes.MouseIO.java

/**
 * @param dataButton/*from w ww .  ja va  2 s.  co  m*/
 * @return
 */
public IData process(DataButton dataButton) {
    if (dataButton.getButtonType() == DataButton.BUTTON_1) {
        setMouseStatus(MouseEvent.BUTTON1, dataButton.getFlag());
    }
    if (dataButton.getButtonType() == DataButton.BUTTON_2) {
        if (middleDoubleClick) {
            setMouseStatus(MouseEvent.BUTTON1, true);
            setMouseStatus(MouseEvent.BUTTON1, false);
            setMouseStatus(MouseEvent.BUTTON1, true);
            setMouseStatus(MouseEvent.BUTTON1, false);
        } else {
            setMouseStatus(MouseEvent.BUTTON2, dataButton.getFlag());
        }
    }
    if (dataButton.getButtonType() == DataButton.BUTTON_3) {
        setMouseStatus(MouseEvent.BUTTON3, dataButton.getFlag());
        // if (dataButton.getFlag()) {
        // setSingleMousePress(DataButton.BUTTON_3);
        // }
    }

    return dataButton;
}

From source file:net.sf.mzmine.modules.visualization.tic.TICPlot.java

@Override
public void mouseClicked(final MouseEvent event) {

    // Let the parent handle the event (selection etc.)
    super.mouseClicked(event);

    // Request focus to receive key events.
    requestFocus();/*from  w ww.j av a 2  s.c  om*/

    // If user double-clicked left button, place a request to open a spectrum.
    if (event.getButton() == MouseEvent.BUTTON1 && event.getClickCount() == 2) {

        showSpectrumRequest = true;
    }
}

From source file:es.udc.fic.medregatas.view.MainAppjFrame.java

private void regatasListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_regatasListMouseClicked

    if (evt.getButton() == MouseEvent.BUTTON1) {
        selectedRegata = (Regata) regatasList.getSelectedValue();
        jLabelTitle.setText(selectedRegata.toString());
        loadTabs();/* www. j  ava 2 s  . c  o m*/
    }
}

From source file:net.sf.mzmine.desktop.impl.projecttree.ProjectTreeMouseHandler.java

public void mouseClicked(MouseEvent e) {

    if (e.isPopupTrigger())
        handlePopupTriggerEvent(e);/*  w  ww.j a  v a2  s .co m*/

    if ((e.getClickCount() == 2) && (e.getButton() == MouseEvent.BUTTON1))
        handleDoubleClickEvent(e);

}

From source file:org.accada.hal.impl.sim.multi.GraphicSimulatorServer.java

/**
 * creates the layered pane if it does not already exists
 * //  w  w w.  ja  v  a  2s  .c  om
 * @return layered pane
 */
private JLayeredPane getJLayeredPane() {
    if (jLayeredPane == null) {
        jLayeredPane = new JLayeredPane();
        jLayeredPane.setLayout(null);
        jLayeredPane.setOpaque(true);
        jLayeredPane.setBackground(Color.WHITE);
        //jLayeredPane.add(getReader(), new Integer(0));

        // add readers
        createReaders(controller.getReaderIds());

        // add context menu
        jLayeredPane.add(getContextMenu());

        // add mouse listener
        jLayeredPane.addMouseListener(new MouseAdapter() {

            // context menu
            public void mouseReleased(MouseEvent e) {
                hideActiveContextMenuAndSelection();
                if (e.getButton() == MouseEvent.BUTTON3) {
                    Point posOnScreen = getJLayeredPane().getLocationOnScreen();
                    contextMenu.setLocation(posOnScreen.x + e.getX(), posOnScreen.y + e.getY());
                    contextMenu.setVisible(true);
                    setActiveContextMenu(contextMenu);
                } else {
                    contextMenu.setVisible(false);
                    if (e.getButton() == MouseEvent.BUTTON1) {
                        selection.select(tags);
                    }
                }
            }

            // selection
            public void mousePressed(final MouseEvent e) {
                hideActiveContextMenuAndSelection();
                if (e.getButton() == MouseEvent.BUTTON1) {
                    selection.setBounds(0, 0, getProperty("WindowWidth"), getProperty("WindowHeight"));
                    selection.setStartPoint(e.getPoint());
                    jLayeredPane.add(selection, new Integer(2));
                }
            }
        });

        // add drag listener
        jLayeredPane.addMouseMotionListener(new MouseMotionAdapter() {
            public void mouseDragged(MouseEvent e) {
                if (selection.isActive()) {
                    selection.setCurrentPoint(e.getPoint());
                }
            }
        });
    }
    return jLayeredPane;
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopTree.java

@Override
public void setItemClickAction(Action action) {
    if (this.doubleClickAction != action) {
        if (action != null) {
            if (itemClickListener == null) {
                itemClickListener = new MouseAdapter() {
                    @Override//from w  w  w  .ja v  a 2  s. c om
                    public void mouseClicked(MouseEvent e) {
                        if (isEditable()) {
                            if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2
                                    && doubleClickAction != null) {

                                int rowForLocation = impl.getRowForLocation(e.getX(), e.getY());
                                TreePath pathForLocation = impl.getPathForRow(rowForLocation);

                                if (pathForLocation != null) {
                                    impl.setSelectionPath(pathForLocation);

                                    doubleClickAction.actionPerform(DesktopTree.this);
                                }
                            }
                        }
                    }
                };
                impl.addMouseListener(itemClickListener);
                impl.setToggleClickCount(0);
            }
        } else {
            impl.removeMouseListener(itemClickListener);
            impl.setToggleClickCount(2);
            itemClickListener = null;
        }
        this.doubleClickAction = action;
    }
}

From source file:org.accada.reader.hal.impl.sim.GraphicSimulator.java

/**
 * creates the layered pane if it does not already exists
 * /*w w w .  j a v  a 2 s  .co  m*/
 * @return layered pane
 */
private JLayeredPane getJLayeredPane() {
    if (jLayeredPane == null) {
        jLayeredPane = new JLayeredPane();
        jLayeredPane.setLayout(null);
        jLayeredPane.setOpaque(true);
        jLayeredPane.setBackground(Color.WHITE);
        jLayeredPane.add(getReader(), new Integer(0));

        // add antennas
        String[] antennaIds = null;
        try {
            antennaIds = controller.getReadPointNames();
        } catch (HardwareException ignored) {
        }
        for (int i = 0; i < antennaIds.length; i++) {
            createNewAntenna(antennaIds[i]);
        }
        jLayeredPane.add(getContextMenu());
        jLayeredPane.add(getMgmtSimMenu());

        // add mouse listener
        jLayeredPane.addMouseListener(new MouseAdapter() {

            // context menu
            public void mouseReleased(MouseEvent e) {
                hideActiveContextMenuAndSelection();
                if (e.getButton() == MouseEvent.BUTTON3) {
                    Point posOnScreen = getJLayeredPane().getLocationOnScreen();
                    contextMenu.setLocation(posOnScreen.x + e.getX(), posOnScreen.y + e.getY());
                    contextMenu.setVisible(true);
                    mgmtSimMenu.setVisible(false);
                    setActiveContextMenu(contextMenu);
                } else {
                    contextMenu.setVisible(false);
                    mgmtSimMenu.setVisible(false);
                    if (e.getButton() == MouseEvent.BUTTON1) {
                        selection.select(tags);
                    }
                }
            }

            // selection
            public void mousePressed(final MouseEvent e) {
                hideActiveContextMenuAndSelection();
                if (e.getButton() == MouseEvent.BUTTON1) {
                    selection.setBounds(0, 0, getProperty("WindowWidth"), getProperty("WindowHeight"));
                    selection.setStartPoint(e.getPoint());
                    jLayeredPane.add(selection, new Integer(2));
                }
            }
        });

        // add drag listener
        jLayeredPane.addMouseMotionListener(new MouseMotionAdapter() {
            public void mouseDragged(MouseEvent e) {
                if (selection.isActive()) {
                    selection.setCurrentPoint(e.getPoint());
                }
            }
        });
    }
    return jLayeredPane;
}

From source file:Filter3dTest.java

/**
 * Gets the mouse code for the button specified in this MouseEvent.
 */// w  ww .j  a  va 2  s. c  o  m
public static int getMouseButtonCode(MouseEvent e) {
    switch (e.getButton()) {
    case MouseEvent.BUTTON1:
        return MOUSE_BUTTON_1;
    case MouseEvent.BUTTON2:
        return MOUSE_BUTTON_2;
    case MouseEvent.BUTTON3:
        return MOUSE_BUTTON_3;
    default:
        return -1;
    }
}