Example usage for java.awt.event MouseEvent getY

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

Introduction

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

Prototype

public int getY() 

Source Link

Document

Returns the vertical y position of the event relative to the source component.

Usage

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

/**
 * Handle event in chart/*  w w w. jav  a 2  s .co  m*/
 *
 * @param event The event
 *
 * @return Did we handle this event
 */
public boolean chartPanelMouseDragged(MouseEvent event) {

    if (SwingUtilities.isRightMouseButton(event)) {
        return EVENT_DONTPASSON;
    }

    closestAnnotation = null;
    //Ignore shift down drag.
    if (event.isShiftDown()) {
        return EVENT_PASSON;
    }

    if (dragging && (draggedAnnotation == null)) {
        return EVENT_PASSON;
    }
    dragging = true;
    if (draggedAnnotation == null) {
        draggedAnnotation = findClosestAnnotation(getAllAnnotations(), event.getX(), event.getY(), true,
                event.isShiftDown());
    }
    if (draggedAnnotation == null) {
        return EVENT_PASSON;
    }

    draggedAnnotation.setPosition(event);
    if (draggedAnnotation instanceof RangeFilter) {
        rangeFiltersChanged();
    }
    if ((draggedAnnotation instanceof WayPoint) || (draggedAnnotation instanceof TrackSegment)) {
        Rectangle2D r = getChartPanel().getScreenDataArea();
        if (event.getX() < r.getX()) {
            panPlot(false, 0.02);
        } else if (event.getX() > r.getX() + r.getWidth()) {
            panPlot(true, 0.02);
        }

    }

    signalChartChanged();
    try {
        setLocationPositions();
    } catch (Exception exc) {
        LogUtil.logException("Setting locations", exc);
    }
    return EVENT_DONTPASSON;

}

From source file:org.apache.syncope.ide.netbeans.view.ResourceExplorerTopComponent.java

private void rootRightClickAction(final MouseEvent evt) {
    JPopupMenu menu = new JPopupMenu();
    JMenuItem refreshItem = new JMenuItem("Refresh Templates");
    JMenuItem resetConnectionItem = new JMenuItem("Reset Connection");
    menu.add(refreshItem);// w w w.j a  v  a 2s  .  c om
    menu.add(resetConnectionItem);

    refreshItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            // simulate close and open to refresh the tree
            componentClosed();
            componentOpened();
        }
    });

    resetConnectionItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent evt) {
            ServerDetailsView serverDetails = getRefreshServerDetails();
            // set previous preferences
            Preferences prefs = NbPreferences.forModule(ResourceExplorerTopComponent.class);
            serverDetails.setDetails(prefs.get("scheme", "http"), prefs.get("host", "localhost"),
                    prefs.get("port", "8080"), prefs.get("username", StringUtils.EMPTY),
                    prefs.get("password", StringUtils.EMPTY));
            // reset connection preferences
            prefs.remove("scheme");
            prefs.remove("host");
            prefs.remove("port");
            prefs.remove("username");
            prefs.remove("password");
            serverDetails.setVisible(true);
        }
    });
    menu.show(evt.getComponent(), evt.getX(), evt.getY());
}

From source file:base.BasePlayer.AminoTable.java

@Override
public void mouseMoved(MouseEvent event) {
    if (!this.isEnabled()) {
        return;// ww w  .j av a2  s.co  m
    }
    mouseY = event.getY();
    mouseX = event.getX();

    repaint();
}

From source file:com.ivli.roim.controls.ChartControl.java

