Example usage for java.awt.event MouseEvent BUTTON3

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

Introduction

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

Prototype

int BUTTON3

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

Click Source Link

Document

Indicates mouse button #3; used by #getButton .

Usage

From source file:ec.ui.view.StabilityView.java

public StabilityView() {
    super();/*from   w  w w  .  jav  a2  s.  c om*/
    setLayout(new BorderLayout());

    this.graphs_ = new LinkedHashMap<>();

    meanRenderer = new XYLineAndShapeRenderer(true, false);
    meanRenderer.setAutoPopulateSeriesPaint(false);
    meanRenderer.setBasePaint(themeSupport.getLineColor(KnownColor.RED));

    pointsRenderer = new XYLineAndShapeRenderer(false, true);
    pointsRenderer.setAutoPopulateSeriesPaint(false);
    pointsRenderer.setAutoPopulateSeriesShape(false);
    pointsRenderer.setBaseShape(new Ellipse2D.Double(-2, -2, 4, 4));
    pointsRenderer.setBasePaint(themeSupport.getLineColor(KnownColor.BLUE));
    pointsRenderer.setBaseShapesFilled(false);

    smoothRenderer = new XYLineAndShapeRenderer(true, false);
    smoothRenderer.setAutoPopulateSeriesPaint(false);
    smoothRenderer.setBasePaint(themeSupport.getLineColor(KnownColor.GREEN));

    mainChart = createChart();
    detailChart = createChart();

    panel = new JChartPanel(null);

    errorPanel = new JPanel(new BorderLayout());
    errorLabel = new JLabel();
    errorLabel.setHorizontalAlignment(SwingConstants.CENTER);
    errorLabel.setFont(errorLabel.getFont().deriveFont(errorLabel.getFont().getSize2D() * 3 / 2));
    errorPanel.add(errorLabel, BorderLayout.CENTER);

    panel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            indexSelected = -1;
            if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
                double x = panel.getChartX(e.getX());
                Graphs g = null;
                for (Bornes b : graphs_.keySet()) {
                    indexSelected++;
                    if (x >= b.min_ && x <= b.max_) {
                        g = graphs_.get(b);
                        break;
                    }
                }
                if (g == null) {
                    return;
                }

                showDetail(g);
            } else if (e.getButton() == MouseEvent.BUTTON3) {
                showMain();
                indexSelected = -1;
            }
        }
    });

    StandardXYToolTipGenerator generator = new StandardXYToolTipGenerator() {
        final DecimalFormat format = new DecimalFormat("0.0000");

        @Override
        public String generateToolTip(XYDataset dataset, int series, int item) {
            try {
                StabilityViewItem i = items.get(indexSelected == -1 ? series : indexSelected);
                int cpt = 0;
                for (Map.Entry<TsDomain, Double> e : i.data.entrySet()) {
                    if (cpt == item) {
                        TsDomain dom = e.getKey();
                        return "(" + dom.getStart().toString() + ", " + dom.getEnd().toString() + ") : "
                                + format.format(e.getValue());
                    }
                    cpt++;
                }
            } catch (IndexOutOfBoundsException e) {
            }
            return null;
        }
    };
    pointsRenderer.setBaseToolTipGenerator(generator);
    cards = new JPanel(new CardLayout());

    cards.add(MAIN_PANEL, panel);

    cards.add(ERROR_PANEL, errorPanel);

    add(cards, BorderLayout.CENTER);

    onColorSchemeChange();
}

From source file:org.eknet.neoswing.view.DefaultVisualizationViewFactory.java

protected void addMousePlugins(DefaultModalGraphMouse<Vertex, Edge> plugin, GraphModel graphModel) {
    plugin.add(new NodePopupMenu(MouseEvent.BUTTON3));
    plugin.add(new NavigateNodeMousePlugin(graphModel));
}

From source file:org.fhcrc.cpl.viewer.mrm.utilities.MRMerMouseListener.java

