Example usage for java.awt.event MouseEvent getPoint

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

Introduction

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

Prototype

public Point getPoint() 

Source Link

Document

Returns the x,y position of the event relative to the source component.

Usage

From source file:com.choicemaker.cm.modelmaker.gui.panels.HoldVsAccuracyPlotPanel.java

private void buildPanel() {
    XYSeriesCollection dataset = new XYSeriesCollection();
    String title = ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.holdvsacc.title");
    data = new XYSeries(title);
    dataset.addSeries(data);//  w  w  w  . ja va 2 s .  co  m
    final PlotOrientation orientation = PlotOrientation.VERTICAL;
    chart = ChartFactory.createXYLineChart(title,
            ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.holdvsacc.cm.accuracy"),
            ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.holdvsacc.holdpercentage"),
            dataset, orientation, true, true, true);
    MouseListener tableMouseListener = new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            Point origin = e.getPoint();
            JTable src = (JTable) e.getSource();
            int row = src.rowAtPoint(origin);
            int col = src.columnAtPoint(origin);
            ModelMaker mm = parent.getModelMaker();
            if (src == accuracyTable) {
                if (col < 2) {
                    if (!Float.isNaN(accuracyData[row][2]) && !Float.isNaN(accuracyData[row][3]))
                        mm.setThresholds(new Thresholds(accuracyData[row][2], accuracyData[row][3]));
                } else if (col == 2) {
                    if (!Float.isNaN(accuracyData[row][2]))
                        mm.setDifferThreshold(accuracyData[row][2]);
                } else {
                    if (!Float.isNaN(accuracyData[row][3]))
                        mm.setMatchThreshold(accuracyData[row][3]);
                }
            } else {
                if (col < 2) {
                    if (!Float.isNaN(hrData[row][2]) && !Float.isNaN(hrData[row][3]))
                        mm.setThresholds(new Thresholds(hrData[row][2], hrData[row][3]));
                } else if (col == 2) {
                    if (!Float.isNaN(hrData[row][2]))
                        mm.setDifferThreshold(hrData[row][2]);
                } else {
                    if (!Float.isNaN(hrData[row][3]))
                        mm.setMatchThreshold(hrData[row][3]);
                }
            }
        }
    };
    chart.setBackgroundPaint(getBackground());
    accuracyTable = new AccuracyTable(true, accuracies);
    accuracyTable.addMouseListener(tableMouseListener);
    accuracyPanel = getPanel(accuracyTable,
            ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.holdvsacc.table.hrvsacc"));

    hrTable = new AccuracyTable(false, hrs);
    hrTable.addMouseListener(tableMouseListener);
    hrPanel = getPanel(hrTable,
            ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.holdvsacc.table.accvshr"));

    accuracyTable.setEnabled(false);
    hrTable.setEnabled(false);
}

From source file:ui.frame.KAIQRFrame.java

public KAIQRFrame() {
    // init frames
    super("KAI QR Code Generator");
    mouseDownCompCoords = null;/*from  w ww .j  a v a  2 s. c  om*/
    addMouseListener(new MouseListener() {
        public void mouseReleased(MouseEvent e) {
            mouseDownCompCoords = null;
        }

        public void mousePressed(MouseEvent e) {
            mouseDownCompCoords = e.getPoint();
        }

        public void mouseExited(MouseEvent e) {
        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseClicked(MouseEvent e) {
        }
    });

    addMouseMotionListener(new MouseMotionListener() {
        public void mouseMoved(MouseEvent e) {
        }

        public void mouseDragged(MouseEvent e) {
            Point currCoords = e.getLocationOnScreen();
            setLocation(currCoords.x - mouseDownCompCoords.x, currCoords.y - mouseDownCompCoords.y);
        }
    });

    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

    menuPanel = p.createPanel(Layouts.grid, 5, 1);
    btnLogOut = b.createButton("Logout");
    btnLogOut.setPreferredSize(new Dimension(100, 50));
    btnLogOut.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            APICall api = new APICall();
            try {
                JSONObject response = new JSONObject(api.logout(Data.targetURL, Data.sessionKey));
                if (response.getString("result").equals("ok")) {
                    UILogin login = new UILogin();
                    Data.mainFrame.setVisible(false);
                }
            } catch (JSONException e1) {
                e1.printStackTrace();
            }
        }
    });
    menuPanel.add(btnLogOut);

    cardPanel = p.createPanel(Layouts.card);
    cardLayout = new CardLayout();
    cardPanel.setLayout(cardLayout);

    getContentPane().setBackground(CustomColor.NavyBlue.returnColor());
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLayout(new BorderLayout());
    setLocationRelativeTo(null);
    add(menuPanel, BorderLayout.WEST);
    add(cardPanel, BorderLayout.CENTER);
    pack();
}

From source file:ShapeTest.java

public ShapeComponent() {
    addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent event) {
            Point p = event.getPoint();
            for (int i = 0; i < points.length; i++) {
                double x = points[i].getX() - SIZE / 2;
                double y = points[i].getY() - SIZE / 2;
                Rectangle2D r = new Rectangle2D.Double(x, y, SIZE, SIZE);
                if (r.contains(p)) {
                    current = i;/*  w ww . j av a2 s.com*/
                    return;
                }
            }
        }

        public void mouseReleased(MouseEvent event) {
            current = -1;
        }
    });
    addMouseMotionListener(new MouseMotionAdapter() {
        public void mouseDragged(MouseEvent event) {
            if (current == -1)
                return;
            points[current] = event.getPoint();
            repaint();
        }
    });
    current = -1;
}