@Override
public void mouseReleased(MouseEvent e) {
    if (SwingUtilities.isRightMouseButton(e)
            && (iMarker instanceof DomainMarker || iSeries instanceof XYSeries)) {
        JPopupMenu mnu = new JPopupMenu(
                java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle").getString("MNU_MARKER_OPERATIONS"));
        if (iSeries instanceof XYSeries) {
            mnu.add(MENUS.ADD.makeItem(this));
            mnu.add(MENUS.EXPORT_CSV.makeItem(this));
            mnu.add(MENUS.DELETE_ALL.makeItem(this));
        } else if (iMarker instanceof DomainMarker) {
            JMenu mi1 = new JMenu(MENUS.MOVE_TO_MIN.iText);
            mi1.add(MENUS.MOVE_TO_MIN.makeItem(this));
            //  mi1.add(MENUS.MOVE_TO_MIN_LEFT.makeItem(this));
            //  mi1.add(MENUS.MOVE_TO_MIN_RIGHT.makeItem(this));
            mnu.add(mi1);/* w w  w. j a  v a2s  . c o m*/
            JMenu mi2 = new JMenu(MENUS.MOVE_TO_MAX.iText);
            mi2.add(MENUS.MOVE_TO_MAX.makeItem(this));
            //  mi2.add(MENUS.MOVE_TO_MAX_LEFT.makeItem(this));
            //  mi2.add(MENUS.MOVE_TO_MAX_RIGHT.makeItem(this));

            mnu.add(mi2);
            mnu.add(MENUS.MOVE_TO_MEDIAN.makeItem(this));

            //if(!getDomainMarkersForSeries()){
            JMenu mi3 = new JMenu(
                    java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle").getString("MARKER_COMMAND.FIT"));
            mi3.add(MENUS.FIT_LEFT.makeItem(this));
            mi3.add(MENUS.FIT_RIGHT.makeItem(this));
            mnu.add(mi3);
            //}

            mnu.add(MENUS.DELETE.makeItem(this));
        }

        mnu.show(this, e.getX(), e.getY());
    } else {
        super.mouseReleased(e);
        dropSelection();
    }
}

From source file:com.projity.contrib.calendar.JXXMonthView.java

protected void selectFromEvent(MouseEvent e) {
    boolean shift = (e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) == InputEvent.SHIFT_DOWN_MASK;
    boolean control = (e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) == InputEvent.CTRL_DOWN_MASK;
    int x = e.getX();
    int y = e.getY();

    long selected = getDayAt(x, y);
    if (selected == -1) {
        return;//ww w. j a v  a  2 s  .  co  m
    }
    if (!control && !shift)
        clearSelection();

    DateSpan selection;
    if (selected <= WEEKDAY_OFFSET) { //hk
        int weekDayNum = (int) (-selected + WEEKDAY_OFFSET);
        selectWeekDay(weekDayNum);
        _asKirkWouldSay_FIRE = true;
        return;
    } else {
        if (_pivotDate == -1 || (!shift))
            selection = new DateSpan(selected, selected);
        else
            selection = new DateSpan(Math.min(_pivotDate, selected), Math.max(_pivotDate, selected));
    }

    select(selection);

    _pivotDate = selected;

    // Arm so we fire action performed on mouse release.
    _asKirkWouldSay_FIRE = true;

}

From source file:org.gumtree.vis.plot1d.Plot1DPanel.java

private void changeInternalLegend(MouseEvent e) {
    // TODO Auto-generated method stub
    Point2D screenPoint = translateScreenToJava2D(e.getPoint());
    //TODO: resize the mask
    Rectangle2D screenArea = getScreenDataArea();
    if (screenArea.contains(screenPoint)) {
        //             Point2D chartPoint = translateScreenToChart(screenPoint);

        //         changeSelectedMask(ChartMaskingUtilities.translateScreenX(
        //               screenPoint.getX(), getScreenDataArea(), getChart()));
        int cursorType = findCursorOnSelectedItem(e.getX(), e.getY());
        switch (cursorType) {
        case Cursor.MOVE_CURSOR:
            moveLegend(e.getPoint());/*w ww  . j a v  a  2  s. c  o  m*/
            break;
        case Cursor.W_RESIZE_CURSOR:
            changeLegendX(e.getPoint());
            break;
        case Cursor.E_RESIZE_CURSOR:
            changeLegendWidth(e.getPoint());
            break;
        default:
            break;
        }
        repaint();
    }
}

From source file:Clavis.Windows.WShedule.java

public synchronized void refreshTable(int val) {
    DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel();
    if (modelo.getRowCount() > 0) {
        int tam = modelo.getRowCount();
        for (int h = 0; h < tam; h++) {
            modelo.removeRow(0);//from  www .j a v  a 2  s  . c  o m
        }
    }

    java.util.List<Keys.Request> requisicoes = new java.util.ArrayList<>();
    if (DataBase.DataBase.testConnection(url)) {
        DataBase.DataBase db = new DataBase.DataBase(url);
        requisicoes = Clavis.RequestList
                .simplifyRequests(db.getRequestsByMaterialByDateInterval(mat, inicio, fim));
        db.close();
    }
    lista = new java.util.ArrayList<>();
    andamento = 0;
    switch (val) {
    case 0:
        estado = lingua.translate("Todos");
        for (Keys.Request req : requisicoes) {
            String[] multipla = req.getActivity().split(":::");
            String saux;
            if (multipla.length > 1) {
                saux = multipla[0];
                Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua);
                pop.create();
                jTable1.addMouseListener(new MouseAdapter() {
                    int x = andamento;
                    int y = 3;

                    @Override
                    public void mousePressed(MouseEvent e) {
                        if (e.getButton() == MouseEvent.BUTTON1) {
                            int row = jTable1.rowAtPoint(e.getPoint());
                            int col = jTable1.columnAtPoint(e.getPoint());
                            if ((row == x) && (col == y)) {
                                pop.show(e.getComponent(), e.getX(), e.getY());
                            }
                        }
                    }

                    @Override
                    public void mouseReleased(MouseEvent e) {
                        if (e.getButton() == MouseEvent.BUTTON1) {
                            if (pop.isShowing()) {
                                pop.setVisible(false);
                            }
                        }
                    }
                });
            } else {
                saux = req.getActivity();
            }
            if (saux.equals("")) {
                saux = lingua.translate("Sem descrio");
            }
            if (mat.getMaterialTypeID() == 1) {
                Object[] ob = { req.getPerson().getName(),
                        req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0),
                        req.getBeginDate().toString(), saux, req.getSubject().getName() };
                modelo.addRow(ob);
            } else {
                Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(),
                        req.getEndDate().toString(), saux };
                modelo.addRow(ob);
            }
            lista.add(req);
            andamento++;
        }
        break;
    case 1:
        estado = lingua.translate("terminado");
        for (Keys.Request req : requisicoes) {
            if (req.isTerminated()) {
                String[] multipla = req.getActivity().split(":::");
                String saux;
                if (multipla.length > 1) {
                    saux = multipla[0];
                    Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua);
                    pop.create();
                    jTable1.addMouseListener(new MouseAdapter() {
                        int x = andamento;
                        int y = 3;

                        @Override
                        public void mousePressed(MouseEvent e) {
                            if (e.getButton() == MouseEvent.BUTTON1) {
                                int row = jTable1.rowAtPoint(e.getPoint());
                                int col = jTable1.columnAtPoint(e.getPoint());
                                if ((row == x) && (col == y)) {
                                    pop.show(e.getComponent(), e.getX(), e.getY());
                                }
                            }
                        }

                        @Override
                        public void mouseReleased(MouseEvent e) {
                            if (e.getButton() == MouseEvent.BUTTON1) {
                                if (pop.isShowing()) {
                                    pop.setVisible(false);
                                }
                            }
                        }
                    });
                } else {
                    saux = req.getActivity();
                }
                if (saux.equals("")) {
                    saux = lingua.translate("Sem descrio");
                }
                if (mat.getMaterialTypeID() == 1) {
                    Object[] ob = { req.getPerson().getName(),
                            req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0),
                            req.getBeginDate().toString(), saux, req.getSubject().getName() };
                    modelo.addRow(ob);
                } else {
                    Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(),
                            req.getEndDate().toString(), saux };
                    modelo.addRow(ob);
                }
                lista.add(req);
                andamento++;
            }
        }
        break;
    case 2:
        estado = lingua.translate("no realizado");
        for (Keys.Request req : requisicoes) {
            if ((!req.isActive()) && ((req.getEndDate().isBigger(new TimeDate.Date()) > 0)
                    || ((req.getEndDate().isBigger(new TimeDate.Date()) == 0)
                            && (req.getTimeEnd().compareTime(new TimeDate.Time()) > 0)))) {
                String[] multipla = req.getActivity().split(":::");
                String saux;
                if (multipla.length > 1) {
                    saux = multipla[0];
                    Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua);
                    pop.create();
                    jTable1.addMouseListener(new MouseAdapter() {
                        int x = andamento;
                        int y = 3;

                        @Override
                        public void mousePressed(MouseEvent e) {
                            if (e.getButton() == MouseEvent.BUTTON1) {
                                int row = jTable1.rowAtPoint(e.getPoint());
                                int col = jTable1.columnAtPoint(e.getPoint());
                                if ((row == x) && (col == y)) {
                                    pop.show(e.getComponent(), e.getX(), e.getY());
                                }
                            }
                        }

                        @Override
                        public void mouseReleased(MouseEvent e) {
                            if (e.getButton() == MouseEvent.BUTTON1) {
                                if (pop.isShowing()) {
                                    pop.setVisible(false);
                                }
                            }
                        }
                    });
                } else {
                    saux = req.getActivity();
                }
                if (saux.equals("")) {
                    saux = lingua.translate("Sem descrio");
                }
                if (mat.getMaterialTypeID() == 1) {
                    Object[] ob = { req.getPerson().getName(),
                            req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0),
                            req.getBeginDate().toString(), saux, req.getSubject().getName() };
                    modelo.addRow(ob);
                } else {
                    Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(),
                            req.getEndDate().toString(), saux };
                    modelo.addRow(ob);
                }
                lista.add(req);
                andamento++;
            }
        }
        break;
    case 3:
        estado = lingua.translate("por realizar");
        for (Keys.Request req : requisicoes) {
            if ((!req.isActive()) && (!req.isTerminated())
                    && ((req.getEndDate().isBigger(new TimeDate.Date()) < 0)
                            || ((req.getEndDate().isBigger(new TimeDate.Date()) == 0)
                                    && (req.getTimeEnd().compareTime(new TimeDate.Time()) < 0)))) {
                String[] multipla = req.getActivity().split(":::");
                String saux;
                if (multipla.length > 1) {
                    saux = multipla[0];
                    Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua);
                    pop.create();
                    jTable1.addMouseListener(new MouseAdapter() {
                        int x = andamento;
                        int y = 3;

                        @Override
                        public void mousePressed(MouseEvent e) {
                            if (e.getButton() == MouseEvent.BUTTON1) {
                                int row = jTable1.rowAtPoint(e.getPoint());
                                int col = jTable1.columnAtPoint(e.getPoint());
                                if ((row == x) && (col == y)) {
                                    pop.show(e.getComponent(), e.getX(), e.getY());
                                }
                            }
                        }

                        @Override
                        public void mouseReleased(MouseEvent e) {
                            if (e.getButton() == MouseEvent.BUTTON1) {
                                if (pop.isShowing()) {
                                    pop.setVisible(false);
                                }
                            }
                        }
                    });
                } else {
                    saux = req.getActivity();
                }
                if (saux.equals("")) {
                    saux = lingua.translate("Sem descrio");
                }
                if (mat.getMaterialTypeID() == 1) {
                    Object[] ob = { req.getPerson().getName(),
                            req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0),
                            req.getBeginDate().toString(), saux, req.getSubject().getName() };
                    modelo.addRow(ob);
                } else {
                    Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(),
                            req.getEndDate().toString(), saux };
                    modelo.addRow(ob);
                }
                lista.add(req);
                andamento++;
            }
        }
        break;
    }
    valores = new String[lista.size()][4];
    for (int i = 0; i < lista.size(); i++) {
        String[] multipla = lista.get(i).getActivity().split(":::");
        String saux = multipla[0];
        if (saux.equals("")) {
            saux = lingua.translate("Sem descrio");
        }
        if (mat.getMaterialTypeID() == 1) {
            valores[i][0] = lista.get(i).getPerson().getName();
            valores[i][1] = lista.get(i).getTimeBegin().toString(0) + " - "
                    + lista.get(i).getTimeEnd().toString(0);
            valores[i][2] = lista.get(i).getBeginDate().toString();
            valores[i][3] = saux + " - " + lista.get(i).getSubject().getName();
        } else {
            valores[i][0] = lista.get(i).getPerson().getName();
            valores[i][1] = lista.get(i).getBeginDate().toString();
            valores[i][2] = lista.get(i).getEndDate().toString();
            valores[i][3] = saux;
        }
    }
}

