本文整理汇总了Java中java.awt.Rectangle.contains方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.contains方法的具体用法?Java Rectangle.contains怎么用?Java Rectangle.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Rectangle
的用法示例。
在下文中一共展示了Rectangle.contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResizingColumn
import java.awt.Rectangle; //导入方法依赖的package包/类
private TableColumn getResizingColumn(JTableHeader header, Point p, int column) {
if (column == -1) {
return null;
}
Rectangle r = header.getHeaderRect(column);
r.grow(-3, 0);
if (r.contains(p)) {
return null;
}
int midPoint = r.x + r.width / 2;
int columnIndex = 0;
if (header.getComponentOrientation().isLeftToRight()) {
columnIndex = (p.x < midPoint) ? column - 1 : column;
} else {
columnIndex = (p.x < midPoint) ? column : column - 1;
}
if (columnIndex == -1) {
return null;
}
return header.getColumnModel().getColumn(columnIndex);
}
示例2: ChecaCursor
import java.awt.Rectangle; //导入方法依赖的package包/类
private void ChecaCursor(Point p) {
if (areas.isEmpty()) {
return;
}
int i = 0;
for (Rectangle r : areas) {
if (r.contains(p)) {
setOverNow(r);
if (i > 1) {
Rectangle r2 = new Rectangle(r.x + r.width - 18, r.y + fh / 2, 16, 16);
if (r2.contains(p)) {
this.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
} else {
this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
}
}
return;
}
i++;
}
setOverNow(null);
this.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
}
示例3: mouseMoved
import java.awt.Rectangle; //导入方法依赖的package包/类
public @Override void mouseMoved(MouseEvent evt) {
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "mouseMoved: x=" + evt.getX() + "; y=" + evt.getY() + "enabled=" + enabled + ", status=" + status + ", flags=" + flags); //NOI18N
}
if (toolTip != null) {
Rectangle ignoredArea = (Rectangle) toolTip.getClientProperty(MOUSE_MOVE_IGNORED_AREA);
Point mousePosition = SwingUtilities.convertPoint(evt.getComponent(), evt.getPoint(), toolTip.getParent());
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "Mouse-Move-Ignored-Area=" + ignoredArea + "; mouse=" + mousePosition //NOI18N
+ "; is-inside=" + (ignoredArea != null ? ignoredArea.contains(mousePosition) : null)); //NOI18N
}
if (ignoredArea != null && ignoredArea.contains(mousePosition)) {
return;
}
}
if (!isToolTipShowing() || (flags & FLAG_HIDE_ON_MOUSE_MOVE) != 0) {
setToolTipVisible(false);
}
if (enabled) {
enterTimer.restart();
}
lastMouseEvent = evt;
}
示例4: obtainNodes
import java.awt.Rectangle; //导入方法依赖的package包/类
/** Utility method. Returns either selected nodes in tree
* (if cursor hotspot is above some selected node) or the node
* the cursor points to.
* @return Node array or null if position of the cursor points
* to no node.
*/
Node[] obtainNodes(DragGestureEvent dge) {
TreePath[] tps = tree.getSelectionPaths();
if (tps == null) {
return null;
}
Node[] result = new Node[tps.length];
int cnt = 0;
for (int i = 0; i < tps.length; i++) {
Rectangle r = tree.getPathBounds(tps[i]);
if (r != null && r.contains(dge.getDragOrigin())) {
cnt++;
}
result[i] = DragDropUtilities.secureFindNode(tps[i].getLastPathComponent());
}
// #41954:
// if the drag source is not at all in path location, do not return
// any nodes
return (cnt == 0) ? null : result;
}
示例5: onAddNewTDTab
import java.awt.Rectangle; //导入方法依赖的package包/类
private MouseAdapter onAddNewTDTab() {
return new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent me) {
JTabbedPane tabbedPane = (JTabbedPane) me.getSource();
if (tabbedPane.getSelectedIndex() != -1 && getSelectedData() == null) {
Rectangle rect = tabbedPane.getUI().
getTabBounds(tabbedPane, tabbedPane.getSelectedIndex());
if (rect.contains(me.getPoint())) {
tabbedPane.setSelectedIndex(tabbedPane.getSelectedIndex() - 1);
addNewTestData(tabbedPane);
}
}
}
};
}
示例6: jList1MouseMoved
import java.awt.Rectangle; //导入方法依赖的package包/类
private void jList1MouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseMoved
// toggle resize/default cursor
if (evt.getX() < RESIZE_AREA_WIDTH) {
QuickSearchPopup.this.setCursor(Cursor.getPredefinedCursor(
Cursor.W_RESIZE_CURSOR));
} else {
QuickSearchPopup.this.setCursor(Cursor.getDefaultCursor());
}
// selection follows mouse move
Point loc = evt.getPoint();
int index = jList1.locationToIndex(loc);
if (index == -1) {
return;
}
Rectangle rect = jList1.getCellBounds(index, index);
if (rect != null && rect.contains(loc)) {
jList1.setSelectedIndex(index);
}
}
示例7: findShedWidget
import java.awt.Rectangle; //导入方法依赖的package包/类
private ShedWidget findShedWidget(Widget searchedEnvelope, Point scenePoint) {
for (Widget searchedEnvelopeChild : searchedEnvelope.getChildren()) {
ShedWidget foundWidget = findShedWidget(searchedEnvelopeChild, scenePoint);
if (foundWidget != null) {
return foundWidget;
}
}
Rectangle localSearchedBounds = searchedEnvelope.getBounds();
Rectangle sceneSearchedBounds = searchedEnvelope.convertLocalToScene(localSearchedBounds);
if (sceneSearchedBounds.contains(scenePoint) && (searchedEnvelope instanceof ShedWidget)) {
return (ShedWidget) searchedEnvelope;
}
return null;
}
示例8: mouseClicked
import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
if (areas.isEmpty()) {
return;
}
int i = 0;
for (Rectangle r : areas) {
if (r.contains(e.getPoint())) {
Rectangle r2 = new Rectangle(r.x + r.width - 18, r.y + fh / 2, 16, 16);
ProcessClick(i);
if (i > 1 && r2.contains(e.getPoint())) {
master.FechaDiagrama(i - 2);
Construa();
ChecaCursor(e.getPoint());
repaint();
}
break;
}
i++;
}
e.consume();
}
示例9: mouseDragged
import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
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);
}
}
}
示例10: compute
import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
public List<Point> compute(List<Point> points) {
ArrayList<Point> bestPoints = new ArrayList<Point> (points) ;
Point relatedLocation = getRelatedSceneLocation();
int direction = 1 ;
int index = 0 ;
//the related location is the center of this anchor. It is possible that
//the list of points started at the opposite anchor (other end of connection).
Point endPoint = bestPoints.get(index);
if (!endPoint.equals(relatedLocation)) {
index = bestPoints.size() - 1 ;
endPoint = bestPoints.get(index);
direction = -1 ;
}
Widget widget = getRelatedWidget();
Rectangle bounds = widget.getBounds();
bounds = widget.convertLocalToScene(bounds);
Point neighbor = bestPoints.get (index+direction) ;
//moving the end point to the end of the anchor from the interior
while (bounds.contains(neighbor)) {
bestPoints.remove(index) ;
endPoint = bestPoints.get (index);
neighbor = bestPoints.get (index+direction);
}
Result intersection = this.computeBoundaryIntersectionPoint(endPoint, neighbor);
bestPoints.remove(index) ;
bestPoints.add(index, intersection.getAnchorSceneLocation());
return bestPoints ;
}
示例11: autoscroll
import java.awt.Rectangle; //导入方法依赖的package包/类
private static void autoscroll(JTree tree, Point cursorLocation) {
Insets insets = DEFAULT_INSETS;
Rectangle outer = tree.getVisibleRect();
Rectangle inner = new Rectangle(outer.x + insets.left, outer.y + insets.top,
outer.width - (insets.left + insets.right), outer.height - (insets.top + insets.bottom));
if (!inner.contains(cursorLocation)) {
Rectangle scrollRect = new Rectangle(cursorLocation.x - insets.left, cursorLocation.y - insets.top,
insets.left + insets.right, insets.top + insets.bottom);
tree.scrollRectToVisible(scrollRect);
}
}
示例12: mouseMoved
import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
public boolean mouseMoved (Point p, JComponent component) {
if (bounds != null && component.getToolTipText() == null) {
for (Rectangle b : bounds) {
if (b.contains(p)) {
component.setToolTipText(text);
return true;
}
}
}
return false;
}
示例13: hitSwimlaneContent
import java.awt.Rectangle; //导入方法依赖的package包/类
/**
* Returns true if the given point is inside the content area of the given
* swimlane. (The content area of swimlanes is transparent to events.) This
* implementation does not check if the given state is a swimlane, it is
* assumed that the caller has checked this before using this method.
*/
public boolean hitSwimlaneContent(mxGraphComponent graphComponent,
mxCellState swimlane, int x, int y)
{
if (swimlane != null)
{
int start = (int) Math.max(2, Math.round(mxUtils.getInt(
swimlane.getStyle(), mxConstants.STYLE_STARTSIZE,
mxConstants.DEFAULT_STARTSIZE)
* graphComponent.getGraph().getView().getScale()));
Rectangle rect = swimlane.getRectangle();
if (mxUtils.isTrue(swimlane.getStyle(),
mxConstants.STYLE_HORIZONTAL, true))
{
rect.y += start;
rect.height -= start;
}
else
{
rect.x += start;
rect.width -= start;
}
return rect.contains(x, y);
}
return false;
}
示例14: ChecarOver
import java.awt.Rectangle; //导入方法依赖的package包/类
private void ChecarOver(Point p) {
if (areas.isEmpty()) {
return;
}
for (Rectangle r : areas) {
if (r.contains(p)) {
setOverNow(r);
return;
}
}
setOverNow(null);
}
示例15: getScreenBoundsForPoint
import java.awt.Rectangle; //导入方法依赖的package包/类
/**
* Returns the screen coordinates for the monitor that contains the
* specified point. This is useful for setups with multiple monitors,
* to ensure that popup windows are positioned properly.
*
* @param x The x-coordinate, in screen coordinates.
* @param y The y-coordinate, in screen coordinates.
* @return The bounds of the monitor that contains the specified point.
*/
public static Rectangle getScreenBoundsForPoint(int x, int y) {
GraphicsEnvironment env = GraphicsEnvironment.
getLocalGraphicsEnvironment();
GraphicsDevice[] devices = env.getScreenDevices();
for (int i=0; i<devices.length; i++) {
GraphicsConfiguration config = devices[i].getDefaultConfiguration();
Rectangle gcBounds = config.getBounds();
if (gcBounds.contains(x, y)) {
return gcBounds;
}
}
// If point is outside all monitors, default to default monitor (?)
return env.getMaximumWindowBounds();
}