Java Code Examples for java.awt.event.MouseEvent.getPoint()

The following are Jave code examples for showing how to use getPoint() of the java.awt.event.MouseEvent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: rapidminer   File: DataViewerTable.java   View Source Code Vote up 6 votes
/** This method ensures that the correct tool tip for the current column is delivered. */
@Override
protected JTableHeader createDefaultTableHeader() {
	JTableHeader header = new JTableHeader(columnModel) {

		private static final long serialVersionUID = 1L;

		@Override
		public String getToolTipText(MouseEvent e) {
			java.awt.Point p = e.getPoint();
			int index = columnModel.getColumnIndexAtX(p.x);
			int realColumnIndex = convertColumnIndexToModel(index);
			return DataViewerTable.this.getHeaderToolTipText(realColumnIndex);
		}
	};
	header.putClientProperty(RapidLookTools.PROPERTY_TABLE_HEADER_BACKGROUND, Colors.WHITE);
	return header;
}
 
Example 2
Project: MaxSim   File: RangeSlider.java   View Source Code Vote up 6 votes
@Override
public void mouseMoved(MouseEvent e) {
    isOverBar = false;
    if (model == null) {
        return;
    }


    Point p = e.getPoint();
    if (isOverFirstPosition(p) || isOverSecondPosition(p)) {
        setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
    } else if (isOverSelection(p)) {
        isOverBar = true;
        setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    } else {
        this.setCursor(Cursor.getDefaultCursor());
    }
    repaint();
}
 
Example 3
Project: rapidminer   File: ListPropertyTable.java   View Source Code Vote up 5 votes
/** This method ensures that the correct tool tip for the current table cell is delivered. */
@Override
public String getToolTipText(MouseEvent e) {
	Point p = e.getPoint();
	int column = columnAtPoint(p);
	if (column == 0) {
		return keyToolTip;
	} else {
		return super.getToolTipText(e);
	}
}
 
Example 4
Project: JavaGraph   File: ContributorsTable.java   View Source Code Vote up 5 votes
@Override
public void mouseMoved(MouseEvent e) {
    JTable table = (JTable) e.getSource();
    Point pt = e.getPoint();
    int prev_row = this.row;
    int prev_col = this.col;
    this.row = table.rowAtPoint(pt);
    this.col = table.columnAtPoint(pt);
    if (this.row != prev_row || this.col != prev_col) {
        Rectangle r = table.getCellRect(this.row, this.col, false);
        r = r.union(table.getCellRect(prev_row, prev_col, false));
        table.repaint(r);
    }
}
 
Example 5
Project: JuggleMasterPro   File: DataJTable.java   View Source Code Vote up 5 votes
@Override final public String getToolTipText(MouseEvent objPmouseEvent) {

		final Point objLpoint = objPmouseEvent.getPoint();
		final int intLrowIndex = this.rowAtPoint(objLpoint);
		final int intLcolumnIndex = this.convertColumnIndexToModel(this.columnAtPoint(objLpoint));
		return this.objGdataJFrame.getToolTipText(this, intLrowIndex, intLcolumnIndex);
	}
 
Example 6
Project: incubator-netbeans   File: NBTabbedPaneController.java   View Source Code Vote up 5 votes
@Override
public void mouseReleased( MouseEvent e ) {
    // close button must not be active when selection change was
    // triggered by mouse press

    Point p = e.getPoint();
    p = SwingUtilities.convertPoint( e.getComponent(), p, container );
    int i = container.indexAtLocation( p.x, p.y );
    if( e.isPopupTrigger() ) {
        if( i >= 0 )
            i = container.indexOf( container.getComponentAt( i ) );
        //Post a popup menu show request
        shouldPerformAction( TabDisplayer.COMMAND_POPUP_REQUEST, i, e );
    }
}
 