public void mouseReleased(MouseEvent e) {
    try {/*from w w  w .  j av a 2 s  .  c  om*/
        if ((e.isShiftDown() || e.getButton() == MouseEvent.BUTTON3) || shifted) {
            //            Rectangle2D scaledDataArea = _chartPanel.getScreenDataArea(
            //                    (int) this.coElutionStart.getX(), (int) this.coElutionStart.getY());
            JFreeChart jfc = _cp.getChart();
            XYPlot p = jfc.getXYPlot();
            CenterZoomNumberAxis czna = (CenterZoomNumberAxis) p.getDomainAxis();
            Rectangle2D screenDataArea = _cp.getScreenDataArea(e.getX(), e.getY());
            Rectangle2D plotboundaries = _cp.getChartRenderingInfo().getPlotInfo().getPlotArea();

            double leftmostOnAxis = czna.getLowerBound();
            double rightmostOnAxis = czna.getUpperBound();
            double leftmostOnRange = this.coElutionRegion.getX();
            double rightmostOnRange = this.coElutionRegion.getX() + this.coElutionRegion.getWidth();
            double leftmostonscreen = screenDataArea.getX();
            double rightmostonscreen = leftmostonscreen + screenDataArea.getWidth();
            double slope = (rightmostOnAxis - leftmostOnAxis) / (rightmostonscreen - leftmostonscreen);
            double transformedLeftRange = (slope * (leftmostOnRange - leftmostonscreen)) + leftmostOnAxis;
            double transformedRightRange = (slope * (rightmostOnRange - leftmostonscreen)) + leftmostOnAxis;
            shifted = false;
            MRMDialog ultimateParent = (MRMDialog) MRMAncestor();
            if (ultimateParent != null) {
                MRMTransition transition = ultimateParent.transitionOnPlot;
                MRMTransition mrmt = transition;
                if (mrmt != null) {
                    int row = mrmt.getTableRow();
                    _ptm.data[row][MRMDialog.peaksData.CoStart.colno] = new Float(0f);
                    _ptm.data[row][MRMDialog.peaksData.CoEnd.colno] = new Float(10000000f);
                    _ptm.setValueAt(new Float(transformedRightRange), row, MRMDialog.peaksData.CoEnd.colno);
                    _ptm.setValueAt(new Float(transformedLeftRange), row, MRMDialog.peaksData.CoStart.colno);
                }
            }
            Graphics2D g2 = (Graphics2D) _cp.getGraphics();
            if (this.coElutionRegion != null)
                drawCoElutionRegion(g2);
            this.coElutionRegion = null;
            this.coElutionStart = null;
        } else {
            _cp.mouseReleased(e);
        }
    } catch (Exception ee) {
    }
}

From source file:dbseer.gui.panel.DBSeerExplainChartPanel.java

@Override
public void mouseDragged(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON3 || this.popupMenu.isShowing()) {
        return;// w w  w. ja v  a2  s .c om
    }
    endX = e.getX();
    endY = e.getY();
    Graphics2D g2 = (Graphics2D) this.getGraphics();
    //      drawSelectRectangle(g2);
    double xmin = Math.min(startX, endX);
    double ymin = Math.min(startY, endY);
    double xmax = Math.max(startX, endX);
    double ymax = Math.max(startY, endY);
    //      this.selectRectangle = new Rectangle2D.Double(
    //            xmin, ymin,
    //            xmax - xmin, ymax - ymin);
    this.x = xmin;
    this.y = ymin;
    this.width = xmax - xmin;
    this.height = ymax - ymin;
    //      drawSelectRectangle(g2);
    //      g2.dispose();

    this.isNewRectangle = false;
    repaint();
}

From source file:playground.sergioo.facilitiesGenerator2012.gui.ClustersPanel.java

@Override
public void mouseClicked(MouseEvent e) {
    double[] p = getWorld(e.getX(), e.getY());
    if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON3)
        camera.centerCamera(p);/*from   www  . j  a  v  a  2 s  .c  o m*/
    else {
        if (window.getOption().equals(Options.ZOOM) && e.getButton() == MouseEvent.BUTTON1)
            camera.zoomIn(p[0], p[1]);
        else if (window.getOption().equals(Options.ZOOM) && e.getButton() == MouseEvent.BUTTON3)
            camera.zoomOut(p[0], p[1]);
    }
    repaint();
}

From source file:org.dodjsoft.tail.TailTopComponent.java

void showContextMenu(MouseEvent evt, TailFilePanel pane) {
    if (evt.getButton() == MouseEvent.BUTTON3) {
        contextMenu.setCurrentPane(pane);
        contextMenu.show(this, evt.getX(), evt.getY());
    }//from w  w w .j  a  v a 2s  . com
}

From source file:pt.lsts.neptus.util.logdownload.LogsDownloaderWorkerUtil.java

/**
 * Creates a {@link MouseListener} to open the selected log folder in MRA.
 * //www  .j a v  a 2  s. c  o  m
 * @param worker
 * @param logFolderList
 * @return
 */
static MouseAdapter createOpenLogInMRAMouseListener(LogsDownloaderWorker worker,
        LogFolderInfoList logFolderList) {
    return new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
                // Test if log can be opened in MRA, and open it

                final String baseFxPath = worker.getDirBaseToStoreFiles() + "/" + worker.getLogLabel() + "/"
                        + logFolderList.getSelectedValue() + "/";
                File logFolder = new File(baseFxPath);
                LogValidity isLogOkForOpening = LogUtils.isValidLSFSource(logFolder);

                JPopupMenu popup = new JPopupMenu();
                JMenuItem jm = popup.add(I18n.text("Open this log in MRA"));
                if (isLogOkForOpening == LogValidity.VALID) {
                    File log = LogUtils.getValidLogFileFromLogFolder(logFolder);
                    jm.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            Thread t = new Thread(
                                    LogsDownloaderWorker.class.getSimpleName() + " :: MRA Openner") {
                                public void run() {
                                    JFrame mra = new NeptusMRA();
                                    mra.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

                                    ((NeptusMRA) mra).getMraFilesHandler().openLog(log);
                                };
                            };
                            t.setDaemon(true);
                            t.start();
                        }
                    });
                } else {
                    jm.setEnabled(false);
                }

                popup.show((Component) e.getSource(), e.getX(), e.getY());
            }
        }
    };
}

