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


Java Rectangle2D.intersect方法代碼示例

本文整理匯總了Java中java.awt.geom.Rectangle2D.intersect方法的典型用法代碼示例。如果您正苦於以下問題:Java Rectangle2D.intersect方法的具體用法?Java Rectangle2D.intersect怎麽用?Java Rectangle2D.intersect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.geom.Rectangle2D的用法示例。


在下文中一共展示了Rectangle2D.intersect方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createIntersection

import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 * @since 1.2
 */
public Rectangle2D createIntersection(Rectangle2D r) {
    if (r instanceof Rectangle) {
        return intersection((Rectangle) r);
    }
    Rectangle2D dest = new Rectangle2D.Double();
    Rectangle2D.intersect(this, r, dest);
    return dest;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:13,代碼來源:Rectangle.java

示例2: damage

import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
 * Damages the area surrounding the caret to cause
 * it to be repainted in a new location.  If paint()
 * is reimplemented, this method should also be
 * reimplemented.  This method should update the
 * caret bounds (x, y, width, and height).
 *
 * @param r  the current location of the caret
 * @see #paint
 */
protected synchronized void damage(final Rectangle r) {
    if (r == null || fPainting) return;

    x = r.x - 4;
    y = r.y;
    width = 10;
    height = r.height;

    // Don't damage the border area.  We can't paint a partial border, so get the
    // intersection of the caret rectangle and the component less the border, if any.
    final Rectangle caretRect = new Rectangle(x, y, width, height);
    final Border border = getComponent().getBorder();
    if (border != null) {
        final Rectangle alloc = getComponent().getBounds();
        alloc.x = alloc.y = 0;
        final Insets borderInsets = border.getBorderInsets(getComponent());
        alloc.x += borderInsets.left;
        alloc.y += borderInsets.top;
        alloc.width -= borderInsets.left + borderInsets.right;
        alloc.height -= borderInsets.top + borderInsets.bottom;
        Rectangle2D.intersect(caretRect, alloc, caretRect);
    }
    x = caretRect.x;
    y = caretRect.y;
    width = Math.max(caretRect.width, 1);
    height = Math.max(caretRect.height, 1);
    repaint();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:39,代碼來源:AquaCaret.java

示例3: damage

import java.awt.geom.Rectangle2D; //導入方法依賴的package包/類
/**
 * Damages the area surrounding the caret to cause
 * it to be repainted in a new location.  If paint()
 * is reimplemented, this method should also be
 * reimplemented.  This method should update the
 * caret bounds (x, y, width, and height).
 *
 * @param r  the current location of the caret
 * @see #paint
 */
@Override
protected synchronized void damage(final Rectangle r) {
    if (r == null || fPainting) return;

    x = r.x - 4;
    y = r.y;
    width = 10;
    height = r.height;

    // Don't damage the border area.  We can't paint a partial border, so get the
    // intersection of the caret rectangle and the component less the border, if any.
    final Rectangle caretRect = new Rectangle(x, y, width, height);
    final Border border = getComponent().getBorder();
    if (border != null) {
        final Rectangle alloc = getComponent().getBounds();
        alloc.x = alloc.y = 0;
        final Insets borderInsets = border.getBorderInsets(getComponent());
        alloc.x += borderInsets.left;
        alloc.y += borderInsets.top;
        alloc.width -= borderInsets.left + borderInsets.right;
        alloc.height -= borderInsets.top + borderInsets.bottom;
        Rectangle2D.intersect(caretRect, alloc, caretRect);
    }
    x = caretRect.x;
    y = caretRect.y;
    width = Math.max(caretRect.width, 1);
    height = Math.max(caretRect.height, 1);
    repaint();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:40,代碼來源:AquaCaret.java


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