本文整理汇总了Java中java.awt.Rectangle.getLocation方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.getLocation方法的具体用法?Java Rectangle.getLocation怎么用?Java Rectangle.getLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Rectangle
的用法示例。
在下文中一共展示了Rectangle.getLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: right
import java.awt.Rectangle; //导入方法依赖的package包/类
public boolean right() {
Fix f = (Fix) getSelectedValue();
Iterable<? extends Fix> subfixes = HintsControllerImpl.getSubfixes(f);
if (subfixes.iterator().hasNext()) {
Rectangle r = getCellBounds(getSelectedIndex(), getSelectedIndex());
Point p = new Point(r.getLocation());
SwingUtilities.convertPointToScreen(p, this);
p.x += r.width;
// p.y += r.height;
HintsUI.getDefault().openSubList(subfixes, p);
return true;
}
return false;
}
示例2: getScrollableUnitIncrement
import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
public int getScrollableUnitIncrement (Rectangle visibleRect, int orientation, int direction) {
int row;
if (orientation == SwingConstants.VERTICAL &&
direction < 0 && (row = getFirstVisibleIndex ()) != -1) {
Rectangle r = getCellBounds (row, row);
if ((r.y == visibleRect.y) && (row != 0)) {
Point loc = r.getLocation ();
loc.y--;
int prevIndex = locationToIndex (loc);
Rectangle prevR = getCellBounds (prevIndex, prevIndex);
if (prevR == null || prevR.y >= r.y) {
return 0;
}
return prevR.height;
}
}
return super.getScrollableUnitIncrement (visibleRect, orientation, direction);
}
示例3: getScrollableUnitIncrement
import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
public int getScrollableUnitIncrement( Rectangle visibleRect, int orientation, int direction ) {
int res = 0;
if( orientation == SwingConstants.VERTICAL ) {
res = getRowHeight() / 2;
} else {
Point columnPoint = visibleRect.getLocation();
columnPoint.x += 1;
int col = columnAtPoint( columnPoint );
if( col >= 0 ) {
Rectangle rect = getCellRect( 0, col, true );
res = rect.width / 2;
} else {
res = super.getScrollableUnitIncrement( visibleRect, orientation, direction );
}
}
if( direction < 0 )
res *= -1;
return res;
}
示例4: mouseExited
import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
public void mouseExited(MouseEvent e) {
if (e.getSource() == listClasses && currentPopup != null) {
// check if hovering above the popup -> do not dismiss.
// the mouse exits the table, when it crosses the boudary to the
// tooltip.
Point screen = e.getLocationOnScreen();
Rectangle visibleRec = listClasses.getVisibleRect();
Point pt = visibleRec.getLocation();
SwingUtilities.convertPointToScreen(pt, listClasses);
visibleRec.setLocation(pt);
if (visibleRec.contains(screen)) {
return;
}
hidePopup();
} else if (e.getSource() == this.popupContents) {
// exit from the popup
hidePopup();
}
}
示例5: getPopupLocation
import java.awt.Rectangle; //导入方法依赖的package包/类
private Point getPopupLocation() {
Dimension popupSize = new Dimension((int) this.comboBox.getSize().getWidth(), (int) this.comboBox.getSize()
.getHeight());
Insets insets = getInsets();
popupSize.setSize(popupSize.width - (insets.right + insets.left),
getPopupHeightForRowCount(this.comboBox.getMaximumRowCount()));
Rectangle popupBounds = computePopupBounds(0, this.comboBox.getBounds().height, popupSize.width,
popupSize.height);
Dimension scrollSize = popupBounds.getSize();
Point popupLocation = popupBounds.getLocation();
this.scroller.setMaximumSize(scrollSize);
this.scroller.setPreferredSize(scrollSize);
this.scroller.setMinimumSize(scrollSize);
this.list.revalidate();
return popupLocation;
}
示例6: scrollAnnotationToVisible
import java.awt.Rectangle; //导入方法依赖的package包/类
public void scrollAnnotationToVisible(Annotation ann) {
// if at least part of the blinking section is visible then we
// need to do no scrolling
// this is required for long annotations that span more than a
// screen
Rectangle visibleView = scroller.getViewport().getViewRect();
int viewStart = textView.viewToModel(visibleView.getLocation());
Point endPoint = new Point(visibleView.getLocation());
endPoint.translate(visibleView.width, visibleView.height);
int viewEnd = textView.viewToModel(endPoint);
int annStart = ann.getStartNode().getOffset().intValue();
int annEnd = ann.getEndNode().getOffset().intValue();
if(annEnd < viewStart || viewEnd < annStart) {
try {
textView.scrollRectToVisible(textView.modelToView(annStart));
} catch(BadLocationException ble) {
// this should never happen
throw new GateRuntimeException(ble);
}
}
}
示例7: setupDropLine
import java.awt.Rectangle; //导入方法依赖的package包/类
private void setupDropLine( DropTargetDragEvent dtde, CategoryList list, int dropIndex ) {
boolean verticalDropBar = list.getColumnCount() > 1;
Rectangle rect = list.getCellBounds( dropIndex, dropIndex );
if( verticalDropBar )
dropBefore = dtde.getLocation().x < (rect.x + rect.width/2);
else
dropBefore = dtde.getLocation().y < (rect.y + rect.height/2);
Point p1 = rect.getLocation();
Point p2 = rect.getLocation();
if( verticalDropBar ) {
p2.y += rect.height;
if( !dropBefore ) {
p1.x += rect.width;
p2.x += rect.width;
}
} else {
p2.x += rect.width;
if( !dropBefore ) {
p1.y += rect.height;
p2.y += rect.height;
}
}
p1 = SwingUtilities.convertPoint( list, p1, palette.getRootPane() );
p2 = SwingUtilities.convertPoint( list, p2, palette.getRootPane() );
Line2D line = new Line2D.Double( p1.x, p1.y, p2.x, p2.y );
dropPane.setDropLine( line );
targetItem = (Item)list.getModel().getElementAt( dropIndex );
}
示例8: getPositionForPopup
import java.awt.Rectangle; //导入方法依赖的package包/类
/**
* For popups invoked by keyboard determines best location for it.
*
* @param table source of popup event
* @return Point best location for menu popup
*/
public static Point getPositionForPopup(JTable table) {
int idx = table.getSelectedRow();
if (idx == -1) idx = 0;
Rectangle rect = table.getCellRect(idx, 1, true);
return rect.getLocation();
}
示例9: computeLastButtonBounds
import java.awt.Rectangle; //导入方法依赖的package包/类
/** Returns bounds of last button in sliding view to which given
* operation belongs. Bounds are relative to desktop layered pane.
*/
private Rectangle computeLastButtonBounds(SlideOperation operation) {
String side = operation.getSide();
SlidingView view = findView(side);
Rectangle screenRect = view.getTabBounds(view.getTopComponents().size() - 1);
Point leftTop = screenRect.getLocation();
if (Constants.BOTTOM.equals(side)) {
leftTop.y += desktop.getHeight() - view.getComponent().getPreferredSize().height;
} else if (Constants.RIGHT.equals(side)) {
leftTop.x += desktop.getWidth() - view.getComponent().getPreferredSize().width;
}
return new Rectangle(leftTop, screenRect.getSize());
}
示例10: getSelectedLocation
import java.awt.Rectangle; //导入方法依赖的package包/类
public Point getSelectedLocation() {
Rectangle r = view.getCellBounds(getSelectedIndex(), getSelectedIndex());
Point p = new Point(r.getLocation());
SwingUtilities.convertPointToScreen(p, view);
p.x += r.width;
return p;
}
示例11: main
import java.awt.Rectangle; //导入方法依赖的package包/类
public static void main(String[] args) throws AWTException
{
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gds = ge.getScreenDevices();
if (gds.length < 2) {
System.out.println("It's a multiscreen test... skipping!");
return;
}
for (int i = 0; i < gds.length; ++i) {
GraphicsDevice gd = gds[i];
GraphicsConfiguration gc = gd.getDefaultConfiguration();
Rectangle screen = gc.getBounds();
Robot robot = new Robot(gd);
// check Robot.mouseMove()
robot.mouseMove(screen.x + mouseOffset.x, screen.y + mouseOffset.y);
Point mouse = MouseInfo.getPointerInfo().getLocation();
Point point = screen.getLocation();
point.translate(mouseOffset.x, mouseOffset.y);
if (!point.equals(mouse)) {
throw new RuntimeException(getErrorText("Robot.mouseMove", i));
}
// check Robot.getPixelColor()
Frame frame = new Frame(gc);
frame.setUndecorated(true);
frame.setSize(100, 100);
frame.setLocation(screen.x + frameOffset.x, screen.y + frameOffset.y);
frame.setBackground(color);
frame.setVisible(true);
robot.waitForIdle();
Rectangle bounds = frame.getBounds();
if (!Util.testBoundsColor(bounds, color, 5, 1000, robot)) {
throw new RuntimeException(getErrorText("Robot.getPixelColor", i));
}
// check Robot.createScreenCapture()
BufferedImage image = robot.createScreenCapture(bounds);
int rgb = color.getRGB();
if (image.getRGB(0, 0) != rgb
|| image.getRGB(image.getWidth() - 1, 0) != rgb
|| image.getRGB(image.getWidth() - 1, image.getHeight() - 1) != rgb
|| image.getRGB(0, image.getHeight() - 1) != rgb) {
throw new RuntimeException(
getErrorText("Robot.createScreenCapture", i));
}
frame.dispose();
}
System.out.println("Test PASSED!");
}
示例12: updateColumnPreferredWidth
import java.awt.Rectangle; //导入方法依赖的package包/类
public void updateColumnPreferredWidth(int column) {
Rectangle visible = getVisibleRect();
if (visible.isEmpty()) return;
Point visibleP = visible.getLocation();
int first = rowAtPoint(visible.getLocation());
visibleP.translate(0, visible.height - 1);
int last = rowAtPoint(visibleP);
int _column = convertColumnIndexToView(column);
int width = computeColumnPreferredWidth(column, _column, first, last);
_getColumnModel().setColumnPreferredWidth(column, width);
}
示例13: insert
import java.awt.Rectangle; //导入方法依赖的package包/类
public static Point insert(final Rectangle in, final Rectangle bounds) {
in.x -= Math.max(0, in.getMaxX() - bounds.getMaxX());
in.y -= Math.max(0, in.getMaxY() - bounds.getMaxY());
in.x += Math.max(0, bounds.getMinX() - in.getMinX());
in.y += Math.max(0, bounds.getMinY() - in.getMinY());
return in.getLocation();
}
示例14: computeTipVisibleBounds
import java.awt.Rectangle; //导入方法依赖的package包/类
/**
* Compute the bounds in which the user can move the mouse without the
* tip window disappearing.
*/
private void computeTipVisibleBounds() {
// Compute area that the mouse can move in without hiding the
// tip window. Note that Java 1.4 can only detect mouse events
// in Java windows, not globally.
Rectangle r = tipWindow.getBounds();
Point p = r.getLocation();
SwingUtilities.convertPointFromScreen(p, textArea);
r.setLocation(p);
tipVisibleBounds.setBounds(r.x,r.y-15, r.width,r.height+15*2);
}
示例15: redispatchComponent
import java.awt.Rectangle; //导入方法依赖的package包/类
private boolean redispatchComponent(MouseEvent e) {
Point p = e.getPoint();
int index = list.locationToIndex(p);
if (index < 0 || index >= list.getModel().getSize()) {
return false;
}
ListCellRenderer renderer = list.getCellRenderer();
if (null == renderer) {
return false;
}
Component renComponent = renderer.getListCellRendererComponent(list, list.getModel().getElementAt(index), index, false, false);
if (null == renComponent) {
return false;
}
Rectangle rect = list.getCellBounds(index, index);
if (null == rect) {
return false;
}
renComponent.setBounds(0, 0, rect.width, rect.height);
renComponent.doLayout();
Point p3 = rect.getLocation();
Point p2 = new Point(p.x - p3.x, p.y - p3.y);
Component dispatchComponent =
SwingUtilities.getDeepestComponentAt(renComponent,
p2.x, p2.y);
if ( e.isPopupTrigger() &&
dispatchComponent instanceof LinkButton &&
!((LinkButton)dispatchComponent).isHandlingPopupEvents() )
{
return false;
}
if (dispatchComponent instanceof AbstractButton) {
if (!((AbstractButton) dispatchComponent).isEnabled()) {
return false;
}
Point p4 = SwingUtilities.convertPoint(renComponent, p2, dispatchComponent);
MouseEvent newEvent = new MouseEvent(dispatchComponent,
e.getID(),
e.getWhen(),
e.getModifiers(),
p4.x, p4.y,
e.getClickCount(),
e.isPopupTrigger(),
MouseEvent.NOBUTTON);
dispatchComponent.dispatchEvent(newEvent);
list.repaint(rect);
e.consume();
return true;
}
return false;
}