From source file:org.gumtree.vis.awt.JChartPanel.java

@Override
public void mouseMoved(MouseEvent e) {
    //        if (isMaskingEnabled() && (e.getModifiers() & maskingKeyMask) != 0) {
    if (selectedTextWrapper == null && isMaskingEnabled()) {
        int cursorType = findCursorOnSelectedItem(e.getX(), e.getY());
        setCursor(Cursor.getPredefinedCursor(cursorType));
    } else {/*from   w  ww  . j  a v  a  2 s .c o  m*/
        Cursor newCursor = defaultCursor;
        if (selectedTextWrapper != null) {
            Point2D screenXY = ChartMaskingUtilities.translateChartPoint(
                    new Point2D.Double(selectedTextWrapper.getMinX(), selectedTextWrapper.getMinY()),
                    getScreenDataArea(), getChart());
            Rectangle2D screenRect = new Rectangle2D.Double(screenXY.getX(), screenXY.getY() - 15,
                    selectedTextWrapper.getWidth(), selectedTextWrapper.getHeight());
            if (screenRect.contains(e.getX(), e.getY())) {
                newCursor = Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR);
            }
        }
        if (newCursor != getCursor()) {
            setCursor(newCursor);
        }
    }
    Line2D oldSelection = selectedMarker;
    findSelectedMarker(e.getPoint());
    if (selectedMarker != oldSelection) {
        repaint();
    }
}

