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:net.sf.mzmine.modules.visualization.ida.IDAPlot.java

@Override
public void mouseClicked(final MouseEvent event) {

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

    if (event.getX() < 70) { // User clicked on Y-axis
        if (event.getClickCount() == 2) { // Reset zoom on Y-axis
            XYDataset data = ((XYPlot) getChart().getPlot()).getDataset();
            Number maximum = DatasetUtilities.findMaximumRangeValue(data);
            getXYPlot().getRangeAxis().setRange(0, 1.05 * maximum.floatValue());
        } else if (event.getClickCount() == 1) {
            // Auto range on Y-axis
            getXYPlot().getRangeAxis().setAutoTickUnitSelection(true);
            getXYPlot().getRangeAxis().setAutoRange(true);
        }/*  www  .  jav  a2s  .co  m*/
    } else if (event.getY() > this.getChartRenderingInfo().getPlotInfo().getPlotArea().getMaxY() - 41
            && event.getClickCount() == 2) {
        // Reset zoom on X-axis
        getXYPlot().getDomainAxis().setAutoTickUnitSelection(true);
        restoreAutoDomainBounds();
    } else if (event.getClickCount() == 2) {
        visualizer.actionPerformed(
                new ActionEvent(event.getSource(), ActionEvent.ACTION_PERFORMED, "SHOW_SPECTRUM"));
    }
}

From source file:net.sf.mzmine.modules.visualization.msms.MsMsPlot.java

@Override
public void mouseClicked(final MouseEvent event) {

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

    if (event.getX() < 70) { // User clicked on Y-axis
        if (event.getClickCount() == 2) { // Reset zoom on Y-axis
            XYDataset data = ((XYPlot) getChart().getPlot()).getDataset();
            Number maximum = DatasetUtils.findMaximumRangeValue(data);
            getXYPlot().getRangeAxis().setRange(0, 1.05 * maximum.floatValue());
        } else if (event.getClickCount() == 1) {
            // Auto range on Y-axis
            getXYPlot().getRangeAxis().setAutoTickUnitSelection(true);
            getXYPlot().getRangeAxis().setAutoRange(true);
        }//from  ww w  . j  a v a2 s.  co m
    } else if (event.getY() > this.getChartRenderingInfo().getPlotInfo().getPlotArea().getMaxY() - 41
            && event.getClickCount() == 2) {
        // Reset zoom on X-axis
        getXYPlot().getDomainAxis().setAutoTickUnitSelection(true);
        restoreAutoDomainBounds();
    } else if (event.getClickCount() == 2) {
        visualizer.actionPerformed(
                new ActionEvent(event.getSource(), ActionEvent.ACTION_PERFORMED, "SHOW_SPECTRUM"));
    }
}

From source file:ucar.unidata.idv.control.chart.ChartAnnotation.java

/**
 * Set the position to the x/y of the event
 *
 * @param event The event//from   w w w .  j a  v a  2  s.  com
 */
public void setPosition(MouseEvent event) {
    setPosition(event.getX(), event.getY());
}

From source file:edu.ku.brc.specify.tasks.subpane.security.NavigationTreeContextMenuMgr.java

public void mousePressed(MouseEvent e) {
    TreePath clickedElement = getTree().getPathForLocation(e.getX(), e.getY());

    // Update the selection if necessary
    updateSelection(clickedElement);/* ww  w .j  a  v a 2s .  c  om*/

    TreePath tp = clickedElement;
    if (tp != null) {
        lastClickComp = (DefaultMutableTreeNode) tp.getLastPathComponent();

        updateBtnUI();
    }
}

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