Example 7
Project: incubator-netbeans   File: ButtonPopupSwitcher.java   View Source Code Vote up 5 votes
private void changeSelection( MouseEvent e ) {
    Point p = e.getPoint();
    // It may have occured on the button that invoked the tabtable
    if (e.getSource() != this) {
        p = SwingUtilities.convertPoint((Component) e.getSource(), p, pTable);
    }
    if (pTable.contains(p)) {
        int row = pTable.rowAtPoint(p);
        int col = pTable.columnAtPoint(p);
        pTable.changeSelection(row, col, false, false);
    } else {
        pTable.clearSelection();
    }
}
 
Example 8
Project: geomapapp   File: XMap.java   View Source Code Vote up 5 votes
public void mouseClicked(MouseEvent e) {
	// GMA 1.6.4: Center on spot where user double-clicks (but not if Digitizer is open)
	if ( e.getClickCount() >= 2 && e.getModifiers()==16 && !((MapApp)app).digitizer.isEnabled()) {
		Point p = e.getPoint();
		doZoom( p, 1 );
	}
}
 
Example 9
Project: incubator-netbeans   File: LineNumbersActionsBar.java   View Source Code Vote up 5 votes
public String getToolTipText(MouseEvent event) {
    Point p = event.getPoint();
    HotSpot spot = getHotspotAt(p);
    if (spot == null) return null;
    Difference diff = spot.getDiff();
    if (diff.getType() == Difference.ADD) {
        return NbBundle.getMessage(LineNumbersActionsBar.class, "TT_DiffPanel_Remove"); // NOI18N
    } else if (diff.getType() == Difference.CHANGE) {
        return NbBundle.getMessage(LineNumbersActionsBar.class, "TT_DiffPanel_Replace"); // NOI18N
    } else {
        return NbBundle.getMessage(LineNumbersActionsBar.class, "TT_DiffPanel_Insert"); // NOI18N
    }
}
 
Example 10
Project: rapidminer   File: EnumerationPropertyTable.java   View Source Code Vote up 5 votes
/** This method ensures that the correct tool tip for the current table cell is delivered. */
@Override
public String getToolTipText(MouseEvent e) {
	Point p = e.getPoint();
	int column = columnAtPoint(p);
	if (column == 0) {
		return keyToolTip;
	} else {
		return super.getToolTipText(e);
	}
}
 
Example 11
Project: incubator-netbeans   File: FmtSpaces.java   View Source Code Vote up 5 votes
public void mouseClicked(MouseEvent e) {
    Point p = e.getPoint();
    TreePath path = cfgTree.getPathForLocation(e.getPoint().x, e.getPoint().y);
    if ( path != null ) {
        Rectangle r = cfgTree.getPathBounds(path);
        if (r != null) {
            if ( r.contains(p)) {
                toggle( path );
            }
        }
    }
}
 
Example 12
Project: incubator-netbeans   File: ButtonPopupSwitcher.java   View Source Code Vote up 5 votes
public void mouseMoved(MouseEvent e) {
    e.consume();
    Point p = e.getPoint();
    // It may have occured on the button that invoked the tabtable
    if (e.getSource() != this) {
        p = SwingUtilities.convertPoint((Component) e.getSource(), p, pTable);
    }
    if (pTable.contains(p)) {
        int row = pTable.rowAtPoint(p);
        int col = pTable.columnAtPoint(p);
        pTable.changeSelection(row, col, false, false);
    } else {
        pTable.clearSelection();
    }
}
 
Example 13
Project: jaer   File: ImageDisplay.java   View Source Code Vote up 5 votes
/** Returns the image position of a mouse event, translating back from OpenGL coordinates to image location.
 *
 * @param evt a  mouse event
 * @return the image location, with 0,0 at the lower left corner.
 *
 */
public Point2D.Float getMouseImagePosition(MouseEvent evt) {
	Point2D.Float p = new Point2D.Float(evt.getPoint().x, evt.getPoint().y);
	float scale = (clipArea.top - clipArea.bottom) / getHeight();  // TODO mysterious scalling of text
	p.x = (p.x * scale) + clipArea.left;
	p.y = sizeY - ((p.y * scale) + clipArea.bottom);
	return p;
}
 