From source file:org.evors.rs.ui.frames.PopulationViewer.java

private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
    int row = jTable1.rowAtPoint(evt.getPoint());
    if (!jTable1.isRowSelected(row)) {
        jTable1.changeSelection(row, 1, false, false);
    }/*from  w  w w .ja  va  2  s . c  o m*/
    menu.show(jTable1, evt.getX(), evt.getY());
}

From source file:org.kalypso.kalypsomodel1d2d.ui.map.channeledit.DrawBanklineWidget.java

@Override
public void mouseMoved(final MouseEvent event) {
    final Point p = event.getPoint();
    if (p == null)
        return;/*from   w  ww.j  av a 2 s. co m*/

    final IMapPanel mapPanel = getMapPanel();
    if (mapPanel == null)
        return;

    m_currentPos = MapUtilities.transform(getMapPanel(), p);

    if (m_edit && m_bankline != null)
        m_lineEditor.moved(m_currentPos);
    else
        getMapPanel().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));

    repaintMap();
}

From source file:org.kalypso.ogc.gml.widgets.base.PanToWidget.java

@Override
public void mouseReleased(final MouseEvent e) {
    if (!ArrayUtils.contains(m_mouseButtons, e.getButton()))
        return;//  w ww  .ja  v a 2s .co  m

    if (m_world2screen == null)
        return;

    final Point point = e.getPoint();

    final GM_Position pixelPos = GeometryFactory.createGM_Position(point.getX(), point.getY());
    m_endPoint = m_world2screen.getSourcePoint(pixelPos);

    perform();
}

From source file:es.emergya.ui.base.plugins.PluggableJTabbedPane.java

@Override
public void mouseClicked(MouseEvent e) {
    if (PluggableJTabbedPane.this.salir.contains(e.getPoint())) {
        ExitHandler eh = new ExitHandler();
        eh.actionPerformed(null);/*from   w w w .  jav  a2 s.c o m*/
    }
}

From source file:mulavito.gui.control.AbstractPopupMousePlugin.java

/**
 * Reduced functionality of super class method and extended by own
 * content-aware editing.//  ww w . ja v  a 2 s .c o  m
 */
@SuppressWarnings("unchecked")
@Override
protected final void handlePopup(final MouseEvent e) {
    if (checkModifiers(e)) {
        final LV vv = (LV) e.getSource();
        final Layout<V, E> layout = vv.getGraphLayout();
        final L graph = (L) layout.getGraph();
        final Point p = e.getPoint();

        final List<V> sel_vertices = getSelectedVertices();
        final List<E> sel_edges = getSelectedEdges();

        GraphElementAccessor<V, E> pickSupport = vv.getPickSupport();
        if (pickSupport != null) {
            V vertex = pickSupport.getVertex(layout, p.getX(), p.getY());
            E edge = pickSupport.getEdge(layout, p.getX(), p.getY());

            if (vertex != null && !sel_vertices.contains(vertex))
                sel_vertices.add(vertex);
            if (edge != null && !sel_edges.contains(edge))
                sel_edges.add(edge);
        }

        popup.removeAll();
        if (sel_vertices.size() > 0)
            createVertexMenuEntries(p, graph, vv, sel_vertices);
        else if (sel_edges.size() > 0)
            createEdgeMenuEntries(p, graph, vv, sel_edges);
        else
            createGeneralMenuEntries(p, graph, vv);

        if (popup.getComponentCount() > 0)
            popup.show(vv, e.getX(), e.getY());
    }
}

From source file:SortedTableModel.java

public String getToolTipText(MouseEvent event) {
    String tip = super.getToolTipText(event);
    int column = columnAtPoint(event.getPoint());
    if ((toolTips != null) && (column < toolTips.length) && (toolTips[column] != null)) {
        tip = toolTips[column];//from  ww w. ja  va2 s.  c  o  m
    }
    return tip;
}

From source file:com.limegroup.gnutella.gui.tables.ActionIconAndNameEditor.java

public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, int row,
        int column) {
    ActionIconAndNameHolder in = (ActionIconAndNameHolder) value;
    action = in.getAction();//from   w w  w.j  a v a  2s .  com

    final Component component = new ActionIconAndNameRenderer().getTableCellRendererComponent(table, value,
            isSelected, true, row, column);
    component.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                if (actionRegion == null) {
                    component_mousePressed(e);
                } else {
                    if (actionRegion.contains(e.getPoint())) {
                        component_mousePressed(e);
                    } else {
                        if (e.getClickCount() >= 2) {
                            Toolkit.getDefaultToolkit().getSystemEventQueue()
                                    .postEvent(new MouseEvent(table, MouseEvent.MOUSE_CLICKED, e.getWhen(),
                                            e.getModifiers(), component.getX() + e.getX(),
                                            component.getY() + e.getY(), e.getClickCount(), false));
                        }
                    }
                }
            } else if (e.getButton() == MouseEvent.BUTTON3) {
                Toolkit.getDefaultToolkit().getSystemEventQueue()
                        .postEvent(new MouseEvent(table, e.getID(), e.getWhen(), e.getModifiers(),
                                component.getX() + e.getX(), component.getY() + e.getY(), e.getClickCount(),
                                true));
            }
        }
    });

    return component;
}