From source file:org.orbisgis.core.ui.plugins.views.geocatalog.Catalog.java

public Catalog() {
    menuTree = new org.orbisgis.core.ui.pluginSystem.menu.MenuTree();
    lstSources = new OGList();
    lstSources.addMouseListener(new MouseAdapter() {

        @Override//from   www.  jav  a 2  s. com
        public void mousePressed(MouseEvent e) {
            showPopup(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            showPopup(e);
        }

        private void showPopup(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
                int path = -1;
                for (int i = 0; i < listModel.getSize(); i++) {
                    if (lstSources.getCellBounds(i, i).contains(e.getPoint())) {
                        path = i;
                        break;
                    }
                }
                int[] selectionPaths = lstSources.getSelectedIndices();
                if ((selectionPaths != null) && (path != -1)) {
                    if (!CollectionUtils.contains(selectionPaths, path)) {
                        if (e.isControlDown()) {
                            lstSources.addSelectionInterval(path, path);
                        } else {
                            lstSources.setSelectionInterval(path, path);
                        }
                    }
                } else if (path == -1) {
                    lstSources.clearSelection();
                } else {
                }
            }
            if (e.isPopupTrigger()) {
                JPopupMenu popup = getPopup();
                if (popup != null) {
                    popup.show(e.getComponent(), e.getX(), e.getY());
                }
            }
        }
    });
    listModel = new SourceListModel();
    lstSources.setModel(listModel);

    this.setLayout(new BorderLayout());
    this.add(new JScrollPane(lstSources), BorderLayout.CENTER);
    this.add(getNorthPanel(), BorderLayout.NORTH);
    SourceListRenderer cellRenderer = new SourceListRenderer(this);
    cellRenderer.setRenderers(new SourceRenderer[0]);
    lstSources.setCellRenderer(cellRenderer);

    dragSource = DragSource.getDefaultDragSource();
    dragSource.createDefaultDragGestureRecognizer(lstSources, DnDConstants.ACTION_COPY_OR_MOVE, this);
    editingSources = new HashMap<String, EditableSource>();

    //Init the file drop system
    FileDrop fileDrop = new FileDrop(this, new FileDrop.Listener() {

        @Override
        public void filesDropped(java.io.File[] files) {
            DataManager dm = (DataManager) Services.getService(DataManager.class);
            SourceManager sourceManager = dm.getSourceManager();
            for (File file : files) {
                // For each file, we ensure that we have a driver
                // that can be used to read it. If we don't, we don't
                // open the file.
                if (OrbisConfiguration.isFileEligible(file)) {
                    try {
                        String name = sourceManager
                                .getUniqueName(FilenameUtils.removeExtension(file.getName()));
                        sourceManager.register(name, file);
                    } catch (SourceAlreadyExistsException e) {
                        ErrorMessages.error(ErrorMessages.SourceAlreadyRegistered + ": ", e);
                    }
                }
            }

        }
    });

}

From source file:playground.sergioo.workplaceCapacities2012.gui.ClustersPanel.java

@Override
public void mouseClicked(MouseEvent e) {
    this.requestFocus();
    double[] p = getWorld(e.getX(), e.getY());
    if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON3)
        camera.centerCamera(p);/* w  ww  .  j ava 2 s.co m*/
    else {
        if (window.getOption().equals(Option.ZOOM) && e.getButton() == MouseEvent.BUTTON1)
            camera.zoomIn(p[0], p[1]);
        else if (window.getOption().equals(Option.ZOOM) && e.getButton() == MouseEvent.BUTTON3)
            camera.zoomOut(p[0], p[1]);
    }
    repaint();
}

From source file:com.igormaznitsa.jhexed.swing.editor.ui.tooloptions.LayerValueIconList.java

protected void processMouseClick(final HexButton source, final MouseEvent evt) {
    if ((evt.getModifiersEx() & (MouseEvent.CTRL_DOWN_MASK | MouseEvent.SHIFT_DOWN_MASK)) != 0) {
        if ((evt.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0) {
            this.selectionModel.addSelectionInterval(source.value.getIndex(), source.value.getIndex());
        } else {/*from  w w  w  .  ja v  a2  s . c o  m*/
            final int selIndex = source.value.getIndex();
            final int minindex = Math.min(selIndex, this.selectionModel.getMinSelectionIndex());
            final int maxindex = Math.max(selIndex, this.selectionModel.getMaxSelectionIndex());
            this.selectionModel.setSelectionInterval(Math.max(0, minindex), Math.max(0, maxindex));
        }
    } else {
        this.selectionModel.setSelectionInterval(source.value.getIndex(), source.value.getIndex());
    }

    switch (evt.getButton()) {
    case MouseEvent.BUTTON1: {
        for (final LayerIconListListener l : this.listeners) {
            l.onLeftClick(source.getHexValue(), source.getHexIcon());
        }
    }
        break;
    case MouseEvent.BUTTON3: {
        for (final LayerIconListListener l : this.listeners) {
            l.onRightClick(source.getHexValue(), source.getHexIcon());
        }
    }
        break;
    }
}