Example usage for java.awt.event MouseEvent getX

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

Introduction

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

Prototype

public int getX() 

Source Link

Document

Returns the horizontal x position of the event relative to the source component.

Usage

From source file:userinterface.properties.GUIGraphHandler.java

private void popUpTriggered(MouseEvent e) {
    if (e.getSource() == theTabs)//just show the background popup
    {//from   w ww .  ja va 2s  .co m
        int index = theTabs.indexAtLocation(e.getX(), e.getY());
        if (index != -1) {
            graphOptions.setEnabled(true);
            zoomMenu.setEnabled(true);

            exportMenu.setEnabled(true);
            importMenu.setEnabled(true);

            printGraph.setEnabled(true);
            deleteGraph.setEnabled(true);

            theTabs.setSelectedIndex(index);

            this.graphMenu.show(theTabs, e.getX(), e.getY());
        } else {
            graphOptions.setEnabled(false);
            zoomMenu.setEnabled(false);

            exportMenu.setEnabled(false);
            importMenu.setEnabled(true);

            printGraph.setEnabled(false);
            deleteGraph.setEnabled(false);

            this.graphMenu.show(theTabs, e.getX(), e.getY());
        }
        return;
    }

    for (int i = 0; i < models.size(); i++) {

        if (e.getSource() == models.get(i)) {

            graphOptions.setEnabled(true);
            zoomMenu.setEnabled(true);

            exportMenu.setEnabled(true);
            importMenu.setEnabled(true);

            printGraph.setEnabled(true);
            deleteGraph.setEnabled(true);

            exportImageEPS.setEnabled(true);
            exportMatlab.setEnabled(getModel(i) instanceof Graph);
            exportXML.setEnabled(getModel(i) instanceof Graph);

            theTabs.setSelectedIndex(i);
            this.graphMenu.show(models.get(i), e.getX(), e.getY());
            return;
        }
    }
}

From source file:org.jax.maanova.fit.gui.ResidualPlotPanel.java

private void mouseMoved(MouseEvent e) {
    if (this.showTooltip) {
        Point2D chartPoint = this.chartPanel.toChartPoint(e.getPoint());

        // find the nearest probe
        XYProbeData[] xyProbeData = this.getXYData();
        double nearestDistance = Double.POSITIVE_INFINITY;
        int nearestArrayIndex = -1;
        int nearestDotIndex = -1;
        for (int arrayIndex = 0; arrayIndex < xyProbeData.length; arrayIndex++) {
            double[] currXData = xyProbeData[arrayIndex].getXData();
            double[] currYData = xyProbeData[arrayIndex].getYData();
            for (int dotIndex = 0; dotIndex < currXData.length; dotIndex++) {
                double currDist = chartPoint.distanceSq(currXData[dotIndex], currYData[dotIndex]);
                if (currDist < nearestDistance) {
                    nearestDistance = currDist;
                    nearestArrayIndex = arrayIndex;
                    nearestDotIndex = dotIndex;
                }/*from w w w .  j  a va  2s.com*/
            }
        }

        if (nearestArrayIndex == -1) {
            this.clearProbePopup();
        } else {
            XYProbeData nearestArrayData = xyProbeData[nearestArrayIndex];
            Point2D probeJava2DCoord = this.getJava2DCoordinates(nearestArrayData.getXData()[nearestDotIndex],
                    nearestArrayData.getYData()[nearestDotIndex]);
            double java2DDist = probeJava2DCoord.distance(e.getX(), e.getY());

            // is the probe close enough to be worth showing (in pixel distance)
            if (java2DDist <= PlotUtil.SCATTER_PLOT_DOT_SIZE_PIXELS * 2) {
                this.showProbePopup(nearestArrayIndex, nearestArrayData.getProbeIndices()[nearestDotIndex],
                        nearestArrayData.getXData()[nearestDotIndex],
                        nearestArrayData.getYData()[nearestDotIndex], e.getX(), e.getY());
            } else {
                this.clearProbePopup();
            }
        }
    }
}

From source file:edu.ucla.stat.SOCR.analyses.gui.NormalPower.java

public void mouseDragged(MouseEvent evt) {
    //////////////System.out.println("mouseDragged     evt = " + evt);
    //int x = evt.getX();

    xPosition = evt.getX();
    yPosition = evt.getY();/*from w  w w  . jav a 2 s .c om*/
    double xPositionOld = muA;
    double yPositionOld = 0;
    double xPositionNew = graphSampleMean.xGraphInverse(xPosition);
    double yPositionNew = graphSampleMean.yGraphInverse(yPosition);

    double diff = xPositionNew - xPositionOld;
    //double scale = Math.abs(mu0 - muA) / 100;
    //////////////System.out.println("mouseDragged mu0 = " + mu0 + ", muA = " + muA + " sampleSE = " + sampleSE + ", scale = " + scale);

    if (/*Math.abs(xPositionOld - xPositionNew) > scale  && */graphSampleMean
            .withinSampleMeanCurve(xPositionNew, yPositionNew)) {

        muA = muA + diff;
        graphSampleMean.setSampleMeanOption(true);
        //////////////////////System.out.println("New muA = " + muA);
        try {
            doSampleMeanNormalCurve();
            //doAnalysis();
        } catch (Exception e) {
            //////////////////////System.out.println(e);
        }
        muAText.setText(muA + "");
        repaint();
        ////System.gc();
    }
}

