當前位置: 首頁>>代碼示例>>Java>>正文


Java Rectangle.contains方法代碼示例

本文整理匯總了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);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:27,代碼來源:ExtendedJTableColumnFitMouseListener.java

示例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));
}
 
開發者ID:chcandido,項目名稱:brModelo,代碼行數:24,代碼來源:Mostrador.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:ToolTipSupport.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:TreeViewDragSupport.java

示例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);
                }
            }
        }
    };
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:17,代碼來源:TestDataComponent.java

示例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);
    }

}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:QuickSearchPopup.java

示例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;
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:17,代碼來源:ShedScene.java

示例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();
}
 
開發者ID:chcandido,項目名稱:brModelo,代碼行數:24,代碼來源:Mostrador.java

示例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);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:CompletionPopup.java

示例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 ;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:38,代碼來源:RectangularAnchor.java

示例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);
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:12,代碼來源:JTreeUtil.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:SummaryCellRenderer.java

示例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;
}
 
開發者ID:GDSRS,項目名稱:TrabalhoFinalEDA2,代碼行數:35,代碼來源:mxInteractiveCanvas.java

示例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);
}
 
開發者ID:chcandido,項目名稱:brModelo,代碼行數:13,代碼來源:Ancorador.java

示例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();
}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:24,代碼來源:Util.java


注:本文中的java.awt.Rectangle.contains方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。