Example 14
Project: rapidminer   File: ExtendedJTable.java   View Source Code Vote up 5 votes
@Override
public void mouseReleased(final MouseEvent e) {
	if (showPopopUpMenu) {
		if (e.isPopupTrigger()) {
			Point p = e.getPoint();
			int row = rowAtPoint(p);
			int c = columnAtPoint(p);

			// don't do anything when outside of table
			if (row < 0 || c < 0) {
				return;
			}
			// only set cell selection if clicked cell is outside current selection
			if (row != -1 && (row < getSelectedRow() || row > getSelectedRow() + getSelectedRowCount() - 1)
					|| c != -1 && (c < getSelectedColumn() || c > getSelectedColumn() + getSelectedColumnCount() - 1)) {
				if (row < getRowCount() && c < getColumnCount()) {
					// needed because sometimes row could be outside [0, getRowCount()-1]
					setRowSelectionInterval(row, row);
					setColumnSelectionInterval(c, c);
				}
			}

			JPopupMenu menu = createPopupMenu();

			showPopupMenu(menu, e.getPoint());
		}
	}
}
 
Example 15
Project: incubator-netbeans   File: FileCompletionPopup.java   View Source Code Vote up 5 votes
public void mouseDragged(MouseEvent e) {
    if (e.getSource() == list) {
        return;
    }
    if ( isVisible() ) {
        MouseEvent newEvent = convertMouseEvent( e );
        Rectangle r = new Rectangle();
        list.computeVisibleRect( r );
        Point location =  newEvent.getPoint();
        int index = list.locationToIndex(location);
        if ( r.contains( location ) ) {
            list.setSelectedIndex(index);
        }
    }
}
 
Example 16
Project: powertext   File: TipWindow.java   View Source Code Vote up 5 votes
@Override
public void mouseExited(MouseEvent e) {
	// Since we registered this listener on the child components of
	// the JWindow, not the JWindow iteself, we have to be careful.
	Component source = (Component)e.getSource();
	Point p = e.getPoint();
	SwingUtilities.convertPointToScreen(p, source);
	if (!TipWindow.this.getBounds().contains(p)) {
		ft.possiblyDisposeOfTipWindow();
	}
}
 
Example 17
Project: MTG-Card-Recognizer   File: WebcamCanvas.java   View Source Code Vote up 5 votes
public void moveBox(MouseEvent a) {
	if(lastDrawn!=null)
	{
		Point b = a.getPoint();
		int w = lastDrawn.getWidth();
		int h = lastDrawn.getHeight();
		int w2 = recogBounds.width/2;
		int h2 = recogBounds.height/2;
		int x = (int)b.getX();
		int y = (int)b.getY();

		if(x>w-w2)
		{
			x=w-w2;
		}
		else if(x<w2)
		{
			x=w2;
		}

		if(y>h-h2)
		{
			y=h-h2;
		}
		else if(y<h2)
		{
			y=h2;
		}

		recogBounds.x = x-w2;
		recogBounds.y = y-h2;
	}
}
 
Example 18
Project: incubator-netbeans   File: DiffSplitPaneDivider.java   View Source Code Vote up 4 votes
public String getToolTipText(MouseEvent event) {
    Point p = event.getPoint();
    DividerAction spot = getHotspotAt(p);
    return spot == null ? null : spot.getValue(Action.NAME).toString();
}
 
Example 19
Project: Bachelor-Thesis   File: DTNSimGUI.java   View Source Code Vote up 4 votes
/**
 * If mouse button is clicked, centers view at that location.
 */
public void mouseClicked(MouseEvent e) {
	
	java.awt.Point p = e.getPoint();
	centerViewAt(field.getWorldPosition(new Coord(p.x, p.y)));
}
 
Example 20
Project: incubator-netbeans   File: TableSheet.java   View Source Code Vote up 4 votes
public void mousePressed(MouseEvent e) {
    Point p = e.getPoint();
    dragging = canResize(p);
    lastMouseX = p.x;
}