From source file:org.gumtree.vis.awt.JChartPanel.java

@Override
public void mouseReleased(MouseEvent e) {
    if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) {
        double xNew = ChartMaskingUtilities.translateScreenX(e.getX(), getScreenDataArea(), getChart());
        double yNew = ChartMaskingUtilities.translateScreenY(e.getY(), getScreenDataArea(), getChart(), 0);
        mouseRightClickLocation = new Point2D.Double(xNew, yNew);
    }//from  w  ww. j  a v  a 2  s. c  o m
    textMovePoint = null;
    super.mouseReleased(e);
}

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

void pnlLinksMouseDragged(MouseEvent evt) {//GEN-FIRST:event_pnlLinksMouseDragged
    // Add your handling code here:

    Container container = pnlInScroll.getParent();
    if (container instanceof JViewport) {
        JViewport viewport = (JViewport) container;
        Point point = viewport.getViewPosition();
        int newX = point.x - (evt.getX() - downX);
        int newY = point.y - (evt.getY() - downY);

        int maxX = pnlInScroll.getWidth() - viewport.getWidth();
        int maxY = pnlInScroll.getHeight() - viewport.getHeight();

        if (newX < 0) {
            newX = 0;/*from w  w w . j  ava2s  .c  o m*/
        }
        if (newX > maxX) {
            newX = maxX;
        }
        if (newY < 0) {
            newY = 0;
        }
        if (newY > maxY) {
            newY = maxY;
        }

        viewport.setViewPosition(new Point(newX, newY));
    }
}