@Override
public void mouseReleased(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON3) {
        displayPopupMenu(e.getX(), e.getY());
        return;/*w  ww.  j  av a2s.c om*/
    }
    repaint();
    int smallX = Math.min(startX, endX);
    int smallY = Math.min(startY, endY);
    int bigX = Math.max(startX, endX);
    int bigY = Math.max(startY, endY);

    XYPlot plot = this.getChart().getXYPlot();
    Rectangle2D plotArea = this.getScreenDataArea();
    double chartSmallX = plot.getDomainAxis().java2DToValue(smallX, plotArea, plot.getDomainAxisEdge());
    double chartBigX = plot.getDomainAxis().java2DToValue(bigX, plotArea, plot.getDomainAxisEdge());
    double chartSmallY = plot.getRangeAxis().java2DToValue(smallY, plotArea, plot.getRangeAxisEdge());
    double chartBigY = plot.getRangeAxis().java2DToValue(bigY, plotArea, plot.getRangeAxisEdge());

    double minXValue = Math.min(chartSmallX, chartBigX);
    double maxXValue = Math.max(chartSmallX, chartBigX);
    double minYValue = Math.min(chartSmallY, chartBigY);
    double maxYValue = Math.max(chartSmallY, chartBigY);

    //testLog.append("Scanning: (" + smallX + ", " + smallY + "), (" + bigX + ", " + bigY + ")\n");
    //testLog.append("Scanning: X = [" + Math.min(chartSmallX, chartBigX) + ", " + Math.max(chartSmallX, chartBigX) + "]\n");
    //testLog.append("Scanning: Y = [" + Math.min(chartSmallY, chartBigY) + ", " + Math.max(chartSmallY, chartBigY) + "]\n");

    Set<XYItemEntity> foundItem = new HashSet<XYItemEntity>();

    XYDataset dataset = this.getChart().getXYPlot().getDataset();
    EntityCollection collection = this.getChartRenderingInfo().getEntityCollection();

    for (Object obj : collection.getEntities()) {
        if (obj instanceof XYItemEntity) {
            XYItemEntity entity = (XYItemEntity) obj;
            int series = entity.getSeriesIndex();
            int idx = entity.getItem();
            if (dataset.getX(series, idx).doubleValue() >= minXValue
                    && dataset.getX(series, idx).doubleValue() <= maxXValue
                    && dataset.getY(series, idx).doubleValue() >= minYValue
                    && dataset.getY(series, idx).doubleValue() <= maxYValue) {
                foundItem.add(entity);
            }
        }
    }

    //      for (int x = smallX; x <= bigX; ++x)
    //      {
    //         for (int y = smallY; y <= bigY; ++y)
    //         {
    //            ChartEntity entity = this.getEntityForPoint(x, y);
    //            if (entity instanceof XYItemEntity)
    //            {
    //               foundItem.add((XYItemEntity)entity);
    //            }
    //         }
    //      }

    selectedItems = foundItem;

    //      outlierRegion.clear();
    //      for (XYItemEntity entity : foundItem)
    //      {
    //         //testLog.append(entity.toString() + "\n");
    //         //testLog.append("Series = " + entity.getSeriesIndex() + ", ");
    //         //testLog.append("X = " + entity.getDataset().getX(entity.getSeriesIndex(), entity.getItem()) + ", ");
    //         //testLog.append("Y = " + entity.getDataset().getY(entity.getSeriesIndex(), entity.getItem()) + "\n");
    //         outlierRegion.add(entity.getDataset().getX(entity.getSeriesIndex(), entity.getItem()).doubleValue());
    //      }
    //
    //      Collections.sort(outlierRegion);
    //      if (!outlierRegion.isEmpty())
    //      {
    //         testLog.setText("");
    //         testLog.append("Outlier time selected = [");
    //         for (int i = 0; i < outlierRegion.size(); ++i)
    //         {
    //            testLog.append(outlierRegion.get(i).toString());
    //            if (i < outlierRegion.size() - 1)
    //            {
    //               testLog.append(" ");
    //            }
    //         }
    //         testLog.append("]\n");
    //      }
}

From source file:hwcdhackwaterloo.GUIMain.java

/**
 * Creates new form NewJFrame//from   w  ww.j  a va  2 s .  c o  m
 */
public GUIMain() {
    initComponents();
    menuPanel.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent e) {
            posX = e.getX();
            posY = e.getY();
        }
    });
    menuPanel.addMouseMotionListener(new MouseAdapter() {
        public void mouseDragged(MouseEvent evt) {
            //sets frame position when mouse dragged         
            setLocation(evt.getXOnScreen() - posX, evt.getYOnScreen() - posY);

        }
    });
}

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