From source file:com.jcraft.weirdx.DDXWindowImpSwing.java

public void mouseReleased(MouseEvent e) {
    if (threeButton) {
        if (threeBstate == sppr) {
            threeBPressed = null;/*from  w w  w .  j a  v a2 s  .  com*/
            threeBstate = s;
            return;
        }
        if (threeBstate == sp) {
            procPressed(threeBPressed);
            threeBPressed = null;
            threeBstate = s;
        } else if (threeBstate == spp) {
            threeBPressed = null;
            threeBstate = sppr;
            e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(),
                    (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK)))
                            | InputEvent.BUTTON2_MASK,
                    e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger());
        }
    }

    procReleased(e);
}

From source file:edu.ku.brc.specify.tasks.ExpressSearchTask.java

/**
 * Shows the Reset menu./*from   www  . ja  v  a  2 s.  c  om*/
 * @param e the mouse event
 */
protected void showContextMenu(MouseEvent e) {
    if (e.isPopupTrigger()) {
        JPopupMenu popup = new JPopupMenu();
        JMenuItem menuItem = new JMenuItem(UIRegistry.getResourceString("ES_TEXT_RESET"));
        menuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ex) {
                searchText.setEnabled(true);
                searchText.setBackground(textBGColor);
                searchText.setText("");

                if (statusBar != null) {
                    statusBar.setProgressDone(EXPRESSSEARCH);
                }
            }
        });
        popup.add(menuItem);
        popup.show(e.getComponent(), e.getX(), e.getY());

    }
}

From source file:com.archivas.clienttools.arcmover.gui.panels.ProfilePanel.java

private void onFileListMouseClicked(MouseEvent evt) {
    try {/*from w ww . j  ava  2  s. c o  m*/
        if (evt.isPopupTrigger()) {

            updateSelectedFile();
            updateRightClickMenu();
            rightClickMenu.show(fileList, evt.getX(), evt.getY());
        }
    } catch (Exception e1) {
        String msg = "Unexpected error showing right-click menu";
        LOG.log(Level.WARNING, msg, e1);
        JOptionPane.showMessageDialog(this, msg, "Error", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:com.jcraft.weirdx.DDXWindowImp.java

public void mouseReleased(MouseEvent e) {
    if (threeButton) {
        if (threeBstate == sppr) {
            threeBPressed = null;/*from  ww  w . java2  s  .com*/
            threeBstate = s;
            return;
        }
        if (threeBstate == sp) {
            procPressed(threeBPressed);
            threeBPressed = null;
            threeBstate = s;
        } else if (threeBstate == spp) {
            threeBPressed = null;
            threeBstate = sppr;
            e = new MouseEvent((Component) e.getSource(), e.getID(), e.getWhen(),
                    (e.getModifiers() & (~(InputEvent.BUTTON1_MASK | InputEvent.BUTTON3_MASK)))
                            | InputEvent.BUTTON2_MASK,
                    e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger());
        }
    }
    try {
        procReleased(e);
    } catch (Exception ee) {
    }
}

From source file:cn.pholance.datamanager.common.components.JRViewer.java

void pnlLinksMousePressed(MouseEvent evt) {//GEN-FIRST:event_pnlLinksMousePressed
    // Add your handling code here:
    pnlLinks.setCursor(new Cursor(Cursor.MOVE_CURSOR));

    downX = evt.getX();
    downY = evt.getY();//www  . ja v a2s .  com
}

From source file:de.mendelson.comm.as2.client.AS2Gui.java

@Override
public void mouseClicked(MouseEvent evt) {
    if (evt.isPopupTrigger() || evt.isMetaDown()) {
        if (evt.getSource().equals(this.jTableMessageOverview)) {
            this.jPopupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
        }/*from ww  w .j  av  a2 s  .c o  m*/
    }
}

From source file:cfa.vo.sed.science.stacker.SedStackerFrame.java

private void jList1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MousePressed
    if (evt.isPopupTrigger()) {
        jList1.setSelectedIndex(jList1.locationToIndex(evt.getPoint()));
        jPopupMenu1.show(jList1, evt.getX(), evt.getY());
    }//from   w w  w  .jav  a 2  s.  c o  m
}