private void handleDoubleClickEvent(MouseEvent e) {
    TreePath clickedPath = tree.getPathForLocation(e.getX(), e.getY());
    if (clickedPath == null)
        return;//from   www.j  av a  2 s.c  om
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) clickedPath.getLastPathComponent();
    Object clickedObject = node.getUserObject();

    if (clickedObject instanceof RawDataFile) {
        RawDataFile clickedFile = (RawDataFile) clickedObject;
        TICVisualizerModule.setupNewTICVisualizer(clickedFile);
    }

    if (clickedObject instanceof PeakList) {
        PeakList clickedPeakList = (PeakList) clickedObject;
        PeakListTableModule.showNewPeakListVisualizerWindow(clickedPeakList);
    }

    if (clickedObject instanceof Scan) {
        Scan clickedScan = (Scan) clickedObject;
        SpectraVisualizerModule.showNewSpectrumWindow(clickedScan.getDataFile(), clickedScan.getScanNumber());
    }

    if (clickedObject instanceof MassList) {
        MassList clickedMassList = (MassList) clickedObject;
        Scan clickedScan = clickedMassList.getScan();
        SpectraVisualizerWindow window = SpectraVisualizerModule
                .showNewSpectrumWindow(clickedScan.getDataFile(), clickedScan.getScanNumber());
        MassListDataSet dataset = new MassListDataSet(clickedMassList);
        window.addDataSet(dataset, Color.green);
    }

    if (clickedObject instanceof PeakListRow) {
        PeakListRow clickedPeak = (PeakListRow) clickedObject;
        PeakSummaryVisualizerModule.showNewPeakSummaryWindow(clickedPeak);
    }

}

From source file:net.sf.mzmine.chartbasics.gui.swing.ChartGestureMouseAdapter.java

/**
 * Find chartentities like JFreeChartEntity, AxisEntity, PlotEntity, TitleEntity, XY...
 * //from  ww w. j av a 2 s.  c  o  m
 * @param chartPanel
 * @param x
 * @param y
 * @return
 */
private ChartEntity findChartEntity(ChartPanel chartPanel, MouseEvent e) {
    // coordinates to find chart entities
    Insets insets = chartPanel.getInsets();
    int x = (int) ((e.getX() - insets.left) / chartPanel.getScaleX());
    int y = (int) ((e.getY() - insets.top) / chartPanel.getScaleY());

    if (lastEntity != null && x == lastEntityX && y == lastEntityY)
        return lastEntity;
    else {
        ChartRenderingInfo info = chartPanel.getChartRenderingInfo();
        ChartEntity entity = null;
        if (info != null) {
            EntityCollection entities = info.getEntityCollection();
            if (entities != null) {
                entity = entities.getEntity(x, y);
            }
        }
        return entity;
    }
}

From source file:org.eevolution.form.VCRPDetail.java

private void handleTreeEvent(MouseEvent e) {

    if (e.getButton() == MouseEvent.BUTTON3) {

        model.getTree().setSelectionPath(model.getTree().getPathForLocation(e.getX(), e.getY()));

        DefaultMutableTreeNode node = (DefaultMutableTreeNode) model.getTree().getSelectionPath()
                .getLastPathComponent();

        if (!(node.getUserObject() instanceof Date) && !(node.getUserObject() instanceof MPPOrderNode)) {

            popup.show(e.getComponent(), e.getX(), e.getY());
        }/*from   www  .  j a  va  2 s.  c  o m*/
    }

    SwingTool.setCursorsFromChild(e.getComponent(), false);
}

From source file:medsavant.enrichment.app.RegionListAggregatePanel.java

private void createSearchableTable() {
    tablePanel = new SearchableTablePanel(pageName,
            new String[] { "Name", "Chromosome", "Start", "End", "Length", "Variants", "Variants / KB",
                    "Individuals" },
            new Class[] { String.class, String.class, Integer.class, Integer.class, Integer.class,
                    Integer.class, Double.class, Integer.class },
            new int[0], true, true, Integer.MAX_VALUE, false, SearchableTablePanel.TableSelectionType.ROW,
            Integer.MAX_VALUE, new AggregationRetriever());

    tablePanel.getTable().addMouseListener(new MouseAdapter() {
        @Override/*w  w  w  .j a  v  a 2s  . com*/
        public void mouseReleased(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
                createPopup().show(e.getComponent(), e.getX(), e.getY());
            }
        }
    });

    showShowCard();
}